|
DataMuseum.dkPresents historical artifacts from the history of: DKUUG/EUUG Conference tapes |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about DKUUG/EUUG Conference tapes Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - downloadIndex: T m
Length: 3963 (0xf7b) Types: TextFile Names: »main.c«
└─⟦a0efdde77⟧ Bits:30001252 EUUGD11 Tape, 1987 Spring Conference Helsinki └─⟦this⟧ »EUUGD11/euug-87hel/sec8/pathalias/main.c«
/* pathalias -- by steve bellovin, as told to peter honeyman */ #ifndef lint static char *sccsid = "@(#)main.c 8.6 (down!honey) 86/09/16"; #endif #define MAIN /* for sccsid in header files */ #include "def.h" /* exports */ extern void die(); char *ProgName; /* for error diagnostics */ char *Cfile; /* current input file */ char *Graphout; /* file for dumping edges (-g option) */ char *Linkout; /* file for dumping shortest path tree */ char **Ifiles; /* argv for vector of input files */ node *Home; /* node for local host */ int Cflag; /* print costs (-c option) */ int Dflag; /* allow routes beyond domains (-D option) */ int Iflag; /* ignore case (-i option) */ int Tflag; /* trace links (-t option) */ int Vflag; /* verbose (-v option) */ int Lineno = 1; /* line number within current input file */ /* imports */ extern long allocation(); extern void wasted(), mapit(), penalize(), hashanalyze(), deadlink(); extern char *local(); extern node *addnode(); extern char *optarg; extern int optind; extern long Lcount, Ncount; #define USAGE "usage: %s [-vci] [-l localname] [-d deadlink] [-t tracelink] [-g edgeout] [-s treeout] [-a avoid] [files ...]\n" main(argc, argv) register int argc; register char **argv; { char *locname = 0, buf[32]; register int c; int errflg = 0; ProgName = argv[0]; (void) allocation(); /* initialize data space monitoring */ Cfile = "[deadlinks]"; /* for tracing dead links */ while ((c = getopt(argc, argv, "a:cd:Dg:il:s:t:v")) != EOF) switch(c) { case 'a': /* adjust cost out of arg */ penalize(optarg, DEFPENALTY); break; case 'c': /* print cost info */ Cflag++; break; case 'd': /* dead host or link */ deadlink(optarg); break; case 'D': /* allow routes beyond domains */ Dflag++; break; case 'g': /* graph output file */ Graphout = optarg; break; case 'i': /* ignore case */ Iflag++; break; case 'l': /* local name */ locname = optarg; break; case 's': /* show shortest path tree */ Linkout = optarg; break; case 't': /* trace this link */ if (tracelink(optarg) < 0) { fprintf(stderr, "%s: can trace only %d links\n", ProgName, NTRACE); exit(1); } Tflag = 1; break; case 'v': /* verbose stderr, mixed blessing */ Vflag++; if (Vflag == 1) { /* v8 pi snarf, benign EBADF elsewhere */ sprintf(buf, "/proc/%05d\n", getpid()); write(3, buf, strlen(buf)); } break; default: errflg++; } if (errflg) { fprintf(stderr, USAGE, ProgName); exit(1); } argv += optind; /* kludge for yywrap() */ if (*argv) { Ifiles = argv; freopen("/dev/null", "r", stdin); } else Cfile = "[stdin]"; if (!locname) locname = local(); if (*locname == 0) { locname = "lostinspace"; fprintf(stderr, "%s: using \"%s\" for local name\n", ProgName, locname); } Home = addnode(locname); /* add home node */ Home->n_cost = 0; /* doesn't cost to get here */ yyparse(); /* read in link info */ if (Vflag > 1) hashanalyze(); vprintf(stderr, "%d vertices, %d edges\n", Ncount, Lcount); vprintf(stderr, "allocation is %ldk after parsing\n", allocation()); Cfile = "[backlinks]"; /* for tracing back links */ Lineno = 0; /* * compute shortest path tree. * * unless -D is asserted on the command line, we avoid routes through * domains. we do this in two passes: * map to domain members (domains are cheap) * map around domains (domains are expensive) * * in the first phase, only domains, their members, and their * aliases are printed. in the second phase, everything * else is printed. * * otherwise (-D option), we treat domains like any other network and * skip the second phase. */ mapit(DOMAINS); if (!Dflag) mapit(NODOMAINS); wasted(); /* how much was wasted in memory allocation? */ exit(0); } void die(s) char *s; { fprintf(stderr, "%s: %s; notify the authorities\n", ProgName, s); #ifdef DEBUG abort(); #else exit(-1); #endif }