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