summaryrefslogtreecommitdiffstats
path: root/filescan-utils.c
diff options
context:
space:
mode:
authorRomain Forlot <romain.forlot@iot.bzh>2018-05-09 12:57:09 +0200
committerRomain Forlot <romain.forlot@iot.bzh>2018-12-13 14:12:02 +0100
commit3ac370d79120d166859c04bb2d5ab043bdba4c0a (patch)
tree1f59cba63700a71857044c69d3c34a3c881bf54a /filescan-utils.c
parent2fdc44f69750b44ab7b1a5fb5f3a447c3607038b (diff)
Documentate, formating, linting.
Change-Id: Id77b9de1b847ca26133abd87511de4e78c7d01f7 Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
Diffstat (limited to 'filescan-utils.c')
-rw-r--r--filescan-utils.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/filescan-utils.c b/filescan-utils.c
index 60905a6..fbcdc64 100644
--- a/filescan-utils.c
+++ b/filescan-utils.c
@@ -27,11 +27,11 @@
#include "filescan-utils.h"
// List Avaliable Configuration Files
-json_object* ScanForConfig (const char* searchPath, CtlScanDirModeT mode, const char *pre, const char *ext) {
+json_object* ScanForConfig (const char* searchPath, CtlScanDirModeT mode, const char *prefix, const char *extention) {
json_object *responseJ;
char *dirPath;
char* dirList= strdup(searchPath);
- size_t extLen=0;
+ size_t extentionLen=0;
int count=0;
int ScanDir (char *searchPath) {
@@ -40,7 +40,7 @@ json_object* ScanForConfig (const char* searchPath, CtlScanDirModeT mode, const
struct dirent *dirEnt;
dirHandle = opendir (searchPath);
if (!dirHandle) {
- AFB_DEBUG ("CONFIG-SCANNING dir=%s not readable", searchPath);
+ AFB_DEBUG("CONFIG-SCANNING dir=%s not readable", searchPath);
return 0;
}
@@ -63,10 +63,10 @@ json_object* ScanForConfig (const char* searchPath, CtlScanDirModeT mode, const
if (dirEnt->d_type == DT_REG || dirEnt->d_type == DT_UNKNOWN) {
// check prefix and extention
- ssize_t extIdx=strlen(dirEnt->d_name)-extLen;
- if (extIdx <= 0) continue;
- if (pre && !strcasestr (dirEnt->d_name, pre)) continue;
- if (ext && strcasecmp (ext, &dirEnt->d_name[extIdx])) continue;
+ ssize_t extentionIdx=strlen(dirEnt->d_name)-extentionLen;
+ if (extentionIdx <= 0) continue;
+ if (prefix && !strcasestr (dirEnt->d_name, prefix)) continue;
+ if (extention && strcasecmp (extention, &dirEnt->d_name[extentionIdx])) continue;
struct json_object *pathJ = json_object_new_object();
json_object_object_add(pathJ, "fullpath", json_object_new_string(searchPath));
@@ -79,7 +79,7 @@ json_object* ScanForConfig (const char* searchPath, CtlScanDirModeT mode, const
return found;
}
- if (ext) extLen=strlen(ext);
+ if (extention) extentionLen=strlen(extention);
responseJ = json_object_new_array();
// loop recursively on dir