]> andersk Git - moira.git/commitdiff
added sms_set_alternate_input() and associated code for sms_complete_operation
authormar <mar>
Wed, 6 Sep 1989 17:43:52 +0000 (17:43 +0000)
committermar <mar>
Wed, 6 Sep 1989 17:43:52 +0000 (17:43 +0000)
lib/mr_ops.c

index 26239e7bdb63fb284bdf5541cc1d761fc37a1fed..f5ef57957bba92591dfe86971c1e810625170633 100644 (file)
@@ -83,7 +83,7 @@ char **motd;
                             (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;
@@ -98,3 +98,64 @@ char **motd;
     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);
+}
+
This page took 0.033455 seconds and 5 git commands to generate.