]> andersk Git - moira.git/blame - lib/mr_query.c
strip off the high bit from all keyboard input
[moira.git] / lib / mr_query.c
CommitLineData
92eb0760 1/*
2 * $Source$
3 * $Author$
4 * $Header$
5 *
6 * Copyright (C) 1987 by the Massachusetts Institute of Technology
7 *
8 * $Log$
d0dbd4ea 9 * Revision 1.4 1987-08-22 17:11:16 wesommer
10 * Increment the nesting level only after we know we're connected.
92eb0760 11 *
d0dbd4ea 12 * Revision 1.3 87/08/02 21:49:53 wesommer
13 * Prevent recursive query call.
14 *
4bff4d9d 15 * Revision 1.2 87/06/16 17:48:58 wesommer
16 * Clean up memory allocation, indenting.
17 *
83e80378 18 * Revision 1.1 87/06/04 01:29:32 wesommer
19 * Initial revision
20 *
92eb0760 21 */
22
23#ifndef lint
24static char *rcsid_sms_query_c = "$Header$";
25#endif lint
26
27#include "sms_private.h"
28
83e80378 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 */
4bff4d9d 35int level = 0;
83e80378 36
92eb0760 37int sms_query(name, argc, argv, callproc, callarg)
83e80378 38 char *name; /* Query name */
39 int argc; /* Arg count */
40 char **argv; /* Args */
41 int (*callproc)(); /* Callback procedure */
42 char *callarg; /* Callback argument */
92eb0760 43{
83e80378 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 */
92eb0760 64
83e80378 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;
4bff4d9d 76
77 if (level) return SMS_QUERY_NOT_REENTRANT;
83e80378 78
79 CHECK_CONNECTED;
d0dbd4ea 80 level++;
92eb0760 81
83e80378 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;
92eb0760 87
83e80378 88 if ((status = sms_do_call(params, &reply)))
89 goto punt;
92eb0760 90
83e80378 91 while ((status = reply->sms_status) == SMS_MORE_DATA) {
92 if (!stopcallbacks)
93 stopcallbacks =
92eb0760 94 (*callproc)(reply->sms_argc, reply->sms_argv, callarg);
92eb0760 95 sms_destroy_reply(reply);
83e80378 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();
4bff4d9d 105 status = SMS_ABORTED;
106 goto punt_1;
92eb0760 107 }
83e80378 108 }
109punt:
110 sms_destroy_reply(reply);
4bff4d9d 111punt_1:
112 level--;
83e80378 113 return status;
92eb0760 114}
83e80378 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.137917 seconds and 5 git commands to generate.