From 49791818610cecd877eb5b865cb6cefa90e92ba0 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 27 May 2005 13:16:26 +0000 Subject: 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) --- source4/web_server/calls.c | 56 +++++++++++++++++++++++++++++++++------------- swat/esptest/loadparm.esp | 3 +++ 2 files changed, 44 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;ilabel, 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); } diff --git a/swat/esptest/loadparm.esp b/swat/esptest/loadparm.esp index b5f3c86b1d..b9f2c54ec5 100644 --- a/swat/esptest/loadparm.esp +++ b/swat/esptest/loadparm.esp @@ -57,6 +57,9 @@ if (request['REQUEST_METHOD'] == "POST") { Here are some commonly used parameters:

<% + +showValue("defined services", lpServices()); + function showParameter(name) { showValue(name, lpGet(name)); } -- cgit