diff options
author | Poul-Henning Kamp <phk@FreeBSD.org> | 1997-07-25 19:27:55 +0000 |
---|---|---|
committer | Poul-Henning Kamp <phk@FreeBSD.org> | 1997-07-25 19:27:55 +0000 |
commit | 3d33409926539d866dcea9fc5cb14113b312adf0 (patch) | |
tree | d2f88b3e9ffa79ffb2cc1a0699dd3ee96c47c3e5 /contrib/tcl/unix/tclUnixSock.c | |
parent | 8569730d6bc2e4cb5e784997313325b13518e066 (diff) |
Notes
Diffstat (limited to 'contrib/tcl/unix/tclUnixSock.c')
-rw-r--r-- | contrib/tcl/unix/tclUnixSock.c | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/contrib/tcl/unix/tclUnixSock.c b/contrib/tcl/unix/tclUnixSock.c index e5d293b36e083..4301889276fd7 100644 --- a/contrib/tcl/unix/tclUnixSock.c +++ b/contrib/tcl/unix/tclUnixSock.c @@ -8,7 +8,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * SCCS: @(#) tclUnixSock.c 1.5 96/04/04 15:28:39 + * SCCS: @(#) tclUnixSock.c 1.6 96/08/08 08:48:51 */ #include "tcl.h" @@ -33,7 +33,8 @@ static int hostnameInited = 0; * Get the network name for this machine, in a system dependent way. * * Results: - * A string containing the network name for this machine. + * A string containing the network name for this machine, or + * an empty string if we can't figure out the name. * * Side effects: * None. @@ -44,13 +45,16 @@ static int hostnameInited = 0; char * Tcl_GetHostName() { +#ifndef NO_UNAME struct utsname u; struct hostent *hp; +#endif if (hostnameInited) { return hostname; } - + +#ifndef NO_UNAME if (uname(&u) > -1) { hp = gethostbyname(u.nodename); if (hp != NULL) { @@ -61,5 +65,17 @@ Tcl_GetHostName() hostnameInited = 1; return hostname; } - return (char *) NULL; +#else + /* + * Uname doesn't exist; try gethostname instead. + */ + + if (gethostname(hostname, sizeof(hostname)) > -1) { + hostnameInited = 1; + return hostname; + } +#endif + + hostname[0] = 0; + return hostname; } |