(int (*)())NULL);
queue_operation(_sms_conn, CON_INPUT, _sms_recv_op);
- complete_operation(_sms_recv_op);
+ sms_complete_operation(_sms_recv_op);
if (OP_STATUS(_sms_recv_op) != OP_COMPLETE) {
sms_disconnect();
status = SMS_ABORTED;
else
return(status);
}
+
+
+/* Tell the library to take care of another input source while it is
+ * processing a query. For instance, an X toolkit application would
+ * do something like
+ * sms_set_alternate_input(ConnectionNumber(XtDisplay(widget)), doxinput);
+ * where doxinput is defined as:
+ * doxinput() {
+ * extern Widget toplevel;
+ * XEvent event;
+ * while (XPending(XtDisplay(toplevel))) {
+ * XNextEvent(XtDisplay(toplevel), &event);
+ * XtDispatchEvent(&event);
+ * }
+ * XFlush(XtDisplay(toplevel));
+ * }
+ */
+
+static int sms_alternate_input = 0;
+static int (*sms_alternate_handler)();
+
+int sms_set_alternate_input(fd, proc)
+int fd;
+int (*proc)();
+{
+ if (sms_alternate_input != 0)
+ return(SMS_ALREADY_CONNECTED);
+ sms_alternate_input = fd;
+ sms_alternate_handler = proc;
+ return(SMS_SUCCESS);
+}
+
+
+/* This is used by the parts of the library that must wait for GDB. It
+ * handles alternate input streams (such as X) as well.
+ */
+
+sms_complete_operation(op)
+OPERATION op;
+{
+ long infd, outfd, exfd;
+ int rc;
+
+ gdb_progress(); /* try for an immediate completion */
+
+ if (sms_alternate_input == 0)
+ return(complete_operation(op));
+
+ infd = (1<<sms_alternate_input);
+ outfd = exfd = 0;
+
+ while(op->status != OP_COMPLETE && op->status != OP_CANCELLED) {
+ rc = con_select(sms_alternate_input, (fd_set *)&infd, (fd_set *)&outfd,
+ (fd_set *)&exfd, (struct timeval *)NULL);
+ if (rc > 0 && sms_alternate_handler) {
+ (*sms_alternate_handler)();
+ }
+ }
+ return(op->status);
+}
+