summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRomain Forlot <romain.forlot@iot.bzh>2017-08-22 19:03:05 +0200
committerRomain Forlot <romain.forlot@iot.bzh>2018-12-13 14:12:02 +0100
commitd02ab63e862b0db074227982d69924b44bc5254d (patch)
tree7a286ce56a88dd72b5ad6d3abda7219d3ec07914
parent047e06d361fbb7c5381ab8a97729da92232f5e6c (diff)
Format and missing header dependencies
Change-Id: If5890445bdb6a676ee6c435f50a27caa8ca5850d Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
-rw-r--r--filescan-utils.c40
-rw-r--r--filescan-utils.h12
2 files changed, 29 insertions, 23 deletions
diff --git a/filescan-utils.c b/filescan-utils.c
index 10c9207..46e461b 100644
--- a/filescan-utils.c
+++ b/filescan-utils.c
@@ -22,13 +22,15 @@
#include <sys/prctl.h>
#include <dirent.h>
+#include "filescan-utils.h"
+
// List Avaliable Configuration Files
PUBLIC json_object* ScanForConfig (const char* searchPath, CtlScanDirModeT mode, const char *pre, const char *ext) {
json_object *responseJ;
char *dirPath;
char* dirList= strdup(searchPath);
- size_t extLen=0;
-
+ size_t extLen=0;
+
void ScanDir (char *searchPath) {
DIR *dirHandle;
struct dirent *dirEnt;
@@ -36,31 +38,31 @@ PUBLIC json_object* ScanForConfig (const char* searchPath, CtlScanDirModeT mode,
if (!dirHandle) {
AFB_DEBUG ("CONFIG-SCANNING dir=%s not readable", searchPath);
return;
- }
-
+ }
+
//AFB_NOTICE ("CONFIG-SCANNING:ctl_listconfig scanning: %s", searchPath);
while ((dirEnt = readdir(dirHandle)) != NULL) {
-
+
// recursively search embedded directories ignoring any directory starting by '.' or '_'
if (dirEnt->d_type == DT_DIR && mode == CTL_SCAN_RECURSIVE) {
char newpath[CONTROL_MAXPATH_LEN];
if (dirEnt->d_name[0]=='.' || dirEnt->d_name[0]=='_') continue;
-
- strncpy(newpath, searchPath, sizeof(newpath));
- strncat(newpath, "/", sizeof(newpath));
- strncat(newpath, dirEnt->d_name, sizeof(newpath));
+
+ strncpy(newpath, searchPath, sizeof(newpath));
+ strncat(newpath, "/", sizeof(newpath));
+ strncat(newpath, dirEnt->d_name, sizeof(newpath));
ScanDir(newpath);
continue;
}
-
+
// Unknown type is accepted to support dump filesystems
if (dirEnt->d_type == DT_REG || dirEnt->d_type == DT_UNKNOWN) {
// check prefix and extention
size_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;
+ if (extIdx <= 0) continue;
+ if (pre && !strcasestr (dirEnt->d_name, pre)) continue;
+ if (ext && strcasecmp (ext, &dirEnt->d_name[extIdx])) continue;
struct json_object *pathJ = json_object_new_object();
json_object_object_add(pathJ, "fullpath", json_object_new_string(searchPath));
@@ -73,13 +75,13 @@ PUBLIC json_object* ScanForConfig (const char* searchPath, CtlScanDirModeT mode,
if (ext) extLen=strlen(ext);
responseJ = json_object_new_array();
-
+
// loop recursively on dir
for (dirPath= strtok(dirList, ":"); dirPath && *dirPath; dirPath=strtok(NULL,":")) {
ScanDir (dirPath);
}
-
- free (dirList);
+
+ free (dirList);
return (responseJ);
}
@@ -106,15 +108,15 @@ PUBLIC const char *GetMidleName(const char*name) {
PUBLIC const char *GetBinderName() {
char psName[17];
static char *binderName=NULL;
-
+
if (binderName) return binderName;
-
+
binderName= getenv("AFB_BINDER_NAME");
if (!binderName) {
// retrieve binder name from process name afb-name-trailer
prctl(PR_GET_NAME, psName,NULL,NULL,NULL);
binderName=(char*)GetMidleName(psName);
}
-
+
return binderName;
}
diff --git a/filescan-utils.h b/filescan-utils.h
index cbe15de..a97d030 100644
--- a/filescan-utils.h
+++ b/filescan-utils.h
@@ -13,15 +13,19 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- *
- * reference:
+ *
+ * reference:
* amixer contents; amixer controls;
- * http://www.tldp.org/HOWTO/Alsa-sound-6.html
+ * http://www.tldp.org/HOWTO/Alsa-sound-6.html
*/
#ifndef FILESCAN_UTILS_H
#define FILESCAN_UTILS_H
+#define AFB_BINDING_VERSION 2
+#include <afb/afb-binding.h>
+#include <json-c/json.h>
+
#ifndef PUBLIC
#define PUBLIC
#endif
@@ -29,7 +33,7 @@
// ctl-misc.c
typedef enum {
- CTL_SCAN_FLAT=0,
+ CTL_SCAN_FLAT=0,
CTL_SCAN_RECURSIVE=1,
} CtlScanDirModeT;