1: /*
   2:  * Copyright (c) 1983 Regents of the University of California.
   3:  * All rights reserved.  The Berkeley software License Agreement
   4:  * specifies the terms and conditions for redistribution.
   5:  */
   6: 
   7: #if !defined(lint) && defined(DOSCCS)
   8: char copyright[] =
   9: "@(#) Copyright (c) 1983 Regents of the University of California.\n\
  10:  All rights reserved.\n";
  11: static char sccsid[] = "@(#)hostid.c	1.3 (2.11BSD GTE) 96/7/10";
  12: #endif
  13: 
  14: #include <sys/types.h>
  15: #include <stdio.h>
  16: #include <ctype.h>
  17: #include <netdb.h>
  18: #include <string.h>
  19: #include <unistd.h>
  20: #include <arpa/inet.h>
  21: 
  22: main(argc, argv)
  23:     int argc;
  24:     char **argv;
  25: {
  26:     register char *id;
  27:     u_long addr;
  28:     long hostid;
  29:     struct hostent *hp;
  30: 
  31:     if (argc < 2) {
  32:         printf("0x%lx\n", gethostid());
  33:         exit(0);
  34:     }
  35: 
  36:     id = argv[1];
  37:     if (hp = gethostbyname(id)) {
  38:         bcopy(hp->h_addr, &addr, sizeof(addr));
  39:         hostid = addr;
  40:     } else if (index(id, '.')) {
  41:         if ((hostid = inet_addr(id)) == -1L)
  42:             usage();
  43:     } else {
  44:         if (id[0] == '0' && (id[1] == 'x' || id[1] == 'X'))
  45:             id += 2;
  46:         if (sscanf(id, "%lx", &hostid) != 1)
  47:             usage();
  48:     }
  49: 
  50:     if  (sethostid(hostid) < 0)
  51:         err(1, "sethostid");
  52:     exit(0);
  53: }
  54: 
  55: usage()
  56:     {
  57:     errx(1,"usage: [hexnum or internet name/address]");
  58: /* NOTREACHED */
  59:     }

Defined functions

main defined in line 22; never used
usage defined in line 55; used 2 times

Defined variables

copyright defined in line 8; never used
sccsid defined in line 11; never used
Last modified: 1996-07-12
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 3154
Valid CSS Valid XHTML 1.0 Strict