|
|
1.1 ! root 1: #include <sys/inet/in.h> ! 2: #include <stdio.h> ! 3: #include "config.h" ! 4: ! 5: static char *files[] = { ! 6: HOSTS, ! 7: NETWORKS, ! 8: }; ! 9: #define NFILES (sizeof(files) / sizeof(files[0])) ! 10: ! 11: /* imported */ ! 12: extern char *in_getw(); ! 13: ! 14: char * ! 15: in_host(addr) ! 16: in_addr addr; ! 17: { ! 18: char buf[512], *p; ! 19: static char b[32]; ! 20: int x, i; ! 21: FILE *fp; ! 22: unsigned char *xp; ! 23: ! 24: xp = (unsigned char *) &addr; ! 25: for(i = 0 ; i < NFILES; i++){ ! 26: if((fp = fopen(files[i], "r")) == 0){ ! 27: perror(files[i]); ! 28: continue; ! 29: } ! 30: ! 31: while(fgets(buf, sizeof(buf), fp)){ ! 32: if(buf[0] == '\n' || buf[0] == '#') ! 33: continue; ! 34: if((p = in_getw(buf, b)) == 0) ! 35: continue; ! 36: x = in_address(b); ! 37: if(x == 0) ! 38: continue; ! 39: if((p = in_getw(p, b)) == 0) ! 40: continue; ! 41: if(x == addr){ ! 42: fclose(fp); ! 43: return(b); ! 44: } ! 45: } ! 46: fclose(fp); ! 47: } ! 48: sprintf(b, "%d.%d.%d.%d", xp[3], xp[2], xp[1], xp[0]); ! 49: return(b); ! 50: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.