home *** CD-ROM | disk | FTP | other *** search
/ The Fred Fish Collection 1.5 / ffcollection-1-5-1992-11.iso / ff_disks / 300-399 / ff319.lzh / CNewsSrc / cnews.orig.lzh / libv8 / gethostname.c < prev    next >
C/C++ Source or Header  |  1989-06-27  |  340b  |  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.