summaryrefslogtreecommitdiff
path: root/source3/param
diff options
context:
space:
mode:
Diffstat (limited to 'source3/param')
-rw-r--r--source3/param/loadparm.c50
1 files changed, 35 insertions, 15 deletions
diff --git a/source3/param/loadparm.c b/source3/param/loadparm.c
index c867c5f508..ea1bb0a23f 100644
--- a/source3/param/loadparm.c
+++ b/source3/param/loadparm.c
@@ -2190,6 +2190,7 @@ FN_GLOBAL_INTEGER(lp_client_ldap_sasl_wrapping, &Globals.client_ldap_sasl_wrappi
/* local prototypes */
static int map_parameter(const char *pszParmName);
+static int map_parameter_canonical(const char *pszParmName, BOOL *inverse);
static BOOL set_boolean(BOOL *pb, const char *pszParmValue);
static const char *get_boolean(BOOL bool_value);
static int getservicebyname(const char *pszServiceName,
@@ -2825,31 +2826,23 @@ BOOL lp_parameter_is_global(const char *pszParmName)
BOOL lp_canonicalize_parameter(const char *parm_name, const char **canon_parm,
BOOL *inverse)
{
- int num, canon_num;
+ int num;
if (!lp_parameter_is_valid(parm_name)) {
*canon_parm = NULL;
return False;
}
- *inverse = False;
- num = map_parameter(parm_name);
- if ((num < 0) || !(parm_table[num].flags & FLAG_HIDE)) {
- /* it is already canonical (parametric are canonical anyways) */
+ num = map_parameter_canonical(parm_name, inverse);
+ if (num < 0) {
+ /* parametric option */
*canon_parm = parm_name;
- return True;
- }
-
- for (canon_num = 0; parm_table[canon_num].label; canon_num++) {
- if (is_synonym_of(num, canon_num, inverse)) {
- *canon_parm = parm_table[canon_num].label;
- return True;
- }
+ } else {
+ *canon_parm = parm_table[num].label;
}
- /* 'include', 'copy', 'config file' and friends left */
- *canon_parm = parm_name;
return True;
+
}
/***************************************************************************
@@ -2878,6 +2871,33 @@ static int map_parameter(const char *pszParmName)
}
/***************************************************************************
+ Map a parameter's string representation to the index of the canonical
+ form of the parameter (it might be a synonym).
+ Returns -1 if the parameter string is not recognised.
+***************************************************************************/
+
+static int map_parameter_canonical(const char *pszParmName, BOOL *inverse)
+{
+ int parm_num, canon_num;
+
+ *inverse = False;
+
+ parm_num = map_parameter(pszParmName);
+ if ((parm_num < 0) || !(parm_table[parm_num].flags & FLAG_HIDE)) {
+ /* invalid, parametric or no canidate for synonyms ... */
+ return parm_num;
+ }
+
+ for (canon_num = 0; parm_table[canon_num].label; canon_num++) {
+ if (is_synonym_of(parm_num, canon_num, inverse)) {
+ return canon_num;
+ }
+ }
+
+ return parm_num;
+}
+
+/***************************************************************************
return true if parameter number parm1 is a synonym of parameter
number parm2 (parm2 being the principal name).
set inverse to True if parm1 is P_BOOLREV and parm2 is P_BOOL,