From 65ae6594970cc1b0851a84d9481c29897c40d84b Mon Sep 17 00:00:00 2001 From: chatty Date: Wed, 6 Jul 1994 11:04:29 +0000 Subject: gethostbyname -> uname --- comm/Address.cc | 17 +++++++++++++++-- comm/OLD/PortServer.cc | 12 ++++++++++++ 2 files changed, 27 insertions(+), 2 deletions(-) (limited to 'comm') diff --git a/comm/Address.cc b/comm/Address.cc index af2e1ae..03391d7 100644 --- a/comm/Address.cc +++ b/comm/Address.cc @@ -20,6 +20,9 @@ #include #include #include +#if 1 +#include +#endif #ifdef __osf__ extern "C" { #endif @@ -326,10 +329,20 @@ UchInetAddress :: LoopBack () return loopback; struct hostent *host; - char name [128]; - + +#if 0 + char name [128]; gethostname (name, sizeof (name)); host = gethostbyname (name); +#else + struct utsname un; + if (uname (&un) < 0) { + Error (ErrFatal, "address", "cannot get name of local host"); + return 0; + } + host = gethostbyname (un.nodename); +#endif + if (! host) { Error (ErrFatal, "address", "cannot get address of local host"); return 0; diff --git a/comm/OLD/PortServer.cc b/comm/OLD/PortServer.cc index 6305c63..eeaa70d 100644 --- a/comm/OLD/PortServer.cc +++ b/comm/OLD/PortServer.cc @@ -22,6 +22,9 @@ #include // sometimes, cuserid is declared in stdio.h ... #include +#if 1 +#include +#endif #ifdef __osf__ extern "C" { #endif @@ -308,10 +311,19 @@ UchPortServer :: MakeKey (const char* key) if (*q == '%') { switch (*++q) { case 'h' : +#if 0 if (gethostname (p, sizeof (buffer) - (p - buffer)) < 0) { SysError (ErrWarn, "UchPortServer::MakeKey"); strcpy (p, "???"); } +#else + struct utsname un; + if (uname (&un) < 0) { + SysError (ErrWarn, "UchPortServer::MakeKey"); + strcpy (p, "???"); + } else + strncpy (p, un.nodename, sizeof (buffer) - (p - buffer)); +#endif break; case 'u' : { char* l = getlogin (); -- cgit v1.1