summaryrefslogtreecommitdiffstats
path: root/ctl-lib/ctl-plugin.c
diff options
context:
space:
mode:
Diffstat (limited to 'ctl-lib/ctl-plugin.c')
-rw-r--r--ctl-lib/ctl-plugin.c46
1 files changed, 23 insertions, 23 deletions
diff --git a/ctl-lib/ctl-plugin.c b/ctl-lib/ctl-plugin.c
index 1732197..e60bd5e 100644
--- a/ctl-lib/ctl-plugin.c
+++ b/ctl-lib/ctl-plugin.c
@@ -85,6 +85,27 @@ static int DispatchOneL2c(void* luaState, char *funcname, Lua2cFunctionT callbac
#endif
}
+int Lua2cAddOne(afb_api_t apiHandle, CtlPluginT *ctlPlugin, void *dlHandle, luaL_Reg *l2cFunc, const char* l2cName, int index) {
+ if(ctlPlugin->ctlL2cFunc->l2cCount)
+ {index += ctlPlugin->ctlL2cFunc->l2cCount+1;}
+ char *funcName;
+ size_t p_length = 6 + strlen(l2cName);
+ funcName = malloc(p_length + 1);
+
+ strncpy(funcName, "lua2c_", p_length + 1);
+ strncat(funcName, l2cName, p_length - strlen (funcName) + 1);
+
+ Lua2cFunctionT l2cFunction = (Lua2cFunctionT) dlsym(dlHandle, funcName);
+ if (!l2cFunction) {
+ AFB_API_ERROR(apiHandle, "CTL-PLUGIN-LOADONE symbol'%s' missing err=%s", funcName, dlerror());
+ return 1;
+ }
+ l2cFunc[index].func = (void*) l2cFunction;
+ l2cFunc[index].name = strdup(l2cName);
+
+ return 0;
+}
+
static int PluginLoadCOne(afb_api_t apiHandle, const char *pluginpath, json_object *lua2csJ, const char *lua2c_prefix, void * handle, CtlPluginT *ctlPlugin)
{
void *dlHandle = dlopen(pluginpath, RTLD_NOW);
@@ -121,27 +142,6 @@ static int PluginLoadCOne(afb_api_t apiHandle, const char *pluginpath, json_obje
if (lua2csJ && lua2cInPlug) {
*lua2cInPlug = (Lua2cWrapperT)DispatchOneL2c;
- int Lua2cAddOne(luaL_Reg *l2cFunc, const char* l2cName, int index) {
- if(ctlPlugin->ctlL2cFunc->l2cCount)
- {index += ctlPlugin->ctlL2cFunc->l2cCount+1;}
- char *funcName;
- size_t p_length = 6 + strlen(l2cName);
- funcName = malloc(p_length + 1);
-
- strncpy(funcName, "lua2c_", p_length + 1);
- strncat(funcName, l2cName, p_length - strlen (funcName) + 1);
-
- Lua2cFunctionT l2cFunction = (Lua2cFunctionT) dlsym(dlHandle, funcName);
- if (!l2cFunction) {
- AFB_API_ERROR(apiHandle, "CTL-PLUGIN-LOADONE symbol'%s' missing err=%s", funcName, dlerror());
- return 1;
- }
- l2cFunc[index].func = (void*) l2cFunction;
- l2cFunc[index].name = strdup(l2cName);
-
- return 0;
- }
-
int count = 0, errCount = 0;
luaL_Reg *l2cFunc = NULL;
if(!ctlPlugin->ctlL2cFunc) {
@@ -159,13 +159,13 @@ static int PluginLoadCOne(afb_api_t apiHandle, const char *pluginpath, json_obje
for (count = 0; count < length; count++) {
int err;
const char *l2cName = json_object_get_string(json_object_array_get_idx(lua2csJ, count));
- err = Lua2cAddOne(l2cFunc, l2cName, count);
+ err = Lua2cAddOne(apiHandle, ctlPlugin, dlHandle, l2cFunc, l2cName, count);
if (err) errCount++;
}
} else {
l2cFunc = calloc(2 + ctlPlugin->ctlL2cFunc->l2cCount, sizeof (luaL_Reg));
const char *l2cName = json_object_get_string(lua2csJ);
- errCount = Lua2cAddOne(l2cFunc, l2cName, count);
+ errCount = Lua2cAddOne(apiHandle, ctlPlugin, dlHandle, l2cFunc, l2cName, count);
count++;
}
if (errCount) {
9' href='#n229'>229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338