summaryrefslogtreecommitdiff
path: root/source3/param
diff options
context:
space:
mode:
authorGarming Sam <garming@catalyst.net.nz>2014-03-20 15:16:37 +1300
committerMichael Adam <obnox@samba.org>2014-07-31 08:17:10 +0200
commit4fa98737f4911a539cb0b14b55667015c66a0f52 (patch)
tree5df14737453d5310d1548d3a67effddb9dd3a4c6 /source3/param
parent9ee7b022e5cbf13f2fc8c6f8c556553eb2ef9f06 (diff)
downloadsamba-4fa98737f4911a539cb0b14b55667015c66a0f52.tar.gz
s3:param: simplify lp_do_parameter to use lpcfg functions
Change-Id: I907794fbbc15ecc4e88e0f6b0d510788e0fca745 Signed-off-by: Garming Sam <garming@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Michael Adam <obnox@samba.org>
Diffstat (limited to 'source3/param')
-rw-r--r--source3/param/loadparm.c84
1 files changed, 8 insertions, 76 deletions
diff --git a/source3/param/loadparm.c b/source3/param/loadparm.c
index 6b3e46ec816..11a10d9b221 100644
--- a/source3/param/loadparm.c
+++ b/source3/param/loadparm.c
@@ -2572,82 +2572,9 @@ void *lp_parm_ptr(struct loadparm_service *service, struct parm_struct *parm)
bool lp_do_parameter(int snum, const char *pszParmName, const char *pszParmValue)
{
- int parmnum, i;
- void *parm_ptr = NULL; /* where we are going to store the result */
- struct parmlist_entry **opt_list;
- TALLOC_CTX *mem_ctx;
TALLOC_CTX *frame = talloc_stackframe();
- bool ok;
struct loadparm_context *lp_ctx;
- struct loadparm_service *service = NULL;
-
- parmnum = lpcfg_map_parameter(pszParmName);
-
- if (parmnum < 0) {
- if (strchr(pszParmName, ':') == NULL) {
- DEBUG(0, ("Ignoring unknown parameter \"%s\"\n",
- pszParmName));
- TALLOC_FREE(frame);
- return true;
- }
-
- /*
- * We've got a parametric option
- */
-
- if (snum < 0) {
- opt_list = &Globals.param_opt;
- set_param_opt(NULL, opt_list, pszParmName, pszParmValue, 0);
- } else {
- opt_list = &ServicePtrs[snum]->param_opt;
- set_param_opt(ServicePtrs[snum], opt_list, pszParmName, pszParmValue, 0);
- }
-
- TALLOC_FREE(frame);
- return true;
- }
-
- /* if it's already been set by the command line, then we don't
- override here */
- if (flags_list[parmnum] & FLAG_CMDLINE) {
- TALLOC_FREE(frame);
- return true;
- }
-
- if (parm_table[parmnum].flags & FLAG_DEPRECATED) {
- DEBUG(1, ("WARNING: The \"%s\" option is deprecated\n",
- pszParmName));
- }
-
- /* we might point at a service, the default service or a global */
- if (snum < 0) {
- parm_ptr = lp_parm_ptr(NULL, &parm_table[parmnum]);
- mem_ctx = Globals.ctx;
- } else {
- if (parm_table[parmnum].p_class == P_GLOBAL) {
- DEBUG(0,
- ("Global parameter %s found in service section!\n",
- pszParmName));
- TALLOC_FREE(frame);
- return true;
- }
- parm_ptr = lp_parm_ptr(ServicePtrs[snum], &parm_table[parmnum]);
-
- if (!ServicePtrs[snum]->copymap)
- init_copymap(ServicePtrs[snum]);
-
- /* this handles the aliases - set the copymap for other entries with
- the same data pointer */
- for (i = 0; parm_table[i].label; i++) {
- if ((parm_table[i].offset == parm_table[parmnum].offset)
- && (parm_table[i].p_class == parm_table[parmnum].p_class)) {
- bitmap_clear(ServicePtrs[snum]->copymap, i);
- }
- }
-
- mem_ctx = ServicePtrs[snum];
- service = ServicePtrs[snum];
- }
+ bool ok;
lp_ctx = loadparm_init_s3(frame,
loadparm_s3_helpers());
@@ -2662,8 +2589,13 @@ bool lp_do_parameter(int snum, const char *pszParmName, const char *pszParmValue
lp_ctx->bInGlobalSection = bInGlobalSection;
lp_ctx->flags = flags_list;
- ok = set_variable(mem_ctx, service, parmnum, parm_ptr, pszParmName, pszParmValue,
- lp_ctx, (snum < 0));
+ if (snum < 0) {
+ ok = lpcfg_do_global_parameter(lp_ctx, pszParmName, pszParmValue);
+ } else {
+ ok = lpcfg_do_service_parameter(lp_ctx, ServicePtrs[snum],
+ pszParmName, pszParmValue);
+ }
+
TALLOC_FREE(frame);
return ok;