summaryrefslogtreecommitdiff
path: root/source4/param/loadparm.c
diff options
context:
space:
mode:
authorJames Peach <jpeach@samba.org>2006-04-24 00:38:53 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 14:04:14 -0500
commit9d9e5abdcee6581ff42d7bdcf7b236472cbec347 (patch)
treeb79dc2522c619273d03efaeca2a0df1550d5a1bd /source4/param/loadparm.c
parent6ab33938d5239e8688440f65e802f627622d301b (diff)
downloadsamba-9d9e5abdcee6581ff42d7bdcf7b236472cbec347.tar.gz
samba-9d9e5abdcee6581ff42d7bdcf7b236472cbec347.tar.bz2
samba-9d9e5abdcee6581ff42d7bdcf7b236472cbec347.zip
r15187: Introduce new param type P_BYTES. This lets config options which specify
byte counts be given in convenient units. (This used to be commit 1b8891a2f389c1016c3cfcbe635ed86d015554d8)
Diffstat (limited to 'source4/param/loadparm.c')
-rw-r--r--source4/param/loadparm.c40
1 files changed, 39 insertions, 1 deletions
diff --git a/source4/param/loadparm.c b/source4/param/loadparm.c
index 922e2f0f04..a033e0815c 100644
--- a/source4/param/loadparm.c
+++ b/source4/param/loadparm.c
@@ -460,7 +460,7 @@ static struct parm_struct parm_table[] = {
{"announce version", P_STRING, P_GLOBAL, &Globals.szAnnounceVersion, NULL, NULL, FLAG_DEVELOPER},
{"announce as", P_ENUM, P_GLOBAL, &Globals.announce_as, NULL, enum_announce_as, FLAG_DEVELOPER},
{"max mux", P_INTEGER, P_GLOBAL, &Globals.max_mux, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
- {"max xmit", P_INTEGER, P_GLOBAL, &Globals.max_xmit, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
+ {"max xmit", P_BYTES, P_GLOBAL, &Globals.max_xmit, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
{"name resolve order", P_LIST, P_GLOBAL, &Globals.szNameResolveOrder, NULL, NULL, FLAG_ADVANCED | FLAG_WIZARD | FLAG_DEVELOPER},
{"max wins ttl", P_INTEGER, P_GLOBAL, &Globals.max_wins_ttl, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
@@ -1061,6 +1061,26 @@ int lp_parm_int(int lookup_service, const char *type, const char *option, int de
return default_v;
}
+/* Return parametric option from a given service. Type is a part of
+ * option before ':'.
+ * Parametric option has following syntax: 'Type: option = value'.
+ */
+
+int lp_parm_bytes(int lookup_service, const char *type, const char *option, int default_v)
+{
+ uint64_t bval;
+
+ const char *value = lp_get_parametric(lookup_service, type, option);
+
+ if (value && conv_str_size(value, &bval)) {
+ if (bval <= INT_MAX) {
+ return (int)bval;
+ }
+ }
+
+ return default_v;
+}
+
/* Return parametric option from a given service. Type is a part of option before ':' */
/* Parametric option has following syntax: 'Type: option = value' */
@@ -1829,6 +1849,21 @@ BOOL lp_do_parameter(int snum, const char *pszParmName, const char *pszParmValue
*(int *)parm_ptr = atoi(pszParmValue);
break;
+ case P_BYTES:
+ {
+ uint64_t val;
+ if (conv_str_size(pszParmValue, &val)) {
+ if (val <= INT_MAX) {
+ *(int *)parm_ptr = (int)val;
+ break;
+ }
+ }
+
+ DEBUG(0,("lp_do_parameter(%s): value is not "
+ "a valid size specifier!\n", pszParmValue));
+ return False;
+ }
+
case P_LIST:
*(const char ***)parm_ptr = str_list_make(talloc_autofree_context(),
pszParmValue, NULL);
@@ -2004,6 +2039,7 @@ static void print_parameter(struct parm_struct *p, void *ptr, FILE * f)
break;
case P_INTEGER:
+ case P_BYTES:
fprintf(f, "%d", *(int *)ptr);
break;
@@ -2039,6 +2075,7 @@ static BOOL equal_parameter(parm_type type, void *ptr1, void *ptr2)
return (*((BOOL *)ptr1) == *((BOOL *)ptr2));
case P_INTEGER:
+ case P_BYTES:
case P_ENUM:
return (*((int *)ptr1) == *((int *)ptr2));
@@ -2127,6 +2164,7 @@ static BOOL is_default(int i)
return parm_table[i].def.bvalue ==
*(BOOL *)parm_table[i].ptr;
case P_INTEGER:
+ case P_BYTES:
case P_ENUM:
return parm_table[i].def.ivalue ==
*(int *)parm_table[i].ptr;