]> andersk Git - moira.git/blob - update/hostname.c
use CODE=ANSI_C option to proc
[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
22 char *PrincipalHostname(char *alias)
23 {
24   struct hostent *h;
25   char *phost = alias;
26   if ((h = gethostbyname(alias)))
27     {
28       char *p = strchr(h->h_name, '.');
29       if (p)
30         *p = NULL;
31       p = phost = h->h_name;
32       do
33         {
34           if (isupper(*p))
35             *p = tolower(*p);
36         }
37       while (*p++);
38     }
39   return phost;
40 }
This page took 0.082257 seconds and 5 git commands to generate.