Critical Link MityCam SoC Firmware  1.0
Critical Link MityCam SoC Firmware
ini.h
Go to the documentation of this file.
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 https://github.com/benhoyt/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 /* Nonzero if ini_handler callback should accept lineno parameter. */
21 #ifndef INI_HANDLER_LINENO
22 #define INI_HANDLER_LINENO 0
23 #endif
24 
25 /* Typedef for prototype of handler function. */
26 #if INI_HANDLER_LINENO
27 typedef int (*ini_handler)(void* user, const char* section,
28  const char* name, const char* value,
29  int lineno);
30 #else
31 typedef int (*ini_handler)(void* user, const char* section,
32  const char* name, const char* value);
33 #endif
34 
35 /* Typedef for prototype of fgets-style reader function. */
36 typedef char* (*ini_reader)(char* str, int num, void* stream);
37 
38 /* Parse given INI-style file. May have [section]s, name=value pairs
39  (whitespace stripped), and comments starting with ';' (semicolon). Section
40  is "" if name=value pair parsed before any section heading. name:value
41  pairs are also supported as a concession to Python's configparser.
42 
43  For each name=value pair parsed, call handler function with given user
44  pointer as well as section, name, and value (data only valid for duration
45  of handler call). Handler should return nonzero on success, zero on error.
46 
47  Returns 0 on success, line number of first error on parse error (doesn't
48  stop on first error), -1 on file open error, or -2 on memory allocation
49  error (only when INI_USE_STACK is zero).
50 */
51 int ini_parse(const char* filename, ini_handler handler, void* user);
52 
53 /* Same as ini_parse(), but takes a FILE* instead of filename. This doesn't
54  close the file when it's finished -- the caller must do that. */
55 int ini_parse_file(FILE* file, ini_handler handler, void* user);
56 
57 /* Same as ini_parse(), but takes an ini_reader function pointer instead of
58  filename. Used for implementing custom or string-based I/O. */
59 int ini_parse_stream(ini_reader reader, void* stream, ini_handler handler,
60  void* user);
61 
62 /* Nonzero to allow multi-line value parsing, in the style of Python's
63  configparser. If allowed, ini_parse() will call the handler with the same
64  name for each subsequent line parsed. */
65 #ifndef INI_ALLOW_MULTILINE
66 #define INI_ALLOW_MULTILINE 1
67 #endif
68 
69 /* Nonzero to allow a UTF-8 BOM sequence (0xEF 0xBB 0xBF) at the start of
70  the file. See http://code.google.com/p/inih/issues/detail?id=21 */
71 #ifndef INI_ALLOW_BOM
72 #define INI_ALLOW_BOM 1
73 #endif
74 
75 /* Nonzero to allow inline comments (with valid inline comment characters
76  specified by INI_INLINE_COMMENT_PREFIXES). Set to 0 to turn off and match
77  Python 3.2+ configparser behaviour. */
78 #ifndef INI_ALLOW_INLINE_COMMENTS
79 #define INI_ALLOW_INLINE_COMMENTS 1
80 #endif
81 #ifndef INI_INLINE_COMMENT_PREFIXES
82 #define INI_INLINE_COMMENT_PREFIXES ";"
83 #endif
84 
85 /* Nonzero to use stack, zero to use heap (malloc/free). */
86 #ifndef INI_USE_STACK
87 #define INI_USE_STACK 1
88 #endif
89 
90 /* Stop parsing on first error (default is to keep parsing). */
91 #ifndef INI_STOP_ON_FIRST_ERROR
92 #define INI_STOP_ON_FIRST_ERROR 0
93 #endif
94 
95 /* Maximum line length for any line in INI file. */
96 #ifndef INI_MAX_LINE
97 #define INI_MAX_LINE 200
98 #endif
99 
100 #ifdef __cplusplus
101 }
102 #endif
103 
104 #endif /* __INI_H__ */
ini_reader
char *(* ini_reader)(char *str, int num, void *stream)
Definition: ini.h:36
ini_parse
int ini_parse(const char *filename, ini_handler handler, void *user)
Definition: ini.c:190
ini_parse_stream
int ini_parse_stream(ini_reader reader, void *stream, ini_handler handler, void *user)
Definition: ini.c:73
ini_handler
int(* ini_handler)(void *user, const char *section, const char *name, const char *value)
Definition: ini.h:31
ini_parse_file
int ini_parse_file(FILE *file, ini_handler handler, void *user)
Definition: ini.c:184