Annotation of researchv9/ipc/src/libin/in_address.c, revision 1.1

1.1     ! root        1: #include <sys/inet/in.h>
        !             2: #include <stdio.h>
        !             3: #include <ctype.h>
        !             4: #include "config.h"
        !             5: 
        !             6: static char *files[] = {
        !             7:        "/usr/ipc/lib/inaddr.local",
        !             8:        "/usr/ipc/lib/inaddr",
        !             9:        "/usr/inet/lib/hosts",
        !            10:        "/usr/inet/lib/networks",
        !            11: };
        !            12: #define NFILES (sizeof(files) / sizeof(files[0]))
        !            13: 
        !            14: extern char *in_getw();
        !            15: 
        !            16: /* translate a host name into an address */
        !            17: in_addr
        !            18: in_address(host)
        !            19: char *host;
        !            20: {
        !            21:        FILE *fp;
        !            22:        char buf[512], b[512], *p;
        !            23:        in_addr addr, in_aton();
        !            24:        int i;
        !            25: 
        !            26:        if(isdigit(host[0]))
        !            27:                return(in_aton(host));
        !            28:        for(i = 0; i < NFILES; i++){
        !            29:                if((fp = fopen(files[i], "r")) == 0){
        !            30:                        continue;
        !            31:                }
        !            32:                while(fgets(buf, sizeof(buf), fp)){
        !            33:                        if(buf[0] == '\n' || buf[0] == '#')
        !            34:                                continue;
        !            35:                        if((p = in_getw(buf, b)) == 0)
        !            36:                                continue;
        !            37:                        addr = in_aton(b);
        !            38:                        while(p = in_getw(p, b)){
        !            39:                                if(strcmp(b, host) == 0){
        !            40:                                        fclose(fp);
        !            41:                                        return(addr);
        !            42:                                }
        !            43:                        }
        !            44:                }
        !            45:                fclose(fp);
        !            46:        }
        !            47:        return(0);
        !            48: }

unix.superglobalmegacorp.com

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