]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/dird/dird_conf.c
kes Extend new GUI api code to tree commands.
[bacula/bacula] / bacula / src / dird / dird_conf.c
index 7c2636f768cd4ca48d4bb0d599195e40f955b7e6..e1b534415a6e1f27d4782ccc8919d6be20c694a0 100644 (file)
@@ -1,30 +1,7 @@
-/*
- *   Main configuration file parser for Bacula Directors,
- *    some parts may be split into separate files such as
- *    the schedule configuration (run_config.c).
- *
- *   Note, the configuration file parser consists of three parts
- *
- *   1. The generic lexical scanner in lib/lex.c and lib/lex.h
- *
- *   2. The generic config  scanner in lib/parse_config.c and
- *      lib/parse_config.h.
- *      These files contain the parser code, some utility
- *      routines, and the common store routines (name, int,
- *      string).
- *
- *   3. The daemon specific file, which contains the Resource
- *      definitions as well as any specific store routines
- *      for the resource records.
- *
- *     Kern Sibbald, January MM
- *
- *     Version $Id$
- */
 /*
    Bacula® - The Network Backup Solution
 
-   Copyright (C) 2000-2006 Free Software Foundation Europe e.V.
+   Copyright (C) 2000-2007 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.
    (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
    Switzerland, email:ftf@fsfeurope.org.
 */
+/*
+ *   Main configuration file parser for Bacula Directors,
+ *    some parts may be split into separate files such as
+ *    the schedule configuration (run_config.c).
+ *
+ *   Note, the configuration file parser consists of three parts
+ *
+ *   1. The generic lexical scanner in lib/lex.c and lib/lex.h
+ *
+ *   2. The generic config  scanner in lib/parse_config.c and
+ *      lib/parse_config.h.
+ *      These files contain the parser code, some utility
+ *      routines, and the common store routines (name, int,
+ *      string).
+ *
+ *   3. The daemon specific file, which contains the Resource
+ *      definitions as well as any specific store routines
+ *      for the resource records.
+ *
+ *     Kern Sibbald, January MM
+ *
+ *     Version $Id$
+ */
+
 
 #include "bacula.h"
 #include "dird.h"
@@ -361,6 +362,7 @@ static RES_ITEM pool_items[] = {
    {"storage",       store_alist_res, ITEM(res_pool.storage),  R_STORAGE, 0, 0},
    {"autoprune",       store_bool,    ITEM(res_pool.AutoPrune), 0, ITEM_DEFAULT, true},
    {"recycle",         store_bool,    ITEM(res_pool.Recycle),   0, ITEM_DEFAULT, true},
+   {"recyclepool",     store_res,     ITEM(res_pool.RecyclePool), R_POOL, 0, 0},
    {NULL, NULL, {0}, 0, 0, 0}
 };
 
@@ -853,8 +855,10 @@ next_run:
               edit_uint64(res->res_pool.MigrationHighBytes, ed2),
               edit_uint64(res->res_pool.MigrationLowBytes, ed3));
       if (res->res_pool.NextPool) {
-         sendit(sock, _("  --> "));
-         dump_resource(-R_POOL, (RES *)res->res_pool.NextPool, sendit, sock);
+         sendit(sock, _("      NextPool=%s\n"), res->res_pool.NextPool->name());
+      }
+      if (res->res_pool.RecyclePool) {
+         sendit(sock, _("      RecyclePool=%s\n"), res->res_pool.RecyclePool->name());
       }
       if (res->res_pool.storage) {
          STORE *store;
@@ -1245,6 +1249,7 @@ void save_resource(int type, RES_ITEM *items, int pass)
          }
          /* Explicitly copy resource pointers from this pass (res_all) */
          res->res_pool.NextPool = res_all.res_pool.NextPool;
+         res->res_pool.RecyclePool = res_all.res_pool.RecyclePool;
          res->res_pool.storage    = res_all.res_pool.storage;
          break;
       case R_CONSOLE:
@@ -1375,7 +1380,7 @@ void save_resource(int type, RES_ITEM *items, int pass)
       error = true;
       break;
    default:
-      printf(_("Unknown resource type %d in save_resrouce.\n"), type);
+      printf(_("Unknown resource type %d in save_resource.\n"), type);
       error = true; 
       break;
    }
@@ -1388,20 +1393,21 @@ void save_resource(int type, RES_ITEM *items, int pass)
          Dmsg3(900, "Inserting first %s res: %s index=%d\n", res_to_str(type),
                res->res_dir.hdr.name, rindex);
       } else {
-         RES *next;
+         RES *next, *last;
          if (res->res_dir.hdr.name == NULL) {
             Emsg1(M_ERROR_TERM, 0, _("Name item is required in %s resource, but not found.\n"),
                   resources[rindex]);
          }   
          /* Add new res to end of chain */
-         for (next=res_head[rindex]; next->next; next=next->next) {
+         for (last=next=res_head[rindex]; next; next=next->next) {
+            last = next;
             if (strcmp(next->name, res->res_dir.hdr.name) == 0) {
                Emsg2(M_ERROR_TERM, 0,
                   _("Attempt to define second %s resource named \"%s\" is not permitted.\n"),
                   resources[rindex].name, res->res_dir.hdr.name);
             }
          }
-         next->next = (RES *)res;
+         last->next = (RES *)res;
          Dmsg4(900, _("Inserting %s res: %s index=%d pass=%d\n"), res_to_str(type),
                res->res_dir.hdr.name, rindex, pass);
       }
@@ -1607,9 +1613,9 @@ static void store_runscript_target(LEX *lc, RES_ITEM *item, int index, int pass)
    if (pass == 2) {
       if (strcmp(lc->str, "%c") == 0) {
          ((RUNSCRIPT*) item->value)->set_target(lc->str);
-      } else if (strcmp(lc->str, "yes") == 0) {
+      } else if (strcasecmp(lc->str, "yes") == 0) {
          ((RUNSCRIPT*) item->value)->set_target("%c");
-      } else if (strcmp(lc->str, "no") == 0) {
+      } else if (strcasecmp(lc->str, "no") == 0) {
          ((RUNSCRIPT*) item->value)->set_target("");
       } else {
          RES *res = GetResWithName(R_CLIENT, lc->str);
@@ -1691,19 +1697,35 @@ static void store_short_runscript(LEX *lc, RES_ITEM *item, int index, int pass)
    scan_to_eol(lc);
 }
 
+/* Store a bool in a bit field without modifing res_all.hdr 
+ * We can also add an option to store_bool to skip res_all.hdr
+ */
+void store_runscript_bool(LEX *lc, RES_ITEM *item, int index, int pass)
+{
+   lex_get_token(lc, T_NAME);
+   if (strcasecmp(lc->str, "yes") == 0 || strcasecmp(lc->str, "true") == 0) {
+      *(bool *)(item->value) = true;
+   } else if (strcasecmp(lc->str, "no") == 0 || strcasecmp(lc->str, "false") == 0) {
+      *(bool *)(item->value) = false;
+   } else {
+      scan_err2(lc, _("Expect %s, got: %s"), "YES, NO, TRUE, or FALSE", lc->str); /* YES and NO must not be translated */
+   }
+   scan_to_eol(lc);
+}
+
 /*
  * new RunScript items
- *   name             handler         value                                code flags default_value
+ *   name             handler              value                             code flags default_value
  */
 static RES_ITEM runscript_items[] = {
  {"command", store_runscript_cmd,    {(char **)&res_runscript},           0,  ITEM_REQUIRED, 0}, 
  {"target", store_runscript_target,  {(char **)&res_runscript},            0,  0, 0}, 
  {"runsonsuccess",    store_bool,    {(char **)&res_runscript.on_success}, 0,  0, 0},
  {"runsonfailure",    store_bool,    {(char **)&res_runscript.on_failure}, 0,  0, 0},
  {"abortjobonerror", store_bool,     {(char **)&res_runscript.abort_on_error}, 0, 0,   0},
  {"runswhen", store_runscript_when,  {(char **)&res_runscript.when},       0,  0, 0},
  {"runsonclient", store_runscript_target,  {(char **)&res_runscript},       0,  0, 0}, /* TODO */
  {NULL, NULL, {0}, 0, 0, 0}
{"command",        store_runscript_cmd,  {(char **)&res_runscript},           0,  ITEM_REQUIRED, 0}, 
{"target",         store_runscript_target,{(char **)&res_runscript},          0,  0, 0}, 
{"runsonsuccess",  store_runscript_bool, {(char **)&res_runscript.on_success},0,  0, 0},
{"runsonfailure",  store_runscript_bool, {(char **)&res_runscript.on_failure},0,  0, 0},
{"abortjobonerror",store_runscript_bool, {(char **)&res_runscript.abort_on_error},0, 0, 0},
{"runswhen",       store_runscript_when, {(char **)&res_runscript.when},      0,  0, 0},
{"runsonclient",   store_runscript_target,{(char **)&res_runscript},          0,  0, 0}, /* TODO */
+ {NULL, NULL, {0}, 0, 0, 0}
 };
 
 /*