aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRomain Forlot <romain.forlot@iot.bzh>2018-07-11 15:23:19 +0200
committerRomain Forlot <romain.forlot@iot.bzh>2018-07-19 13:34:08 +0000
commitdff3d17ccbdff57699b6902ca92595379a2cfa11 (patch)
tree4fc72a04e2bece593cc089097cdbf82750de91ee
parent4d1dc3cabe19056b8db473aa8941a7f20ff874ce (diff)
Search the conf file using env and static variables
This helps finding configuration in several locations by concatenating environment variables and hardcoded variables. Then it is possible for the apps to retrieve its files or values in any environment (native, board, sdk) more easily. Depends-On: I0ad19242612559d1f4b66b6f9af9e7032d4675a8 Depends-On: Ic448ff017e6158bec05895d63688b8968b5c6434 Change-Id: I26a725c368e8354cfc2531d58de6dc362f7d0618 Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
m---------afb-helpers0
m---------app-controller-submodule0
m---------conf.d/app-templates0
-rw-r--r--src/aft.c23
4 files changed, 17 insertions, 6 deletions
diff --git a/afb-helpers b/afb-helpers
-Subproject 52f04783535948f2782780992710276f3419e56
+Subproject 4f99d163cb8a993f176f305566dbd8a93c79144
diff --git a/app-controller-submodule b/app-controller-submodule
-Subproject 440be0984f16562fdf321c770d65787ecea0e36
+Subproject 88892db78f2f5b047923af5b36169052c96bc3c
diff --git a/conf.d/app-templates b/conf.d/app-templates
-Subproject 332f377e84a673cdcfe52ce71c932f39c4b4802
+Subproject 6fb38467ca1609a1aa1be865b38648f37861af7
diff --git a/src/aft.c b/src/aft.c
index bbcaf97..36a8b17 100644
--- a/src/aft.c
+++ b/src/aft.c
@@ -23,6 +23,8 @@
#include "aft.h"
#include "mapis.h"
+
+#define CONTROL_PREFIX "aft"
// default api to print log when apihandle not avaliable
afb_dynapi *AFB_default;
@@ -109,25 +111,34 @@ static int CtrlLoadOneApi(void *cbdata, AFB_ApiT apiHandle) {
int afbBindingEntry(afb_dynapi *apiHandle) {
int status, err = 0;
- const char *dirList = NULL, *configPath = NULL;
+ size_t len = 0;
+ char *dirList;
+ const char *prefix = CONTROL_PREFIX, *envDirList = NULL, *configPath = NULL;
json_object *resourcesJ = NULL, *eventsJ = NULL;
CtlConfigT *ctrlConfig = NULL;
AFB_default = apiHandle;
- AFB_ApiNotice(apiHandle, "Controller in afbBindingVdyn");
+ AFB_ApiNotice(apiHandle, "Controller in afbBindingEntry");
+
+ envDirList = getEnvDirList(prefix, "CONFIG_PATH");
- dirList = getenv("CONTROL_CONFIG_PATH");
- if (!dirList)
+ if(envDirList) {
+ len = strlen(CONTROL_CONFIG_PATH) + strlen(envDirList);
+ dirList = malloc(len + 1);
+ snprintf(dirList, len + 1, "%s:%s", envDirList, CONTROL_CONFIG_PATH);
+ }
+ else {
dirList = CONTROL_CONFIG_PATH;
+ }
- configPath = CtlConfigSearch(apiHandle, dirList, "aft");
+ configPath = CtlConfigSearch(apiHandle, dirList, prefix);
if (!configPath) {
AFB_ApiError(apiHandle, "CtlPreInit: No %s* config found in %s ", GetBinderName(), dirList);
return ERROR;
}
// load config file and create API
- ctrlConfig = CtlLoadMetaData(apiHandle, configPath);
+ ctrlConfig = CtlLoadMetaDataUsingPrefix(apiHandle, configPath, prefix);
if (!ctrlConfig) {
AFB_ApiError(apiHandle,
"CtrlBindingDyn No valid control config file in:\n-- %s",