Clemens Valens
/
LED_panel
32x64 3-color message board http://elektorembedded.blogspot.com/
ini.h@0:7a63bd42cf24, 2010-05-05 (annotated)
- Committer:
- Clemo
- Date:
- Wed May 05 12:04:34 2010 +0000
- Revision:
- 0:7a63bd42cf24
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Clemo | 0:7a63bd42cf24 | 1 | /* inih -- simple .INI file parser |
Clemo | 0:7a63bd42cf24 | 2 | |
Clemo | 0:7a63bd42cf24 | 3 | inih is released under the New BSD license (see LICENSE.txt). Go to the project |
Clemo | 0:7a63bd42cf24 | 4 | home page for more info: |
Clemo | 0:7a63bd42cf24 | 5 | |
Clemo | 0:7a63bd42cf24 | 6 | http://code.google.com/p/inih/ |
Clemo | 0:7a63bd42cf24 | 7 | |
Clemo | 0:7a63bd42cf24 | 8 | */ |
Clemo | 0:7a63bd42cf24 | 9 | |
Clemo | 0:7a63bd42cf24 | 10 | #ifndef __INI_H__ |
Clemo | 0:7a63bd42cf24 | 11 | #define __INI_H__ |
Clemo | 0:7a63bd42cf24 | 12 | |
Clemo | 0:7a63bd42cf24 | 13 | /* Make this header file easier to include in C++ code */ |
Clemo | 0:7a63bd42cf24 | 14 | #ifdef __cplusplus |
Clemo | 0:7a63bd42cf24 | 15 | extern "C" { |
Clemo | 0:7a63bd42cf24 | 16 | #endif |
Clemo | 0:7a63bd42cf24 | 17 | |
Clemo | 0:7a63bd42cf24 | 18 | /* Parse given INI-style file. May have [section]s, name=value pairs |
Clemo | 0:7a63bd42cf24 | 19 | (whitespace stripped), and comments starting with ';' (semicolon). Section |
Clemo | 0:7a63bd42cf24 | 20 | is "" if name=value pair parsed before any section heading. |
Clemo | 0:7a63bd42cf24 | 21 | |
Clemo | 0:7a63bd42cf24 | 22 | For each name=value pair parsed, call handler function with given user |
Clemo | 0:7a63bd42cf24 | 23 | pointer as well as section, name, and value (data only valid for duration |
Clemo | 0:7a63bd42cf24 | 24 | of handler call). Handler should return nonzero on success, zero on error. |
Clemo | 0:7a63bd42cf24 | 25 | |
Clemo | 0:7a63bd42cf24 | 26 | Returns 0 on success, line number of first error on parse error, or -1 on |
Clemo | 0:7a63bd42cf24 | 27 | file open error. |
Clemo | 0:7a63bd42cf24 | 28 | */ |
Clemo | 0:7a63bd42cf24 | 29 | int ini_parse(const char* filename, |
Clemo | 0:7a63bd42cf24 | 30 | int (*handler)(void* user, const char* section, |
Clemo | 0:7a63bd42cf24 | 31 | const char* name, const char* value), |
Clemo | 0:7a63bd42cf24 | 32 | void* user); |
Clemo | 0:7a63bd42cf24 | 33 | |
Clemo | 0:7a63bd42cf24 | 34 | /* Nonzero to allow multi-line value parsing, in the style of Python's |
Clemo | 0:7a63bd42cf24 | 35 | ConfigParser. If allowed, ini_parse() will call the handler with the same |
Clemo | 0:7a63bd42cf24 | 36 | name for each subsequent line parsed. */ |
Clemo | 0:7a63bd42cf24 | 37 | #ifndef INI_ALLOW_MULTILINE |
Clemo | 0:7a63bd42cf24 | 38 | #define INI_ALLOW_MULTILINE 1 |
Clemo | 0:7a63bd42cf24 | 39 | #endif |
Clemo | 0:7a63bd42cf24 | 40 | |
Clemo | 0:7a63bd42cf24 | 41 | #ifdef __cplusplus |
Clemo | 0:7a63bd42cf24 | 42 | } |
Clemo | 0:7a63bd42cf24 | 43 | #endif |
Clemo | 0:7a63bd42cf24 | 44 | |
Clemo | 0:7a63bd42cf24 | 45 | #endif /* __INI_H__ */ |