home *** CD-ROM | disk | FTP | other *** search
/ Il CD di internet / CD.iso / SOURCE / D / LIBC / LIBC-4.6 / LIBC-4 / libc-linux / sysdeps / linux / __gethstnm.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-08-20  |  464 b   |  30 lines

  1. #include <string.h>
  2. #include <unistd.h>
  3. #include <sys/utsname.h>
  4. #include <errno.h>
  5.  
  6. int
  7. __gethostname(char *name, size_t len)
  8. {
  9.   struct utsname uts;
  10.  
  11.   if (name == NULL) {
  12.     errno = EINVAL;
  13.     return -1;
  14.   }
  15.  
  16.   if (__uname(&uts) == -1) return -1;
  17.  
  18.   if (strlen(uts.nodename)+1 > len) {
  19.     errno = EINVAL;
  20.     return -1;
  21.   }
  22.   strcpy(name, uts.nodename);
  23.   return 0;
  24. }
  25.  
  26. #include <gnu-stabs.h>
  27. #ifdef weak_alias
  28. weak_alias (__gethostname, gethostname);
  29. #endif
  30.