]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/dird/dird_conf.c
Add heap stats to Dir and SD -- eliminate #ifdefs
[bacula/bacula] / bacula / src / dird / dird_conf.c
index 0511dc946f5dcefa033f99c2fad711adc435a3b3..18591c256ff9aa5d494267fc65e8a99d6ef9426d 100644 (file)
@@ -50,6 +50,8 @@
  */
 int r_first = R_FIRST;
 int r_last  = R_LAST;
+static RES *sres_head[R_LAST - R_FIRST + 1];
+RES **res_head = sres_head;
 
 /* Imported subroutines */
 extern void store_run(LEX *lc, RES_ITEM *item, int index, int pass);
@@ -318,19 +320,19 @@ extern RES_ITEM msgs_items[];
  *  name            items        rcode        res_head
  */
 RES_TABLE resources[] = {
-   {"director",      dir_items,   R_DIRECTOR,  NULL},
-   {"client",        cli_items,   R_CLIENT,    NULL},
-   {"job",           job_items,   R_JOB,       NULL},
-   {"storage",       store_items, R_STORAGE,   NULL},
-   {"catalog",       cat_items,   R_CATALOG,   NULL},
-   {"schedule",      sch_items,   R_SCHEDULE,  NULL},
-   {"fileset",       fs_items,    R_FILESET,   NULL},
-   {"pool",          pool_items,  R_POOL,      NULL},
-   {"messages",      msgs_items,  R_MSGS,      NULL},
-   {"counter",       counter_items, R_COUNTER, NULL},
-   {"console",       con_items,   R_CONSOLE,   NULL},
-   {"jobdefs",       job_items,   R_JOBDEFS,   NULL},
-   {NULL,           NULL,        0,           NULL}
+   {"director",      dir_items,   R_DIRECTOR},
+   {"client",        cli_items,   R_CLIENT},
+   {"job",           job_items,   R_JOB},
+   {"storage",       store_items, R_STORAGE},
+   {"catalog",       cat_items,   R_CATALOG},
+   {"schedule",      sch_items,   R_SCHEDULE},
+   {"fileset",       fs_items,    R_FILESET},
+   {"pool",          pool_items,  R_POOL},
+   {"messages",      msgs_items,  R_MSGS},
+   {"counter",       counter_items, R_COUNTER},
+   {"console",       con_items,   R_CONSOLE},
+   {"jobdefs",       job_items,   R_JOBDEFS},
+   {NULL,           NULL,        0}
 };
 
 
@@ -351,7 +353,7 @@ struct s_jl joblevels[] = {
    {"Data",          L_VERIFY_DATA,     JT_VERIFY},
    {" ",             L_NONE,            JT_ADMIN},
    {" ",             L_NONE,            JT_RESTORE},
-   {NULL,           0}
+   {NULL,           0,                          0}
 };
 
 /* Keywords (RHS) permitted in Job type records   
@@ -397,11 +399,11 @@ struct s_kw ReplaceOptions[] = {
    {NULL,              0}
 };
 
-char *level_to_str(int level)
+const char *level_to_str(int level)
 {
    int i;
    static char level_no[30];
-   char *str = level_no;
+   const char *str = level_no;
 
    bsnprintf(level_no, sizeof(level_no), "%d", level);    /* default if not found */
    for (i=0; joblevels[i].level_name; i++) {
@@ -414,7 +416,7 @@ char *level_to_str(int level)
 }
 
 /* Dump contents of resource */
-void dump_resource(int type, RES *reshdr, void sendit(void *sock, char *fmt, ...), void *sock)
+void dump_resource(int type, RES *reshdr, void sendit(void *sock, const char *fmt, ...), void *sock)
 {
    URES *res = (URES *)reshdr;
    bool recurse = true;
@@ -1090,19 +1092,16 @@ void save_resource(int type, RES_ITEM *items, int pass)
    }
    /* Common */
    if (!error) {
-      if (type == R_JOBDEFS) {
-         Dmsg0(200, "Storing JobDefs definition.\n");
-      }
       res = (URES *)malloc(size);
       memcpy(res, &res_all, size);
-      if (!resources[rindex].res_head) {
-        resources[rindex].res_head = (RES *)res; /* store first entry */
-         Dmsg3(200, "Inserting first %s res: %s index=%d\n", res_to_str(type),
+      if (!res_head[rindex]) {
+        res_head[rindex] = (RES *)res; /* store first entry */
+         Dmsg3(900, "Inserting first %s res: %s index=%d\n", res_to_str(type),
               res->res_dir.hdr.name, rindex);
       } else {
         RES *next;
         /* Add new res to end of chain */
-        for (next=resources[rindex].res_head; next->next; next=next->next) {
+        for (next=res_head[rindex]; next->next; next=next->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"),
@@ -1110,7 +1109,7 @@ void save_resource(int type, RES_ITEM *items, int pass)
            }
         }
         next->next = (RES *)res;
-         Dmsg4(200, "Inserting %s res: %s index=%d pass=%d\n", res_to_str(type),
+         Dmsg4(900, "Inserting %s res: %s index=%d pass=%d\n", res_to_str(type),
               res->res_dir.hdr.name, rindex, pass);
       }
    }
@@ -1196,10 +1195,10 @@ void store_acl(LEX *lc, RES_ITEM *item, int index, int pass)
       if (pass == 1) {
         if (((alist **)item->value)[item->code] == NULL) {   
            ((alist **)item->value)[item->code] = new alist(10, owned_by_alist);
-//          Dmsg1(400, "Defined new ACL alist at %d\n", item->code);
+//          Dmsg1(900, "Defined new ACL alist at %d\n", item->code);
         }
         ((alist **)item->value)[item->code]->append(bstrdup(lc->str));
-//       Dmsg2(400, "Appended to %d %s\n", item->code, lc->str);
+//       Dmsg2(900, "Appended to %d %s\n", item->code, lc->str);
       }
       token = lex_get_token(lc, T_ALL);
       if (token == T_COMMA) {
@@ -1232,12 +1231,12 @@ static void store_backup(LEX *lc, RES_ITEM *item, int index, int pass)
    while ((token = lex_get_token(lc, T_ALL)) != T_EOL) {
       bool found = false;
 
-      Dmsg1(150, "store_backup got token=%s\n", lex_tok_to_str(token));
+      Dmsg1(900, "store_backup got token=%s\n", lex_tok_to_str(token));
       
       if (token != T_IDENTIFIER && token != T_UNQUOTED_STRING && token != T_QUOTED_STRING) {
          scan_err1(lc, "Expected a backup/verify keyword, got: %s", lc->str);
       }
-      Dmsg1(190, "Got keyword: %s\n", lc->str);
+      Dmsg1(900, "Got keyword: %s\n", lc->str);
       for (i=0; BakVerFields[i].name; i++) {
         if (strcasecmp(lc->str, BakVerFields[i].name) == 0) {
            found = true;
@@ -1245,7 +1244,7 @@ static void store_backup(LEX *lc, RES_ITEM *item, int index, int pass)
                scan_err1(lc, "Expected an equals, got: %s", lc->str);
            }
            token = lex_get_token(lc, T_NAME);
-            Dmsg1(190, "Got value: %s\n", lc->str);
+            Dmsg1(900, "Got value: %s\n", lc->str);
            switch (BakVerFields[i].token) {
             case 'C':
               /* Find Client Resource */
@@ -1309,7 +1308,7 @@ static void store_restore(LEX *lc, RES_ITEM *item, int index, int pass)
 
    lc->options |= LOPT_NO_IDENT;      /* make spaces significant */
 
-   Dmsg0(190, "Enter store_restore()\n");
+   Dmsg0(900, "Enter store_restore()\n");
    
    ((JOB *)(item->value))->JobType = item->code;
    while ((token = lex_get_token(lc, T_ALL)) != T_EOL) {
@@ -1319,14 +1318,14 @@ static void store_restore(LEX *lc, RES_ITEM *item, int index, int pass)
          scan_err1(lc, "expected a name, got: %s", lc->str);
       }
       for (i=0; RestoreFields[i].name; i++) {
-         Dmsg1(190, "Restore kw=%s\n", lc->str);
+         Dmsg1(900, "Restore kw=%s\n", lc->str);
         if (strcasecmp(lc->str, RestoreFields[i].name) == 0) {
            found = true;
            if (lex_get_token(lc, T_ALL) != T_EQUALS) {
                scan_err1(lc, "Expected an equals, got: %s", lc->str);
            }
            token = lex_get_token(lc, T_ALL);
-            Dmsg1(190, "Restore value=%s\n", lc->str);
+            Dmsg1(900, "Restore value=%s\n", lc->str);
            switch (RestoreFields[i].token) {
             case 'B':
               /* Bootstrap */
@@ -1366,7 +1365,7 @@ static void store_restore(LEX *lc, RES_ITEM *item, int index, int pass)
               }
               errno = 0;
               res_all.res_job.RestoreJobId = strtol(lc->str, NULL, 0);
-               Dmsg1(190, "RestorJobId=%d\n", res_all.res_job.RestoreJobId);
+               Dmsg1(900, "RestorJobId=%d\n", res_all.res_job.RestoreJobId);
               if (errno != 0) {
                   scan_err1(lc, "expected an integer number, got: %s", lc->str);
               }