]> andersk Git - moira.git/blob - update/hostname.c
Initial revision
[moira.git] / update / hostname.c
1 /*
2  *      $Source$
3  *      $Header$
4  */
5
6 #ifndef lint
7 static char *rcsid_hostname_c = "$Header$";
8 #endif  lint
9
10 /* PrincipalHostname, borrowed from rcmd.c in Kerberos code */
11 #include <stdio.h>
12 #include <sys/types.h>
13 #include <netinet/in.h>
14 #include <netdb.h>
15 #include <ctype.h>
16 #include <strings.h>
17 char *
18 PrincipalHostname(alias)
19      char *alias;
20 {
21      struct hostent *h;
22      char *phost = alias;
23      if ((h=gethostbyname(alias)) != (struct hostent *)NULL) {
24           char *p = index(h->h_name, '.');
25           if (p)
26                *p = NULL;
27           p = phost = h->h_name;
28           do {
29                if (isupper(*p))
30                     *p = tolower(*p);
31           } while (*p++);
32      }
33      return(phost);
34 }
This page took 0.038146 seconds and 5 git commands to generate.