home *** CD-ROM | disk | FTP | other *** search
/ RISC DISC 1 / RISC_DISC_1.iso / pd_share / code / unixlib / !UnixLib / src / unix / c / gethostnam < prev    next >
Encoding:
Text File  |  1994-09-30  |  574 b   |  33 lines

  1. static char sccs_id[] = "@(#) gethostname.c 1.2 " __DATE__ " HJR";
  2.  
  3. /* gethostname.c (c) Copyright 1990 H.Rogers */
  4.  
  5. #include <string.h>
  6. #include <errno.h>
  7.  
  8. #include "sys/unix.h"
  9. #include "sys/os.h"
  10.  
  11. /* gethostname() returns "acorn<station>" */
  12.  
  13. char *
  14. gethostname (void)
  15. {
  16.   int r[3];
  17.   os_error *e;
  18.   static char buf[8];
  19.   static char hex[16] = "0123456789abcdef";
  20.  
  21.   strcpy (buf, "acorn");
  22.   if (e = os_byte (0xa1, 0, 0, r))
  23.     {
  24.       __seterr (e);
  25.       return (0);
  26.     }
  27.   buf[7] = 0;
  28.   buf[6] = hex[r[1] & 0xf];
  29.   buf[5] = hex[(r[1] >> 4) & 0xf];
  30.  
  31.   return (buf);
  32. }
  33.