# 2.11BSD#431 - /usr/src/usr.bin/struct/0.args.c

##### Functions

    getargs           X
    setsw             X

##### Variables

    debug             X
    errflag           X
    exitsize          X
    inputform         X
    intcase           X
    labinc            X
    labinit           X
    levbrk            X
    levnxt            X
    maxhash           X
    maxnode           X
    maxprogsw         X
    progress          X
    progsw            X
    swval             X

##### Macros

    maxtemp           X

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

#### Defined functions

getargs defined in line 44; used 2 times

- in /usr/src/usr.bin/struct/main.c line 22-25(2)

setsw defined in line 71; used 1 times

- in line 53

#### Defined variables

debug defined in line 20; used 6 times

- in line 39
- in /usr/src/usr.bin/struct/main.c line 26-27(2), 42-52(3)

errflag defined in line 8; used 4 times

- in line 62, 82, 92
- in /usr/src/usr.bin/struct/1.form.c line 86

exitsize defined in line 13; used 1 times

- in line 36

inputform defined in line 19; used 1 times

- in line 39

intcase defined in line 12; used 1 times

- in line 35

labinc defined in line 18; used 1 times

- in line 38

labinit defined in line 17; used 1 times

- in line 38

levbrk defined in line 21; used 1 times

- in line 40

levnxt defined in line 22; used 1 times

- in line 40

maxhash defined in line 15; used 1 times

- in line 37

maxnode defined in line 14; used 1 times

- in line 36

maxprogsw defined in line 25; used 1 times

- in line 88

progress defined in line 16; used 4 times

- in line 37
- in /usr/src/usr.bin/struct/main.c line 45-50(2), 57

progsw defined in line 26; used 1 times

- in line 88

sccsid defined in line 2; never used
swval defined in line 35; used 3 times

- in line 96-100(3)

#### Defined macros

maxtemp defined in line 75; used 2 times

- in line 76-79(2)

Last modified: 1987-02-17 Generated: 2016-12-26 | Generated by src2html V0.67 page hit count: 683 |