Annotation of 42BSD/ingres/source/support/printr.c, revision 1.1.1.1

1.1       root        1: # include      <stdio.h>
                      2: # include      <ingres.h>
                      3: # include      <aux.h>
                      4: # include      <access.h>
                      5: # include      <lock.h>
                      6: # include      <pv.h>
                      7: # include      <sccs.h>
                      8: 
                      9: SCCSID(@(#)printr.c    7.2     5/31/83)
                     10: 
                     11: 
                     12: extern int     Status;
                     13: short          tTdbu[100];
                     14: 
                     15: main(argc, argv)
                     16: int    argc;
                     17: char   *argv[];
                     18: {
                     19:        extern struct out_arg   Out_arg;
                     20:        register char           **av;
                     21:        register char           *q;
                     22:        register char           *p;
                     23:        int                     i;
                     24:        int                     badf;
                     25:        char                    style;
                     26:        char                    *user_ovrd;
                     27:        int                     mode;
                     28:        int                     nc;
                     29:        PARM                    pv[PV_MAXPC];
                     30:        PARM                    *pp;
                     31:        extern char             *Parmvect[];
                     32:        extern char             *Flagvect[];
                     33:        extern char             *Dbpath;
                     34: 
                     35:        argv[argc] = NULL;
                     36: 
                     37: #      ifdef xSTR1
                     38:        tTrace(argv, 'T', tTdbu, 100);
                     39: #      endif
                     40: 
                     41:        mode = -1;
                     42:        badf = 0;
                     43: 
                     44:        /*
                     45:        **  Scan the argument vector and otherwise initialize.
                     46:        */
                     47: 
                     48:        i = initucode(argc, argv, TRUE, NULL, M_SHARE);
                     49:        switch (i)
                     50:        {
                     51:          case 0:
                     52:          case 5:
                     53:                break;
                     54: 
                     55:          case 1:
                     56:          case 6:
                     57:                printf("Database %s does not exist\n", Parmvect[0]);
                     58:                exit(-1);
                     59: 
                     60:          case 2:
                     61:                printf("You are not authorized to access this database\n");
                     62:                exit(-1);
                     63: 
                     64:          case 3:
                     65:                printf("You are not a valid INGRES user\n");
                     66:                exit(-1);
                     67: 
                     68:          case 4:
                     69:                printf("No database name specified\n");
                     70:                badf++;
                     71:                break;
                     72: 
                     73:          default:
                     74:                syserr("main: initucode %d", i);
                     75:        }
                     76: 
                     77:        for (av = Flagvect; (p = *av) != NULL; av++)
                     78:        {
                     79:                if (p[0] != '-')
                     80:                        goto badflag;
                     81:                switch (p[1])
                     82:                {
                     83:                  case 'h':             /* do headers on each page */
                     84:                        mode = 0;
                     85:                        if (p[2] == 0)
                     86:                                break;
                     87:                        Out_arg.linesperpage = atoi(&p[2]);
                     88:                        break;
                     89: 
                     90:                  case 's':             /* supress headers and footers */
                     91:                        mode = 1;
                     92:                        if (p[2] != 0)
                     93:                                goto badflag;
                     94:                        break;
                     95: 
                     96:                  case 'c':             /* set cNwidth */
                     97:                        Out_arg.c0width = atoi(&p[2]);
                     98:                        break;
                     99:                        {
                    100:                        badflag:
                    101:                                printf("bad flag %s\n", p);
                    102:                                badf++;
                    103:                                continue;
                    104:                        }
                    105:                        break;
                    106: 
                    107:                  case 'i':             /* set iNwidth */
                    108:                        switch (p[2])
                    109:                        {
                    110: 
                    111:                          case '1':
                    112:                                Out_arg.i1width = atoi(&p[3]);
                    113:                                break;
                    114: 
                    115:                          case '2':
                    116:                                Out_arg.i2width = atoi(&p[3]);
                    117:                                break;
                    118: 
                    119:                          case '4':
                    120:                                Out_arg.i4width = atoi(&p[3]);
                    121:                                break;
                    122: 
                    123:                          default:
                    124:                                goto badflag;
                    125: 
                    126:                        }
                    127:                        break;
                    128: 
                    129:                  case 'f':             /* set fNwidth */
                    130:                        style = p[3];
                    131:                        switch (style)
                    132:                        {
                    133: 
                    134:                          case 'e':
                    135:                          case 'E':
                    136:                          case 'f':
                    137:                          case 'F':
                    138:                          case 'g':
                    139:                          case 'G':
                    140:                          case 'n':
                    141:                          case 'N':
                    142:                                break;
                    143: 
                    144:                          default:
                    145:                                goto badflag;
                    146: 
                    147:                        }
                    148:                        for (q = &p[4]; *q != '.'; q++)
                    149:                                if (*q == 0)
                    150:                                        goto badflag;
                    151:                        *q++ = 0;
                    152:                        switch (p[2])
                    153:                        {
                    154: 
                    155:                          case '4':
                    156:                                Out_arg.f4width = atoi(&p[4]);
                    157:                                Out_arg.f4prec = atoi(q);
                    158:                                Out_arg.f4style = style;
                    159:                                break;
                    160: 
                    161:                          case '8':
                    162:                                Out_arg.f8width = atoi(&p[4]);
                    163:                                Out_arg.f8prec = atoi(q);
                    164:                                Out_arg.f8style = style;
                    165:                                break;
                    166: 
                    167:                          default:
                    168:                                goto badflag;
                    169: 
                    170:                        }
                    171:                        break;
                    172: 
                    173:                  case 'v':
                    174:                        if (p[2] == 0 || p[3] != 0)
                    175:                                goto badflag;
                    176:                        Out_arg.coldelim = p[2];
                    177:                        break;
                    178: 
                    179:                  default:
                    180:                        goto badflag;
                    181:                }
                    182:        }
                    183: 
                    184:        /*
                    185:        **  Build parameter vector for print call
                    186:        */
                    187: 
                    188:        for (nc = 1, pp = pv; Parmvect[nc] != NULL; nc++)
                    189:                ((pp++)->pv_val).pv_str = Parmvect[nc];
                    190:        if (mode != -1)
                    191:                ((pp++)->pv_val).pv_int = mode;
                    192:        pp->pv_type = PV_EOF;
                    193: 
                    194:        /*
                    195:        **  Check for usage errors.
                    196:        */
                    197: 
                    198:        if (nc < 2)
                    199:        {
                    200:                badf++;
                    201:                printf("usage:  printr [flags] database relation ...\n");
                    202:        }
                    203:        if (badf)
                    204:        {
                    205:                fflush(stdout);
                    206:                exit(-1);
                    207:        }
                    208: 
                    209:        p = Parmvect[0];        /* data base is first parameter */
                    210:        if (chdir(Dbpath) < 0)
                    211:                syserr("cannot access data base %s", p);
                    212: #      ifdef xTTR2
                    213:        if (tTf(1, 0))
                    214:                printf("entered database %s\n", Dbpath);
                    215: #      endif
                    216: 
                    217:        /* initialize access methods (and Admin struct) for user_ovrd test */
                    218:        acc_init();
                    219: 
                    220:        set_so_buf();
                    221: #      ifdef xTTR1
                    222:        if (tTf(1, 1))
                    223:                printf("printing %s\n", p);
                    224: #      endif
                    225: 
                    226:        print(nc - 1, pv);
                    227:        fflush(stdout);
                    228:        exit(0);
                    229: }
                    230: 
                    231: 
                    232: 
                    233: rubproc()
                    234: {
                    235:        fflush(stdout);
                    236:        exit(0);
                    237: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.