diff options
author | Garming Sam <garming@catalyst.net.nz> | 2014-02-25 16:58:21 +1300 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2014-05-07 19:49:17 +0200 |
commit | 9d90969a37244c5e2ddb90daf5ac439cb33cdbf0 (patch) | |
tree | 62f64f4ccf43988f715a66d35e7d2e012a27842d /lib/param/loadparm.c | |
parent | 66338032c243e4fe49a3b7cd71c74b14d7b2c784 (diff) | |
download | samba-9d90969a37244c5e2ddb90daf5ac439cb33cdbf0.tar.gz samba-9d90969a37244c5e2ddb90daf5ac439cb33cdbf0.tar.xz samba-9d90969a37244c5e2ddb90daf5ac439cb33cdbf0.zip |
param: copy parametric option helper to lib/param
Signed-off-by: Garming Sam <garming@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Diffstat (limited to 'lib/param/loadparm.c')
-rw-r--r-- | lib/param/loadparm.c | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/lib/param/loadparm.c b/lib/param/loadparm.c index e8b0874d4fb..7728e6dd0c7 100644 --- a/lib/param/loadparm.c +++ b/lib/param/loadparm.c @@ -237,6 +237,55 @@ static bool do_section(const char *pszSectionName, void *); /* This is a helper function for parametrical options support. */ /* It returns a pointer to parametrical option value if it exists or NULL otherwise */ /* Actual parametrical functions are quite simple */ +struct parmlist_entry *get_parametric_helper(struct loadparm_service *service, + const char *type, const char *option, + struct parmlist_entry *global_opts) +{ + char* param_key; + struct parmlist_entry *data = NULL; + TALLOC_CTX *mem_ctx = talloc_stackframe(); + + param_key = talloc_asprintf(mem_ctx, "%s:%s", type, option); + if (param_key == NULL) { + DEBUG(0,("asprintf failed!\n")); + TALLOC_FREE(mem_ctx); + return NULL; + } + + /* + * Try to fetch the option from the data. + */ + if (service != NULL) { + data = service->param_opt; + while (data != NULL) { + if (strwicmp(data->key, param_key) == 0) { + TALLOC_FREE(mem_ctx); + return data; + } + data = data->next; + } + } + + /* + * Fall back to fetching from the globals. + */ + data = global_opts; + while (data != NULL) { + if (strwicmp(data->key, param_key) == 0) { + TALLOC_FREE(mem_ctx); + return data; + } + data = data->next; + } + + + TALLOC_FREE(mem_ctx); + + return NULL; + + +} + const char *lpcfg_get_parametric(struct loadparm_context *lp_ctx, struct loadparm_service *service, const char *type, const char *option) |