]>
Commit | Line | Data |
---|---|---|
de56407f | 1 | /* |
2 | * $Source$ | |
3 | * $Header$ | |
4 | */ | |
546bc43b | 5 | /* (c) Copyright 1988 by the Massachusetts Institute of Technology. */ |
6 | /* For copying and distribution information, please see the file */ | |
7 | /* <mit-copyright.h>. */ | |
de56407f | 8 | |
9 | #ifndef lint | |
10 | static char *rcsid_hostname_c = "$Header$"; | |
11 | #endif lint | |
12 | ||
13 | /* PrincipalHostname, borrowed from rcmd.c in Kerberos code */ | |
546bc43b | 14 | #include <mit-copyright.h> |
de56407f | 15 | #include <stdio.h> |
16 | #include <sys/types.h> | |
17 | #include <netinet/in.h> | |
18 | #include <netdb.h> | |
19 | #include <ctype.h> | |
20 | #include <strings.h> | |
21 | char * | |
22 | PrincipalHostname(alias) | |
23 | char *alias; | |
24 | { | |
25 | struct hostent *h; | |
26 | char *phost = alias; | |
27 | if ((h=gethostbyname(alias)) != (struct hostent *)NULL) { | |
28 | char *p = index(h->h_name, '.'); | |
29 | if (p) | |
30 | *p = NULL; | |
31 | p = phost = h->h_name; | |
32 | do { | |
33 | if (isupper(*p)) | |
34 | *p = tolower(*p); | |
35 | } while (*p++); | |
36 | } | |
37 | return(phost); | |
38 | } |