]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/filed/filed_conf.c
Use dcr more in SD + int to bool conversions
[bacula/bacula] / bacula / src / filed / filed_conf.c
index 4c37767bb2c55a054d5a8dd405eb90e01e4c4ed4..23d8e627805ecc1313ec4acc3c4ee587c3a042ec 100644 (file)
@@ -51,6 +51,9 @@
  */
 int r_first = R_FIRST;
 int r_last  = R_LAST;
+static RES *sres_head[R_LAST - R_FIRST + 1];
+RES **res_head = sres_head;
+
 
 /* Forward referenced subroutines */
 
@@ -76,7 +79,7 @@ int  res_all_size = sizeof(res_all);
  */ 
 
 /* Client or File daemon "Global" resources */
-static struct res_items cli_items[] = {
+static RES_ITEM cli_items[] = {
    {"name",        store_name,  ITEM(res_client.hdr.name), 0, ITEM_REQUIRED, 0},
    {"description", store_str,   ITEM(res_client.hdr.desc), 0, 0, 0},
    {"fdport",      store_pint,  ITEM(res_client.FDport),  0, ITEM_DEFAULT, 9102},
@@ -94,7 +97,7 @@ static struct res_items cli_items[] = {
 };
 
 /* Directors that can use our services */
-static struct res_items dir_items[] = {
+static RES_ITEM dir_items[] = {
    {"name",        store_name,     ITEM(res_dir.hdr.name),  0, ITEM_REQUIRED, 0},
    {"description", store_str,      ITEM(res_dir.hdr.desc),  0, 0, 0},
    {"password",    store_password, ITEM(res_dir.password),  0, ITEM_REQUIRED, 0},
@@ -104,23 +107,23 @@ static struct res_items dir_items[] = {
 };
 
 /* Message resource */
-extern struct res_items msgs_items[];
+extern RES_ITEM msgs_items[];
 
 /* 
  * This is the master resource definition.  
  * It must have one item for each of the resources.
  */
-struct s_res resources[] = {
-   {"director",      dir_items,   R_DIRECTOR,  NULL},
-   {"filedaemon",    cli_items,   R_CLIENT,    NULL},
-   {"client",        cli_items,   R_CLIENT,    NULL}, /* alias for filedaemon */
-   {"messages",      msgs_items,  R_MSGS,      NULL},
-   {NULL,           NULL,        0,           NULL}
+RES_TABLE resources[] = {
+   {"director",      dir_items,   R_DIRECTOR},
+   {"filedaemon",    cli_items,   R_CLIENT},
+   {"client",        cli_items,   R_CLIENT},     /* alias for filedaemon */
+   {"messages",      msgs_items,  R_MSGS},
+   {NULL,           NULL,        0}
 };
 
 
 /* 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;
    int recurse = 1;
@@ -163,13 +166,10 @@ void dump_resource(int type, RES *reshdr, void sendit(void *sock, char *fmt, ...
  * resource chain is traversed.  Mainly we worry about freeing
  * allocated strings (names).
  */
-void free_resource(int type)
+void free_resource(RES *sres, int type)
 {
-   URES *res;
    RES *nres;
-   int rindex = type - r_first;
-
-   res = (URES *)resources[rindex].res_head;
+   URES *res = (URES *)sres;
 
    if (res == NULL) {
       return;
@@ -222,9 +222,8 @@ void free_resource(int type)
    if (res) {
       free(res);
    }
-   resources[rindex].res_head = nres;
    if (nres) {
-      free_resource(type);
+      free_resource(nres, type);
    }
 }
 
@@ -232,7 +231,7 @@ void free_resource(int type)
  * the resource. If this is pass 2, we update any resource
  * pointers (currently only in the Job resource).
  */
-void save_resource(int type, struct res_items *items, int pass)
+void save_resource(int type, RES_ITEM *items, int pass)
 {
    URES *res;
    int rindex = type - r_first;
@@ -310,12 +309,12 @@ void save_resource(int type, struct res_items *items, int pass)
    if (!error) {
       res = (URES *)malloc(size);
       memcpy(res, &res_all, size);
-      if (!resources[rindex].res_head) {
-        resources[rindex].res_head = (RES *)res; /* store first entry */
+      if (!res_head[rindex]) {
+        res_head[rindex] = (RES *)res; /* store first entry */
       } 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"),