From: Eric Bollengier Date: Thu, 18 Mar 2021 13:54:42 +0000 (+0100) Subject: Add support for store_alist_str() in plugin configuration items X-Git-Tag: Release-11.0.2~11 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=983af0c5dec6a99e92d4b3b0e12a90b2fe041a49;p=thirdparty%2Fbacula.git Add support for store_alist_str() in plugin configuration items --- diff --git a/bacula/src/dird/ua_run.c b/bacula/src/dird/ua_run.c index c6de5c2fd..01f7afbc7 100644 --- a/bacula/src/dird/ua_run.c +++ b/bacula/src/dird/ua_run.c @@ -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; } diff --git a/bacula/src/lib/ini.c b/bacula/src/lib/ini.c index d20ed6411..79e5efa65 100644 --- a/bacula/src/lib/ini.c +++ b/bacula/src/lib/ini.c @@ -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; }