1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-23 17:34:34 +03:00

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 commit is contained in:
Michael Adam 2007-08-20 09:32:30 +00:00 committed by Gerald (Jerry) Carter
parent 888e657d75
commit 07dc0fecf5

View File

@ -2817,6 +2817,22 @@ BOOL lp_parameter_is_global(const char *pszParmName)
return False; return False;
} }
/**************************************************************************
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. Determine the canonical name for a parameter.
Indicate when it is an inverse (boolean) synonym instead of a Indicate when it is an inverse (boolean) synonym instead of a
@ -2924,21 +2940,25 @@ static int map_parameter(const char *pszParmName)
static int map_parameter_canonical(const char *pszParmName, BOOL *inverse) static int map_parameter_canonical(const char *pszParmName, BOOL *inverse)
{ {
int parm_num, canon_num; int parm_num, canon_num;
BOOL loc_inverse = False;
*inverse = False;
parm_num = map_parameter(pszParmName); parm_num = map_parameter(pszParmName);
if ((parm_num < 0) || !(parm_table[parm_num].flags & FLAG_HIDE)) { if ((parm_num < 0) || !(parm_table[parm_num].flags & FLAG_HIDE)) {
/* invalid, parametric or no canidate for synonyms ... */ /* invalid, parametric or no canidate for synonyms ... */
return parm_num; goto done;
} }
for (canon_num = 0; parm_table[canon_num].label; canon_num++) { for (canon_num = 0; parm_table[canon_num].label; canon_num++) {
if (is_synonym_of(parm_num, canon_num, inverse)) { if (is_synonym_of(parm_num, canon_num, &loc_inverse)) {
return canon_num; parm_num = canon_num;
goto done;
} }
} }
done:
if (inverse != NULL) {
*inverse = loc_inverse;
}
return parm_num; return parm_num;
} }
@ -2955,6 +2975,7 @@ static BOOL is_synonym_of(int parm1, int parm2, BOOL *inverse)
(parm_table[parm1].flags & FLAG_HIDE) && (parm_table[parm1].flags & FLAG_HIDE) &&
!(parm_table[parm2].flags & FLAG_HIDE)) !(parm_table[parm2].flags & FLAG_HIDE))
{ {
if (inverse != NULL) {
if ((parm_table[parm1].type == P_BOOLREV) && if ((parm_table[parm1].type == P_BOOLREV) &&
(parm_table[parm2].type == P_BOOL)) (parm_table[parm2].type == P_BOOL))
{ {
@ -2962,6 +2983,7 @@ static BOOL is_synonym_of(int parm1, int parm2, BOOL *inverse)
} else { } else {
*inverse = False; *inverse = False;
} }
}
return True; return True;
} }
return False; return False;