home *** CD-ROM | disk | FTP | other *** search
/ The Fatted Calf / The Fatted Calf.iso / Unix / CNews / Source / libv8 / gethostname.c < prev    next >
Encoding:
C/C++ Source or Header  |  1986-10-29  |  340 b   |  23 lines

  1. /*
  2.  * Uglix gethostname simulation
  3.  */
  4.  
  5. #include <sys/types.h>
  6. #include <sys/utsname.h>
  7.  
  8. #define min(a, b) ((a) < (b)? (a): (b))
  9.  
  10. int
  11. gethostname(buf, size)
  12. char *buf;
  13. int size;
  14. {
  15.     struct utsname ugnm;
  16.     char *strncpy();
  17.  
  18.     if (uname(&ugnm) < 0)
  19.         return -1;
  20.     (void) strncpy(buf, ugnm.nodename, min(sizeof ugnm.nodename, size));
  21.     return 0;
  22. }
  23.