summaryrefslogtreecommitdiffstats
path: root/ctl-lib/ctl-config.c
diff options
context:
space:
mode:
authorRomain Forlot <romain.forlot@iot.bzh>2018-07-12 18:18:01 +0200
committerRomain Forlot <romain.forlot@iot.bzh>2018-07-17 12:30:55 +0200
commit88892db78f2f5b047923af5b36169052c96bc3c0 (patch)
treed0e6a7f5cfcc9824c0990b5dc6457892734ed62a /ctl-lib/ctl-config.c
parent440be0984f16562fdf321c770d65787ecea0e36d (diff)
Use prefix variable to find controller's plugins
Prefix is the most reliable variable to find files or variables for a controller, so this lets you access it wherever it is needed without using global hardcoded variables. This helps to search for controller's plugins in several locations depending on environment variables and hardcoded variables (CONTROL_PLUGIN_PATH, CONTROL_CONFIG_PATH). This implies also a change a LUA interpreter loading step to correctly set the package.path variables with the environment variables, too. Correct the missing 'extern' in function declarations. Depends-On: Ic448ff017e6158bec05895d63688b8968b5c6434 Change-Id: I0ad19242612559d1f4b66b6f9af9e7032d4675a8 Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
Diffstat (limited to 'ctl-lib/ctl-config.c')
-rw-r--r--ctl-lib/ctl-config.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/ctl-lib/ctl-config.c b/ctl-lib/ctl-config.c
index 3153f13..a98cb34 100644
--- a/ctl-lib/ctl-config.c
+++ b/ctl-lib/ctl-config.c
@@ -161,7 +161,7 @@ int CtlConfigExec(AFB_ApiT apiHandle, CtlConfigT *ctlConfig) {
return errcount;
}
-CtlConfigT *CtlLoadMetaData(AFB_ApiT apiHandle, const char* filepath) {
+CtlConfigT *CtlLoadMetaDataUsingPrefix(AFB_ApiT apiHandle,const char* filepath, const char *prefix) {
json_object *ctlConfigJ;
CtlConfigT *ctlHandle=NULL;
int err;
@@ -195,9 +195,14 @@ CtlConfigT *CtlLoadMetaData(AFB_ApiT apiHandle, const char* filepath) {
}
ctlHandle->configJ = ctlConfigJ;
+ ctlHandle->prefix = prefix;
return ctlHandle;
}
+CtlConfigT *CtlLoadMetaData(AFB_ApiT apiHandle, const char* filepath) {
+ return CtlLoadMetaDataUsingPrefix(apiHandle, filepath, NULL);
+}
+
void wrap_json_array_add(void* array, json_object *val) {
json_object_array_add(array, (json_object*)val);
}
@@ -302,7 +307,7 @@ int CtlLoadSections(AFB_ApiT apiHandle, CtlConfigT *ctlHandle, CtlSectionT *sect
int err;
#ifdef CONTROL_SUPPORT_LUA
- err= LuaConfigLoad(apiHandle);
+ err= LuaConfigLoad(apiHandle, ctlHandle->prefix);
if (err)
return 1;
#endif
@@ -313,6 +318,7 @@ int CtlLoadSections(AFB_ApiT apiHandle, CtlConfigT *ctlHandle, CtlSectionT *sect
json_object * sectionJ;
int done = json_object_object_get_ex(ctlHandle->configJ, sections[idx].key, &sectionJ);
if (done) {
+ sections[idx].prefix = ctlHandle->prefix;
json_object* updatedSectionJ = LoadAdditionalsFiles(apiHandle, ctlHandle, sections[idx].key, sectionJ);
err += sections[idx].loadCB(apiHandle, &sections[idx], updatedSectionJ);
}