From b98b0e107f67055d20db6005b6dee676a79c06a7 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Fri, 20 May 1994 13:50:43 +0000 Subject: merge with 1.10 + local build mods --- lib/xgethostname.c | 4 ++-- old/sh-utils/ChangeLog | 28 ++++++++++++++++++++++++++++ old/sh-utils/NEWS | 3 ++- src/hostname.c | 22 ++++++++++++++++++++++ 4 files changed, 54 insertions(+), 3 deletions(-) diff --git a/lib/xgethostname.c b/lib/xgethostname.c index 86408e775..9973b45be 100644 --- a/lib/xgethostname.c +++ b/lib/xgethostname.c @@ -46,12 +46,12 @@ xgethostname () int err; size = INITIAL_HOSTNAME_LENGTH; + hostname = xmalloc (size); while (1) { - hostname = xmalloc (size); hostname[size - 1] = '\0'; err = gethostname (hostname, size); - if (err || hostname[size - 1] == '\0') + if (err == 0 && hostname[size - 1] == '\0') break; size *= 2; hostname = xrealloc (hostname, size); diff --git a/old/sh-utils/ChangeLog b/old/sh-utils/ChangeLog index 5fd167149..d9378dc06 100644 --- a/old/sh-utils/ChangeLog +++ b/old/sh-utils/ChangeLog @@ -1,5 +1,33 @@ +Thu May 19 01:10:20 1994 Jim Meyering (meyering@comco.com) + + * Version 1.10. + + * lib/Makefile.in (DISTFILES): Add getdate.c and posixtm.c. + + * src/Makefile.in (users.c): Use cp if hard link fails. + From Ian Lance Taylor. + + * Makefile.in (dist): Change package name from shellutils to sh-utils. + That allows a hyphen and 5-character version number without exceeding + the 14-character limit on file name length. shellutils-1.10 would + have been too long. + * version.c: Update package name. + + * hostname.c: Include before "system.h". + From Kaveh Ghazi and Karl Berry. + + * hostname.c (sethostname) [!HAVE_SETHOSTNAME && HAVE_SYSINFO && + HAVE_SYS_SYSTEMINFO_H && HAVE_LIMITS_H]: New function. SVR4 systems + prefer sysinfo over sethostname. + * configure.in (AC_HAVE_FUNCS): Add sysinfo. + (AC_HAVE_HEADERS): Add sys/systeminfo.h. + From Kaveh Ghazi. + Fri May 13 09:45:23 1994 Jim Meyering (meyering@comco.com) + * lib/xgethostname.c (xgethostname): Call xmalloc outside the loop. + Correct loop termination condition. + * pwd.c: Include before "system.h". From Kaveh Ghazi. diff --git a/old/sh-utils/NEWS b/old/sh-utils/NEWS index 7bd07a0e9..27afdfaeb 100644 --- a/old/sh-utils/NEWS +++ b/old/sh-utils/NEWS @@ -1,4 +1,5 @@ -User visible changes in release 2.0 +User visible changes in release 1.10 +* change package name from shellutils to sh-utils * add hostname, pwd, and users commands * --version outputs the name of the utility as well as the package name and version number. diff --git a/src/hostname.c b/src/hostname.c index 300dac405..441c08953 100644 --- a/src/hostname.c +++ b/src/hostname.c @@ -29,10 +29,32 @@ #endif #include +#include #include "system.h" #include "long-options.h" +#if !defined(HAVE_SETHOSTNAME) && defined(HAVE_SYSINFO) && \ + defined (HAVE_SYS_SYSTEMINFO_H) && defined(HAVE_LIMITS_H) +#include +#include + +int +sethostname (name, namelen) + char *name; + int namelen; +{ + /* Using sysinfo() is the SVR4 mechanism to set a hostname. */ + int result; + + result = sysinfo (SI_SET_HOSTNAME, name, namelen); + + return (result == -1 ? result : 0); +} + +#define HAVE_SETHOSTNAME 1 /* Now we have it... */ +#endif + void error (); char *xgethostname (); -- cgit v1.2.3-70-g09d2