]> 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 769ae122a5139babe1c6bb8dc4838cf31a0696f5..79544a66a76cd5876bca9b9c1800d8afcdeab182 100644 (file)
@@ -77,14 +77,14 @@ static int sleepcmd(FILE *input, BSOCK *UA_sock);
 static void usage()
 {
    fprintf(stderr, _(
-"\nVersion: " VERSION " (" BDATE ")\n\n"
+"\nVersion: " VERSION " (" BDATE ") %s %s %s\n\n"
 "Usage: console [-s] [-c config_file] [-d debug_level] [config_file]\n"
 "       -c <file>   set configuration file to file\n"
 "       -dnn        set debug level to nn\n"
 "       -s          no signals\n"
 "       -t          test - read configuration and exit\n"
 "       -?          print this message.\n"  
-"\n"));
+"\n"), HOST_OS, DISTNAME, DISTVER);
 
    exit(1);
 }
@@ -191,7 +191,11 @@ static void read_and_process_input(FILE *input, BSOCK *UA_sock)
       if (stat < 0) {
         break;                       /* error */
       } else if (stat == 0) {        /* timeout */
-         bnet_fsend(UA_sock, ".messages");
+         if (strcmp(prompt, "*") == 0) {
+            bnet_fsend(UA_sock, ".messages");
+        } else {
+           continue;
+        }
       } else {
         at_prompt = FALSE;
         /* @ => internal command for us */
@@ -373,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) {
@@ -419,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);
    }
@@ -504,7 +521,8 @@ again:
 
 static int versioncmd(FILE *input, BSOCK *UA_sock)
 {
-   sendit("Version: " VERSION " (" BDATE ")\n");
+   sendit("Version: " VERSION " (" BDATE ") %s %s %s\n",
+      HOST_OS, DISTNAME, DISTVER);
    return 1;
 }
 
@@ -513,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);
@@ -549,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) {
@@ -565,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;