]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/console/console.c
This commit was manufactured by cvs2svn to create tag
[bacula/bacula] / bacula / src / console / console.c
index deba1f9c25cb5ec44fd5c2d76797147030e4427c..79544a66a76cd5876bca9b9c1800d8afcdeab182 100644 (file)
@@ -191,8 +191,10 @@ static void read_and_process_input(FILE *input, BSOCK *UA_sock)
       if (stat < 0) {
         break;                       /* error */
       } else if (stat == 0) {        /* timeout */
-        if (at_prompt) {
+         if (strcmp(prompt, "*") == 0) {
             bnet_fsend(UA_sock, ".messages");
+        } else {
+           continue;
         }
       } else {
         at_prompt = FALSE;
@@ -375,6 +377,20 @@ try_again:
 
    Dmsg0(40, "Opened connection with Director daemon\n");
 
+   sendit(_("Enter a period to cancel a command.\n"));
+
+   char *env = getenv("HOME");
+   if (env) {
+      FILE *fd;
+      pm_strcpy(&UA_sock->msg, env);
+      pm_strcat(&UA_sock->msg, "/.bconsolerc");
+      fd = fopen(UA_sock->msg, "r");
+      if (fd) {
+       read_and_process_input(fd, UA_sock);
+       fclose(fd);
+      }
+   }
+
    read_and_process_input(stdin, UA_sock);
 
    if (UA_sock) {
@@ -421,9 +437,8 @@ get_cmd(FILE *input, char *prompt, BSOCK *sock, int sec)
    if (!line) {
       exit(1);
    }
-   strcpy(sock->msg, line);
-   strip_trailing_junk(sock->msg);
-   sock->msglen = strlen(sock->msg);
+   strip_trailing_junk(line);
+   sock->msglen = pm_strcpy(&sock->msg, line);
    if (sock->msglen) {
       add_history(sock->msg);
    }
@@ -516,17 +531,18 @@ static int inputcmd(FILE *input, BSOCK *UA_sock)
    FILE *fd;
 
    if (argc > 2) {
-      sendit(_("Too many arguments.\n"));
-      return 0;
+      sendit(_("Too many arguments on input command.\n"));
+      return 1;
    }
    if (argc == 1) {
-      sendit(_("First argument must be a filename.\n"));
-      return 0;
+      sendit(_("First argument to input command must be a filename.\n"));
+      return 1;
    }
    fd = fopen(argk[1], "r");
    if (!fd) {
-      sendit(_("Cannot open file. ERR=%s\n"), strerror(errno));
-      return 0; 
+      sendit(_("Cannot open file %s for input. ERR=%s\n"), 
+        argk[1], strerror(errno));
+      return 1; 
    }
    read_and_process_input(fd, UA_sock);
    fclose(fd);
@@ -552,7 +568,7 @@ static int do_outputcmd(FILE *input, BSOCK *UA_sock)
    char *mode = "a+";
 
    if (argc > 3) {
-      sendit(_("Too many arguments.\n"));
+      sendit(_("Too many arguments on output/tee command.\n"));
       return 1;
    }
    if (argc == 1) {
@@ -568,7 +584,8 @@ static int do_outputcmd(FILE *input, BSOCK *UA_sock)
    }
    fd = fopen(argk[1], mode);
    if (!fd) {
-      sendit(_("Cannot open file. ERR=%s\n"), strerror(errno));
+      sendit(_("Cannot open file %s for output. ERR=%s\n"), 
+        argk[1], strerror(errno));
       return 1; 
    }
    output = fd;