os: xtrans: drop NEED_UTSNAME
All our supported platforms have this utsname.h. Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
This commit is contained in:
parent
00316d71a7
commit
1dbc9d03ac
22
os/Xtrans.c
22
os/Xtrans.c
|
@ -53,6 +53,7 @@ from The Open Group.
|
||||||
#ifdef HAVE_SYSTEMD_DAEMON
|
#ifdef HAVE_SYSTEMD_DAEMON
|
||||||
#include <systemd/sd-daemon.h>
|
#include <systemd/sd-daemon.h>
|
||||||
#endif
|
#endif
|
||||||
|
#include <sys/utsname.h>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The transport table contains a definition for every transport (protocol)
|
* The transport table contains a definition for every transport (protocol)
|
||||||
|
@ -1316,35 +1317,18 @@ static int TRANS(WriteV) (XtransConnInfo ciptr, struct iovec *iov, int iovcnt)
|
||||||
#endif /* WIN32 */
|
#endif /* WIN32 */
|
||||||
|
|
||||||
|
|
||||||
#if defined(_POSIX_SOURCE) || defined(SVR4) || defined(__SVR4)
|
|
||||||
#ifndef NEED_UTSNAME
|
|
||||||
#define NEED_UTSNAME
|
|
||||||
#endif
|
|
||||||
#include <sys/utsname.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* TRANS(GetHostname) - similar to gethostname but allows special processing.
|
* TRANS(GetHostname) - similar to gethostname but allows special processing.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int TRANS(GetHostname) (char *buf, int maxlen)
|
int TRANS(GetHostname) (char *buf, int maxlen)
|
||||||
|
|
||||||
{
|
{
|
||||||
int len;
|
|
||||||
|
|
||||||
#ifdef NEED_UTSNAME
|
|
||||||
struct utsname name;
|
struct utsname name;
|
||||||
|
|
||||||
uname (&name);
|
uname (&name);
|
||||||
len = strlen (name.nodename);
|
|
||||||
|
int len = strlen (name.nodename);
|
||||||
if (len >= maxlen) len = maxlen - 1;
|
if (len >= maxlen) len = maxlen - 1;
|
||||||
memcpy (buf, name.nodename, len);
|
memcpy (buf, name.nodename, len);
|
||||||
buf[len] = '\0';
|
buf[len] = '\0';
|
||||||
#else
|
|
||||||
buf[0] = '\0';
|
|
||||||
(void) gethostname (buf, maxlen);
|
|
||||||
buf [maxlen - 1] = '\0';
|
|
||||||
len = strlen(buf);
|
|
||||||
#endif /* NEED_UTSNAME */
|
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
|
@ -74,10 +74,6 @@ from The Open Group.
|
||||||
|
|
||||||
#include "os/Xtrans.h"
|
#include "os/Xtrans.h"
|
||||||
|
|
||||||
#ifndef _X_UNUSED /* Defined in Xfuncproto.h in xproto >= 7.0.22 */
|
|
||||||
# define _X_UNUSED /* */
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef XTRANSDEBUG
|
#ifdef XTRANSDEBUG
|
||||||
# include <stdio.h>
|
# include <stdio.h>
|
||||||
#endif /* XTRANSDEBUG */
|
#endif /* XTRANSDEBUG */
|
||||||
|
@ -85,23 +81,10 @@ from The Open Group.
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
#ifndef WIN32
|
#ifndef WIN32
|
||||||
# include <sys/socket.h>
|
# include <sys/socket.h>
|
||||||
# include <netinet/in.h>
|
# include <netinet/in.h>
|
||||||
# include <arpa/inet.h>
|
# include <arpa/inet.h>
|
||||||
|
# define ESET(val) errno = val
|
||||||
/*
|
|
||||||
* Moved the setting of NEED_UTSNAME to this header file from Xtrans.c,
|
|
||||||
* to avoid a race condition. JKJ (6/5/97)
|
|
||||||
*/
|
|
||||||
|
|
||||||
# if defined(_POSIX_SOURCE) || defined(SVR4) || defined(__SVR4)
|
|
||||||
# ifndef NEED_UTSNAME
|
|
||||||
# define NEED_UTSNAME
|
|
||||||
# endif
|
|
||||||
# include <sys/utsname.h>
|
|
||||||
# endif
|
|
||||||
|
|
||||||
# define ESET(val) errno = val
|
|
||||||
# define EGET() errno
|
# define EGET() errno
|
||||||
|
|
||||||
#else /* WIN32 */
|
#else /* WIN32 */
|
||||||
|
|
|
@ -798,9 +798,7 @@ TRANS(LocalGetNextTransport)(void)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef NEED_UTSNAME
|
|
||||||
#include <sys/utsname.h>
|
#include <sys/utsname.h>
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Make sure 'host' is really local.
|
* Make sure 'host' is really local.
|
||||||
|
@ -815,15 +813,11 @@ HostReallyLocal (const char *host)
|
||||||
* by either uname() or gethostname(). We try both if possible.
|
* by either uname() or gethostname(). We try both if possible.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef NEED_UTSNAME
|
|
||||||
struct utsname name;
|
struct utsname name;
|
||||||
#endif
|
|
||||||
char buf[256];
|
char buf[256];
|
||||||
|
|
||||||
#ifdef NEED_UTSNAME
|
|
||||||
if (uname (&name) >= 0 && strcmp (host, name.nodename) == 0)
|
if (uname (&name) >= 0 && strcmp (host, name.nodename) == 0)
|
||||||
return (1);
|
return (1);
|
||||||
#endif
|
|
||||||
|
|
||||||
buf[0] = '\0';
|
buf[0] = '\0';
|
||||||
(void) gethostname (buf, 256);
|
(void) gethostname (buf, 256);
|
||||||
|
|
Loading…
Reference in New Issue