summaryrefslogtreecommitdiff
path: root/source3/param
diff options
context:
space:
mode:
authorMichael Adam <obnox@samba.org>2007-08-17 16:03:18 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:29:54 -0500
commitc56874d1129c6e5759acc5b125b5e8edd44a997c (patch)
treebb186109e0148c8986ad6f325013627c9601e0b6 /source3/param
parentbb76f3f98ed2e49ad4114a34a2a7fa0e6655f33d (diff)
downloadsamba-c56874d1129c6e5759acc5b125b5e8edd44a997c.tar.gz
samba-c56874d1129c6e5759acc5b125b5e8edd44a997c.tar.bz2
samba-c56874d1129c6e5759acc5b125b5e8edd44a997c.zip
r24527: Add a function lp_canonicalize_parameter_with_value that turns
a parameter and value into the canonical paramter with the value inverted if it was in invers boolean synonym. Make net conf use this function when storing parameters. Michael (This used to be commit 3b762ab18392fd06427957b0263262e3b8e34b9d)
Diffstat (limited to 'source3/param')
-rw-r--r--source3/param/loadparm.c45
1 files changed, 45 insertions, 0 deletions
diff --git a/source3/param/loadparm.c b/source3/param/loadparm.c
index ea1bb0a23f..bd318791b5 100644
--- a/source3/param/loadparm.c
+++ b/source3/param/loadparm.c
@@ -2845,6 +2845,51 @@ BOOL lp_canonicalize_parameter(const char *parm_name, const char **canon_parm,
}
+/**************************************************************************
+ Determine the canonical name for a parameter.
+ Turn the value given into the inverse boolean expression when
+ the synonym is an invers boolean synonym.
+
+ Return True if parm_name is a valid parameter name and
+ in case it is an invers boolean synonym, if the val string could
+ successfully be converted to the reverse bool.
+ Return false in all other cases.
+**************************************************************************/
+
+BOOL lp_canonicalize_parameter_with_value(const char *parm_name,
+ const char *val,
+ const char **canon_parm,
+ const char **canon_val)
+{
+ int num;
+ BOOL inverse;
+
+ if (!lp_parameter_is_valid(parm_name)) {
+ *canon_parm = NULL;
+ *canon_val = NULL;
+ return False;
+ }
+
+ num = map_parameter_canonical(parm_name, &inverse);
+ if (num < 0) {
+ /* parametric option */
+ *canon_parm = parm_name;
+ *canon_val = val;
+ } else {
+ *canon_parm = parm_table[num].label;
+ if (inverse) {
+ if (!lp_invert_boolean(val, canon_val)) {
+ *canon_val = NULL;
+ return False;
+ }
+ } else {
+ *canon_val = val;
+ }
+ }
+
+ return True;
+}
+
/***************************************************************************
Map a parameter's string representation to something we can use.
Returns False if the parameter string is not recognised, else TRUE.