summaryrefslogtreecommitdiff
path: root/source3/param
diff options
context:
space:
mode:
authorMichael Adam <obnox@samba.org>2007-08-17 15:38:19 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:29:54 -0500
commitbb76f3f98ed2e49ad4114a34a2a7fa0e6655f33d (patch)
tree857cf5e518fd5d1c19b73a5e447396fe2dc0f7ab /source3/param
parent7190e7515b93f2756d49c493b9b633bf3ea63c81 (diff)
downloadsamba-bb76f3f98ed2e49ad4114a34a2a7fa0e6655f33d.tar.gz
samba-bb76f3f98ed2e49ad4114a34a2a7fa0e6655f33d.tar.bz2
samba-bb76f3f98ed2e49ad4114a34a2a7fa0e6655f33d.zip
r24526: Refactor determiniation of the index of the canonical form of a
parameter given in string representation into a function of its own (map_parameter_canonical). Michael (This used to be commit 0dfb5eee25e287c129f7d34e4d079c60d56dce59)
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,