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

Defined functions

main defined in line 17; never used
rubproc defined in line 235; never used

Defined variables

Btree_fd defined in line 15; never used
tTdbu defined in line 13; used 1 times
  • in line 40
Last modified: 1986-04-17
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 1061
Valid CSS Valid XHTML 1.0 Strict