summaryrefslogtreecommitdiff
path: root/source4/param
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2011-10-06 16:59:19 +1100
committerAndrew Bartlett <abartlet@samba.org>2011-10-07 10:17:00 +0200
commit556ef6ac906ef6155c21714aaa6f3cf3ee52a9ac (patch)
tree1689c1878f7204589770dcf6ad5b9f548cf3a080 /source4/param
parent63862516213d9e556db039a3278233c45ff11404 (diff)
downloadsamba-556ef6ac906ef6155c21714aaa6f3cf3ee52a9ac.tar.gz
samba-556ef6ac906ef6155c21714aaa6f3cf3ee52a9ac.tar.bz2
samba-556ef6ac906ef6155c21714aaa6f3cf3ee52a9ac.zip
s4-param copy print_parameter and equal_parameter in from source3
This will allow these functions to be put into lib/param shortly. Andrew Bartlett Autobuild-User: Andrew Bartlett <abartlet@samba.org> Autobuild-Date: Fri Oct 7 10:17:01 CEST 2011 on sn-devel-104
Diffstat (limited to 'source4/param')
-rw-r--r--source4/param/loadparm.c34
1 files changed, 24 insertions, 10 deletions
diff --git a/source4/param/loadparm.c b/source4/param/loadparm.c
index a9fa002931..f31ac0654e 100644
--- a/source4/param/loadparm.c
+++ b/source4/param/loadparm.c
@@ -2822,8 +2822,9 @@ bool lpcfg_set_option(struct loadparm_context *lp_ctx, const char *option)
static void print_parameter(struct parm_struct *p, void *ptr, FILE * f)
{
+ /* For the seperation of lists values that we print below */
+ const char *list_sep = ", ";
int i;
- const char *list_sep = ", "; /* For the seperation of lists values that we print below */
switch (p->type)
{
case P_ENUM:
@@ -2853,9 +2854,15 @@ static void print_parameter(struct parm_struct *p, void *ptr, FILE * f)
fprintf(f, "%c", *(char *)ptr);
break;
- case P_OCTAL:
- fprintf(f, "0%o", *(int *)ptr);
+ case P_OCTAL: {
+ int val = *(int *)ptr;
+ if (val == -1) {
+ fprintf(f, "-1");
+ } else {
+ fprintf(f, "0%o", val);
+ }
break;
+ }
case P_CMDLIST:
list_sep = " ";
@@ -2863,13 +2870,17 @@ static void print_parameter(struct parm_struct *p, void *ptr, FILE * f)
case P_LIST:
if ((char ***)ptr && *(char ***)ptr) {
char **list = *(char ***)ptr;
-
for (; *list; list++) {
+ /* surround strings with whitespace in double quotes */
if (*(list+1) == NULL) {
- /* last item, print no extra seperator after */
+ /* last item, no extra separator */
list_sep = "";
}
- fprintf(f, "%s%s", *list, list_sep);
+ if ( strchr_m( *list, ' ' ) ) {
+ fprintf(f, "\"%s\"%s", *list, list_sep);
+ } else {
+ fprintf(f, "%s%s", *list, list_sep);
+ }
}
}
break;
@@ -2880,6 +2891,8 @@ static void print_parameter(struct parm_struct *p, void *ptr, FILE * f)
fprintf(f, "%s", *(char **)ptr);
}
break;
+ case P_SEP:
+ break;
}
}
@@ -2895,18 +2908,17 @@ static bool equal_parameter(parm_type type, void *ptr1, void *ptr2)
return (*((bool *)ptr1) == *((bool *)ptr2));
case P_INTEGER:
+ case P_ENUM:
case P_OCTAL:
case P_BYTES:
- case P_ENUM:
return (*((int *)ptr1) == *((int *)ptr2));
case P_CHAR:
return (*((char *)ptr1) == *((char *)ptr2));
- case P_CMDLIST:
case P_LIST:
- return str_list_equal((const char **)(*(char ***)ptr1),
- (const char **)(*(char ***)ptr2));
+ case P_CMDLIST:
+ return str_list_equal(*(const char ***)ptr1, *(const char ***)ptr2);
case P_STRING:
case P_USTRING:
@@ -2918,6 +2930,8 @@ static bool equal_parameter(parm_type type, void *ptr1, void *ptr2)
p2 = NULL;
return (p1 == p2 || strequal(p1, p2));
}
+ case P_SEP:
+ break;
}
return false;
}