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>
21 #include "mr_private.h"
24 /* Invoke a DCM update. */
30 struct mr_params *params = NULL;
31 struct mr_params *reply = NULL;
35 params->mr_version_no = sending_version_no;
36 params->mr_procno = MR_DO_UPDATE;
38 params->mr_argl = NULL;
39 params->mr_argv = NULL;
41 if ((status = mr_do_call(params, &reply)) == 0)
42 status = reply->mr_status;
44 mr_destroy_reply(reply);
50 /* Get the MR motd. This returns an MR status, and motd will either
51 * point to NULL or the motd in a static buffer.
59 struct mr_params *params = NULL;
60 struct mr_params *reply = NULL;
61 static char buffer[1024];
66 params->mr_version_no = sending_version_no;
67 params->mr_procno = MR_MOTD;
69 params->mr_argl = NULL;
70 params->mr_argv = NULL;
72 if ((status = mr_do_call(params, &reply)))
75 while ((status = reply->mr_status) == MR_MORE_DATA) {
76 if (reply->mr_argc > 0) {
77 strncpy(buffer, reply->mr_argv[0], sizeof(buffer));
80 mr_destroy_reply(reply);
83 initialize_operation(_mr_recv_op, mr_start_recv, &reply,
85 queue_operation(_mr_conn, CON_INPUT, _mr_recv_op);
87 mr_complete_operation(_mr_recv_op);
88 if (OP_STATUS(_mr_recv_op) != OP_COMPLETE) {
95 mr_destroy_reply(reply);
96 /* for backwards compatability */
97 if (status == MR_UNKNOWN_PROC)
104 /* Tell the library to take care of another input source while it is
105 * processing a query. For instance, an X toolkit application would
107 * mr_set_alternate_input(ConnectionNumber(XtDisplay(widget)), doxinput);
108 * where doxinput is defined as:
110 * extern Widget toplevel;
112 * while (XPending(XtDisplay(toplevel))) {
113 * XNextEvent(XtDisplay(toplevel), &event);
114 * XtDispatchEvent(&event);
116 * XFlush(XtDisplay(toplevel));
120 static int mr_alternate_input = 0;
121 static int (*mr_alternate_handler)();
123 int mr_set_alternate_input(fd, proc)
127 if (mr_alternate_input != 0)
128 return(MR_ALREADY_CONNECTED);
129 mr_alternate_input = fd;
130 mr_alternate_handler = proc;
135 /* This is used by the parts of the library that must wait for GDB. It
136 * handles alternate input streams (such as X) as well.
139 mr_complete_operation(op)
142 long infd, outfd, exfd;
145 gdb_progress(); /* try for an immediate completion */
147 if (mr_alternate_input == 0)
148 return(complete_operation(op));
150 infd = (1<<mr_alternate_input);
153 while(op->status != OP_COMPLETE && op->status != OP_CANCELLED) {
154 rc = con_select(mr_alternate_input, (fd_set *)&infd, (fd_set *)&outfd,
155 (fd_set *)&exfd, (struct timeval *)NULL);
156 if (rc > 0 && mr_alternate_handler) {
157 (*mr_alternate_handler)();