source: trunk/athena/bin/discuss/libds/host.c @ 1934

Revision 1934, 1.7 KB checked in by srz, 35 years ago (diff)
Added standard copyright notice.
Line 
1/*
2 *
3 *      Copyright (C) 1988, 1989 by the Massachusetts Institute of Technology
4 *      Developed by the MIT Student Information Processing Board (SIPB).
5 *      For copying information, see the file mit-copyright.h in this release.
6 *
7 */
8/*
9 *
10 *      $Source: /afs/dev.mit.edu/source/repository/athena/bin/discuss/libds/host.c,v $
11 *      $Header: /afs/dev.mit.edu/source/repository/athena/bin/discuss/libds/host.c,v 1.5 1989-06-03 00:21:10 srz Exp $
12 *
13 * host.c () -- Program to return the default hostname, internet style. 
14 *              Placed here because UNIX is too brain-damaged to have this
15 *              routine (gethostname is doesn't return unique names.  This
16 *              caches the result.
17 *
18 */
19#ifndef lint
20static char *rcsid_host_c = "$Header: /afs/dev.mit.edu/source/repository/athena/bin/discuss/libds/host.c,v 1.5 1989-06-03 00:21:10 srz Exp $";
21#endif lint
22
23#include <strings.h>
24#include <netdb.h>
25#include <ctype.h>
26
27char *
28local_host_name ()
29{
30     static char myhostname [100];
31     struct hostent *hp;
32
33     if (myhostname [0] != '\0')
34          return (myhostname);
35
36     gethostname (myhostname, sizeof (myhostname));
37
38     hp = gethostbyname (myhostname);
39     if (hp == 0)
40          return(myhostname);
41
42     strcpy (myhostname, hp -> h_name);
43     return (myhostname);
44}
45
46int namcmp(str1, str2)
47register char *str1, *str2;
48{
49     register char c1,c2;
50
51     while (*str1 && *str2) {
52          if (*str1 == *str2) {
53                  str1++;
54                  str2++;
55          } else if (isalpha (*str1)) {
56               c1 = *str1++;
57               c2 = *str2++;
58               if (islower (c1))
59                    c1 = toupper (c1);
60               if (islower (c2))
61                    c2 = toupper (c2);
62               if (c1 == c2)
63                    continue;
64               return(1);
65          } else
66               return (1);
67     }
68
69     return (*str1 || *str2);
70}
71
Note: See TracBrowser for help on using the repository browser.