diff options
author | Romain Forlot <romain.forlot@iot.bzh> | 2018-05-17 17:08:18 +0200 |
---|---|---|
committer | Romain Forlot <romain.forlot@iot.bzh> | 2018-12-13 15:02:54 +0100 |
commit | 934910288403aeb42ea9a54d112268dcfe906e3b (patch) | |
tree | 7e19d325576855a6d76127a19df2b1fdfb186b3a /ctl-lib/ctl-config.c | |
parent | cf3c9191510735699da14bb5a680f6af9b8a8dcf (diff) |
Handle no prefix given
If no prefix given, then only use the binder name
to search config file.
Change-Id: I504ea27dccb8892e12e09d3e9e42bc281bcf87b0
Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
Diffstat (limited to 'ctl-lib/ctl-config.c')
-rw-r--r-- | ctl-lib/ctl-config.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/ctl-lib/ctl-config.c b/ctl-lib/ctl-config.c index 581440c..4e9d01d 100644 --- a/ctl-lib/ctl-config.c +++ b/ctl-lib/ctl-config.c @@ -48,9 +48,14 @@ json_object* CtlConfigScan(const char *dirList, const char *prefix) { controlFile[CONTROL_MAXPATH_LEN - 1] = '\0'; - strncpy(controlFile, prefix, CONTROL_MAXPATH_LEN - 1); - strncat(controlFile, binderName, CONTROL_MAXPATH_LEN - strlen(controlFile) - 1); - + if(prefix[0] != '\0') { + strncpy(controlFile, prefix, CONTROL_MAXPATH_LEN - 1); + strncat(controlFile, "-", CONTROL_MAXPATH_LEN - strlen(controlFile) - 1); + strncat(controlFile, binderName, CONTROL_MAXPATH_LEN - strlen(controlFile) - 1); + } + else { + strncpy(controlFile, binderName, CONTROL_MAXPATH_LEN - 1); + } // search for default dispatch config file json_object* responseJ = ScanForConfig(dirList, CTL_SCAN_RECURSIVE, controlFile, ".json"); |