]> andersk Git - moira.git/blame_incremental - lib/mr_query.c
replace hardcoded ATHENA realm with call to get_krbrlm();
[moira.git] / lib / mr_query.c
... / ...
CommitLineData
1/*
2 * $Source$
3 * $Author$
4 * $Header$
5 *
6 * Copyright (C) 1987 by the Massachusetts Institute of Technology
7 *
8 * $Log$
9 * Revision 1.4 1987-08-22 17:11:16 wesommer
10 * Increment the nesting level only after we know we're connected.
11 *
12 * Revision 1.3 87/08/02 21:49:53 wesommer
13 * Prevent recursive query call.
14 *
15 * Revision 1.2 87/06/16 17:48:58 wesommer
16 * Clean up memory allocation, indenting.
17 *
18 * Revision 1.1 87/06/04 01:29:32 wesommer
19 * Initial revision
20 *
21 */
22
23#ifndef lint
24static char *rcsid_sms_query_c = "$Header$";
25#endif lint
26
27#include "sms_private.h"
28
29/*
30 * This routine is the primary external interface to the sms library.
31 *
32 * It builds a new argument vector with the query handle prepended,
33 * and calls sms_query_internal.
34 */
35int level = 0;
36
37int sms_query(name, argc, argv, callproc, callarg)
38 char *name; /* Query name */
39 int argc; /* Arg count */
40 char **argv; /* Args */
41 int (*callproc)(); /* Callback procedure */
42 char *callarg; /* Callback argument */
43{
44 register char **nargv = (char **)malloc(sizeof(char *) * (argc+1));
45 register int status = 0;
46 nargv[0] = name;
47 bcopy((char *)argv, (char *)(nargv+1), sizeof(char *) * argc);
48 status = sms_query_internal(argc+1, nargv, callproc, callarg);
49 free(nargv);
50 return status;
51}
52/*
53 * This routine makes an SMS query.
54 *
55 * argv[0] is the query name.
56 * argv[1..argc-1] are the query arguments.
57 *
58 * callproc is called once for each returned value, with arguments
59 * argc, argv, and callarg.
60 * If it returns a non-zero value, further calls to it are not done, and
61 * all future data from the server is ignored (there should be some
62 * way to send it a quench..)
63 */
64
65int sms_query_internal(argc, argv, callproc, callarg)
66 int argc; /* Arg count */
67 char **argv; /* Args */
68 int (*callproc)(); /* Callback procedure */
69 char *callarg; /* Callback argument */
70{
71 int status;
72 sms_params params_st;
73 register sms_params *params = NULL;
74 sms_params *reply = NULL;
75 int stopcallbacks = 0;
76
77 if (level) return SMS_QUERY_NOT_REENTRANT;
78
79 CHECK_CONNECTED;
80 level++;
81
82 params = &params_st;
83 params->sms_procno = SMS_QUERY;
84 params->sms_argc = argc;
85 params->sms_argl = NULL;
86 params->sms_argv = argv;
87
88 if ((status = sms_do_call(params, &reply)))
89 goto punt;
90
91 while ((status = reply->sms_status) == SMS_MORE_DATA) {
92 if (!stopcallbacks)
93 stopcallbacks =
94 (*callproc)(reply->sms_argc, reply->sms_argv, callarg);
95 sms_destroy_reply(reply);
96 reply = NULL;
97
98 initialize_operation(_sms_recv_op, sms_start_recv, &reply,
99 (int (*)())NULL);
100 queue_operation(_sms_conn, CON_INPUT, _sms_recv_op);
101
102 complete_operation(_sms_recv_op);
103 if (OP_STATUS(_sms_recv_op) != OP_COMPLETE) {
104 sms_disconnect();
105 status = SMS_ABORTED;
106 goto punt_1;
107 }
108 }
109punt:
110 sms_destroy_reply(reply);
111punt_1:
112 level--;
113 return status;
114}
115/*
116 * Local Variables:
117 * mode: c
118 * c-indent-level: 4
119 * c-continued-statement-offset: 4
120 * c-brace-offset: -4
121 * c-argdecl-indent: 4
122 * c-label-offset: -4
123 * End:
124 */
This page took 0.214006 seconds and 5 git commands to generate.