No idea why I had to do this.
[hdmi-switcher.git] / lib / inih / ini.h
1 /* inih -- simple .INI file parser
2
3 inih is released under the New BSD license (see LICENSE.txt). Go to the project
4 home page for more info:
5
6 http://code.google.com/p/inih/
7
8 */
9
10 #ifndef __INI_H__
11 #define __INI_H__
12
13 /* Make this header file easier to include in C++ code */
14 #ifdef __cplusplus
15 extern "C" {
16 #endif
17
18 #include <stdio.h>
19
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.
24
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.
28
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).
32 */
33 int ini_parse(const char* filename,
34 int (*handler)(void* user, const char* section,
35 const char* name, const char* value),
36 void* user);
37
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),
43 void* user);
44
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
50 #endif
51
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 */
54 #ifndef INI_ALLOW_BOM
55 #define INI_ALLOW_BOM 1
56 #endif
57
58 /* Nonzero to use stack, zero to use heap (malloc/free). */
59 #ifndef INI_USE_STACK
60 #define INI_USE_STACK 1
61 #endif
62
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
66 #endif
67
68 /* Maximum line length for any line in INI file. */
69 #ifndef INI_MAX_LINE
70 #define INI_MAX_LINE 200
71 #endif
72
73 #ifdef __cplusplus
74 }
75 #endif
76
77 #endif /* __INI_H__ */