diff --git a/qdf/inc/qdf_parse.h b/qdf/inc/qdf_parse.h index 44a9350509..781e6542b0 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 27a3f1b448..ee7c2c136d 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; }