mirror of
https://github.com/samba-team/samba.git
synced 2025-01-11 05:18:09 +03:00
param: use set_variable_helper in s3 loadparm
Change-Id: I1ed19ee7290f6b52f624e2aa700cf402cfcb255d Signed-off-by: Garming Sam <garming@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Nadezhda Ivanova <nivanova@samba.org>
This commit is contained in:
parent
5b5e3ec403
commit
f1c28fcc23
@ -2642,126 +2642,7 @@ bool lp_do_parameter(int snum, const char *pszParmName, const char *pszParmValue
|
||||
}
|
||||
|
||||
TALLOC_FREE(frame);
|
||||
|
||||
/* switch on the type of variable it is */
|
||||
switch (parm_table[parmnum].type)
|
||||
{
|
||||
case P_BOOL: {
|
||||
bool b;
|
||||
if (!set_boolean(pszParmValue, &b)) {
|
||||
DEBUG(0, ("set_variable_helper(%s): value is not "
|
||||
"boolean!\n", pszParmValue));
|
||||
return false;
|
||||
}
|
||||
*(bool *)parm_ptr = b;
|
||||
}
|
||||
break;
|
||||
|
||||
case P_BOOLREV: {
|
||||
bool b;
|
||||
if (!set_boolean(pszParmValue, &b)) {
|
||||
DEBUG(0, ("set_variable_helper(%s): value is not "
|
||||
"boolean!\n", pszParmValue));
|
||||
return false;
|
||||
}
|
||||
*(bool *)parm_ptr = !b;
|
||||
}
|
||||
break;
|
||||
|
||||
case P_INTEGER:
|
||||
*(int *)parm_ptr = lp_int(pszParmValue);
|
||||
break;
|
||||
|
||||
case P_CHAR:
|
||||
*(char *)parm_ptr = *pszParmValue;
|
||||
break;
|
||||
|
||||
case P_OCTAL:
|
||||
i = sscanf(pszParmValue, "%o", (int *)parm_ptr);
|
||||
if ( i != 1 ) {
|
||||
DEBUG ( 0, ("Invalid octal number %s\n", pszParmName ));
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
|
||||
case P_BYTES:
|
||||
{
|
||||
uint64_t val;
|
||||
if (conv_str_size_error(pszParmValue, &val)) {
|
||||
if (val <= INT_MAX) {
|
||||
*(int *)parm_ptr = (int)val;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
DEBUG(0, ("set_variable_helper(%s): value is not "
|
||||
"a valid size specifier!\n", pszParmValue));
|
||||
return false;
|
||||
}
|
||||
|
||||
case P_CMDLIST:
|
||||
TALLOC_FREE(*(char ***)parm_ptr);
|
||||
*(const char * const **)parm_ptr
|
||||
= (const char * const *)str_list_make_v3(mem_ctx,
|
||||
pszParmValue, NULL);
|
||||
break;
|
||||
|
||||
case P_LIST:
|
||||
{
|
||||
char **new_list = str_list_make_v3(mem_ctx,
|
||||
pszParmValue, NULL);
|
||||
if (new_list == NULL) {
|
||||
break;
|
||||
}
|
||||
|
||||
for (i=0; new_list[i]; i++) {
|
||||
if (*(const char ***)parm_ptr != NULL &&
|
||||
new_list[i][0] == '+' &&
|
||||
new_list[i][1])
|
||||
{
|
||||
if (!str_list_check(*(const char ***)parm_ptr,
|
||||
&new_list[i][1])) {
|
||||
*(const char ***)parm_ptr = str_list_add(*(const char ***)parm_ptr,
|
||||
&new_list[i][1]);
|
||||
}
|
||||
} else if (*(const char ***)parm_ptr != NULL &&
|
||||
new_list[i][0] == '-' &&
|
||||
new_list[i][1])
|
||||
{
|
||||
str_list_remove(*(const char ***)parm_ptr,
|
||||
&new_list[i][1]);
|
||||
} else {
|
||||
if (i != 0) {
|
||||
DEBUG(0, ("Unsupported list syntax for: %s = %s\n",
|
||||
pszParmName, pszParmValue));
|
||||
return false;
|
||||
}
|
||||
*(const char * const **)parm_ptr = (const char * const *) new_list;
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case P_STRING:
|
||||
lpcfg_string_set(mem_ctx, (char **)parm_ptr, pszParmValue);
|
||||
break;
|
||||
|
||||
case P_USTRING:
|
||||
lpcfg_string_set_upper(mem_ctx, (char **)parm_ptr, pszParmValue);
|
||||
break;
|
||||
|
||||
case P_ENUM:
|
||||
if (!lp_set_enum_parm(&parm_table[parmnum], pszParmValue, (int*)parm_ptr)) {
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
|
||||
case P_SEP:
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
return set_variable_helper(mem_ctx, parmnum, parm_ptr, pszParmName, pszParmValue);
|
||||
}
|
||||
|
||||
/***************************************************************************
|
||||
|
Loading…
Reference in New Issue
Block a user