summaryrefslogtreecommitdiff
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
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)
-rw-r--r--source4/param/loadparm.c40
-rw-r--r--source4/param/loadparm.h2
-rwxr-xr-xsource4/script/tests/selftest.sh1
-rw-r--r--source4/scripting/ejs/smbcalls_config.c3
4 files changed, 43 insertions, 3 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;
diff --git a/source4/param/loadparm.h b/source4/param/loadparm.h
index 02fc004f9a..cbd017db7c 100644
--- a/source4/param/loadparm.h
+++ b/source4/param/loadparm.h
@@ -30,7 +30,7 @@
/* the following are used by loadparm for option lists */
typedef enum {
- P_BOOL,P_INTEGER,P_LIST,P_STRING,P_USTRING,P_ENUM,P_SEP
+ P_BOOL,P_INTEGER,P_BYTES,P_LIST,P_STRING,P_USTRING,P_ENUM,P_SEP
} parm_type;
typedef enum {
diff --git a/source4/script/tests/selftest.sh b/source4/script/tests/selftest.sh
index 0337d664a0..be4e916947 100755
--- a/source4/script/tests/selftest.sh
+++ b/source4/script/tests/selftest.sh
@@ -122,6 +122,7 @@ cat >$CONFFILE<<EOF
panic action = $SRCDIR/script/gdb_backtrace %PID% %PROG%
wins support = yes
server role = pdc
+ max xmit = 32K
[tmp]
path = $TMPDIR
diff --git a/source4/scripting/ejs/smbcalls_config.c b/source4/scripting/ejs/smbcalls_config.c
index 949dd0321a..fae497e2a5 100644
--- a/source4/scripting/ejs/smbcalls_config.c
+++ b/source4/scripting/ejs/smbcalls_config.c
@@ -126,7 +126,7 @@ static int ejs_lpGet(MprVarHandle eid, int argc, char **argv)
/* its a global parameter */
parm = lp_parm_struct(argv[0]);
if (parm == NULL) return -1;
- parm_ptr = parm->ptr;
+ parm_ptr = lp_parm_ptr(-1, parm);
}
if (parm == NULL || parm_ptr == NULL) {
@@ -143,6 +143,7 @@ static int ejs_lpGet(MprVarHandle eid, int argc, char **argv)
mpr_Return(eid, mprCreateBoolVar(*(BOOL *)parm_ptr));
break;
case P_INTEGER:
+ case P_BYTES:
mpr_Return(eid, mprCreateIntegerVar(*(int *)parm_ptr));
break;
case P_ENUM: