|
|
1.1 ! root 1: /* ! 2: * $Source: /usr/src/kerberosIV/krb/RCS/get_phost.c,v $ ! 3: * $Author: kfall $ ! 4: * ! 5: * Copyright 1988 by the Massachusetts Institute of Technology. ! 6: * ! 7: * For copying and distribution information, please see the file ! 8: * <mit-copyright.h>. ! 9: */ ! 10: ! 11: #ifndef lint ! 12: static char *rcsid_phost_c = ! 13: "$Header: /usr/src/kerberosIV/krb/RCS/get_phost.c,v 4.7 90/06/25 20:57:57 kfall Exp $"; ! 14: #endif /* lint */ ! 15: ! 16: #include <mit-copyright.h> ! 17: #include <stdio.h> ! 18: #include <ctype.h> ! 19: #include <netdb.h> ! 20: ! 21: char *index(); ! 22: ! 23: /* ! 24: * This routine takes an alias for a host name and returns the first ! 25: * field, lower case, of its domain name. For example, if "menel" is ! 26: * an alias for host officially named "menelaus" (in /etc/hosts), for ! 27: * the host whose official name is "MENELAUS.MIT.EDU", the name "menelaus" ! 28: * is returned. ! 29: * ! 30: * This is done for historical Athena reasons: the Kerberos name of ! 31: * rcmd servers (rlogin, rsh, rcp) is of the form "rcmd.host@realm" ! 32: * where "host"is the lowercase for of the host name ("menelaus"). ! 33: * This should go away: the instance should be the domain name ! 34: * (MENELAUS.MIT.EDU). But for now we need this routine... ! 35: * ! 36: * A pointer to the name is returned, if found, otherwise a pointer ! 37: * to the original "alias" argument is returned. ! 38: */ ! 39: ! 40: char * krb_get_phost(alias) ! 41: char *alias; ! 42: { ! 43: struct hostent *h; ! 44: char *phost = alias; ! 45: if ((h=gethostbyname(alias)) != (struct hostent *)NULL ) { ! 46: char *p = index( h->h_name, '.' ); ! 47: if (p) ! 48: *p = NULL; ! 49: p = phost = h->h_name; ! 50: do { ! 51: if (isupper(*p)) *p=tolower(*p); ! 52: } while (*p++); ! 53: } ! 54: return(phost); ! 55: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.