|
|
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(@(#)helpr.c 7.1 2/5/81) ! 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 int i; ! 22: register char *p; ! 23: extern char *Parmvect[]; ! 24: extern char *Flagvect[]; ! 25: extern char *Dbpath; ! 26: int nc; ! 27: PARM newpv[PV_MAXPC]; ! 28: PARM *nv; ! 29: char *qm; ! 30: char *qmtest(); ! 31: ! 32: argv[argc] = NULL; ! 33: ! 34: # ifdef xSTR1 ! 35: tTrace(argv, 'T', tTdbu, 100); ! 36: # endif ! 37: ! 38: i = initucode(argc, argv, TRUE, NULL, M_SHARE); ! 39: # ifdef xSTR2 ! 40: if (tTf(0, 1)) ! 41: printf("initucode=%d, Dbpath='%s'\n", i, Dbpath); ! 42: # endif ! 43: switch (i) ! 44: { ! 45: case 0: ! 46: case 5: ! 47: break; ! 48: ! 49: case 1: ! 50: case 6: ! 51: printf("Database %s does not exist\n", Parmvect[0]); ! 52: exit(-1); ! 53: ! 54: case 2: ! 55: printf("You are not authorized to access this database\n"); ! 56: exit(-1); ! 57: ! 58: case 3: ! 59: printf("You are not a valid INGRES user\n"); ! 60: exit(-1); ! 61: ! 62: case 4: ! 63: printf("No database name specified\n"); ! 64: usage: ! 65: printf("usage: helpr database [relname ...]\n"); ! 66: exit(-1); ! 67: ! 68: default: ! 69: syserr("initucode %d", i); ! 70: } ! 71: ! 72: /* ! 73: if (Flagvect[0] != NULL) ! 74: { ! 75: printf("No flags are allowed for this command\n"); ! 76: goto usage; ! 77: } ! 78: */ ! 79: ! 80: if (chdir(Dbpath) < 0) ! 81: syserr("cannot access data base %s", p); ! 82: # ifdef xTTR2 ! 83: if (tTf(1, 0)) ! 84: printf("entered database %s\n", Dbpath); ! 85: # endif ! 86: ! 87: /* initialize access methods (and Admin struct) for user_ovrd test */ ! 88: acc_init(); ! 89: # ifdef xTTR3 ! 90: if (tTf(2, 0)) ! 91: printf("access methods initialized\n"); ! 92: # endif ! 93: ! 94: set_so_buf(); ! 95: ! 96: av = &Parmvect[1]; /* get first param after database name */ ! 97: p = *av; ! 98: if (p == NULL) ! 99: { ! 100: /* special case of no relations specified */ ! 101: newpv[0].pv_type = PV_STR; ! 102: newpv[0].pv_val.pv_str = "2"; ! 103: newpv[1].pv_type = PV_EOF; ! 104: # ifdef xTTR3 ! 105: if (tTf(3, 0)) ! 106: printf("calling help, no relations specified\n"); ! 107: # endif ! 108: help(1, newpv); ! 109: } ! 110: else ! 111: { ! 112: do ! 113: { ! 114: nc = 0; ! 115: nv = newpv; ! 116: ! 117: if ((qm = qmtest(p)) != NULL) ! 118: { ! 119: /* either help view, integrity or protect */ ! 120: av++; ! 121: while ((p = *av++) != NULL) ! 122: { ! 123: if ((i = (int) qmtest(p)) != NULL) ! 124: { ! 125: /* change of qmtest result */ ! 126: qm = (char *) i; ! 127: continue; ! 128: } ! 129: (nv)->pv_type = PV_STR; ! 130: (nv++)->pv_val.pv_str = qm; ! 131: (nv)->pv_type = PV_STR; ! 132: (nv++)->pv_val.pv_str = p; ! 133: nc += 2; ! 134: } ! 135: # ifdef xTTR3 ! 136: if (tTf(3, 0)) ! 137: printf("calling display\n"); ! 138: # endif ! 139: nv->pv_type = PV_EOF; ! 140: /* ! 141: display(nc, newpv); ! 142: */ ! 143: } ! 144: else ! 145: { ! 146: /* help relname */ ! 147: while ((p = *av++) != NULL && qmtest(p) == NULL) ! 148: { ! 149: if (sequal("all", p)) ! 150: { ! 151: (nv)->pv_type = PV_STR; ! 152: (nv++)->pv_val.pv_str = "3"; ! 153: nc++; ! 154: } ! 155: else ! 156: { ! 157: (nv)->pv_type = PV_STR; ! 158: (nv++)->pv_val.pv_str = "0"; ! 159: (nv)->pv_type = PV_STR; ! 160: (nv++)->pv_val.pv_str = p; ! 161: nc += 2; ! 162: } ! 163: } ! 164: nv->pv_type = PV_EOF; ! 165: # ifdef xTTR3 ! 166: if (tTf(3, 0)) ! 167: printf("calling help\n"); ! 168: # endif ! 169: help(nc, newpv); ! 170: /* this backs av up one step, so ! 171: * that it points at the keywords (permit, ! 172: * integrity, view) or the NULL ! 173: */ ! 174: --av; ! 175: } ! 176: } while (p != NULL); ! 177: } ! 178: fflush(stdout); ! 179: exit(0); ! 180: } ! 181: ! 182: ! 183: ! 184: char *qmtest(p) ! 185: register char *p; ! 186: { ! 187: if (sequal("view", p)) ! 188: return ("4"); ! 189: else if (sequal("permit", p)) ! 190: return ("5"); ! 191: else if (sequal("integrity", p)) ! 192: return ("6"); ! 193: else ! 194: return (NULL); ! 195: } ! 196: ! 197: ! 198: rubproc() ! 199: { ! 200: exit(1); ! 201: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.