diff options
author | Dustin Brown <dustinb@codeaurora.org> | 2018-02-22 15:14:07 -0800 |
---|---|---|
committer | snandini <snandini@codeaurora.org> | 2018-02-26 15:57:53 -0800 |
commit | b067d27d61eb79a654a6545e516b3dddf402ebe0 (patch) | |
tree | 8e5e027c4aea819b187c58eecfc3a838231c6b1b /qdf | |
parent | c729c57e65c674923061b548b1177c1c622d78c7 (diff) | |
download | qca-wfi-host-cmn-b067d27d61eb79a654a6545e516b3dddf402ebe0.tar.gz |
qcacmn: Add context parameter to qdf_ini_parse()
In order to avoid global state, add a context parameter to
qdf_ini_parse. This parameter will get passed back to consumers via
the existing callbacks.
Change-Id: Icd74a58815701b4603924838bb84c7956058da6b
CRs-Fixed: 2194517
Diffstat (limited to 'qdf')
-rw-r--r-- | qdf/inc/qdf_parse.h | 17 | ||||
-rw-r--r-- | qdf/src/qdf_parse.c | 10 |
2 files changed, 15 insertions, 12 deletions
diff --git a/qdf/inc/qdf_parse.h b/qdf/inc/qdf_parse.h index 44a935050..781e6542b 100644 --- a/qdf/inc/qdf_parse.h +++ b/qdf/inc/qdf_parse.h @@ -17,7 +17,7 @@ */ /** - * DOC: Thin filesystem API abstractions + * DOC: Text parsing related abstractions, not related to a specific type */ #ifndef __QDF_PARSE_H @@ -25,15 +25,21 @@ #include "qdf_status.h" +typedef QDF_STATUS (*qdf_ini_section_cb)(void *context, const char *name); +typedef QDF_STATUS (*qdf_ini_item_cb)(void *context, + const char *key, + const char *value); + /** - * cfg_ini_parse() - parse an ini file + * qdf_ini_parse() - parse an ini file * @ini_path: The full file path of the ini file to parse + * @context: The caller supplied context to pass into callbacks * @item_cb: Ini item (key/value pair) handler callback function * Return QDF_STATUS_SUCCESS to continue parsing, else to abort * @section_cb: Ini section header handler callback function * Return QDF_STATUS_SUCCESS to continue parsing, else to abort * - * The *.ini file format is a simple format consiting of a list of key/value + * The *.ini file format is a simple format consisting of a list of key/value * pairs (items), separated by an '=' character. Comments are initiated with * a '#' character. Sections are also supported, using '[' and ']' around the * section name. e.g. @@ -50,9 +56,8 @@ * Return: QDF_STATUS */ QDF_STATUS -qdf_ini_parse(const char *ini_path, - QDF_STATUS (*item_cb)(const char *key, const char *value), - QDF_STATUS (*section_cb)(const char *name)); +qdf_ini_parse(const char *ini_path, void *context, + qdf_ini_item_cb item_cb, qdf_ini_section_cb section_cb); #endif /* __QDF_PARSE_H */ diff --git a/qdf/src/qdf_parse.c b/qdf/src/qdf_parse.c index 27a3f1b44..ee7c2c136 100644 --- a/qdf/src/qdf_parse.c +++ b/qdf/src/qdf_parse.c @@ -24,10 +24,8 @@ #include "qdf_trace.h" #include "qdf_types.h" -QDF_STATUS -qdf_ini_parse(const char *ini_path, - QDF_STATUS (*item_cb)(const char *key, const char *value), - QDF_STATUS (*section_cb)(const char *name)) +QDF_STATUS qdf_ini_parse(const char *ini_path, void *context, + qdf_ini_item_cb item_cb, qdf_ini_section_cb section_cb) { QDF_STATUS status; char *fbuf; @@ -98,7 +96,7 @@ qdf_ini_parse(const char *ini_path, * 3) a line containing whitespace */ if (value) { - status = item_cb(key, value); + status = item_cb(context, key, value); if (QDF_IS_STATUS_ERROR(status)) goto free_fbuf; } else if (key[0] == '[') { @@ -108,7 +106,7 @@ qdf_ini_parse(const char *ini_path, qdf_err("Invalid *.ini syntax '%s'", key); } else { key[len - 1] = '\0'; - status = section_cb(key + 1); + status = section_cb(context, key + 1); if (QDF_IS_STATUS_ERROR(status)) goto free_fbuf; } |