diff options
author | Michael Adam <obnox@samba.org> | 2007-08-21 14:47:15 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 12:30:09 -0500 |
commit | b9a7a2b966f3fb9757d8ff7e4c94e78d6728e74a (patch) | |
tree | c1273b84f3391171bbb4ef33d3040d21a6ceb20d /source3/param | |
parent | e88a6d34383b37d9b6d019004a55e7cc4fc4f075 (diff) | |
download | samba-b9a7a2b966f3fb9757d8ff7e4c94e78d6728e74a.tar.gz samba-b9a7a2b966f3fb9757d8ff7e4c94e78d6728e74a.tar.bz2 samba-b9a7a2b966f3fb9757d8ff7e4c94e78d6728e74a.zip |
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 used to be commit d13eaa60f504987445b7333ef6972491c9483e6a)
Diffstat (limited to 'source3/param')
-rw-r--r-- | source3/param/loadparm.c | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/source3/param/loadparm.c b/source3/param/loadparm.c index e65a649584..6e05e5e554 100644 --- a/source3/param/loadparm.c +++ b/source3/param/loadparm.c @@ -3087,25 +3087,41 @@ void show_parameter_list(void) static BOOL set_boolean(BOOL *pb, const char *pszParmValue) { BOOL bRetval; + BOOL value; bRetval = True; if (strwicmp(pszParmValue, "yes") == 0 || strwicmp(pszParmValue, "true") == 0 || strwicmp(pszParmValue, "1") == 0) - *pb = True; + value = True; else if (strwicmp(pszParmValue, "no") == 0 || strwicmp(pszParmValue, "False") == 0 || strwicmp(pszParmValue, "0") == 0) - *pb = False; + value = False; else { DEBUG(0, ("ERROR: Badly formed boolean in configuration file: \"%s\".\n", pszParmValue)); bRetval = False; } + + if (pb != NULL) { + *pb = value; + } + 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") ***************************************************************************/ |