source: trunk/athena/bin/discuss/libds/stubs.c @ 22404

Revision 22404, 15.7 KB checked in by ghudson, 19 years ago (diff)
Eliminate declarations of system functions which cause warnings or errors. Fix some broken ss library calls.
Line 
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 *      $Id: stubs.c,v 1.18 2006-03-10 07:11:38 ghudson Exp $
11 *
12 * stubs.c -- These are stubs that handle the calling of routines.
13 *
14 *
15 */
16#ifndef lint
17static char rcsid_stubs_c[] =
18    "$Id: stubs.c,v 1.18 2006-03-10 07:11:38 ghudson Exp $";
19#endif /* lint */
20
21/* Derived from CORE.PAS 06/21/86 by SRZ */
22
23#include <stdlib.h>
24#include <discuss/interface.h>
25#include "rpc.h"
26#include <discuss/tfile.h>
27#include <discuss/acl.h>
28
29extern bool recvbool();
30extern char *recvstr();
31dsc_acl *recv_acl();
32
33static char discuss[] = "discuss";
34
35/*
36 *
37 * add_trn () --
38 * adds a transaction to the current meeting, either as a reply or an
39 * original transaction.  Returns an error code, and the transaction number
40 * given to the transaction
41 *
42 */
43add_trn (mtg_name, source_file, subject, reply_trn, result_trn, result)
44char *mtg_name;
45tfile source_file;
46char *subject;
47trn_nums reply_trn;             /* trn replying to;  0 if original */
48trn_nums *result_trn;           /* trn number given to added trn */
49int *result;
50{
51     startsend(ADD_TRN);
52     if (rpc_err) { *result = rpc_err; return; }
53     sendstr(mtg_name);
54     sendfile(source_file);
55     sendstr(subject);
56     sendint(reply_trn);
57     sendit(discuss);
58     senddata(source_file);
59     if (rpc_err) { *result = rpc_err; return; }
60     recvreply ();
61     if (rpc_err) { *result = rpc_err; return; }
62     *result_trn = recvint();
63     *result = recvint();
64     if (rpc_err) { *result = rpc_err; return; }
65     return;
66}
67
68/*
69 *
70 * add_trn2 () --
71 * adds a transaction to the current meeting, either as a reply or an
72 * original transaction.  Allows a signature to be given.
73 * Returns an error code, and the transaction number given to the transaction
74 *
75 */
76add_trn2 (mtg_name, source_file, subject, signature, reply_trn, result_trn, result)
77char *mtg_name;
78tfile source_file;
79char *subject;
80char *signature;
81trn_nums reply_trn;             /* trn replying to;  0 if original */
82trn_nums *result_trn;           /* trn number given to added trn */
83int *result;
84{
85     startsend(ADD_TRN2);
86     if (rpc_err) { *result = rpc_err; return; }
87     sendstr(mtg_name);
88     sendfile(source_file);
89     sendstr(subject);
90     sendstr(signature);
91     sendint(reply_trn);
92     sendit(discuss);
93     senddata(source_file);
94     if (rpc_err) { *result = rpc_err; return; }
95     recvreply ();
96     if (rpc_err) { *result = rpc_err; return; }
97     *result_trn = recvint();
98     *result = recvint();
99     if (rpc_err) { *result = rpc_err; return; }
100     return;
101}
102
103/*
104 *
105 * get_trn_info () --
106 * returns information about the given transaction in info, with an error
107 * code as its return argument
108 *
109 */
110get_trn_info (mtg_name, trn, info, result)
111char *mtg_name;
112trn_nums trn;
113trn_info *info;
114int *result;
115{
116     info -> subject = NULL;                    /* Not allocated */
117     info -> author = NULL;
118     startsend(GET_TRN_INFO);
119     if (rpc_err) { *result = rpc_err; return; }
120     sendstr(mtg_name);
121     sendint(trn);
122     sendit(discuss);
123     if (rpc_err) { *result = rpc_err; return; }
124     recvreply();
125     if (rpc_err) { *result = rpc_err; return; }
126     recv_trn_info(info);
127     *result = recvint();
128     if (rpc_err) { *result = rpc_err; return; }
129     return;
130}
131
132/*
133 *
134 * get_trn_info2 () --
135 * returns information about the given transaction in info, with an error
136 * code as its return argument
137 *
138 */
139get_trn_info2 (mtg_name, trn, info, result)
140char *mtg_name;
141trn_nums trn;
142trn_info2 *info;
143int *result;
144{
145     info -> subject = NULL;                    /* Not allocated */
146     info -> author = NULL;
147     startsend(GET_TRN_INFO2);
148     if (rpc_err) { *result = rpc_err; return; }
149     sendstr(mtg_name);
150     sendint(trn);
151     sendit(discuss);
152     if (rpc_err) { *result = rpc_err; return; }
153     recvreply();
154     if (rpc_err) { *result = rpc_err; return; }
155     recv_trn_info2(info);
156     *result = recvint();
157     if (rpc_err) { *result = rpc_err; return; }
158     return;
159}
160
161/*
162 *
163 * get_trn_info3 () --
164 * returns information about the given transaction in info, with an error
165 * code as its return argument
166 *
167 */
168get_trn_info3 (mtg_name, trn, info, result)
169char *mtg_name;
170trn_nums trn;
171trn_info3 *info;
172int *result;
173{
174     info -> subject = NULL;                    /* Not allocated */
175     info -> author = NULL;
176     startsend(GET_TRN_INFO3);
177     if (rpc_err) { *result = rpc_err; return; }
178     sendstr(mtg_name);
179     sendint(trn);
180     sendit(discuss);
181     if (rpc_err) { *result = rpc_err; return; }
182     recvreply();
183     if (rpc_err) { *result = rpc_err; return; }
184     recv_trn_info3(info);
185     *result = recvint();
186     if (rpc_err) { *result = rpc_err; return; }
187     return;
188}
189
190
191/*
192 *
193 * delete_trn () --
194 * deletes the given transaction from the current meeting.  Returns an
195 * error code
196 *
197 */
198delete_trn (mtg_name, trn, result)
199char *mtg_name;
200trn_nums trn;
201int *result;
202{
203     startsend(DELETE_TRN);
204     if (rpc_err) { *result = rpc_err; return; }
205     sendstr(mtg_name);
206     sendint(trn);
207     sendit(discuss);
208     if (rpc_err) { *result = rpc_err; return; }
209     recvreply();
210     if (rpc_err) { *result = rpc_err; return; }
211     *result = recvint();
212     if (rpc_err) { *result = rpc_err; return; }
213     return;
214}
215
216/*
217 *
218 * retrieve_trn () --
219 * retrieves a previously deleted transaction from the current meeting, if
220 * possible.  trn must refer to a deleted transaction.  An error code is
221 * returned
222 *
223 */
224retrieve_trn (mtg_name, trn, result)
225char *mtg_name;
226trn_nums trn;
227int *result;
228{
229     startsend(RETRIEVE_TRN);
230     if (rpc_err) { *result = rpc_err; return; }
231     sendstr (mtg_name);
232     sendint (trn);
233     sendit(discuss);
234     if (rpc_err) { *result = rpc_err; return; }
235     recvreply();
236     if (rpc_err) { *result = rpc_err; return; }
237     *result = recvint();
238     if (rpc_err) { *result = rpc_err; return; }
239     return;
240}
241
242
243
244/*
245 *
246 * create_mtg () --
247 * Creates a new meeting with the given long_mtg name, where location is the
248 * it's place in the hierarchy, and the long_mtg_name is its canonical name.
249 * The chairman of the new meeting is the current user.
250 *
251 */
252create_mtg (location, long_mtg_name, public, result)
253char *location,*long_mtg_name;
254bool public;
255int *result;
256{
257     startsend(CREATE_MTG);
258     if (rpc_err) { *result = rpc_err; return; }
259     sendstr(location);
260     sendstr(long_mtg_name);
261     sendbool(public);
262     sendit(discuss);
263     if (rpc_err) { *result = rpc_err; return; }
264     recvreply();
265     if (rpc_err) { *result = rpc_err; return; }
266     *result = recvint();
267     if (rpc_err) { *result = rpc_err; return; }
268     return;
269}
270
271
272/*
273 *
274 * old_get_mtg_info () --
275 * returns information about the given meeting.  Return argument is an
276 * error code
277 *
278 */
279old_get_mtg_info (mtg_name, info, result)
280char *mtg_name;
281mtg_info *info;
282int *result;
283{
284     info -> location = NULL;
285     info -> long_name = NULL;
286     info -> chairman = NULL;
287     startsend(OLD_GET_MTG_INFO);
288     if (rpc_err) { *result = rpc_err; return; }
289     sendstr(mtg_name);
290     sendit(discuss);
291     if (rpc_err) { *result = rpc_err; return; }
292     recvreply();
293     if (rpc_err) { *result = rpc_err; return; }
294     old_recv_mtg_info(info);
295     *result = recvint();
296     if (rpc_err) { *result = rpc_err; return; }
297     return;
298}
299/*
300 *
301 * get_mtg_info () --
302 * returns information about the given meeting.  Return argument is an
303 * error code
304 *
305 */
306get_mtg_info (mtg_name, info, result)
307char *mtg_name;
308mtg_info *info;
309int *result;
310{
311     info -> location = NULL;
312     info -> long_name = NULL;
313     info -> chairman = NULL;
314     info -> access_modes = NULL;
315     startsend(GET_MTG_INFO);
316     if (rpc_err) { *result = rpc_err; return; }
317     sendstr(mtg_name);
318     sendit(discuss);
319     if (rpc_err) { *result = rpc_err; return; }
320     recvreply();
321     if (rpc_err) { *result = rpc_err; return; }
322     recv_mtg_info(info);
323     *result = recvint();
324     if (rpc_err) { *result = rpc_err; return; }
325     return;
326}
327
328/*
329 *
330 * get_trn () --
331 * gets the given transaction, and feeds it through dest_file.  Returns an
332 * error code
333 *
334 */
335get_trn (mtg_name, trn, dest_file, result)
336char *mtg_name;
337trn_nums trn;
338tfile dest_file;
339int *result;
340{
341     startsend(GET_TRN);
342     if (rpc_err) { *result = rpc_err; return; }
343     sendstr(mtg_name);
344     sendint(trn);
345     sendfile(dest_file);
346     sendit(discuss);
347     if (rpc_err) { *result = rpc_err; return; }
348     recvdata(dest_file);
349     recvreply();
350     if (rpc_err) { *result = rpc_err; return; }
351     *result = recvint();
352     if (rpc_err) { *result = rpc_err; return; }
353     return;
354}
355
356/*
357 *
358 * remove_mtg () --
359 * removes the given meeting from the meeting list.  This should
360 * probably go ahead and physically remove the contents of the meeting
361 * but that's not obvious if we have the access to do that.
362 *
363 */
364remove_mtg (mtg_name, result)
365char *mtg_name;
366int *result;
367{
368     startsend(REMOVE_MTG);
369     if (rpc_err) { *result = rpc_err; return; }
370     sendstr(mtg_name);
371     sendit(discuss);
372     if (rpc_err) { *result = rpc_err; return; }
373     recvreply();
374     if (rpc_err) { *result = rpc_err; return; }
375     *result = recvint();
376     if (rpc_err) { *result = rpc_err; return; }
377     return;
378}
379/*
380 *
381 * updated_mtg () -- Quick procedure to check if the meeting is updated
382 *                   with respect to a given time and transaction number.
383 *
384 */
385updated_mtg (mtg_name, date_attended, last, updated, result)
386char *mtg_name;
387int date_attended, last;
388bool *updated;
389int *result;
390{
391     startsend(UPDATED_MTG);
392     if (rpc_err) { *result = rpc_err; return; }
393     sendstr(mtg_name);
394     sendint(date_attended);
395     sendint(last);
396     sendit(discuss);
397     if (rpc_err) { *result = rpc_err; return; }
398     recvreply();
399     if (rpc_err) { *result = rpc_err; return; }
400     *updated = recvbool();
401     *result = recvint();
402     if (rpc_err) { *result = rpc_err; return; }
403     return;
404}
405#define rpccheck if (rpc_err) { *result = rpc_err; return; }
406/*
407 * get_acl () -- Get access control list.
408 */
409get_acl(mtg_name, result, list)
410        char *mtg_name;
411        int *result;            /* RETURN */
412        dsc_acl **list;         /* RETURN */
413{
414        startsend(GET_ACL);
415        rpccheck;
416        sendstr(mtg_name);
417        sendit(discuss);
418        rpccheck;
419        recvreply();
420        if (rpc_err) { *result = rpc_err; return; }
421        *result = recvint();
422        *list = recv_acl();
423        rpccheck;
424        return;
425}
426
427get_access(mtg_name, princ_name, modes, result)
428        char *mtg_name;
429        char *princ_name;
430        char **modes;           /* RETURN */
431        int *result;            /* RETURN */
432{
433        *modes = NULL;     
434        startsend(GET_ACCESS);
435        rpccheck;
436        sendstr(mtg_name);
437        sendstr(princ_name);
438        sendit(discuss);
439        rpccheck;
440        recvreply();
441        if (rpc_err) { *result = rpc_err; return; }
442        *modes = recvstr();
443        *result = recvint();
444        rpccheck;
445        return;
446}
447set_access(mtg_name, princ_name, modes, result)
448        char *mtg_name;
449        char *princ_name;
450        char *modes;
451        int *result;            /* RETURN */
452{
453        startsend(SET_ACCESS);
454        rpccheck;
455        sendstr(mtg_name);
456        sendstr(princ_name);
457        sendstr(modes);
458        sendit(discuss);
459        rpccheck;
460        recvreply();
461        if (rpc_err) { *result = rpc_err; return; }
462        *result = recvint();
463        rpccheck;
464        return;
465}
466
467delete_access(mtg_name, princ_name, result)
468        char *mtg_name;
469        char *princ_name;
470        int *result;            /* RETURN */
471{
472        startsend(DELETE_ACCESS);
473        rpccheck;
474        sendstr(mtg_name);
475        sendstr(princ_name);
476        sendit(discuss);
477        rpccheck;
478        recvreply();
479        if (rpc_err) { *result = rpc_err; return; }
480        *result = recvint();
481        rpccheck;
482        return;
483}
484
485set_trn_flags(mtg_name, trn, flags, result)
486char *mtg_name;
487trn_nums trn;
488int flags;
489int *result;
490{
491     startsend(SET_TRN_FLAGS);
492     if (rpc_err) { *result = rpc_err; return; }
493     sendstr(mtg_name);
494     sendint(trn);
495     sendint(flags);
496     sendit(discuss);
497     if (rpc_err) { *result = rpc_err; return; }
498     recvreply();
499     if (rpc_err) { *result = rpc_err; return; }
500     *result = recvint();
501     if (rpc_err) { *result = rpc_err; return; }
502     return;
503}
504
505
506dwhoami(ident, result)
507        char **ident;
508        int *result;
509{
510        *result = 0;
511        *ident = NULL;
512        startsend(WHO_AM_I);
513        rpccheck;
514        sendit(discuss);
515        rpccheck;
516        recvreply();
517        if (rpc_err) { *result = rpc_err; return; }
518        *ident = recvstr();
519        rpccheck;
520        return;
521}
522
523get_server_version()
524{
525        int vers_num,result;
526
527        startsend(GET_SERVER_VERSION);
528        if (rpc_err) return (SERVER_0);
529        sendit(discuss);
530        if (rpc_err) return (SERVER_0);
531        recvreply();
532        if (rpc_err) return (SERVER_0);
533        vers_num = recvint();
534        if (rpc_err) return (SERVER_0);
535        result = recvint();
536        if (rpc_err) return (SERVER_0);
537        return(vers_num);
538}
539
540/*
541 *
542 * recv_trn_info -- recv a trn_info struct.
543 *
544 */
545recv_trn_info(tinfo)
546trn_info *tinfo;
547{
548     tinfo -> version = recvint ();
549     tinfo -> current = recvint ();
550     tinfo -> prev = recvint ();
551     tinfo -> next = recvint ();
552     tinfo -> pref = recvint ();
553     tinfo -> nref = recvint ();
554     tinfo -> fref = recvint ();
555     tinfo -> lref = recvint ();
556     tinfo -> chain_index = recvint ();
557     tinfo -> date_entered = recvint ();
558     tinfo -> num_lines = recvint ();
559     tinfo -> num_chars = recvint ();
560     tinfo -> subject = recvstr ();
561     tinfo -> author = recvstr ();
562}
563
564/*
565 *
566 * recv_trn_info2 -- recv a trn_info2 struct.
567 *
568 */
569recv_trn_info2(tinfo)
570trn_info2 *tinfo;
571{
572     tinfo -> version = recvint ();
573     tinfo -> current = recvint ();
574     tinfo -> prev = recvint ();
575     tinfo -> next = recvint ();
576     tinfo -> pref = recvint ();
577     tinfo -> nref = recvint ();
578     tinfo -> fref = recvint ();
579     tinfo -> lref = recvint ();
580     tinfo -> chain_index = recvint ();
581     tinfo -> date_entered = recvint ();
582     tinfo -> num_lines = recvint ();
583     tinfo -> num_chars = recvint ();
584     tinfo -> subject = recvstr ();
585     tinfo -> author = recvstr ();
586     tinfo -> flags = recvint ();
587}
588
589/*
590 *
591 * recv_trn_info3 -- recv a trn_info2 struct.
592 *
593 */
594recv_trn_info3(tinfo)
595trn_info3 *tinfo;
596{
597     tinfo -> version = recvint ();
598     tinfo -> current = recvint ();
599     tinfo -> prev = recvint ();
600     tinfo -> next = recvint ();
601     tinfo -> pref = recvint ();
602     tinfo -> nref = recvint ();
603     tinfo -> fref = recvint ();
604     tinfo -> lref = recvint ();
605     tinfo -> chain_index = recvint ();
606     tinfo -> date_entered = recvint ();
607     tinfo -> num_lines = recvint ();
608     tinfo -> num_chars = recvint ();
609     tinfo -> subject = recvstr ();
610     tinfo -> author = recvstr ();
611     tinfo -> flags = recvint ();
612     tinfo -> signature = recvstr ();
613}
614   
615/*
616 *
617 * old_recv_mtg_info -- Recv a mtg info struct.
618 *
619 */
620old_recv_mtg_info(minfo)
621mtg_info *minfo;
622{
623     minfo -> version = recvint ();
624     minfo -> location = recvstr ();
625     minfo -> long_name = recvstr ();
626     minfo -> chairman = recvstr ();
627     minfo -> first = recvint ();
628     minfo -> last = recvint ();
629     minfo -> lowest = recvint ();
630     minfo -> highest = recvint ();
631     minfo -> date_created = recvint ();
632     minfo -> date_modified = recvint ();
633     minfo -> public_flag = recvbool ();
634}
635
636/*
637 *
638 * recv_mtg_info -- Recv a mtg info struct.
639 *
640 */
641recv_mtg_info(minfo)
642mtg_info *minfo;
643{
644     minfo -> version = recvint ();
645     minfo -> location = recvstr ();
646     minfo -> long_name = recvstr ();
647     minfo -> chairman = recvstr ();
648     minfo -> first = recvint ();
649     minfo -> last = recvint ();
650     minfo -> lowest = recvint ();
651     minfo -> highest = recvint ();
652     minfo -> date_created = recvint ();
653     minfo -> date_modified = recvint ();
654     minfo -> public_flag = recvbool ();
655     minfo -> access_modes = recvstr ();
656}
657
658dsc_acl *recv_acl()
659{
660        /* The following code would lose points in 6.170... */
661        register dsc_acl *result = (dsc_acl *) malloc(sizeof(dsc_acl));
662        register dsc_acl_entry *ae;
663        register unsigned int len;
664        len = recvint();
665        result->acl_length = len;
666        if (len > 1000) /* Bogus! */ {
667                /*XXX Put some error checking in here */
668        }
669        result->acl_entries =
670            (dsc_acl_entry *) malloc(sizeof(dsc_acl_entry) * len);
671        for (ae = result->acl_entries; len; --len, ++ae) {
672                ae->modes = recvstr(); 
673                ae->principal = recvstr();
674        }
675        return result;
676}
677               
Note: See TracBrowser for help on using the repository browser.