summaryrefslogtreecommitdiff
path: root/source4/scripting/ejs/smbcalls_config.c
diff options
context:
space:
mode:
Diffstat (limited to 'source4/scripting/ejs/smbcalls_config.c')
-rw-r--r--source4/scripting/ejs/smbcalls_config.c49
1 files changed, 13 insertions, 36 deletions
diff --git a/source4/scripting/ejs/smbcalls_config.c b/source4/scripting/ejs/smbcalls_config.c
index 6f15ee5a4a..1c76757659 100644
--- a/source4/scripting/ejs/smbcalls_config.c
+++ b/source4/scripting/ejs/smbcalls_config.c
@@ -25,6 +25,7 @@
#include "param/loadparm.h"
#include "system/network.h"
#include "lib/socket/netif.h"
+#include "param/param.h"
/*
return a list of defined services
@@ -35,8 +36,8 @@ static int ejs_lpServices(MprVarHandle eid, int argc, char **argv)
const char **list = NULL;
if (argc != 0) return -1;
- for (i=0;i<lp_numservices();i++) {
- list = str_list_add(list, lp_servicename(i));
+ for (i=0;i<lp_numservices(global_loadparm);i++) {
+ list = str_list_add(list, lp_servicename(lp_servicebynum(global_loadparm, i)));
}
talloc_steal(mprMemCtx(), list);
mpr_Return(eid, mprList("services", list));
@@ -45,27 +46,6 @@ static int ejs_lpServices(MprVarHandle eid, int argc, char **argv)
/*
- return a list of parameter categories
-*/
-static int ejs_lpCategories(MprVarHandle eid, int argc, char **argv)
-{
- struct parm_struct *parm_table = lp_parm_table();
- int i;
- const char **list = NULL;
- if (argc != 0) return -1;
-
- for (i=0;parm_table[i].label;i++) {
- if (parm_table[i].class == P_SEPARATOR) {
- list = str_list_add(list, parm_table[i].label);
- }
- }
- talloc_steal(mprMemCtx(), list);
- mpr_Return(eid, mprList("categories", list));
- return 0;
-}
-
-
-/*
allow access to loadparm variables from inside ejs scripts in web apps
can be called in 4 ways:
@@ -86,9 +66,10 @@ static int ejs_lpGet(MprVarHandle eid, int argc, char **argv)
if (argc < 1) return -1;
if (argc == 2) {
+ struct loadparm_service *service;
/* its a share parameter */
- int snum = lp_servicenumber(argv[0]);
- if (snum == -1) {
+ service = lp_service(global_loadparm, argv[0]);
+ if (service == NULL) {
mpr_Return(eid, mprCreateUndefinedVar());
return 0;
}
@@ -103,7 +84,7 @@ static int ejs_lpGet(MprVarHandle eid, int argc, char **argv)
mpr_Return(eid, mprCreateUndefinedVar());
return 0;
}
- value = lp_get_parametric(snum, type, option);
+ value = lp_get_parametric(global_loadparm, service, type, option);
if (value == NULL) {
mpr_Return(eid, mprCreateUndefinedVar());
return 0;
@@ -117,7 +98,7 @@ static int ejs_lpGet(MprVarHandle eid, int argc, char **argv)
mpr_Return(eid, mprCreateUndefinedVar());
return 0;
}
- parm_ptr = lp_parm_ptr(snum, parm);
+ parm_ptr = lp_parm_ptr(service, parm);
} else if (strchr(argv[0], ':')) {
/* its a global parametric option */
const char *type = talloc_strndup(mprMemCtx(),
@@ -128,7 +109,7 @@ static int ejs_lpGet(MprVarHandle eid, int argc, char **argv)
mpr_Return(eid, mprCreateUndefinedVar());
return 0;
}
- value = lp_get_parametric(-1, type, option);
+ value = lp_get_parametric(global_loadparm, NULL, type, option);
if (value == NULL) {
mpr_Return(eid, mprCreateUndefinedVar());
return 0;
@@ -142,7 +123,7 @@ static int ejs_lpGet(MprVarHandle eid, int argc, char **argv)
mpr_Return(eid, mprCreateUndefinedVar());
return 0;
}
- parm_ptr = lp_parm_ptr(-1, parm);
+ parm_ptr = lp_parm_ptr(NULL, parm);
}
if (parm == NULL || parm_ptr == NULL) {
@@ -157,7 +138,7 @@ static int ejs_lpGet(MprVarHandle eid, int argc, char **argv)
mpr_ReturnString(eid, *(char **)parm_ptr);
break;
case P_BOOL:
- mpr_Return(eid, mprCreateBoolVar(*(BOOL *)parm_ptr));
+ mpr_Return(eid, mprCreateBoolVar(*(bool *)parm_ptr));
break;
case P_INTEGER:
case P_OCTAL:
@@ -176,9 +157,6 @@ static int ejs_lpGet(MprVarHandle eid, int argc, char **argv)
case P_LIST:
mpr_Return(eid, mprList(parm->label, *(const char ***)parm_ptr));
break;
- case P_SEP:
- mpr_Return(eid, mprCreateUndefinedVar());
- return 0;
}
return 0;
}
@@ -198,7 +176,7 @@ static int ejs_lpSet(MprVarHandle eid, int argc, char **argv)
return -1;
}
- mpr_Return(eid, mprCreateBoolVar(lp_set_cmdline(argv[0], argv[1])));
+ mpr_Return(eid, mprCreateBoolVar(lp_set_cmdline(global_loadparm, argv[0], argv[1])));
return 0;
}
@@ -209,7 +187,7 @@ static int ejs_lpSet(MprVarHandle eid, int argc, char **argv)
*/
static int ejs_lpReload(MprVarHandle eid, int argc, char **argv)
{
- BOOL ret = lp_load();
+ bool ret = lp_load(lp_configfile(global_loadparm));
if (ret) {
unload_interfaces();
}
@@ -228,7 +206,6 @@ static int ejs_loadparm_init(MprVarHandle eid, int argc, struct MprVar **argv)
mprSetStringCFunction(obj, "set", ejs_lpSet);
mprSetStringCFunction(obj, "reload", ejs_lpReload);
mprSetStringCFunction(obj, "services", ejs_lpServices);
- mprSetStringCFunction(obj, "categories", ejs_lpCategories);
return 0;
}