]> andersk Git - moira.git/blobdiff - lib/mr_ops.c
sms -> mr
[moira.git] / lib / mr_ops.c
index 2930937b45fb5fafa0c17aa66278005251e20d01..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;
@@ -92,5 +92,70 @@ char **motd;
     }  
  punt:
     sms_destroy_reply(reply);
-    return(status);
+    /* for backwards compatability */
+    if (status == SMS_UNKNOWN_PROC)
+      return(0);
+    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.040945 seconds and 4 git commands to generate.