]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/console/console.c
Implement Qmsg() + conio linking
[bacula/bacula] / bacula / src / console / console.c
index 6436ab9a3549e23e4470ff775e47356b1fa3eedb..614951411754f432c660b06e794e292173aa19aa 100644 (file)
@@ -196,10 +196,19 @@ static void read_and_process_input(FILE *input, BSOCK *UA_sock)
       }
       if (tty_input) {
         stat = get_cmd(input, prompt, UA_sock, 30);
-        clrbrk();
+        if (usrbrk() == 1) {
+           clrbrk();
+        }
+        if (usrbrk()) {
+           break;
+        }
       } else {
+        /* Reading input from a file */
         int len = sizeof_pool_memory(UA_sock->msg) - 1;
-        if (fgets(UA_sock->msg, len, input) == NULL || usrbrk()) {
+        if (usrbrk()) {
+           break;
+        }
+        if (fgets(UA_sock->msg, len, input) == NULL) {
            stat = -1;
         } else {
            sendit(UA_sock->msg);  /* echo to terminal */
@@ -245,6 +254,11 @@ static void read_and_process_input(FILE *input, BSOCK *UA_sock)
            sendit(UA_sock->msg);
         }
       }
+      if (usrbrk() > 1) {
+        break;
+      } else {
+        clrbrk();
+      }
       if (!stop) {
         fflush(stdout);
       }
@@ -404,6 +418,7 @@ try_again:
    LockRes();
    CONRES *cons = (CONRES *)GetNextRes(R_CONSOLE, (RES *)NULL);
    UnlockRes();
+   /* If cons==NULL, default console will be used */
    if (!authenticate_director(&jcr, dir, cons)) {
       fprintf(stderr, "ERR=%s", UA_sock->msg);
       terminate_console(0);
@@ -554,6 +569,9 @@ again:
       }
       break;
    }
+   if (usrbrk()) {
+      clrbrk();
+   }
    strip_trailing_junk(sock->msg);
    sock->msglen = strlen(sock->msg);
    return 1;