Annotation of 43BSD/lib/libc/net/getservbyname.c, revision 1.1

1.1     ! root        1: /*
        !             2:  * Copyright (c) 1983 Regents of the University of California.
        !             3:  * All rights reserved.  The Berkeley software License Agreement
        !             4:  * specifies the terms and conditions for redistribution.
        !             5:  */
        !             6: 
        !             7: #if defined(LIBC_SCCS) && !defined(lint)
        !             8: static char sccsid[] = "@(#)getservbyname.c    5.3 (Berkeley) 5/19/86";
        !             9: #endif LIBC_SCCS and not lint
        !            10: 
        !            11: #include <netdb.h>
        !            12: 
        !            13: extern int _serv_stayopen;
        !            14: 
        !            15: struct servent *
        !            16: getservbyname(name, proto)
        !            17:        char *name, *proto;
        !            18: {
        !            19:        register struct servent *p;
        !            20:        register char **cp;
        !            21: 
        !            22:        setservent(_serv_stayopen);
        !            23:        while (p = getservent()) {
        !            24:                if (strcmp(name, p->s_name) == 0)
        !            25:                        goto gotname;
        !            26:                for (cp = p->s_aliases; *cp; cp++)
        !            27:                        if (strcmp(name, *cp) == 0)
        !            28:                                goto gotname;
        !            29:                continue;
        !            30: gotname:
        !            31:                if (proto == 0 || strcmp(p->s_proto, proto) == 0)
        !            32:                        break;
        !            33:        }
        !            34:        if (!_serv_stayopen)
        !            35:                endservent();
        !            36:        return (p);
        !            37: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.