6 * Copyright (C) 1987, 1989, 1990 by the Massachusetts Institute of
8 * For copying and distribution information, please see the file
11 * This routine is part of the client library. It handles
12 * the protocol operations: invoking an update and getting the
13 * MR message of the day.
17 static char *rcsid_sms_do_update_c = "$Header$";
20 #include <mit-copyright.h>
22 #include "mr_private.h"
25 /* Invoke a DCM update. */
31 struct mr_params *params = NULL;
32 struct mr_params *reply = NULL;
36 params->mr_version_no = sending_version_no;
37 params->mr_procno = MR_DO_UPDATE;
39 params->mr_argl = NULL;
40 params->mr_argv = NULL;
42 if ((status = mr_do_call(params, &reply)) == 0)
43 status = reply->mr_status;
45 mr_destroy_reply(reply);
51 /* Get the MR motd. This returns an MR status, and motd will either
52 * point to NULL or the motd in a static buffer.
60 struct mr_params *params = NULL;
61 struct mr_params *reply = NULL;
62 static char buffer[1024];
67 params->mr_version_no = sending_version_no;
68 params->mr_procno = MR_MOTD;
70 params->mr_argl = NULL;
71 params->mr_argv = NULL;
73 if ((status = mr_do_call(params, &reply)))
76 while ((status = reply->mr_status) == MR_MORE_DATA) {
77 if (reply->mr_argc > 0) {
78 strncpy(buffer, reply->mr_argv[0], sizeof(buffer));
81 mr_destroy_reply(reply);
84 initialize_operation(_mr_recv_op, mr_start_recv, &reply,
86 queue_operation(_mr_conn, CON_INPUT, _mr_recv_op);
88 mr_complete_operation(_mr_recv_op);
89 if (OP_STATUS(_mr_recv_op) != OP_COMPLETE) {
96 mr_destroy_reply(reply);
97 /* for backwards compatability */
98 if (status == MR_UNKNOWN_PROC)
105 /* Tell the library to take care of another input source while it is
106 * processing a query. For instance, an X toolkit application would
108 * mr_set_alternate_input(ConnectionNumber(XtDisplay(widget)), doxinput);
109 * where doxinput is defined as:
111 * extern Widget toplevel;
113 * while (XPending(XtDisplay(toplevel))) {
114 * XNextEvent(XtDisplay(toplevel), &event);
115 * XtDispatchEvent(&event);
117 * XFlush(XtDisplay(toplevel));
121 static int mr_alternate_input = 0;
122 static int (*mr_alternate_handler)();
124 int mr_set_alternate_input(fd, proc)
128 if (mr_alternate_input != 0)
129 return(MR_ALREADY_CONNECTED);
130 mr_alternate_input = fd;
131 mr_alternate_handler = proc;
136 /* This is used by the parts of the library that must wait for GDB. It
137 * handles alternate input streams (such as X) as well.
140 mr_complete_operation(op)
143 long infd, outfd, exfd;
146 gdb_progress(); /* try for an immediate completion */
148 if (mr_alternate_input == 0)
149 return(complete_operation(op));
151 infd = (1<<mr_alternate_input);
154 while(op->status != OP_COMPLETE && op->status != OP_CANCELLED) {
155 rc = con_select(mr_alternate_input, (fd_set *)&infd, (fd_set *)&outfd,
156 (fd_set *)&exfd, (struct timeval *)NULL);
157 if (rc > 0 && mr_alternate_handler) {
158 (*mr_alternate_handler)();