mirror of
https://github.com/samba-team/samba.git
synced 2025-08-05 12:22:11 +03:00
r24602: Add function lp_string_is_valid_boolean() to check if a string
contains a correct representation of a boolean value (in the understanding of loadparm.c). Make set_boolean() catch passing NULL for the boolean target. Michael
This commit is contained in:
committed by
Gerald (Jerry) Carter
parent
12cb06d6ad
commit
d13eaa60f5
@ -3087,25 +3087,41 @@ void show_parameter_list(void)
|
|||||||
static BOOL set_boolean(BOOL *pb, const char *pszParmValue)
|
static BOOL set_boolean(BOOL *pb, const char *pszParmValue)
|
||||||
{
|
{
|
||||||
BOOL bRetval;
|
BOOL bRetval;
|
||||||
|
BOOL value;
|
||||||
|
|
||||||
bRetval = True;
|
bRetval = True;
|
||||||
if (strwicmp(pszParmValue, "yes") == 0 ||
|
if (strwicmp(pszParmValue, "yes") == 0 ||
|
||||||
strwicmp(pszParmValue, "true") == 0 ||
|
strwicmp(pszParmValue, "true") == 0 ||
|
||||||
strwicmp(pszParmValue, "1") == 0)
|
strwicmp(pszParmValue, "1") == 0)
|
||||||
*pb = True;
|
value = True;
|
||||||
else if (strwicmp(pszParmValue, "no") == 0 ||
|
else if (strwicmp(pszParmValue, "no") == 0 ||
|
||||||
strwicmp(pszParmValue, "False") == 0 ||
|
strwicmp(pszParmValue, "False") == 0 ||
|
||||||
strwicmp(pszParmValue, "0") == 0)
|
strwicmp(pszParmValue, "0") == 0)
|
||||||
*pb = False;
|
value = False;
|
||||||
else {
|
else {
|
||||||
DEBUG(0,
|
DEBUG(0,
|
||||||
("ERROR: Badly formed boolean in configuration file: \"%s\".\n",
|
("ERROR: Badly formed boolean in configuration file: \"%s\".\n",
|
||||||
pszParmValue));
|
pszParmValue));
|
||||||
bRetval = False;
|
bRetval = False;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (pb != NULL) {
|
||||||
|
*pb = value;
|
||||||
|
}
|
||||||
|
|
||||||
return (bRetval);
|
return (bRetval);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
Check if a given string correctly represents a boolean value.
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
BOOL lp_string_is_valid_boolean(const char *parm_value)
|
||||||
|
{
|
||||||
|
return set_boolean(NULL, parm_value);
|
||||||
|
}
|
||||||
|
|
||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
Get the standard string representation of a boolean value ("yes" or "no")
|
Get the standard string representation of a boolean value ("yes" or "no")
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
Reference in New Issue
Block a user