summaryrefslogtreecommitdiffstats
path: root/interfaces/interfaces.pri
blob: 07b9e6a87fe70ef92aa5ab2588dc960778d49fbc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# Copyright (C) 2016 The Qt Company Ltd.
# Copyright (C) 2016, 2017 Mentor Graphics Development (Deutschland) GmbH
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

INCLUDEPATH += $$PWD $$OUT_PWD/../interfaces/

LIBS += -L$$OUT_PWD/../interfaces/ -linterfaces
pan class="cp">#ifndef _CTL_PLUGIN_INCLUDE_ #define _CTL_PLUGIN_INCLUDE_ #ifdef __cplusplus extern "C" { #endif #ifndef _GNU_SOURCE #define _GNU_SOURCE #endif #include <stdio.h> #include <json-c/json.h> #include <afb/afb-binding.h> #ifndef CTL_PLUGIN_MAGIC #define CTL_PLUGIN_MAGIC 852369147 #endif #ifndef UNUSED_ARG #define UNUSED_ARG(x) UNUSED_ ## x __attribute__((__unused__)) #define UNUSED_FUNCTION(x) __attribute__((__unused__)) UNUSED_ ## x #endif #ifdef CONTROL_SUPPORT_LUA typedef struct luaL_Reg luaL_Reg; typedef struct CtlLua2cFuncT { luaL_Reg *l2cFunc; const char *prefix; int l2cCount; } CtlLua2cFuncT; #endif typedef struct { const char *uid; const long magic; } CtlPluginMagicT; typedef struct { const char *uid; const char *info; afb_api_t api; void *dlHandle; void *context; json_object *paramsJ; #ifdef CONTROL_SUPPORT_LUA CtlLua2cFuncT *ctlL2cFunc; #endif } CtlPluginT; typedef enum { CTL_TYPE_NONE=0, CTL_TYPE_API, CTL_TYPE_CB, CTL_TYPE_LUA, } CtlActionTypeT; typedef enum { CTL_STATUS_DONE=0, CTL_STATUS_ERR=-1, CTL_STATUS_EVT=1, CTL_STATUS_FREE=2, } CtlActionStatusT; typedef struct { const char *uid; afb_api_t api; afb_req_t request; void *context; CtlPluginT *plugin; CtlActionStatusT status; } CtlSourceT; typedef struct { const char *uid; const char *info; const char *privileges; afb_api_t api; json_object *argsJ; CtlActionTypeT type; union { struct { const char* api; const char* verb; } subcall; struct { const char* plugin; const char* funcname; } lua; struct { const char* funcname; int (*callback)(CtlSourceT *source, json_object *argsJ, json_object *queryJ); CtlPluginT *plugin; } cb; } exec; } CtlActionT; typedef int(*DispatchPluginInstallCbT)(CtlPluginT *plugin, void* handle); #define MACRO_STR_VALUE(arg) #arg #define CTLP_CAPI_REGISTER(pluglabel) CtlPluginMagicT CtlPluginMagic={.uid=pluglabel,.magic=CTL_PLUGIN_MAGIC}; struct afb_binding_data_v2; #define CTLP_ONLOAD(plugin, handle) int CtlPluginOnload(CtlPluginT *plugin, void* handle) #define CTLP_INIT(plugin, handle) int CtlPluginInit(CtlPluginT *plugin, void* handle) #define CTLP_CAPI(funcname, source, argsJ, queryJ) int funcname(CtlSourceT *source, json_object* argsJ, json_object* queryJ) // LUA2c Wrapper macro. Allows to call C code from Lua script typedef int (*Lua2cFunctionT)(CtlSourceT *source, json_object *argsJ, json_object **responseJ); typedef int (*Lua2cWrapperT) (void*luaHandle, const char *funcname, Lua2cFunctionT callback); #define CTLP_LUA_REGISTER(pluglabel) Lua2cWrapperT Lua2cWrap; CTLP_CAPI_REGISTER(pluglabel); #define CTLP_LUA2C(funcname, source, argsJ, responseJ) int funcname (CtlSourceT* source, json_object* argsJ, json_object** responseJ);\ int lua2c_ ## funcname (void* luaState){return((*Lua2cWrap)(luaState, MACRO_STR_VALUE(funcname), funcname));};\ int funcname (CtlSourceT* source, json_object* argsJ, json_object** responseJ) extern char *GetBindingParentDirPath(afb_api_t apiHandle); extern char *GetDefaultPluginSearchPath(afb_api_t apiHandle); #ifdef __cplusplus } #endif #endif /* _CTL_PLUGIN_INCLUDE_ */