]> andersk Git - moira.git/blame - update/hostname.c
strings.h -> string.h, the former doesn't exists on the sun now.
[moira.git] / update / hostname.c
CommitLineData
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
10static 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>
8617eaf2 20#include <string.h>
de56407f 21char *
22PrincipalHostname(alias)
23 char *alias;
24{
25 struct hostent *h;
26 char *phost = alias;
27 if ((h=gethostbyname(alias)) != (struct hostent *)NULL) {
8617eaf2 28 char *p = strchr(h->h_name, '.');
de56407f 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.813429 seconds and 5 git commands to generate.