]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
Add support for store_alist_str() in plugin configuration items
authorEric Bollengier <eric@baculasystems.com>
Thu, 18 Mar 2021 13:54:42 +0000 (14:54 +0100)
committerEric Bollengier <eric@baculasystems.com>
Fri, 26 Mar 2021 13:57:58 +0000 (14:57 +0100)
bacula/src/dird/ua_run.c
bacula/src/lib/ini.c

index c6de5c2fdfe4b731d2967e43666cfe9cec7b1e7e..01f7afbc7f410a83d836b6a7cd40a126ee4ab3f0 100644 (file)
@@ -1033,6 +1033,15 @@ configure_again:
          if (found) {
             ini->items[i].val.int64val = ua->int64_val;
          }
+
+      } else if (h == ini_store_alist_str) {
+         found = ini->items[i].found = get_cmd(ua, prompt.c_str());
+         if (found) {
+            if (!ini->items[i].val.alistval) {
+               ini->items[i].val.alistval = New(alist(10, owned_by_alist));
+            }
+            ini->items[i].val.alistval->append(bstrdup(ua->cmd));
+         }
       }
       goto configure_again;
    }
index d20ed6411ed2b3285d07985b1145517585a4f3f9..79e5efa65865333b62cfbbe5966520b7ddf21e98 100644 (file)
@@ -125,12 +125,10 @@ void ConfigFile::clear_items()
       if (items[i].found) {
          /* special members require delete or free */
          if (items[i].handler == ini_store_str) {
-            free(items[i].val.strval);
-            items[i].val.strval = NULL;
+            bfree_and_null(items[i].val.strval);
 
          } else if (items[i].handler == ini_store_alist_str) {
-            delete items[i].val.alistval;
-            items[i].val.alistval = NULL;
+            bdelete_and_null(items[i].val.alistval);
          }
          items[i].found = false;
       }
@@ -541,7 +539,20 @@ bool ini_store_alist_str(LEX *lc, ConfigFile *inifile, ini_items *item)
 {
    alist *list = item->val.alistval;
    if (!lc) {
-      /* TODO, write back the alist to edit buffer */
+      bool first=true;
+      char *str;
+      pm_strcpy(inifile->edit, "");
+      if (list) {
+         POOL_MEM tmp;
+         foreach_alist(str, list) {
+            if (first) {
+               first = false;
+            } else {
+               pm_strcat(inifile->edit, ",");
+            }
+            pm_strcat(inifile->edit, quote_string(tmp.addr(), str));
+         }
+      }
       return true;
    }