From b65178642727536972d0c04e53b2310be58beb2e Mon Sep 17 00:00:00 2001 From: fulup Date: Fri, 11 Aug 2017 19:44:21 +0200 Subject: Almost working version with Json Config, Lua script and sharelib callbacks. --- Controler-afb/ctl-binding.h | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) (limited to 'Controler-afb/ctl-binding.h') diff --git a/Controler-afb/ctl-binding.h b/Controler-afb/ctl-binding.h index abcb2f4..deef93c 100644 --- a/Controler-afb/ctl-binding.h +++ b/Controler-afb/ctl-binding.h @@ -28,6 +28,13 @@ #endif #define STATIC static +// sharelib ctl-plugin* +typedef struct { + long magic; + char *label; +} CtlPluginMagicT; + +#define CTL_PLUGIN_REGISTER(pluglabel) CtlPluginMagicT CtlPluginMagic={.magic=CTL_PLUGIN_MAGIC,.label=pluglabel}; struct afb_binding_data_v2; // polctl-binding.c PUBLIC int CtlBindingInit (); @@ -43,14 +50,6 @@ PUBLIC void ctlapi_event_test (afb_req request); // ctl-policy // ----------- -typedef enum { - CTLAPI_NAVIGATION, - CTLAPI_MULTIMEDIA, - CTLAPI_EMERGENCY, - - CTL_NONE=-1 -} DispatchCtlEnumT; - typedef enum { CTL_SCAN_FLAT=0, CTL_SCAN_RECURSIVE=1, @@ -71,15 +70,23 @@ typedef struct DispatchActionS{ const char* call; json_object *argsJ; int timeout; - json_object* (*actionCB)(struct DispatchActionS *action,json_object *response, void *context); + int (*actionCB)(afb_req request, struct DispatchActionS *action, void *context); } DispatchActionT; PUBLIC int DispatchInit(void); -PUBLIC void ctlapi_dispatch (DispatchCtlEnumT control, afb_req request); +PUBLIC void ctlapi_dispatch (char* control, afb_req request); // ctl-lua.c + +typedef enum { + LUA_DOCALL, + LUA_DOSTRING, + LUA_DOSCRIPT, +} LuaDoActionT; + PUBLIC int LuaLibInit (); PUBLIC json_object* ScanForConfig (char* searchPath, CtlScanDirModeT mode, char *pre, char *ext); +PUBLIC int LuaCallFunc (afb_req request, DispatchActionT *action); PUBLIC void ctlapi_lua_docall (afb_req request); PUBLIC void ctlapi_lua_dostring (afb_req request); PUBLIC void ctlapi_lua_doscript (afb_req request); -- cgit 1.2.3-korg