1 | /* |
---|
2 | * |
---|
3 | * Copyright (C) 1988, 1989 by the Massachusetts Institute of Technology |
---|
4 | * Developed by the MIT Student Information Processing Board (SIPB). |
---|
5 | * For copying information, see the file mit-copyright.h in this release. |
---|
6 | * |
---|
7 | */ |
---|
8 | /* |
---|
9 | * |
---|
10 | * dispatch.c -- Procedure to do the dispatching on an RPC call. |
---|
11 | * This contains the procedure table. |
---|
12 | * |
---|
13 | * $Header: /afs/dev.mit.edu/source/repository/athena/bin/discuss/server/dispatch.c,v 1.11 1990-02-24 18:59:24 srz Exp $ |
---|
14 | * $Source: /afs/dev.mit.edu/source/repository/athena/bin/discuss/server/dispatch.c,v $ |
---|
15 | * $Locker: $ |
---|
16 | * $Log: not supported by cvs2svn $ |
---|
17 | * Revision 1.10 89/06/03 00:42:47 srz |
---|
18 | * Added standard copyright notice. |
---|
19 | * |
---|
20 | * Revision 1.9 89/01/29 17:16:38 srz |
---|
21 | * Added flag routines. |
---|
22 | * |
---|
23 | * Revision 1.8 89/01/04 22:18:43 raeburn |
---|
24 | * Added RCS stuff and copyright, fixed include paths. |
---|
25 | * |
---|
26 | */ |
---|
27 | |
---|
28 | #include "rpc.h" |
---|
29 | #include <discuss/interface.h> |
---|
30 | #include <discuss/tfile.h> |
---|
31 | #include <discuss/acl.h> |
---|
32 | #include "ansi.h" |
---|
33 | |
---|
34 | #ifndef lint |
---|
35 | static const char rcsid_dispatch_c[] = |
---|
36 | "$Header: /afs/dev.mit.edu/source/repository/athena/bin/discuss/server/dispatch.c,v 1.11 1990-02-24 18:59:24 srz Exp $"; |
---|
37 | #endif |
---|
38 | |
---|
39 | extern bool recvbool(); |
---|
40 | extern char *recvstr(); |
---|
41 | extern tfile recvfile(); |
---|
42 | extern char *malloc(); |
---|
43 | extern char rpc_caller []; |
---|
44 | struct proc_table procs[] = { |
---|
45 | 0, {0, 0, 0, 0, 0, 0, 0, 0}, /* unused */ |
---|
46 | 4, {STRTYPE, TFILETYPE, STRTYPE, INTTYPE, 0, 0, 0, 0}, /* add_trn */ |
---|
47 | 2, {STRTYPE, INTTYPE, 0, 0, 0, 0, 0, 0}, /* get_trn_info */ |
---|
48 | 2, {STRTYPE, INTTYPE, 0, 0, 0, 0, 0, 0}, /* delete_trn */ |
---|
49 | 2, {STRTYPE, INTTYPE, 0, 0, 0, 0, 0, 0}, /* retrieve_trn */ |
---|
50 | 3, {STRTYPE, STRTYPE, BOOLTYPE, 0, 0, 0, 0, 0}, /* create_mtg */ |
---|
51 | 1, {STRTYPE, 0, 0, 0, 0, 0, 0, 0}, /* old_get_mtg_info */ |
---|
52 | 0, { 0, 0, 0, 0, 0, 0, 0, 0}, /* start_mtg_info */ |
---|
53 | 0, { 0, 0, 0, 0, 0, 0, 0, 0}, /* next_mtg_info */ |
---|
54 | 3, {STRTYPE, INTTYPE, TFILETYPE, 0, 0, 0, 0, 0}, /* get_trn */ |
---|
55 | 1, {STRTYPE, 0, 0, 0, 0, 0, 0, 0}, /* remove_mtg */ |
---|
56 | 1, {STRTYPE, 0, 0, 0, 0, 0, 0, 0}, /* get_mtg_info */ |
---|
57 | 1, {STRTYPE, 0, 0, 0, 0, 0, 0, 0}, /* get_acl */ |
---|
58 | 2, {STRTYPE, STRTYPE, 0, 0, 0, 0, 0, 0}, /* get_access */ |
---|
59 | 3, {STRTYPE, STRTYPE, STRTYPE, 0, 0, 0, 0, 0}, /* set_access */ |
---|
60 | 2, {STRTYPE, STRTYPE, STRTYPE, 0, 0, 0, 0, 0}, /* delete_access */ |
---|
61 | 0, {0, 0, 0, 0, 0, 0, 0, 0}, /* whoami */ |
---|
62 | 2, {STRTYPE, INTTYPE, 0, 0, 0, 0, 0, 0}, /* get_trn_info2 */ |
---|
63 | 0, {0, 0, 0, 0, 0, 0, 0, 0}, /* get_server_version */ |
---|
64 | 3, {STRTYPE, INTTYPE, INTTYPE, 0, 0, 0, 0, 0}, /* set_trn_flags */ |
---|
65 | 5, {STRTYPE, TFILETYPE, STRTYPE, STRTYPE, INTTYPE, 0, 0, 0, 0}, /* add_trn2 */ |
---|
66 | 2, {STRTYPE, INTTYPE, 0, 0, 0, 0, 0, 0} /* get_trn_info3 */ |
---|
67 | }; |
---|
68 | |
---|
69 | int numprocs = sizeof (procs) / sizeof (procs [0]); |
---|
70 | |
---|
71 | dispatch (procno) |
---|
72 | int procno; |
---|
73 | { |
---|
74 | char *c1,*c2,*c3; |
---|
75 | char *modes; |
---|
76 | int i1,i2; |
---|
77 | bool b1; |
---|
78 | tfile t1,mem_tfile(); |
---|
79 | int result; |
---|
80 | dsc_acl *list; |
---|
81 | trn_info tinfo; |
---|
82 | trn_info2 tinfo2; |
---|
83 | trn_info3 tinfo3; |
---|
84 | mtg_info minfo; |
---|
85 | |
---|
86 | switch (procno) { |
---|
87 | |
---|
88 | /* add_trn (mtg_name, source_file, subject, reply_trn, result_trn, result) */ |
---|
89 | case ADD_TRN: |
---|
90 | c1 = recvstr(); /* mtg_name */ |
---|
91 | t1 = recvfile(); /* source_file */ |
---|
92 | c2 = recvstr(); /* subject */ |
---|
93 | i1 = recvint(); /* reply_trn */ |
---|
94 | add_trn (c1, t1, c2, i1, &i2, &result); |
---|
95 | startreply(); |
---|
96 | sendint(i2); |
---|
97 | sendint(result); |
---|
98 | sendreply(); |
---|
99 | |
---|
100 | tdestroy(t1); |
---|
101 | free(c1); |
---|
102 | free(c2); |
---|
103 | break; |
---|
104 | |
---|
105 | /* get_trn_info (mtg_name, trn, info, result) */ |
---|
106 | case GET_TRN_INFO: |
---|
107 | c1 = recvstr(); /* mtg_name */ |
---|
108 | i1 = recvint(); /* trn */ |
---|
109 | get_trn_info (c1, i1, &tinfo, &result); |
---|
110 | startreply(); |
---|
111 | send_trn_info(&tinfo); |
---|
112 | sendint(result); |
---|
113 | sendreply(); |
---|
114 | |
---|
115 | free(tinfo.subject); |
---|
116 | free(tinfo.author); |
---|
117 | free(c1); |
---|
118 | break; |
---|
119 | |
---|
120 | /* delete_trn (mtg_name, trn, result) */ |
---|
121 | case DELETE_TRN: |
---|
122 | c1 = recvstr(); /* mtg_name */ |
---|
123 | i1 = recvint(); /* trn */ |
---|
124 | delete_trn (c1, i1, &result); |
---|
125 | startreply(); |
---|
126 | sendint(result); |
---|
127 | sendreply(); |
---|
128 | free(c1); |
---|
129 | break; |
---|
130 | |
---|
131 | /* retrieve_trn (mtg_name, trn, result) */ |
---|
132 | case RETRIEVE_TRN: |
---|
133 | c1 = recvstr(); /* mtg_name */ |
---|
134 | i1 = recvint(); /* trn */ |
---|
135 | retrieve_trn (c1, i1, &result); |
---|
136 | startreply(); |
---|
137 | sendint(result); |
---|
138 | sendreply(); |
---|
139 | free(c1); |
---|
140 | break; |
---|
141 | |
---|
142 | /* create_mtg (location, long_mtg_name, public, result) */ |
---|
143 | case CREATE_MTG: |
---|
144 | c1 = recvstr(); /* location */ |
---|
145 | c2 = recvstr(); /* long_mtg_name */ |
---|
146 | b1 = recvbool(); /* public flag */ |
---|
147 | create_mtg (c1, c2, b1, &result); |
---|
148 | startreply(); |
---|
149 | sendint(result); |
---|
150 | sendreply(); |
---|
151 | free(c1); |
---|
152 | free(c2); |
---|
153 | break; |
---|
154 | |
---|
155 | /* get_mtg_info (mtg_name, info, result) */ |
---|
156 | case GET_MTG_INFO: |
---|
157 | c1 = recvstr(); /* mtg_name */ |
---|
158 | get_mtg_info (c1, &minfo, &result); |
---|
159 | startreply(); |
---|
160 | send_mtg_info(&minfo); |
---|
161 | sendint(result); |
---|
162 | sendreply(); |
---|
163 | |
---|
164 | free(minfo.location); |
---|
165 | free(minfo.long_name); |
---|
166 | free(minfo.chairman); |
---|
167 | free(minfo.access_modes); |
---|
168 | free(c1); |
---|
169 | break; |
---|
170 | |
---|
171 | /* old_get_mtg_info (mtg_name, info, result) */ |
---|
172 | case OLD_GET_MTG_INFO: |
---|
173 | c1 = recvstr(); /* mtg_name */ |
---|
174 | get_mtg_info (c1, &minfo, &result); |
---|
175 | startreply(); |
---|
176 | old_send_mtg_info(&minfo); |
---|
177 | sendint(result); |
---|
178 | sendreply(); |
---|
179 | |
---|
180 | free(minfo.location); |
---|
181 | free(minfo.long_name); |
---|
182 | free(minfo.chairman); |
---|
183 | free(minfo.access_modes); |
---|
184 | free(c1); |
---|
185 | break; |
---|
186 | |
---|
187 | /* get_trn (mtg_name, trn, dest_file, result) */ |
---|
188 | case GET_TRN: |
---|
189 | c1 = recvstr(); /* mtg_name */ |
---|
190 | i1 = recvint(); /* trn */ |
---|
191 | t1 = recvfile (); /* dest_file */ |
---|
192 | get_trn (c1, i1, t1, &result); |
---|
193 | tdestroy (t1); |
---|
194 | startreply(); |
---|
195 | sendint(result); |
---|
196 | sendreply(); |
---|
197 | free(c1); |
---|
198 | break; |
---|
199 | |
---|
200 | /* remove_mtg (mtg_name, result) */ |
---|
201 | case REMOVE_MTG: |
---|
202 | c1 = recvstr(); /* mtg_name */ |
---|
203 | remove_mtg (c1, &result); |
---|
204 | startreply(); |
---|
205 | sendint(result); |
---|
206 | sendreply(); |
---|
207 | free(c1); |
---|
208 | break; |
---|
209 | |
---|
210 | /* updated_mtg (mtg_name, date_attended, last, updated, result) */ |
---|
211 | case UPDATED_MTG: |
---|
212 | c1 = recvstr(); /* mtg_name */ |
---|
213 | i1 = recvint(); /* date_attended */ |
---|
214 | i2 = recvint(); /* last */ |
---|
215 | updated_mtg (c1, i1, i2, &b1, &result); |
---|
216 | startreply(); |
---|
217 | sendbool(b1); |
---|
218 | sendint (result); |
---|
219 | sendreply(); |
---|
220 | free(c1); |
---|
221 | |
---|
222 | break; |
---|
223 | /* get_acl (mtg_name) */ |
---|
224 | case GET_ACL: |
---|
225 | c1 = recvstr(); /* mtg_name */ |
---|
226 | get_acl (c1, &result, &list); |
---|
227 | startreply(); |
---|
228 | sendint(result); |
---|
229 | send_acl(list); |
---|
230 | sendreply(); |
---|
231 | acl_destroy(list); |
---|
232 | free(c1); |
---|
233 | break; |
---|
234 | |
---|
235 | /* get_access(mtg_name, princ_name) */ |
---|
236 | case GET_ACCESS: |
---|
237 | c1 = recvstr(); |
---|
238 | c2 = recvstr(); |
---|
239 | get_access(c1, c2, &modes, &result); |
---|
240 | startreply(); |
---|
241 | sendstr(modes); |
---|
242 | sendint(result); |
---|
243 | sendreply(); |
---|
244 | free(modes); |
---|
245 | free(c1); |
---|
246 | free(c2); |
---|
247 | |
---|
248 | break; |
---|
249 | /* set_access(mtg_name, princ_name, mode) */ |
---|
250 | case SET_ACCESS: |
---|
251 | c1 = recvstr(); |
---|
252 | c2 = recvstr(); |
---|
253 | c3 = recvstr(); |
---|
254 | set_access(c1, c2, c3, &result); |
---|
255 | startreply(); |
---|
256 | sendint(result); |
---|
257 | sendreply(); |
---|
258 | free(c1); |
---|
259 | free(c2); |
---|
260 | free(c3); |
---|
261 | break; |
---|
262 | |
---|
263 | case DELETE_ACCESS: |
---|
264 | c1 = recvstr(); |
---|
265 | c2 = recvstr(); |
---|
266 | delete_access(c1, c2, &result); |
---|
267 | startreply(); |
---|
268 | sendint(result); |
---|
269 | sendreply(); |
---|
270 | free(c1); |
---|
271 | free(c2); |
---|
272 | break; |
---|
273 | |
---|
274 | case WHO_AM_I: |
---|
275 | startreply(); |
---|
276 | sendstr(rpc_caller); |
---|
277 | sendreply(); |
---|
278 | break; |
---|
279 | |
---|
280 | /* get_trn_info2 (mtg_name, trn, info, result) */ |
---|
281 | case GET_TRN_INFO2: |
---|
282 | c1 = recvstr(); /* mtg_name */ |
---|
283 | i1 = recvint(); /* trn */ |
---|
284 | get_trn_info2 (c1, i1, &tinfo2, &result); |
---|
285 | startreply(); |
---|
286 | send_trn_info2(&tinfo2); |
---|
287 | sendint(result); |
---|
288 | sendreply(); |
---|
289 | |
---|
290 | free(tinfo2.subject); |
---|
291 | free(tinfo2.author); |
---|
292 | free(c1); |
---|
293 | break; |
---|
294 | |
---|
295 | /* get_server_version (version_number, result) */ |
---|
296 | case GET_SERVER_VERSION: |
---|
297 | startreply(); |
---|
298 | sendint(SERVER_2); /* Includes get_trn_info3 */ |
---|
299 | sendint(0); /* Success */ |
---|
300 | sendreply(); |
---|
301 | break; |
---|
302 | |
---|
303 | /* set_trn_flags (mtg_name, trn, flags, result) */ |
---|
304 | case SET_TRN_FLAGS: |
---|
305 | c1 = recvstr(); /* mtg_name */ |
---|
306 | i1 = recvint(); /* trn */ |
---|
307 | i2 = recvint(); /* flags */ |
---|
308 | set_trn_flags (c1, i1, i2, &result); |
---|
309 | startreply(); |
---|
310 | sendint(result); |
---|
311 | sendreply(); |
---|
312 | |
---|
313 | free(c1); |
---|
314 | break; |
---|
315 | |
---|
316 | /* add_trn2 (mtg_name, source_file, subject, signature, reply_trn, result_trn, result) */ |
---|
317 | case ADD_TRN2: |
---|
318 | c1 = recvstr(); /* mtg_name */ |
---|
319 | t1 = recvfile(); /* source_file */ |
---|
320 | c2 = recvstr(); /* subject */ |
---|
321 | c3 = recvstr(); /* signature */ |
---|
322 | i1 = recvint(); /* reply_trn */ |
---|
323 | add_trn2 (c1, t1, c2, c3, i1, &i2, &result); |
---|
324 | startreply(); |
---|
325 | sendint(i2); |
---|
326 | sendint(result); |
---|
327 | sendreply(); |
---|
328 | |
---|
329 | tdestroy(t1); |
---|
330 | free(c1); |
---|
331 | free(c2); |
---|
332 | free(c3); |
---|
333 | break; |
---|
334 | |
---|
335 | /* get_trn_info3 (mtg_name, trn, info, result) */ |
---|
336 | case GET_TRN_INFO3: |
---|
337 | c1 = recvstr(); /* mtg_name */ |
---|
338 | i1 = recvint(); /* trn */ |
---|
339 | get_trn_info3 (c1, i1, &tinfo3, &result); |
---|
340 | startreply(); |
---|
341 | send_trn_info3(&tinfo3); |
---|
342 | sendint(result); |
---|
343 | sendreply(); |
---|
344 | |
---|
345 | free(tinfo3.subject); |
---|
346 | free(tinfo3.author); |
---|
347 | free(tinfo3.signature); |
---|
348 | free(c1); |
---|
349 | break; |
---|
350 | } |
---|
351 | return; /* all done for now */ |
---|
352 | } |
---|
353 | |
---|
354 | /* |
---|
355 | * |
---|
356 | * send_trn_info -- send a trn_info struct. |
---|
357 | * |
---|
358 | */ |
---|
359 | send_trn_info(tinfo) |
---|
360 | trn_info *tinfo; |
---|
361 | { |
---|
362 | sendint (tinfo -> version); |
---|
363 | sendint (tinfo -> current); |
---|
364 | sendint (tinfo -> prev); |
---|
365 | sendint (tinfo -> next); |
---|
366 | sendint (tinfo -> pref); |
---|
367 | sendint (tinfo -> nref); |
---|
368 | sendint (tinfo -> fref); |
---|
369 | sendint (tinfo -> lref); |
---|
370 | sendint (tinfo -> chain_index); |
---|
371 | sendint (tinfo -> date_entered); |
---|
372 | sendint (tinfo -> num_lines); |
---|
373 | sendint (tinfo -> num_chars); |
---|
374 | sendstr (tinfo -> subject); |
---|
375 | sendstr (tinfo -> author); |
---|
376 | } |
---|
377 | |
---|
378 | /* |
---|
379 | * |
---|
380 | * send_trn_info2 -- send a trn_info2 struct. |
---|
381 | * |
---|
382 | */ |
---|
383 | send_trn_info2(tinfo) |
---|
384 | trn_info2 *tinfo; |
---|
385 | { |
---|
386 | sendint (tinfo -> version); |
---|
387 | sendint (tinfo -> current); |
---|
388 | sendint (tinfo -> prev); |
---|
389 | sendint (tinfo -> next); |
---|
390 | sendint (tinfo -> pref); |
---|
391 | sendint (tinfo -> nref); |
---|
392 | sendint (tinfo -> fref); |
---|
393 | sendint (tinfo -> lref); |
---|
394 | sendint (tinfo -> chain_index); |
---|
395 | sendint (tinfo -> date_entered); |
---|
396 | sendint (tinfo -> num_lines); |
---|
397 | sendint (tinfo -> num_chars); |
---|
398 | sendstr (tinfo -> subject); |
---|
399 | sendstr (tinfo -> author); |
---|
400 | sendint (tinfo -> flags); |
---|
401 | } |
---|
402 | |
---|
403 | /* |
---|
404 | * |
---|
405 | * send_trn_info3 -- send a trn_info3 struct. |
---|
406 | * |
---|
407 | */ |
---|
408 | send_trn_info3(tinfo) |
---|
409 | trn_info3 *tinfo; |
---|
410 | { |
---|
411 | sendint (tinfo -> version); |
---|
412 | sendint (tinfo -> current); |
---|
413 | sendint (tinfo -> prev); |
---|
414 | sendint (tinfo -> next); |
---|
415 | sendint (tinfo -> pref); |
---|
416 | sendint (tinfo -> nref); |
---|
417 | sendint (tinfo -> fref); |
---|
418 | sendint (tinfo -> lref); |
---|
419 | sendint (tinfo -> chain_index); |
---|
420 | sendint (tinfo -> date_entered); |
---|
421 | sendint (tinfo -> num_lines); |
---|
422 | sendint (tinfo -> num_chars); |
---|
423 | sendstr (tinfo -> subject); |
---|
424 | sendstr (tinfo -> author); |
---|
425 | sendint (tinfo -> flags); |
---|
426 | sendstr (tinfo -> signature); |
---|
427 | } |
---|
428 | |
---|
429 | /* |
---|
430 | * |
---|
431 | * send_mtg_info -- Send a mtg info struct. |
---|
432 | * |
---|
433 | */ |
---|
434 | old_send_mtg_info(minfo) |
---|
435 | mtg_info *minfo; |
---|
436 | { |
---|
437 | sendint (minfo -> version); |
---|
438 | sendstr (minfo -> location); |
---|
439 | sendstr (minfo -> long_name); |
---|
440 | sendstr (minfo -> chairman); |
---|
441 | sendint (minfo -> first); |
---|
442 | sendint (minfo -> last); |
---|
443 | sendint (minfo -> lowest); |
---|
444 | sendint (minfo -> highest); |
---|
445 | sendint (minfo -> date_created); |
---|
446 | sendint (minfo -> date_modified); |
---|
447 | sendbool (minfo -> public_flag); |
---|
448 | } |
---|
449 | |
---|
450 | /* |
---|
451 | * |
---|
452 | * send_mtg_info -- Send a mtg info struct. |
---|
453 | * |
---|
454 | */ |
---|
455 | send_mtg_info(minfo) |
---|
456 | mtg_info *minfo; |
---|
457 | { |
---|
458 | sendint (minfo -> version); |
---|
459 | sendstr (minfo -> location); |
---|
460 | sendstr (minfo -> long_name); |
---|
461 | sendstr (minfo -> chairman); |
---|
462 | sendint (minfo -> first); |
---|
463 | sendint (minfo -> last); |
---|
464 | sendint (minfo -> lowest); |
---|
465 | sendint (minfo -> highest); |
---|
466 | sendint (minfo -> date_created); |
---|
467 | sendint (minfo -> date_modified); |
---|
468 | sendbool (minfo -> public_flag); |
---|
469 | sendstr (minfo -> access_modes); |
---|
470 | } |
---|
471 | |
---|
472 | /* |
---|
473 | * send_acl -- Send an access control list. |
---|
474 | */ |
---|
475 | send_acl(acl) |
---|
476 | dsc_acl *acl; |
---|
477 | { |
---|
478 | register dsc_acl_entry *ae; |
---|
479 | register int n; |
---|
480 | |
---|
481 | if (!acl) { |
---|
482 | sendint(0); |
---|
483 | return; |
---|
484 | } |
---|
485 | |
---|
486 | sendint (acl->acl_length); |
---|
487 | for (ae=acl->acl_entries, n=acl->acl_length; |
---|
488 | n; |
---|
489 | --n, ++ae) { |
---|
490 | sendstr(ae->modes); |
---|
491 | sendstr(ae->principal); |
---|
492 | } |
---|
493 | } |
---|