Revision 8855,
1.7 KB
checked in by ghudson, 28 years ago
(diff) |
BSD -> ANSI string and memory functions
|
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.6 1996-09-19 22:30:50 ghudson 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 |
---|
20 | static char *rcsid_host_c = "$Header: /afs/dev.mit.edu/source/repository/athena/bin/discuss/libds/host.c,v 1.6 1996-09-19 22:30:50 ghudson Exp $"; |
---|
21 | #endif lint |
---|
22 | |
---|
23 | #include <string.h> |
---|
24 | #include <netdb.h> |
---|
25 | #include <ctype.h> |
---|
26 | |
---|
27 | char * |
---|
28 | local_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 | |
---|
46 | int namcmp(str1, str2) |
---|
47 | register 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.