* print some info to the client while putting stuff into the db
authorWilfried Göesgens <willi@citadel.org>
Tue, 26 Jun 2007 20:55:08 +0000 (20:55 +0000)
committerWilfried Göesgens <willi@citadel.org>
Tue, 26 Jun 2007 20:55:08 +0000 (20:55 +0000)
* use select() to read more from the citserver.

citadel/sendcommand.c
citadel/serv_vandelay.c

index 5e80465a9abe31db3334809884221b5d922e1137..d7affd61105d486870b83d01c7170f1b202f6de0 100644 (file)
@@ -142,11 +142,15 @@ int main(int argc, char **argv)
        int a;
        char cmd[SIZ];
        char buf[SIZ];
+       char rbuf[SIZ];
 
        int relh=0;
        int home=0;
        char relhome[PATH_MAX]="";
        char ctdldir[PATH_MAX]=CTDLDIR;
+       fd_set read_fd;
+       struct timeval tv;
+       int ret, err;
 
        strcpy(ctdl_home_directory, DEFAULT_PORT);
 
@@ -193,6 +197,9 @@ int main(int argc, char **argv)
        CtdlIPC_chat_recv(ipc, buf);
        fprintf(stderr, "%s\n", buf);
 
+       tv.tv_sec = 0;
+       tv.tv_usec = 1000;
+
        if (buf[0] == '1') {
                while (CtdlIPC_chat_recv(ipc, buf), strcmp(buf, "000")) {
                        printf("%s\n", buf);
@@ -209,6 +216,28 @@ int main(int argc, char **argv)
                                        buf[strlen(buf) - 1] = 0;
                        if (strcmp(buf, "000"))
                                CtdlIPC_chat_send(ipc, buf);
+
+                       FD_ZERO(&read_fd);
+                       FD_SET(ipc->sock, &read_fd);
+                       ret = select(ipc->sock+1, &read_fd, NULL, NULL,  &tv);
+                       err=errno;
+                       if (err!=0)
+                               printf("select failed: %d", err);
+
+                       if (ret == -1) {
+                               if (!(errno == EINTR || errno == EAGAIN))
+                                       printf("select failed: %d", err);
+                               return 1;
+                       }
+
+                       if (ret != 0){
+                               rbuf[0] = '\0';
+                               read(ipc->sock, rbuf, SIZ);
+                               if (rbuf[0]!=0) {
+                                       printf (rbuf);
+                                       memset (rbuf, '\0', SIZ);
+                               }
+                       }
                } while (strcmp(buf, "000"));
                CtdlIPC_chat_send(ipc, "000");
        }
index b8ab892f06b533c98baf7d058915b3282542f2a6..a2f3ac3c2e72cdce3decc074d149b4d2d934e252 100644 (file)
@@ -646,16 +646,27 @@ void artv_import_message(void) {
 
 void artv_do_import(void) {
        char buf[SIZ];
+       char abuf[SIZ];
        char s_version[SIZ];
        int version;
 
        unbuffer_output();
 
        cprintf("%d sock it to me\n", SEND_LISTING);
+       abuf[0] = '\0';
+       unbuffer_output();
        while (client_getln(buf, sizeof buf), strcmp(buf, "000")) {
 
                lprintf(CTDL_DEBUG, "import keyword: <%s>\n", buf);
-
+               if ((abuf[0] == '\0') || (strcasecmp(buf, abuf))) {
+                       cprintf ("\n\nImporting datatype %s\n", buf);
+                       strncpy (abuf, buf, SIZ);                       
+               }
+                       else {
+                       cprintf(".");
+                       
+               }
+               
                if (!strcasecmp(buf, "version")) {
                        client_getln(s_version, sizeof s_version);
                        version = atoi(s_version);
@@ -676,6 +687,7 @@ void artv_do_import(void) {
        }
        lprintf(CTDL_INFO, "Invalid keyword <%s>.  Flushing input.\n", buf);
        while (client_getln(buf, sizeof buf), strcmp(buf, "000"))  ;;
+       cprintf("done.\n");
        rebuild_euid_index();
 }