From be0851f7542c5d07077285567b6f6691af172b1b Mon Sep 17 00:00:00 2001 From: Garming Sam Date: Tue, 18 Feb 2014 12:06:57 +1300 Subject: param: move set_param_opt to lib/param Signed-off-by: Garming Sam Reviewed-by: Andrew Bartlett Reviewed-on: https://gerrit.samba.org/109 Reviewed-by: Andreas Schneider Reviewed-by: Jeremy Allison --- lib/param/loadparm.c | 57 ++++++++++++++++++++++++++++++++++++++++++++ source3/param/loadparm.c | 62 ------------------------------------------------ 2 files changed, 57 insertions(+), 62 deletions(-) diff --git a/lib/param/loadparm.c b/lib/param/loadparm.c index 636c41bd20..63be8c4bc0 100644 --- a/lib/param/loadparm.c +++ b/lib/param/loadparm.c @@ -855,6 +855,63 @@ static struct loadparm_service *getservicebyname(struct loadparm_context *lp_ctx return NULL; } +/** + * Add a parametric option to a parmlist_entry, + * replacing old value, if already present. + */ +void set_param_opt(TALLOC_CTX *mem_ctx, + struct parmlist_entry **opt_list, + const char *opt_name, + const char *opt_value, + unsigned priority) +{ + struct parmlist_entry *new_opt, *opt; + bool not_added; + + opt = *opt_list; + not_added = true; + + /* Traverse destination */ + while (opt) { + /* If we already have same option, override it */ + if (strwicmp(opt->key, opt_name) == 0) { + if ((opt->priority & FLAG_CMDLINE) && + !(priority & FLAG_CMDLINE)) { + /* it's been marked as not to be + overridden */ + return; + } + TALLOC_FREE(opt->value); + TALLOC_FREE(opt->list); + opt->value = talloc_strdup(opt, opt_value); + opt->priority = priority; + not_added = false; + break; + } + opt = opt->next; + } + if (not_added) { + new_opt = talloc(mem_ctx, struct parmlist_entry); + if (new_opt == NULL) { + smb_panic("OOM"); + } + + new_opt->key = talloc_strdup(new_opt, opt_name); + if (new_opt->key == NULL) { + smb_panic("talloc_strdup failed"); + } + + new_opt->value = talloc_strdup(new_opt, opt_value); + if (new_opt->value == NULL) { + smb_panic("talloc_strdup failed"); + } + + new_opt->list = NULL; + new_opt->priority = priority; + DLIST_ADD(*opt_list, new_opt); + } +} + /** * Copy a service structure to another. * If pcopymapDest is NULL then copy all fields diff --git a/source3/param/loadparm.c b/source3/param/loadparm.c index ca6abbc877..dfe15d0d54 100644 --- a/source3/param/loadparm.c +++ b/source3/param/loadparm.c @@ -2154,68 +2154,6 @@ struct loadparm_service *lp_default_loadparm_service() If pcopymapDest is NULL then copy all fields ***************************************************************************/ -/** - * Add a parametric option to a parmlist_entry, - * replacing old value, if already present. - */ -static void set_param_opt(TALLOC_CTX *mem_ctx, - struct parmlist_entry **opt_list, - const char *opt_name, - const char *opt_value, - unsigned priority) -{ - struct parmlist_entry *new_opt, *opt; - bool not_added; - - opt = *opt_list; - not_added = true; - - /* Traverse destination */ - while (opt) { - /* If we already have same option, override it */ - if (strwicmp(opt->key, opt_name) == 0) { - if ((opt->priority & FLAG_CMDLINE) && - !(priority & FLAG_CMDLINE)) { - /* it's been marked as not to be - overridden */ - return; - } - string_free(&opt->value); - TALLOC_FREE(opt->list); - - opt->value = talloc_strdup(opt, opt_value); - if (opt->value == NULL) { - smb_panic("talloc_strdup failed"); - } - - opt->priority = priority; - not_added = false; - break; - } - opt = opt->next; - } - if (not_added) { - new_opt = talloc(mem_ctx, struct parmlist_entry); - if (new_opt == NULL) { - smb_panic("OOM"); - } - - new_opt->key = talloc_strdup(new_opt, opt_name); - if (new_opt->key == NULL) { - smb_panic("talloc_strdup failed"); - } - - new_opt->value = talloc_strdup(new_opt, opt_value); - if (new_opt->value == NULL) { - smb_panic("talloc_strdup failed"); - } - - new_opt->list = NULL; - new_opt->priority = priority; - DLIST_ADD(*opt_list, new_opt); - } -} - static void copy_service(struct loadparm_service *pserviceDest, struct loadparm_service *pserviceSource, struct bitmap *pcopymapDest) { -- cgit