xref: /wlan-dirver/qca-wifi-host-cmn/qdf/inc/qdf_parse.h (revision 3149adf58a329e17232a4c0e58d460d025edd55a)
1 /*
2  * Copyright (c) 2018 The Linux Foundation. All rights reserved.
3  *
4  * Permission to use, copy, modify, and/or distribute this software for
5  * any purpose with or without fee is hereby granted, provided that the
6  * above copyright notice and this permission notice appear in all
7  * copies.
8  *
9  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
10  * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
11  * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
12  * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
13  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
14  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
15  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
16  * PERFORMANCE OF THIS SOFTWARE.
17  */
18 
19 /**
20  * DOC: Text parsing related abstractions, not related to a specific type
21  */
22 
23 #ifndef __QDF_PARSE_H
24 #define __QDF_PARSE_H
25 
26 #include "qdf_status.h"
27 
28 typedef QDF_STATUS (*qdf_ini_section_cb)(void *context, const char *name);
29 typedef QDF_STATUS (*qdf_ini_item_cb)(void *context,
30 				      const char *key,
31 				      const char *value);
32 
33 /**
34  * qdf_ini_parse() - parse an ini file
35  * @ini_path: The full file path of the ini file to parse
36  * @context: The caller supplied context to pass into callbacks
37  * @item_cb: Ini item (key/value pair) handler callback function
38  *	Return QDF_STATUS_SUCCESS to continue parsing, else to abort
39  * @section_cb: Ini section header handler callback function
40  *	Return QDF_STATUS_SUCCESS to continue parsing, else to abort
41  *
42  * The *.ini file format is a simple format consisting of a list of key/value
43  * pairs (items), separated by an '=' character. Comments are initiated with
44  * a '#' character. Sections are also supported, using '[' and ']' around the
45  * section name. e.g.
46  *
47  *	# comments are started with a '#' character
48  *	# items are key/value string pairs, separated by the '=' character
49  *	someKey1=someValue1
50  *	someKey2=someValue2 # this is also a comment
51  *
52  *	# section headers are enclosed in square brackets
53  *	[some section header] # new section begins
54  *	someKey3=someValue3
55  *
56  * Return: QDF_STATUS
57  */
58 QDF_STATUS
59 qdf_ini_parse(const char *ini_path, void *context,
60 	      qdf_ini_item_cb item_cb, qdf_ini_section_cb section_cb);
61 
62 #endif /* __QDF_PARSE_H */
63 
64