diff options
author | Romain Forlot <romain.forlot@iot.bzh> | 2018-07-12 18:18:43 +0200 |
---|---|---|
committer | Romain Forlot <romain.forlot@iot.bzh> | 2018-07-17 00:51:53 +0200 |
commit | 4f99d163cb8a993f176f305566dbd8a93c79144c (patch) | |
tree | 829a0012c7e8bc030aaafa2cbd38a4bac2483579 /filescan-utils.h | |
parent | f46a0dca64c56d78d08b5c4f84d011f8beaa55d3 (diff) |
Retrieve directory list from environment variables
This adds a function able to retrieve from a prefix and suffix
an environment variable. This is meant to search config or plugin
files from potentially several sources, environment and source code.
This tries to get 2 environments variables:
- prefix+binderName+suffix (eg: AFT_LOWCAN_CONFIG_PATH)
- prefix+suffix (eg: AFT_CONFIG_PATH)
Then it returns the one found or both if they exist with the
most accurate one (with the binder name) first followed by the
other.
Change-Id: Ic448ff017e6158bec05895d63688b8968b5c6434
Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
Diffstat (limited to 'filescan-utils.h')
-rw-r--r-- | filescan-utils.h | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/filescan-utils.h b/filescan-utils.h index 317ee7e..bf8fb53 100644 --- a/filescan-utils.h +++ b/filescan-utils.h @@ -55,14 +55,14 @@ typedef enum { * * @return const char* */ -const char *GetMiddleName(const char *name); +extern const char *GetMiddleName(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(); +extern const char *GetBinderName(); /** * @brief Scan a directory searching all files matching pattern: @@ -77,7 +77,7 @@ const char *GetBinderName(); * 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); +extern json_object* ScanForConfig (const char* searchPath, CtlScanDirModeT mode, const char *prefix, const char *extension); /** * @brief Get the Binding root directory file descriptor object @@ -86,7 +86,21 @@ json_object* ScanForConfig (const char* searchPath, CtlScanDirModeT mode, const * * @return char* string representing the path to binding root directory. */ -char *GetBindingDirPath(struct afb_dynapi *dynapi); +extern char *GetBindingDirPath(struct afb_dynapi *dynapi); + +/** + * @brief Get the environment directory colon separated path list. This take the + * prefix add the binder's name then the suffix as environment variable name and + * also search for another variable without the binder's name (so only + * prefix+suffix). + * + * @param prefix Environment variable prefix + * @param suffix Environment variable suffix + * + * @return const char* a string representing a colon separated path list or NULL + * is case of error or none environment variables found. + */ +extern const char *getEnvDirList(const char *prefix, const char *suffix); #ifdef __cplusplus } |