]> andersk Git - moira.git/blame - server/mr_scall.c
Added three error codes.
[moira.git] / server / mr_scall.c
CommitLineData
a3cf6921 1/*
2 * $Source$
3 * $Author$
4 * $Header$
5 *
6 * Copyright (C) 1987 by the Massachusetts Institute of Technology
7 *
8 * $Log$
c27b3454 9 * Revision 1.4 1987-06-21 16:42:00 wesommer
10 * Performance work, rearrangement of include files.
a3cf6921 11 *
c27b3454 12 * Revision 1.3 87/06/04 01:35:01 wesommer
13 * Added a working query request handler.
14 *
78849033 15 * Revision 1.2 87/06/03 16:07:50 wesommer
16 * Fixes for lint.
17 *
5dbd09a0 18 * Revision 1.1 87/06/02 20:07:10 wesommer
19 * Initial revision
20 *
a3cf6921 21 */
22
23#ifndef lint
24static char *rcsid_sms_scall_c = "$Header$";
25#endif lint
26
27#include <krb.h>
78849033 28#include <errno.h>
a3cf6921 29#include "sms_server.h"
30extern char buf1[];
31extern int nclients;
32extern char *whoami;
33
34extern void clist_delete(), do_auth(), do_shutdown();
35void do_call();
36
37/*
38 * Welcome to the (finite state) machine (highest level).
39 */
40void
41do_client(cp)
42 client *cp;
43{
44 if (OP_STATUS(cp->pending_op) == OP_CANCELLED) {
45 (void) sprintf(buf1, "Closed connection (now %d client%s)",
46 nclients-1,
47 nclients!=2?"s":"");
48 com_err(whoami, 0, buf1);
49 clist_delete(cp);
50 return;
51 }
52 switch (cp->action) {
53 case CL_ACCEPT:
54 case CL_SEND:
55 /* Start recieving next request */
56 initialize_operation(cp->pending_op, sms_start_recv,
5dbd09a0 57 (char *)&cp->args, (int (*)())NULL);
a3cf6921 58 queue_operation(cp->con, CON_INPUT, cp->pending_op);
59 cp->action = CL_RECEIVE;
60 break;
61 case CL_RECEIVE:
62 /* Data is here. Process it & start it heading back */
63 do_call(cp); /* This may block for a while. */
64 initialize_operation(cp->pending_op, sms_start_send,
5dbd09a0 65 (char *)&cp->reply, (int (*)())NULL);
a3cf6921 66 queue_operation(cp->con, CON_OUTPUT, cp->pending_op);
67 cp->action = CL_SEND;
68 break;
69 }
70}
71
72#ifdef notdef
73char *procnames[] = {
74 "noop",
75 "auth",
76 "shutdown",
78849033 77 "query",
a3cf6921 78 };
79#endif notdef
80
81void
82do_call(cl)
83 client *cl;
84{
85 int pn;
86 cl->reply.sms_argc = 0;
87 cl->reply.sms_status = 0;
88 if (((pn = cl->args->sms_procno) < 0) ||
89 (pn > SMS_MAX_PROC)) {
90 com_err(whoami, 0, "procno out of range");
91 cl->reply.sms_status = SMS_UNKNOWN_PROC;
92 return;
93 }
94#ifdef SMS_DBG
95 fprintf(stderr, "[#%d] %s(", cl->id, procnames[pn]);
96 for (i=0; i < cl->args->sms_argc; i++) {
97 if (i) fputc(',', stderr);
98 frequote(stderr,cl->args->sms_argv[i]);
99 }
100 fprintf(stderr, ")\n");
101#endif SMS_DBG
102
103 switch(pn) {
104 case SMS_NOOP:
105 cl->reply.sms_status = 0;
106 com_err(whoami, 0, "noop");
107 return;
108 case SMS_AUTH:
109 do_auth(cl);
110 return;
78849033 111
112 case SMS_QUERY:
a3cf6921 113 do_retr(cl);
114 return;
a3cf6921 115
116 case SMS_SHUTDOWN:
117 do_shutdown(cl);
118 return;
119 }
120}
121
78849033 122retr_callback(argc, argv, p_cp)
123 int argc;
124 char **argv;
125 char *p_cp;
126{
127 register client *cp = (client *)p_cp;
128 /* XXX MEM when are these freed?? */
129 /*
130 * This takes too much advantage of the fact that
131 * serialization of the data happens during the queue operation.
132 */
133 sms_params *arg_tmp = (sms_params *)db_alloc(sizeof(sms_params));
134 OPERATION op_tmp = create_operation();
78849033 135
136#ifdef notdef /* We really don't want this logged */
137 com_err(whoami, 0, "Returning next data:");
138 log_args(argc, argv);
139#endif notdef
140
141 arg_tmp->sms_status = SMS_MORE_DATA;
142 arg_tmp->sms_argc = argc;
143 arg_tmp->sms_argv = argv;
144 arg_tmp->sms_flattened = (char *)NULL;
145 arg_tmp->sms_argl = (int *)NULL;
146 reset_operation(op_tmp);
147 initialize_operation(op_tmp, sms_start_send, (char *)arg_tmp,
148 (int (*)())NULL);
149 queue_operation(cp->con, CON_OUTPUT, op_tmp);
150}
151
152
a3cf6921 153do_retr(cl)
154 client *cl;
155{
78849033 156 cl->reply.sms_argc = 0;
157 cl->reply.sms_status = 0;
c27b3454 158#ifdef notdef
78849033 159 if (!cl->clname) {
160 com_err(whoami, 0, "Unauthenticated query rejected");
161 cl->reply.sms_status = EACCES;
162 return;
163 }
c27b3454 164#endif notdef
78849033 165 com_err(whoami, 0, "Processing query: ");
166 log_args(cl->args->sms_argc, cl->args->sms_argv);
a3cf6921 167
78849033 168 sms_process_query(cl->args->sms_argv[0],
169 cl->args->sms_argc-1,
170 cl->args->sms_argv+1,
171 retr_callback,
172 (char *)cl);
173
174 com_err(whoami, 0, "Query complete.");
a3cf6921 175}
78849033 176
This page took 1.0067 seconds and 5 git commands to generate.