# 2.11BSD#431 - /usr/ingres/source/support/printr.c

##### Functions

    main              X
    rubproc           X

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

#### Defined functions

main defined in line 11; never used
rubproc defined in line 229; never used

Last modified: 1995-02-12 Generated: 2016-12-26 | Generated by src2html V0.67 page hit count: 1210 |