]> andersk Git - moira.git/blob - update/hostname.c
Read it and weep.
[moira.git] / update / hostname.c
1 /*
2  *      $Source$
3  *      $Header$
4  */
5 /*  (c) Copyright 1988 by the Massachusetts Institute of Technology. */
6 /*  For copying and distribution information, please see the file */
7 /*  <mit-copyright.h>. */
8
9 #ifndef lint
10 static char *rcsid_hostname_c = "$Header$";
11 #endif  lint
12
13 /* PrincipalHostname, borrowed from rcmd.c in Kerberos code */
14 #include <mit-copyright.h>
15 #include <stdio.h>
16 #include <sys/types.h>
17 #include <netinet/in.h>
18 #include <netdb.h>
19 #include <ctype.h>
20 #include <string.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 = strchr(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 }
This page took 0.036899 seconds and 5 git commands to generate.