]> andersk Git - moira.git/blame - update/hostname.c
Allocate a new socket each time rather than keeping one around,
[moira.git] / update / hostname.c
CommitLineData
de56407f 1/*
2 * $Source$
3 * $Header$
4 */
5
6#ifndef lint
7static 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>
17char *
18PrincipalHostname(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 1.209047 seconds and 5 git commands to generate.