6 * Copyright (C) 1987, 1989 by the Massachusetts Institute of Technology
7 * For copying and distribution information, please see the file
10 * This routine is part of the client library. It handles
11 * the protocol operations: invoking an update and getting the
12 * SMS message of the day.
16 static char *rcsid_sms_do_update_c = "$Header$";
19 #include <mit-copyright.h>
20 #include "sms_private.h"
23 /* Invoke a DCM update. */
29 struct sms_params *params = NULL;
30 struct sms_params *reply = NULL;
34 params->sms_version_no = sending_version_no;
35 params->sms_procno = SMS_DO_UPDATE;
37 params->sms_argl = NULL;
38 params->sms_argv = NULL;
40 if ((status = sms_do_call(params, &reply)) == 0)
41 status = reply->sms_status;
43 sms_destroy_reply(reply);
49 /* Get the SMS motd. This returns an SMS status, and motd will either
50 * point to NULL or the motd in a static buffer.
58 struct sms_params *params = NULL;
59 struct sms_params *reply = NULL;
60 static char buffer[1024];
65 params->sms_version_no = sending_version_no;
66 params->sms_procno = SMS_MOTD;
68 params->sms_argl = NULL;
69 params->sms_argv = NULL;
71 if ((status = sms_do_call(params, &reply)))
74 while ((status = reply->sms_status) == SMS_MORE_DATA) {
75 if (reply->sms_argc > 0) {
76 strncpy(buffer, reply->sms_argv[0], sizeof(buffer));
79 sms_destroy_reply(reply);
82 initialize_operation(_sms_recv_op, sms_start_recv, &reply,
84 queue_operation(_sms_conn, CON_INPUT, _sms_recv_op);
86 sms_complete_operation(_sms_recv_op);
87 if (OP_STATUS(_sms_recv_op) != OP_COMPLETE) {
94 sms_destroy_reply(reply);
95 /* for backwards compatability */
96 if (status == SMS_UNKNOWN_PROC)
103 /* Tell the library to take care of another input source while it is
104 * processing a query. For instance, an X toolkit application would
106 * sms_set_alternate_input(ConnectionNumber(XtDisplay(widget)), doxinput);
107 * where doxinput is defined as:
109 * extern Widget toplevel;
111 * while (XPending(XtDisplay(toplevel))) {
112 * XNextEvent(XtDisplay(toplevel), &event);
113 * XtDispatchEvent(&event);
115 * XFlush(XtDisplay(toplevel));
119 static int sms_alternate_input = 0;
120 static int (*sms_alternate_handler)();
122 int sms_set_alternate_input(fd, proc)
126 if (sms_alternate_input != 0)
127 return(SMS_ALREADY_CONNECTED);
128 sms_alternate_input = fd;
129 sms_alternate_handler = proc;
134 /* This is used by the parts of the library that must wait for GDB. It
135 * handles alternate input streams (such as X) as well.
138 sms_complete_operation(op)
141 long infd, outfd, exfd;
144 gdb_progress(); /* try for an immediate completion */
146 if (sms_alternate_input == 0)
147 return(complete_operation(op));
149 infd = (1<<sms_alternate_input);
152 while(op->status != OP_COMPLETE && op->status != OP_CANCELLED) {
153 rc = con_select(sms_alternate_input, (fd_set *)&infd, (fd_set *)&outfd,
154 (fd_set *)&exfd, (struct timeval *)NULL);
155 if (rc > 0 && sms_alternate_handler) {
156 (*sms_alternate_handler)();