1: /* pathalias -- by steve bellovin, as told to peter honeyman */
2: #ifndef lint
3: static char *sccsid = "@(#)main.c 8.1 (down!honey) 86/01/19";
4: #endif
5:
6: #define MAIN /* for sccsid in header files */
7:
8: #include "def.h"
9:
10: #define USAGE "usage: %s [-vci] [-l localname] [-d deadlink] [-t tracelink] [-g file] [-s file]\n"
11:
12: main(argc, argv)
13: int argc;
14: char *argv[];
15: {
16: char *locname = 0;
17: int c, errflg = 0;
18:
19: ProgName = argv[0];
20: (void) allocation(); /* initialize data space monitoring */
21: Cfile = "[deadlinks]"; /* for tracing dead links */
22: while ((c = getopt(argc, argv, "cd:g:il:s:t:v")) != EOF)
23: switch(c) {
24: case 'c': /* print cost info */
25: Cflag++;
26: break;
27: case 'd': /* dead host or link */
28: deadlink(optarg);
29: break;
30: case 'g': /* graph output file */
31: Graphout = optarg;
32: break;
33: case 'i': /* ignore case */
34: Iflag++;
35: break;
36: case 'l': /* local name */
37: locname = optarg;
38: break;
39: case 's': /* show shortest path tree */
40: Linkout = optarg;
41: break;
42: case 't': /* trace this link */
43: if (tracelink(optarg) < 0) {
44: fprintf(stderr, "%s: can trace only %d links\n", ProgName, NTRACE);
45: exit(1);
46: }
47: Tflag = 1;
48: break;
49: case 'v': /* verbose stderr, mixed blessing */
50: Vflag++;
51: break;
52: default:
53: errflg++;
54: }
55:
56: if (errflg) {
57: fprintf(stderr, USAGE, ProgName);
58: exit(1);
59: }
60: argv += optind; /* kludge for yywrap() */
61:
62: if (*argv) {
63: Ifiles = argv;
64: freopen("/dev/null", "r", stdin);
65: }
66:
67: if (!locname)
68: locname = local();
69: if (*locname == 0) {
70: locname = "lostinspace";
71: fprintf(stderr, "%s: using \"%s\" for local name\n",
72: ProgName, locname);
73: }
74:
75: Home = addnode(locname); /* add home node */
76: Home->n_cost = 0; /* doesn't cost to get here */
77:
78: yyparse(); /* read in link info */
79:
80: if (Vflag > 1)
81: hashanalyze();
82: vprintf(stderr, "%d vertices, %d edges\n", Ncount, Lcount);
83: vprintf(stderr, "allocation is %ldk after parsing\n", allocation());
84:
85: Cfile = "[backlinks]"; /* for tracing back links */
86: Lineno = 0;
87:
88: mapit(); /* compute shortest path tree */
89: vprintf(stderr, "allocation is %ldk after mapping\n", allocation());
90:
91: printit(); /* traverse tree and print paths */
92: vprintf(stderr, "allocation is %ldk after printing\n", allocation());
93:
94: exit(0);
95: }
96:
97: badmagic(n)
98: {
99: if (n) {
100: fprintf(stderr, "%s: cannot recover!\n", ProgName);
101: #ifdef DEBUG
102: abort();
103: #else
104: exit(n);
105: #endif
106: }
107: }
Defined functions
main
defined in line
12;
never used
Defined variables
sccsid
defined in line
3;
never used
Defined macros
MAIN
defined in line
6;
never used
USAGE
defined in line
10; used 1 times