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-05-09 13:01:53 +0200
commit73f8d93f0db5a960bf22e9d080283e967f6bbfb6 (patch)
tree1f59cba63700a71857044c69d3c34a3c881bf54a /filescan-utils.c
parentaca86d46417a1afb198c927aea79e50a96925580 (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