1*c0eed0b9Srrh #ifndef lint 2*c0eed0b9Srrh static char sccsid[] = "@(#)0.args.c 4.1 (Berkeley) 02/11/83"; 3*c0eed0b9Srrh #endif not lint 4*c0eed0b9Srrh 5*c0eed0b9Srrh #include <stdio.h> 6*c0eed0b9Srrh # 7*c0eed0b9Srrh #include "def.h" 8*c0eed0b9Srrh int errflag; 9*c0eed0b9Srrh FILE *infd; 10*c0eed0b9Srrh 11*c0eed0b9Srrh 12*c0eed0b9Srrh int intcase=1, arbcase=0; 13*c0eed0b9Srrh int exitsize=0; /* max number of nodes to be left in loop without iterating */ 14*c0eed0b9Srrh int maxnode=400; /* max number of nodes */ 15*c0eed0b9Srrh int maxhash=347; /* prime number = size of hash table */ 16*c0eed0b9Srrh int progress=0; /* if not 0, print line number every n lines, n = progress */ 17*c0eed0b9Srrh int labinit=10; /* labels generated starting with labinit */ 18*c0eed0b9Srrh int labinc=10; /* labels increase by labinc */ 19*c0eed0b9Srrh int inputform=0; /* = 0 if freeform input, 1 if standard form input */ 20*c0eed0b9Srrh int debug=0; 21*c0eed0b9Srrh int levbrk=1; /* true implies multilevel breaks; false implies single-level breaks only */ 22*c0eed0b9Srrh int levnxt=1; /* true implies multilevel nexts; false implies single-level nexts only */ 23*c0eed0b9Srrh 24*c0eed0b9Srrh 25*c0eed0b9Srrh int maxprogsw=12; /* number of program switches which can be set */ 26*c0eed0b9Srrh char *progsw[] = {"i", "a", 27*c0eed0b9Srrh "e", "m", 28*c0eed0b9Srrh "h", "p", 29*c0eed0b9Srrh "t", "c", 30*c0eed0b9Srrh "s", "d", 31*c0eed0b9Srrh "b", "n" 32*c0eed0b9Srrh }; 33*c0eed0b9Srrh 34*c0eed0b9Srrh 35*c0eed0b9Srrh int *swval[] = {&intcase, &arbcase, 36*c0eed0b9Srrh &exitsize, &maxnode, 37*c0eed0b9Srrh &maxhash, &progress, 38*c0eed0b9Srrh &labinit, &labinc, 39*c0eed0b9Srrh &inputform, &debug, 40*c0eed0b9Srrh &levbrk, &levnxt 41*c0eed0b9Srrh }; 42*c0eed0b9Srrh 43*c0eed0b9Srrh 44*c0eed0b9Srrh char *getargs(argc, argv) 45*c0eed0b9Srrh int argc; char *argv[]; 46*c0eed0b9Srrh { 47*c0eed0b9Srrh int n, infile; 48*c0eed0b9Srrh infile = 0; 49*c0eed0b9Srrh 50*c0eed0b9Srrh for (n = 1; n < argc; ++n) 51*c0eed0b9Srrh { 52*c0eed0b9Srrh if (argv[n][0] == '-') 53*c0eed0b9Srrh setsw(&argv[n][1]); 54*c0eed0b9Srrh else 55*c0eed0b9Srrh { 56*c0eed0b9Srrh if (infile != 0) 57*c0eed0b9Srrh error("multiple input files - using first one: ", argv[infile],""); 58*c0eed0b9Srrh else 59*c0eed0b9Srrh infile = n; 60*c0eed0b9Srrh } 61*c0eed0b9Srrh } 62*c0eed0b9Srrh if (errflag) 63*c0eed0b9Srrh exit(1); 64*c0eed0b9Srrh if (!infile) faterr("no input file","",""); 65*c0eed0b9Srrh infd = fopen(argv[infile],"r"); 66*c0eed0b9Srrh if (infd == NULL) 67*c0eed0b9Srrh faterr("can't open input file:",argv[infile],""); 68*c0eed0b9Srrh return; 69*c0eed0b9Srrh } 70*c0eed0b9Srrh 71*c0eed0b9Srrh setsw(str) 72*c0eed0b9Srrh char *str; 73*c0eed0b9Srrh { 74*c0eed0b9Srrh int i, val, swnum; 75*c0eed0b9Srrh #define maxtemp 15 76*c0eed0b9Srrh char temp[maxtemp]; 77*c0eed0b9Srrh for (i = 0; 'a' <= str[i] && str[i] <= 'z'; ++i) 78*c0eed0b9Srrh { 79*c0eed0b9Srrh if (i >= maxtemp) 80*c0eed0b9Srrh { 81*c0eed0b9Srrh error("invalid switch:",str,""); 82*c0eed0b9Srrh errflag = 1; 83*c0eed0b9Srrh } 84*c0eed0b9Srrh temp[i] = str[i]; 85*c0eed0b9Srrh } 86*c0eed0b9Srrh temp[i] = '\0'; 87*c0eed0b9Srrh 88*c0eed0b9Srrh swnum = find(temp,progsw,maxprogsw); 89*c0eed0b9Srrh if (swnum == -1) 90*c0eed0b9Srrh { 91*c0eed0b9Srrh error("invalid switch:", str,""); 92*c0eed0b9Srrh errflag = 1; 93*c0eed0b9Srrh return; 94*c0eed0b9Srrh } 95*c0eed0b9Srrh if (str[i] == '\0') 96*c0eed0b9Srrh *(swval[swnum]) = !*(swval[swnum]); 97*c0eed0b9Srrh else 98*c0eed0b9Srrh { 99*c0eed0b9Srrh sscanf(&str[i],"%d",&val); 100*c0eed0b9Srrh *(swval[swnum]) = val; 101*c0eed0b9Srrh } 102*c0eed0b9Srrh } 103