/* * $Source$ * $Header$ */ /* (c) Copyright 1988 by the Massachusetts Institute of Technology. */ /* For copying and distribution information, please see the file */ /* . */ #ifndef lint static char *rcsid_hostname_c = "$Header$"; #endif lint /* PrincipalHostname, borrowed from rcmd.c in Kerberos code */ #include #include #include #include #include #include #include char *PrincipalHostname(char *alias) { struct hostent *h; char *phost = alias; if ((h = gethostbyname(alias))) { char *p = strchr(h->h_name, '.'); if (p) *p = NULL; p = phost = h->h_name; do { if (isupper(*p)) *p = tolower(*p); } while (*p++); } return phost; }