aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ctl-apidef.h48
-rw-r--r--ctl-apidef.json6
-rw-r--r--ctl-lua.c16
3 files changed, 37 insertions, 33 deletions
diff --git a/ctl-apidef.h b/ctl-apidef.h
index 68f9725..100fc79 100644
--- a/ctl-apidef.h
+++ b/ctl-apidef.h
@@ -36,21 +36,21 @@ static const char _afb_description_v2_control[] =
"missions\":{\"$ref\":\"#/components/x-permissions/navigation\"},\"parame"
"ters\":[{\"in\":\"query\",\"name\":\"zone\",\"required\":false,\"schema\""
":{\"type\":\"string\"}}],\"responses\":{\"200\":{\"$ref\":\"#/components"
- "/responses/200\"}}}},\"/lua_docall\":{\"description\":\"Execute LUA stri"
- "ng script.\",\"get\":{\"x-permissions\":{\"$ref\":\"#/components/x-permi"
- "ssions/navigation\"},\"parameters\":[{\"in\":\"query\",\"name\":\"func\""
- ",\"required\":true,\"schema\":{\"type\":\"string\"}},{\"in\":\"query\",\""
- "name\":\"args\",\"required\":false,\"schema\":{\"type\":\"array\"}}],\"r"
- "esponses\":{\"200\":{\"$ref\":\"#/components/responses/200\"}}}},\"/lua_"
- "dostring\":{\"description\":\"Execute LUA string script.\",\"get\":{\"x-"
- "permissions\":{\"$ref\":\"#/components/x-permissions/navigation\"},\"par"
- "ameters\":[{\"in\":\"query\",\"required\":true,\"schema\":{\"type\":\"st"
- "ring\"}}],\"responses\":{\"200\":{\"$ref\":\"#/components/responses/200\""
- "}}}},\"/lua_doscript\":{\"description\":\"Execute LUA string script.\",\""
- "get\":{\"x-permissions\":{\"$ref\":\"#/components/x-permissions/navigati"
- "on\"},\"parameters\":[{\"in\":\"query\",\"name\":\"filename\",\"required"
- "\":true,\"schema\":{\"type\":\"string\"}}],\"responses\":{\"200\":{\"$re"
- "f\":\"#/components/responses/200\"}}}}}}"
+ "/responses/200\"}}}},\"/request\":{\"description\":\"Execute LUA string "
+ "script.\",\"get\":{\"x-permissions\":{\"$ref\":\"#/components/x-permissi"
+ "ons/navigation\"},\"parameters\":[{\"in\":\"query\",\"name\":\"func\",\""
+ "required\":true,\"schema\":{\"type\":\"string\"}},{\"in\":\"query\",\"na"
+ "me\":\"args\",\"required\":false,\"schema\":{\"type\":\"array\"}}],\"res"
+ "ponses\":{\"200\":{\"$ref\":\"#/components/responses/200\"}}}},\"/execlu"
+ "a\":{\"description\":\"Execute LUA string script.\",\"get\":{\"x-permiss"
+ "ions\":{\"$ref\":\"#/components/x-permissions/navigation\"},\"parameters"
+ "\":[{\"in\":\"query\",\"required\":true,\"schema\":{\"type\":\"string\"}"
+ "}],\"responses\":{\"200\":{\"$ref\":\"#/components/responses/200\"}}}},\""
+ "/scriptlua\":{\"description\":\"Execute LUA string script.\",\"get\":{\""
+ "x-permissions\":{\"$ref\":\"#/components/x-permissions/navigation\"},\"p"
+ "arameters\":[{\"in\":\"query\",\"name\":\"filename\",\"required\":true,\""
+ "schema\":{\"type\":\"string\"}}],\"responses\":{\"200\":{\"$ref\":\"#/co"
+ "mponents/responses/200\"}}}}}}"
;
static const struct afb_auth _afb_auths_v2_control[] = {
@@ -59,9 +59,9 @@ static const struct afb_auth _afb_auths_v2_control[] = {
void ctlapi_monitor(struct afb_req req);
void ctlapi_dispatch(struct afb_req req);
- void ctlapi_lua_docall(struct afb_req req);
- void ctlapi_lua_dostring(struct afb_req req);
- void ctlapi_lua_doscript(struct afb_req req);
+ void ctlapi_request(struct afb_req req);
+ void ctlapi_execlua(struct afb_req req);
+ void ctlapi_scriptlua(struct afb_req req);
static const struct afb_verb_v2 _afb_verbs_v2_control[] = {
{
@@ -79,22 +79,22 @@ static const struct afb_verb_v2 _afb_verbs_v2_control[] = {
.session = AFB_SESSION_NONE_V2
},
{
- .verb = "lua_docall",
- .callback = ctlapi_lua_docall,
+ .verb = "request",
+ .callback = ctlapi_request,
.auth = &_afb_auths_v2_control[0],
.info = NULL,
.session = AFB_SESSION_NONE_V2
},
{
- .verb = "lua_dostring",
- .callback = ctlapi_lua_dostring,
+ .verb = "execlua",
+ .callback = ctlapi_execlua,
.auth = &_afb_auths_v2_control[0],
.info = NULL,
.session = AFB_SESSION_NONE_V2
},
{
- .verb = "lua_doscript",
- .callback = ctlapi_lua_doscript,
+ .verb = "scriptlua",
+ .callback = ctlapi_scriptlua,
.auth = &_afb_auths_v2_control[0],
.info = NULL,
.session = AFB_SESSION_NONE_V2
diff --git a/ctl-apidef.json b/ctl-apidef.json
index c35cbc0..f292eec 100644
--- a/ctl-apidef.json
+++ b/ctl-apidef.json
@@ -170,7 +170,7 @@
}
}
},
- "/lua_docall": {
+ "/request": {
"description": "Execute LUA string script.",
"get": {
"x-permissions": {
@@ -201,7 +201,7 @@
}
}
},
- "/lua_dostring": {
+ "/execlua": {
"description": "Execute LUA string script.",
"get": {
"x-permissions": {
@@ -223,7 +223,7 @@
}
}
},
- "/lua_doscript": {
+ "/scriptlua": {
"description": "Execute LUA string script.",
"get": {
"x-permissions": {
diff --git a/ctl-lua.c b/ctl-lua.c
index 3f45055..01cf1b9 100644
--- a/ctl-lua.c
+++ b/ctl-lua.c
@@ -673,7 +673,7 @@ STATIC void LuaDoAction (LuaDoActionT action, afb_req request) {
const char *func;
json_object *argsJ=NULL;
- err= wrap_json_unpack (queryJ, "{s:s, s?o !}", "func", &func, "args", &argsJ);
+ err= wrap_json_unpack (queryJ, "{s:s, s?o !}", "request", &func, "args", &argsJ);
if (err) {
AFB_ERROR ("LUA-DOCALL-SYNTAX missing func|args query=%s", json_object_get_string(queryJ));
goto OnErrorExit;
@@ -708,7 +708,7 @@ STATIC void LuaDoAction (LuaDoActionT action, afb_req request) {
// scan luascript search path once
static json_object *luaScriptPathJ =NULL;
- err= wrap_json_unpack (queryJ, "{s:s, s?s s?o !}", "script", &script,"func", &func, "args", &argsJ);
+ err= wrap_json_unpack (queryJ, "{s:s, s?s s?o !}", "target", &script,"function", &func, "args", &argsJ);
if (err) {
AFB_ERROR ("LUA-DOSCRIPT-SYNTAX:missing script|(args,arg) query=%s", json_object_get_string(queryJ));
goto OnErrorExit;
@@ -747,7 +747,11 @@ STATIC void LuaDoAction (LuaDoActionT action, afb_req request) {
}
// if no func name given try to deduct from filename
- if (!func) func= (char*)GetMidleName(filename);
+ if (!func && (func=(char*)GetMidleName(filename))!=NULL) {
+ strncpy(luaScriptPath,"_", sizeof(luaScriptPath));
+ strncat(luaScriptPath,func, sizeof(luaScriptPath));
+ func=luaScriptPath;
+ }
if (!func) {
AFB_ERROR ("LUA-DOSCRIPT:FAIL to deduct funcname from %s", filename);
goto OnErrorExit;
@@ -789,15 +793,15 @@ STATIC void LuaDoAction (LuaDoActionT action, afb_req request) {
return;
}
-PUBLIC void ctlapi_lua_dostring (afb_req request) {
+PUBLIC void ctlapi_execlua (afb_req request) {
LuaDoAction (LUA_DOSTRING, request);
}
-PUBLIC void ctlapi_lua_docall (afb_req request) {
+PUBLIC void ctlapi_request (afb_req request) {
LuaDoAction (LUA_DOCALL, request);
}
-PUBLIC void ctlapi_lua_doscript (afb_req request) {
+PUBLIC void ctlapi_scriptlua (afb_req request) {
LuaDoAction (LUA_DOSCRIPT, request);
}