summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRomain Forlot <romain.forlot@iot.bzh>2018-05-09 12:58:40 +0200
committerRomain Forlot <romain.forlot@iot.bzh>2018-05-14 15:09:28 +0200
commit41b43537bd98416d8e3f43ea82560240f94e74f0 (patch)
treef625bfdfdaaff2e6643d4fa4285bc707a6116110
parentb5ceb3cca02bd46d2a6296631fe607b3edd38e17 (diff)
Use new version of function GetBindingDirPath
That follow the last update in afb-helpers submodule used. Change-Id: Ia6149ae96c1591f3d0791f4263e8beafbe6e764d Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
-rw-r--r--ctl-lib/ctl-config.c9
-rw-r--r--ctl-lib/ctl-plugin.c22
2 files changed, 16 insertions, 15 deletions
diff --git a/ctl-lib/ctl-config.c b/ctl-lib/ctl-config.c
index 8dc06fa..2637188 100644
--- a/ctl-lib/ctl-config.c
+++ b/ctl-lib/ctl-config.c
@@ -165,6 +165,7 @@ json_object* LoadAdditionalsFiles(AFB_ApiT apiHandle, CtlConfigT *ctlHandle, con
json_object* CtlUpdateSectionConfig(AFB_ApiT apiHandle, CtlConfigT *ctlHandle, const char *key, json_object *sectionJ, json_object *filesJ) {
json_object *sectionArrayJ;
+ const char *bindingPath = GetBindingDirPath(apiHandle);
if(! json_object_is_type(sectionJ, json_type_array)) {
sectionArrayJ = json_object_new_array();
@@ -183,9 +184,9 @@ json_object* CtlUpdateSectionConfig(AFB_ApiT apiHandle, CtlConfigT *ctlHandle, c
json_object *oneFileJ = json_object_array_get_idx(filesJ, idx);
json_object *responseJ = ScanForConfig(CONTROL_CONFIG_PATH ,CTL_SCAN_RECURSIVE, json_object_get_string(oneFileJ), ".json");
responseJ = responseJ ? responseJ:
- ScanForConfig(GetBindingDirPath(), CTL_SCAN_RECURSIVE, json_object_get_string(oneFileJ), ".json");
+ ScanForConfig(bindingPath, CTL_SCAN_RECURSIVE, json_object_get_string(oneFileJ), ".json");
if(!responseJ) {
- AFB_ApiError(apiHandle, "No config files found in search path. No changes has been made\n -- %s\n -- %s", CONTROL_CONFIG_PATH, GetBindingDirPath());
+ AFB_ApiError(apiHandle, "No config files found in search path. No changes has been made\n -- %s\n -- %s", CONTROL_CONFIG_PATH, bindingPath);
return sectionArrayJ;
}
const char *oneFile = ConfigSearch(apiHandle, responseJ);
@@ -202,9 +203,9 @@ json_object* CtlUpdateSectionConfig(AFB_ApiT apiHandle, CtlConfigT *ctlHandle, c
} else {
json_object *responseJ = ScanForConfig(CONTROL_CONFIG_PATH ,CTL_SCAN_RECURSIVE, json_object_get_string(filesJ), ".json");
responseJ = responseJ ? responseJ:
- ScanForConfig(GetBindingDirPath(), CTL_SCAN_RECURSIVE, json_object_get_string(filesJ), ".json");
+ ScanForConfig(bindingPath, CTL_SCAN_RECURSIVE, json_object_get_string(filesJ), ".json");
if(!responseJ) {
- AFB_ApiError(apiHandle, "No config files found in search path. No changes has been made\n -- %s\n -- %s", CONTROL_CONFIG_PATH, GetBindingDirPath());
+ AFB_ApiError(apiHandle, "No config files found in search path. No changes has been made\n -- %s\n -- %s", CONTROL_CONFIG_PATH, bindingPath);
return sectionArrayJ;
}
const char *oneFile = ConfigSearch(apiHandle, responseJ);
diff --git a/ctl-lib/ctl-plugin.c b/ctl-lib/ctl-plugin.c
index 70d8817..562f58e 100644
--- a/ctl-lib/ctl-plugin.c
+++ b/ctl-lib/ctl-plugin.c
@@ -233,34 +233,34 @@ static int LoadFoundPlugins(AFB_ApiT apiHandle, json_object *scanResult, json_ob
return 0;
}
-static char *GetDefaultSearchPath()
+static char *GetDefaultSearchPath(AFB_ApiT apiHandle)
{
char *searchPath;
- const char *bPath;
+ const char *bindingPath;
const char *envPath;
- size_t bPath_len, envPath_len, CTL_PLGN_len;
+ size_t bindingPath_len, envPath_len, CTL_PLGN_len;
- bPath = GetBindingDirPath();
+ bindingPath = GetBindingDirPath(apiHandle);
envPath = getenv("CONTROL_PLUGIN_PATH");
- bPath_len = strlen(bPath);
+ bindingPath_len = strlen(bindingPath);
envPath_len = envPath ? strlen(envPath) : 0;
CTL_PLGN_len = envPath_len ? 0 : strlen(CONTROL_PLUGIN_PATH);
/* Allocating with the size of binding root dir path + environment if found
* + 2 for the NULL terminating character and the additionnal separator
- * between bPath and envPath concatenation.
+ * between bindingPath and envPath concatenation.
*/
if(envPath) {
- searchPath = calloc(1, sizeof(char) *((bPath_len + envPath_len) + 2));
+ searchPath = calloc(1, sizeof(char) *((bindingPath_len + envPath_len) + 2));
strncat(searchPath, envPath, envPath_len);
}
else {
- searchPath = calloc(1, sizeof(char) * ((bPath_len + CTL_PLGN_len) + 2));
+ searchPath = calloc(1, sizeof(char) * ((bindingPath_len + CTL_PLGN_len) + 2));
strncat(searchPath, CONTROL_PLUGIN_PATH, CTL_PLGN_len);
}
strncat(searchPath, ":", 1);
- strncat(searchPath, bPath, bPath_len);
+ strncat(searchPath, bindingPath, bindingPath_len);
return searchPath;
}
@@ -301,7 +301,7 @@ static int PluginLoad (AFB_ApiT apiHandle, CtlPluginT *ctlPlugin, json_object *p
// if search path not in Json config file, then try default
searchPath = (sPath) ?
strdup(sPath) :
- GetDefaultSearchPath();
+ GetDefaultSearchPath(apiHandle);
// default file equal uid
if (!fileJ) {
@@ -331,7 +331,7 @@ static int PluginLoad (AFB_ApiT apiHandle, CtlPluginT *ctlPlugin, json_object *p
json_object_put(pluginPathJ); // No more needs for that json_object.
return 1;
}
- LoadFoundPlugins(apiHandle, pluginPathJ, lua2c_prefix, lua2csJ, handle, ctlPlugin);
+ LoadFoundPlugins(apiHandle, pluginPathJ, lua2csJ, lua2c_prefix, handle, ctlPlugin);
}
}