]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/console/console.c
Enhance mountcache with rescan option after interval.
[bacula/bacula] / bacula / src / console / console.c
index 761c21a5616b4ebc26ce3c9deee2b51b16d48839..a5a56064b3910fe07c2b1abfce46dd4de5b6f949 100644 (file)
@@ -1,12 +1,12 @@
 /*
    Bacula® - The Network Backup Solution
 
-   Copyright (C) 2000-2009 Free Software Foundation Europe e.V.
+   Copyright (C) 2000-2011 Free Software Foundation Europe e.V.
 
    The main author of Bacula is Kern Sibbald, with contributions from
    many others, a complete list can be found in the file AUTHORS.
    This program is Free Software; you can redistribute it and/or
-   modify it under the terms of version two of the GNU General Public
+   modify it under the terms of version three of the GNU Affero General Public
    License as published by the Free Software Foundation and included
    in the file LICENSE.
 
@@ -15,7 +15,7 @@
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
    General Public License for more details.
 
-   You should have received a copy of the GNU General Public License
+   You should have received a copy of the GNU Affero General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
@@ -31,7 +31,6 @@
  *
  *     Kern Sibbald, September MM
  *
- *     Version $Id$
  */
 
 #include "bacula.h"
@@ -324,7 +323,7 @@ static void read_and_process_input(FILE *input, BSOCK *UA_sock)
       if (is_bnet_stop(UA_sock)) {
          break;                       /* error or term */
       } else if (stat == BNET_SIGNAL) {
-         if (UA_sock->msglen == BNET_PROMPT) {
+         if (UA_sock->msglen == BNET_SUB_PROMPT) {
             at_prompt = true;
          }
          Dmsg1(100, "Got poll %s\n", bnet_sig_to_ascii(UA_sock));
@@ -523,7 +522,7 @@ void get_items(const char *what)
 
 typedef enum 
 {
-   ITEM_ARG,       /* item with simple list like .job */
+   ITEM_ARG,       /* item with simple list like .jobs */
    ITEM_HELP       /* use help item=xxx and detect all arguments */
 } cpl_item_t;
 
@@ -598,7 +597,8 @@ static struct cpl_keywords_t cpl_keywords[] = {
    {"pool=",      ".pool"          },
    {"fileset=",   ".fileset"       },
    {"client=",    ".client"        },
-   {"job=",       ".job"           },
+   {"job=",       ".jobs"          },
+   {"restorejob=",".jobs type=R"  },
    {"level=",     ".level"         },
    {"storage=",   ".storage"       },
    {"schedule=",  ".schedule"      },
@@ -610,6 +610,7 @@ static struct cpl_keywords_t cpl_keywords[] = {
    {"mark",       ".ls"            },
    {"m",          ".ls"            },
    {"unmark",     ".lsmark"        },
+   {"catalog=",   ".catalogs"      },
    {"actiononpurge=", ".actiononpurge" }
 };
 #define key_size ((int)(sizeof(cpl_keywords)/sizeof(struct cpl_keywords_t)))
@@ -676,6 +677,11 @@ static int eolcmd(FILE *input, BSOCK *UA_sock)
    return 1;
 }
 
+/*
+ * Return 1 if OK
+ *        0 if no input
+ *       -1 error (must stop)
+ */
 int
 get_cmd(FILE *input, const char *prompt, BSOCK *sock, int sec)
 {
@@ -692,7 +698,7 @@ get_cmd(FILE *input, const char *prompt, BSOCK *sock, int sec)
        */
       line = readline((char *)prompt);   /* cast needed for old readlines */
       if (!line) {
-         exit(1);
+         return -1;                      /* error return and exit */
       }
       strip_trailing_junk(line);
       command = line;
@@ -702,7 +708,7 @@ get_cmd(FILE *input, const char *prompt, BSOCK *sock, int sec)
      sendit(_("Command logic problem\n"));
      sock->msglen = 0;
      sock->msg[0] = 0;
-     return 0;
+     return 0;                  /* No input */
    }
 
    /*
@@ -733,7 +739,7 @@ get_cmd(FILE *input, const char *prompt, BSOCK *sock, int sec)
       actuallyfree(line);       /* allocated by readline() malloc */
       line = NULL;
    }
-   return 1;
+   return 1;                    /* OK */
 }
 
 #else /* no readline, do it ourselves */
@@ -846,8 +852,9 @@ static int console_update_history(const char *histfile)
    int ret=0;
 
 #ifdef HAVE_READLINE
-/* first, try to truncate the history file, and if it
- * fail, the file is probably not present, and we
+/*
+ * first, try to truncate the history file, and if it
+ * fails, the file is probably not present, and we
  * can use write_history to create it
  */
 
@@ -856,7 +863,6 @@ static int console_update_history(const char *histfile)
    } else {
       ret = write_history(histfile);
    }
-
 #endif
 
    return ret;
@@ -867,7 +873,6 @@ static int console_init_history(const char *histfile)
    int ret=0;
 
 #ifdef HAVE_READLINE
-
    using_history();
    ret = read_history(histfile);
    /* Tell the completer that we want a complete . */
@@ -1132,7 +1137,7 @@ int main(int argc, char *argv[])
    start_watchdog();                        /* Start socket watchdog */
 
    if(!select_director(director, &dir, &cons)) {
-      return 0;
+      return 1;
    }
 
    senditf(_("Connecting to Director %s:%d\n"), dir->address,dir->DIRport);