mirror of
https://github.com/X11Libre/xserver.git
synced 2026-04-14 17:18:09 +00:00
os: xtrans: replace _XSERVTransGetHostname() by xhostname()
Now that we have the OS layer xhostname() wrapper, we don't need the _XSERVTransGetHostname() function anymore. Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
This commit is contained in:
committed by
Enrico Weigelt
parent
ab08f9e0a2
commit
d5dda483cb
38
os/Xtrans.c
38
os/Xtrans.c
@@ -56,6 +56,7 @@ from The Open Group.
|
||||
#endif
|
||||
|
||||
#include "os/ossock.h"
|
||||
#include "os/xhostname.h"
|
||||
|
||||
/*
|
||||
* The transport table contains a definition for every transport (protocol)
|
||||
@@ -201,7 +202,6 @@ _XSERVTransParseAddress (const char *address,
|
||||
char *mybuf, *tmpptr = NULL;
|
||||
const char *_protocol = NULL;
|
||||
const char *_host, *_port;
|
||||
char hostnamebuf[256];
|
||||
char *_host_buf;
|
||||
int _host_len;
|
||||
|
||||
@@ -305,10 +305,12 @@ _XSERVTransParseAddress (const char *address,
|
||||
*mybuf ++= '\0';
|
||||
|
||||
_host_len = strlen(_host);
|
||||
|
||||
struct xhostname hn;
|
||||
if (_host_len == 0)
|
||||
{
|
||||
_XSERVTransGetHostname (hostnamebuf, sizeof (hostnamebuf));
|
||||
_host = hostnamebuf;
|
||||
xhostname(&hn);
|
||||
_host = hn.name;
|
||||
}
|
||||
#ifdef IPv6
|
||||
/* hostname in IPv6 [numeric_addr]:0 form? */
|
||||
@@ -1060,34 +1062,4 @@ static int _XSERVTransWriteV (XtransConnInfo ciptr, struct iovec *iov, int iovcn
|
||||
return total;
|
||||
}
|
||||
|
||||
/*
|
||||
* _XSERVTransGetHostname - similar to gethostname but allows special processing.
|
||||
*/
|
||||
int _XSERVTransGetHostname (char *buf, int maxlen)
|
||||
{
|
||||
buf[0] = '\0';
|
||||
(void) gethostname (buf, maxlen);
|
||||
buf [maxlen - 1] = '\0';
|
||||
return strlen(buf);
|
||||
}
|
||||
|
||||
#else /* WIN32 */
|
||||
|
||||
#include <sys/utsname.h>
|
||||
|
||||
/*
|
||||
* _XSERVTransGetHostname - similar to gethostname but allows special processing.
|
||||
*/
|
||||
int _XSERVTransGetHostname (char *buf, int maxlen)
|
||||
{
|
||||
struct utsname name;
|
||||
uname (&name);
|
||||
|
||||
int len = strlen (name.nodename);
|
||||
if (len >= maxlen) len = maxlen - 1;
|
||||
memcpy (buf, name.nodename, len);
|
||||
buf[len] = '\0';
|
||||
return len;
|
||||
}
|
||||
|
||||
#endif /* WIN32 */
|
||||
|
||||
@@ -292,9 +292,4 @@ int _XSERVTransConvertAddress (
|
||||
Xtransaddr ** /* addrp */
|
||||
);
|
||||
|
||||
int _XSERVTransGetHostname (
|
||||
char * /* buf */,
|
||||
int /* maxlen */
|
||||
);
|
||||
|
||||
#endif /* _XTRANS_H_ */
|
||||
|
||||
@@ -62,6 +62,8 @@ from The Open Group.
|
||||
#include <X11/Xwinsock.h>
|
||||
#endif
|
||||
|
||||
#include "os/xhostname.h"
|
||||
|
||||
#if defined(IPv6) && !defined(AF_INET6)
|
||||
#error "Cannot build IPv6 support without AF_INET6"
|
||||
#endif
|
||||
@@ -189,8 +191,9 @@ int _XSERVTransConvertAddress(int *familyp, int *addrlenp, Xtransaddr **addrp)
|
||||
* host name for authentication.
|
||||
*/
|
||||
|
||||
char hostnamebuf[256];
|
||||
int len = _XSERVTransGetHostname (hostnamebuf, sizeof hostnamebuf);
|
||||
struct xhostname hn;
|
||||
xhostname(&hn);
|
||||
int len = strlen(hn.name);
|
||||
|
||||
if (len > 0) {
|
||||
if (*addrp && *addrlenp < (len + 1))
|
||||
@@ -201,7 +204,7 @@ int _XSERVTransConvertAddress(int *familyp, int *addrlenp, Xtransaddr **addrp)
|
||||
if (!*addrp)
|
||||
*addrp = malloc (len + 1);
|
||||
if (*addrp) {
|
||||
strcpy ((char *) *addrp, hostnamebuf);
|
||||
strcpy ((char *) *addrp, hn.name);
|
||||
*addrlenp = len;
|
||||
} else {
|
||||
*addrlenp = 0;
|
||||
|
||||
Reference in New Issue
Block a user