diff src/utils.cc @ 320:781f2e240975

[project @ 1994-01-28 20:00:20 by jwe]
author jwe
date Fri, 28 Jan 1994 20:01:18 +0000
parents 3c23b8ea9099
children 82d30a23c979
line wrap: on
line diff
--- a/src/utils.cc
+++ b/src/utils.cc
@@ -32,7 +32,7 @@
   read_octal               sub_append_string
   decode_prompt_string     pathname_backup
   make_absolute            get_working_directory
-  change_to_directory
+  change_to_directory      gethostname
 
 */
 
@@ -1117,6 +1117,28 @@
     }
 }
 
+#if !defined (HAVE_GETHOSTNAME) && defined (HAVE_SYS_UTSNAME_H)
+extern "C"
+{
+#include <sys/utsname.h>
+int
+gethostname (char *name, int namelen)
+{
+  int i;
+  struct utsname ut;
+
+  --namelen;
+
+  uname (&ut);
+  i = strlen (ut.nodename) + 1;
+  strncpy (name, ut.nodename, i < namelen ? i : namelen);
+  name[namelen] = '\0';
+
+  return 0;
+}
+}
+#endif
+
 /*
  * Has file `A' been modified after time `T'?
  *