summaryrefslogtreecommitdiffstats
path: root/source4/web_server
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2005-05-27 13:16:26 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:17:07 -0500
commit49791818610cecd877eb5b865cb6cefa90e92ba0 (patch)
tree57e260112367d100a94284e99afda79bf87565d2 /source4/web_server
parent590f56d564d8bcaa9ff1c4bcdbcbb0d3b5c9f7f1 (diff)
downloadsamba-49791818610cecd877eb5b865cb6cefa90e92ba0.tar.gz
samba-49791818610cecd877eb5b865cb6cefa90e92ba0.tar.xz
samba-49791818610cecd877eb5b865cb6cefa90e92ba0.zip
r7019: - added esp call lpServices() which returns a list of services in smb.conf.
- added a test of lpServices() in the esptest scripts (This used to be commit 94308d8fed7796ddfc32883a1c27ec8ebfff842d)
Diffstat (limited to 'source4/web_server')
-rw-r--r--source4/web_server/calls.c56
1 files changed, 41 insertions, 15 deletions
diff --git a/source4/web_server/calls.c b/source4/web_server/calls.c
index 6f1649d131..859ae17433 100644
--- a/source4/web_server/calls.c
+++ b/source4/web_server/calls.c
@@ -62,6 +62,43 @@ static int esp_typeof(struct EspRequest *ep, int argc, struct MprVar **argv)
return 0;
}
+/*
+ setup a return of a string list
+*/
+static void esp_returnlist(struct EspRequest *ep,
+ const char *name, const char **list)
+{
+ struct MprVar var;
+ int i;
+
+ var = mprCreateObjVar(name, ESP_HASH_SIZE);
+ for (i=0;list[i];i++) {
+ char idx[16];
+ struct MprVar val;
+ mprItoa(i, idx, sizeof(idx));
+ val = mprCreateStringVar(list[i], 1);
+ mprCreateProperty(&var, idx, &val);
+ }
+ espSetReturn(ep, var);
+}
+
+/*
+ return a list of defined services
+*/
+static int esp_lpServices(struct EspRequest *ep, int argc, char **argv)
+{
+ int i;
+ const char **list;
+ if (argc != 0) return -1;
+
+ for (i=0;i<lp_numservices();i++) {
+ list = str_list_add(list, lp_servicename(i));
+ }
+ talloc_steal(ep, list);
+ esp_returnlist(ep, "services", list);
+ return 0;
+}
+
/*
allow access to loadparm variables from inside esp scripts in swat
@@ -146,25 +183,13 @@ static int esp_lpGet(struct EspRequest *ep, int argc, char **argv)
return 0;
}
}
- return -1;
-
- case P_LIST: {
- const char **list = *(const char ***)parm_ptr;
- struct MprVar var;
- var = mprCreateObjVar(parm->label, 10);
- for (i=0;list[i];i++) {
- char idx[16];
- struct MprVar val;
- mprItoa(i, idx, sizeof(idx));
- val = mprCreateStringVar(list[i], 1);
- mprCreateProperty(&var, idx, &val);
- }
- espSetReturn(ep, var);
+ return -1;
+ case P_LIST:
+ esp_returnlist(ep, parm->label, *(const char ***)parm_ptr);
break;
case P_SEP:
return -1;
}
- }
return 0;
}
@@ -174,5 +199,6 @@ static int esp_lpGet(struct EspRequest *ep, int argc, char **argv)
void http_setup_ejs_functions(void)
{
espDefineStringCFunction(NULL, "lpGet", esp_lpGet, NULL);
+ espDefineStringCFunction(NULL, "lpServices", esp_lpServices, NULL);
espDefineCFunction(NULL, "typeof", esp_typeof, NULL);
}