summaryrefslogtreecommitdiff
path: root/source3/param
diff options
context:
space:
mode:
authorMichael Adam <obnox@samba.org>2007-08-20 09:32:30 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:30:07 -0500
commit987d7010f827464191a9f29cdc7a72591c6b806b (patch)
treefe37ad5297c61e801db82705e58bf5e08548a45e /source3/param
parent8bab4bdc5dc73f460034d366495705c68eef5347 (diff)
downloadsamba-987d7010f827464191a9f29cdc7a72591c6b806b.tar.gz
samba-987d7010f827464191a9f29cdc7a72591c6b806b.tar.bz2
samba-987d7010f827464191a9f29cdc7a72591c6b806b.zip
r24572: Allow for functions map_parameter_canonical() and is_synonym_of() to
be called with inverse == NULL. Add a new function lp_parameter_is_canonical() to check whether a parameter name is the canonical name (as apposed to an alias). Michael (This used to be commit 07dc0fecf5116b34e468bddae8b36920c492717a)
Diffstat (limited to 'source3/param')
-rw-r--r--source3/param/loadparm.c44
1 files changed, 33 insertions, 11 deletions
diff --git a/source3/param/loadparm.c b/source3/param/loadparm.c
index bd318791b5..e65a649584 100644
--- a/source3/param/loadparm.c
+++ b/source3/param/loadparm.c
@@ -2818,6 +2818,22 @@ BOOL lp_parameter_is_global(const char *pszParmName)
}
/**************************************************************************
+ Check whether the given name is the canonical name of a parameter.
+ Returns False if it is not a valid parameter Name.
+ For parametric options, True is returned.
+**************************************************************************/
+
+BOOL lp_parameter_is_canonical(const char *parm_name)
+{
+ if (!lp_parameter_is_valid(parm_name)) {
+ return False;
+ }
+
+ return (map_parameter(parm_name) ==
+ map_parameter_canonical(parm_name, NULL));
+}
+
+/**************************************************************************
Determine the canonical name for a parameter.
Indicate when it is an inverse (boolean) synonym instead of a
"usual" synonym.
@@ -2924,21 +2940,25 @@ static int map_parameter(const char *pszParmName)
static int map_parameter_canonical(const char *pszParmName, BOOL *inverse)
{
int parm_num, canon_num;
-
- *inverse = False;
+ BOOL loc_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;
+ goto done;
}
for (canon_num = 0; parm_table[canon_num].label; canon_num++) {
- if (is_synonym_of(parm_num, canon_num, inverse)) {
- return canon_num;
+ if (is_synonym_of(parm_num, canon_num, &loc_inverse)) {
+ parm_num = canon_num;
+ goto done;
}
}
+done:
+ if (inverse != NULL) {
+ *inverse = loc_inverse;
+ }
return parm_num;
}
@@ -2955,12 +2975,14 @@ static BOOL is_synonym_of(int parm1, int parm2, BOOL *inverse)
(parm_table[parm1].flags & FLAG_HIDE) &&
!(parm_table[parm2].flags & FLAG_HIDE))
{
- if ((parm_table[parm1].type == P_BOOLREV) &&
- (parm_table[parm2].type == P_BOOL))
- {
- *inverse = True;
- } else {
- *inverse = False;
+ if (inverse != NULL) {
+ if ((parm_table[parm1].type == P_BOOLREV) &&
+ (parm_table[parm2].type == P_BOOL))
+ {
+ *inverse = True;
+ } else {
+ *inverse = False;
+ }
}
return True;
}