1 /* inih -- simple .INI file parser
3 inih is released under the New BSD license (see LICENSE.txt). Go to the project
4 home page for more info:
6 http://code.google.com/p/inih/
13 /* Make this header file easier to include in C++ code */
20 /* Parse given INI-style file. May have [section]s, name=value pairs
21 (whitespace stripped), and comments starting with ';' (semicolon). Section
22 is "" if name=value pair parsed before any section heading. name:value
23 pairs are also supported as a concession to Python's ConfigParser.
25 For each name=value pair parsed, call handler function with given user
26 pointer as well as section, name, and value (data only valid for duration
27 of handler call). Handler should return nonzero on success, zero on error.
29 Returns 0 on success, line number of first error on parse error (doesn't
30 stop on first error), -1 on file open error, or -2 on memory allocation
31 error (only when INI_USE_STACK is zero).
33 int ini_parse(const char* filename
,
34 int (*handler
)(void* user
, const char* section
,
35 const char* name
, const char* value
),
38 /* Same as ini_parse(), but takes a FILE* instead of filename. This doesn't
39 close the file when it's finished -- the caller must do that. */
40 int ini_parse_file(FILE* file
,
41 int (*handler
)(void* user
, const char* section
,
42 const char* name
, const char* value
),
45 /* Nonzero to allow multi-line value parsing, in the style of Python's
46 ConfigParser. If allowed, ini_parse() will call the handler with the same
47 name for each subsequent line parsed. */
48 #ifndef INI_ALLOW_MULTILINE
49 #define INI_ALLOW_MULTILINE 1
52 /* Nonzero to allow a UTF-8 BOM sequence (0xEF 0xBB 0xBF) at the start of
53 the file. See http://code.google.com/p/inih/issues/detail?id=21 */
55 #define INI_ALLOW_BOM 1
58 /* Nonzero to use stack, zero to use heap (malloc/free). */
60 #define INI_USE_STACK 1
63 /* Stop parsing on first error (default is to keep parsing). */
64 #ifndef INI_STOP_ON_FIRST_ERROR
65 #define INI_STOP_ON_FIRST_ERROR 0
68 /* Maximum line length for any line in INI file. */
70 #define INI_MAX_LINE 200
77 #endif /* __INI_H__ */