1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-11 05:18:09 +03:00

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 0dfb5eee25)
This commit is contained in:
Michael Adam 2007-08-17 15:38:19 +00:00 committed by Gerald (Jerry) Carter
parent 7190e7515b
commit bb76f3f98e

View File

@ -2190,6 +2190,7 @@ FN_GLOBAL_INTEGER(lp_client_ldap_sasl_wrapping, &Globals.client_ldap_sasl_wrappi
/* local prototypes */ /* local prototypes */
static int map_parameter(const char *pszParmName); 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 BOOL set_boolean(BOOL *pb, const char *pszParmValue);
static const char *get_boolean(BOOL bool_value); static const char *get_boolean(BOOL bool_value);
static int getservicebyname(const char *pszServiceName, 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 lp_canonicalize_parameter(const char *parm_name, const char **canon_parm,
BOOL *inverse) BOOL *inverse)
{ {
int num, canon_num; int num;
if (!lp_parameter_is_valid(parm_name)) { if (!lp_parameter_is_valid(parm_name)) {
*canon_parm = NULL; *canon_parm = NULL;
return False; return False;
} }
*inverse = False; num = map_parameter_canonical(parm_name, inverse);
num = map_parameter(parm_name); if (num < 0) {
if ((num < 0) || !(parm_table[num].flags & FLAG_HIDE)) { /* parametric option */
/* it is already canonical (parametric are canonical anyways) */
*canon_parm = parm_name; *canon_parm = parm_name;
return True; } else {
*canon_parm = parm_table[num].label;
} }
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;
}
}
/* 'include', 'copy', 'config file' and friends left */
*canon_parm = parm_name;
return True; return True;
} }
/*************************************************************************** /***************************************************************************
@ -2877,6 +2870,33 @@ static int map_parameter(const char *pszParmName)
return (-1); return (-1);
} }
/***************************************************************************
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 return true if parameter number parm1 is a synonym of parameter
number parm2 (parm2 being the principal name). number parm2 (parm2 being the principal name).