Freeman Oldman / NUCLEO_STM32F401RE_CC3000_ILI9341
Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers ini.h Source File

ini.h

00001 /* inih -- simple .INI file parser
00002 
00003 inih is released under the New BSD license (see LICENSE.txt). Go to the project
00004 home page for more info:
00005 
00006 http://code.google.com/p/inih/
00007 
00008 */
00009 
00010 #ifndef __INI_H__
00011 #define __INI_H__
00012 
00013 /* Make this header file easier to include in C++ code */
00014 #ifdef __cplusplus
00015 extern "C" {
00016 #endif
00017 
00018 #include <stdio.h>
00019 
00020 /* Parse given INI-style file. May have [section]s, name=value pairs
00021    (whitespace stripped), and comments starting with ';' (semicolon). Section
00022    is "" if name=value pair parsed before any section heading. name:value
00023    pairs are also supported as a concession to Python's ConfigParser.
00024 
00025    For each name=value pair parsed, call handler function with given user
00026    pointer as well as section, name, and value (data only valid for duration
00027    of handler call). Handler should return nonzero on success, zero on error.
00028 
00029    Returns 0 on success, line number of first error on parse error (doesn't
00030    stop on first error), -1 on file open error, or -2 on memory allocation
00031    error (only when INI_USE_STACK is zero).
00032 */
00033 int ini_parse(const char* filename,
00034               int (*handler)(void* user, const char* section,
00035                              const char* name, const char* value),
00036               void* user);
00037 
00038 /* Same as ini_parse(), but takes a FILE* instead of filename. This doesn't
00039    close the file when it's finished -- the caller must do that. */
00040 int ini_parse_file(FILE* file,
00041                    int (*handler)(void* user, const char* section,
00042                                   const char* name, const char* value),
00043                    void* user);
00044 
00045 /* Nonzero to allow multi-line value parsing, in the style of Python's
00046    ConfigParser. If allowed, ini_parse() will call the handler with the same
00047    name for each subsequent line parsed. */
00048 #ifndef INI_ALLOW_MULTILINE
00049 #define INI_ALLOW_MULTILINE 1
00050 #endif
00051 
00052 /* Nonzero to allow a UTF-8 BOM sequence (0xEF 0xBB 0xBF) at the start of
00053    the file. See http://code.google.com/p/inih/issues/detail?id=21 */
00054 #ifndef INI_ALLOW_BOM
00055 #define INI_ALLOW_BOM 1
00056 #endif
00057 
00058 /* Nonzero to use stack, zero to use heap (malloc/free). */
00059 #ifndef INI_USE_STACK
00060 #define INI_USE_STACK 1
00061 #endif
00062 
00063 /* Stop parsing on first error (default is to keep parsing). */
00064 #ifndef INI_STOP_ON_FIRST_ERROR
00065 #define INI_STOP_ON_FIRST_ERROR 0
00066 #endif
00067 
00068 /* Maximum line length for any line in INI file. */
00069 #ifndef INI_MAX_LINE
00070 #define INI_MAX_LINE 200
00071 #endif
00072 
00073 #ifdef __cplusplus
00074 }
00075 #endif
00076 
00077 #endif /* __INI_H__ */
00078