diff options
-rw-r--r-- | curl-wrap.c | 3 | ||||
-rw-r--r-- | curl-wrap.h | 2 | ||||
-rw-r--r-- | filescan-utils.c | 16 | ||||
-rw-r--r-- | filescan-utils.h | 46 |
4 files changed, 51 insertions, 16 deletions
diff --git a/curl-wrap.c b/curl-wrap.c index 851eeb7..4e0c831 100644 --- a/curl-wrap.c +++ b/curl-wrap.c @@ -36,7 +36,7 @@ struct buffer { static const char* curl_concatenate_args(const char * const *args, const char *sep, size_t *length) { int i; - size_t lq, l; + size_t lq; const char *null; char *result, *front; @@ -62,7 +62,6 @@ static const char* curl_concatenate_args(const char * const *args, const char *s /* make the resulting args string contenated */ i = 0; front = result; - l = 0; while (args[i]) { if (i) { front = stpcpy(front, sep); diff --git a/curl-wrap.h b/curl-wrap.h index 3b42ef4..ab91bca 100644 --- a/curl-wrap.h +++ b/curl-wrap.h @@ -49,5 +49,3 @@ CURL *curl_wrap_prepare_post_unescaped(const char *base, const char *path, const CURL *curl_wrap_prepare_post_escaped(const char *base, const char *path, const char * const *args); -/* vim: set colorcolumn=80: */ - 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 diff --git a/filescan-utils.h b/filescan-utils.h index fb942e0..fc3a6a7 100644 --- a/filescan-utils.h +++ b/filescan-utils.h @@ -43,15 +43,53 @@ #define CONTROL_MAXPATH_LEN 255 #endif +/** + * @brief enum describing which mode to use in ScanForConfig function + * + */ typedef enum { - CTL_SCAN_FLAT=0, - CTL_SCAN_RECURSIVE=1, + CTL_SCAN_FLAT=0, /**< Simple flat search */ + CTL_SCAN_RECURSIVE=1, /**< Recursive search */ } CtlScanDirModeT; -const char *GetMidleName(const char*name); +/** + * @brief Get rid of the binder name prefix 'afbd-' + * + * @param name will be typically the full binder name + * + * @return const char* + */ +const char *GetMidleName(const char *name); + +/** + * @brief Get the Binder Name without the prefix set by the AGL appfw 'afbd-' + * + * @return const char* the Binder name without the prefix. + */ const char *GetBinderName(); -json_object* ScanForConfig (const char* searchPath, CtlScanDirModeT mode, const char *pre, const char *ext); +/** + * @brief Scan a directory searching all files matching pattern: + * 'prefix*extention'. + * + * @param searchPath directory where to begin the searching + * @param mode either or not the search will be recursive. + * @param prefix file prefix that will be looking for + * @param extention file extention that will be looking for + * + * @return json_object* a json_object array of object with 2 parts a 'fullpath' + * describing the fullpath to reach the file and 'filename' containing the + * matched files. + */ +json_object* ScanForConfig (const char* searchPath, CtlScanDirModeT mode, const char *prefix, const char *extension); + +/** + * @brief Get the Binding root directory file descriptor object + * + * @param dynapi : Could be NULL if you don't use dynamic api + * + * @return char* string representing the path to binding root directory. + */ char *GetBindingDirPath(struct afb_dynapi *dynapi); #ifdef __cplusplus |