14 #ifndef _LIBCONFINI_HEADER_ 15 #define _LIBCONFINI_HEADER_ 25 #define _LIBCONFINI_INIFORMAT_DECLARATION_(SIZE, PROPERTY, DEFAULT) unsigned char PROPERTY:SIZE; 26 #define _LIBCONFINI_INIFORMAT_ASSIGNEMENT_(SIZE, PROPERTY, DEFAULT) DEFAULT, 27 #define _LIBCONFINI_INIFORMAT_STRUCT_ struct IniFormat { _LIBCONFINI_INIFORMAT_AS_(_LIBCONFINI_INIFORMAT_DECLARATION_) } 28 #define _LIBCONFINI_DEFAULT_FORMAT_ { _LIBCONFINI_INIFORMAT_AS_(_LIBCONFINI_INIFORMAT_ASSIGNEMENT_) } 35 #define _LIBCONFINI_INIFORMAT_AS_(______) 39 ______( 7, delimiter_symbol, INI_EQUALS ) \ 40 ______( 1, case_sensitive, 0 ) 42 ______( 2, semicolon_marker, INI_DISABLED_OR_COMMENT ) \ 43 ______( 2, hash_marker, INI_DISABLED_OR_COMMENT ) \ 44 ______( 2, section_paths, INI_ABSOLUTE_AND_RELATIVE ) \ 45 ______( 2, multiline_nodes, INI_MULTILINE_EVERYWHERE ) 47 ______( 1, no_single_quotes, 0 ) \ 48 ______( 1, no_double_quotes, 0 ) \ 49 ______( 1, no_spaces_in_names, 0 ) \ 50 ______( 1, implicit_is_not_empty, 0 ) \ 51 ______( 1, do_not_collapse_values, 0 ) \ 52 ______( 1, preserve_empty_quotes, 0 ) \ 53 ______( 1, disabled_after_space, 0 ) \ 54 ______( 1, disabled_can_be_implicit, 0 ) 59 #define INIFORMAT_HAS_NO_ESC(FMT) (FMT.multiline_nodes == INI_NO_MULTILINE && FMT.no_double_quotes && FMT.no_single_quotes) 98 FILE *
const ini_file,
100 int (*
const f_init) (
104 int (*
const f_foreach) (
108 void *
const user_data
112 const char *
const path,
114 int (*
const f_init) (
118 int (*
const f_foreach) (
122 void *
const user_data
126 const char *
const simple_string_a,
127 const char *
const simple_string_b,
132 const char *
const simple_string,
133 const char *
const ini_string,
138 const char *
const ini_string_a,
139 const char *
const ini_string_b,
144 const char *
const ini_string_a,
145 const char *
const ini_string_b,
146 const char delimiter,
151 char *
const ini_string,
156 char *
const ini_string,
161 const char *
const ini_string,
162 const char delimiter,
167 const char *
const ini_string,
168 const char delimiter,
170 int (*
const f_foreach) (
171 const char * fullstring,
178 void *
const user_data
182 const char **
const ini_strptr,
183 const char delimiter,
188 char *
const ini_string,
189 const char delimiter,
194 char *
const ini_string,
195 const char delimiter,
201 const char delimiter,
206 char *
const ini_string,
207 const char delimiter,
209 int (*
const f_foreach) (
216 void *
const user_data
224 char *
const implicit_value,
225 const size_t implicit_v_len
237 const char *
const ini_string,
238 const signed int return_value
247 const char * ini_string
251 const char * ini_string
255 const char * ini_string
259 const char * ini_string
268 #define CONFINI_ERROR 252 330 static const IniFormat INI_UNIXLIKE_FORMAT = { 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 };
346 #undef _LIBCONFINI_INIFORMAT_DECLARATION_ 347 #undef _LIBCONFINI_INIFORMAT_ASSIGNEMENT_ 348 #undef _LIBCONFINI_INIFORMAT_STRUCT_ 349 #undef _LIBCONFINI_DEFAULT_FORMAT_ void ini_global_set_lowercase_mode(_Bool lowercase)
Sets the value of the global variable INI_GLOBAL_LOWERCASE_MODE
Definition: confini.c:3900
int(*const ini_get_int)(const char *ini_string)
Link to atoi()
Definition: confini.c:4082
int ini_array_foreach(const char *const ini_string, const char delimiter, const IniFormat format, int(*const f_foreach)(const char *fullstring, size_t memb_offset, size_t memb_length, size_t memb_num, IniFormat format, void *foreach_other), void *const user_data)
Calls a custom function for each member of a stringified INI array without modifying the content of t...
Definition: confini.c:3256
int load_ini_file(FILE *const ini_file, const IniFormat format, int(*const f_init)(IniStatistics *statistics, void *init_other), int(*const f_foreach)(IniDispatch *dispatch, void *foreach_other), void *const user_data)
Parses an INI file and dispatches its content using a FILE structure as argument. ...
Definition: confini.c:1642
Definition: confini.h:321
static const IniFormat INI_UNIXLIKE_FORMAT
A model format for Unix-like CONF files (space characters are delimiters between keys and values) ...
Definition: confini.h:330
_Bool ini_string_match_ss(const char *const simple_string_a, const char *const simple_string_b, const IniFormat format)
Compares two simple strings and checks if they match.
Definition: confini.c:2200
Definition: confini.h:284
int ini_array_split(char *const ini_string, const char delimiter, const IniFormat format, int(*const f_foreach)(char *member, size_t memb_length, size_t memb_num, IniFormat format, void *foreach_other), void *const user_data)
Splits a stringified INI array into NUL-separated members and calls a custom function for each member...
Definition: confini.c:3795
Definition: confini.h:290
Definition: confini.h:277
Definition: confini.h:320
Definition: confini.h:275
Definition: confini.h:273
_Bool ini_array_match(const char *const ini_string_a, const char *const ini_string_b, const char delimiter, const IniFormat format)
Compares two INI arrays and checks if they match.
Definition: confini.c:2648
Definition: confini.h:323
Definition: confini.h:315
size_t v_len
Definition: confini.h:84
struct IniDispatch IniDispatch
Dispatch of a single INI node.
Definition: confini.h:289
Definition: confini.h:285
Definition: confini.h:313
Global statistics about an INI file.
Definition: confini.h:70
uint8_t type
Definition: confini.h:79
Definition: confini.h:274
IniFormatNum ini_fton(const IniFormat format)
Calculates the IniFormatNum of an IniFormat
Definition: confini.c:3943
Definition: confini.h:299
Definition: confini.h:276
const size_t bytes
Definition: confini.h:72
static const IniFormat INI_DEFAULT_FORMAT
A model format for standard INI files.
Definition: confini.h:327
double(*const ini_get_float)(const char *ini_string)
Link to atof()
Definition: confini.c:4088
int load_ini_path(const char *const path, const IniFormat format, int(*const f_init)(IniStatistics *statistics, void *init_other), int(*const f_foreach)(IniDispatch *dispatch, void *foreach_other), void *const user_data)
Parses an INI file and dispatches its content using a path as argument.
Definition: confini.c:2149
IniDelimiters
Most used key-value and array delimiters (but a delimiter may also be any other ASCII character) ...
Definition: confini.h:294
char * data
Definition: confini.h:80
size_t ini_string_parse(char *const ini_string, const IniFormat format)
Unescapes \\, \' and \" and removes all unescaped quotes (if single/double quotes are considered meta...
Definition: confini.c:2996
Definition: confini.h:312
IniMultiline
Possible values of IniFormat::multiline_nodes.
Definition: confini.h:319
IniNodeType
INI node types.
Definition: confini.h:282
Definition: confini.h:286
signed int ini_get_bool(const char *const ini_string, const signed int return_value)
Checks whether a string matches one of the booleans listed in the private constant INI_BOOLEANS (case...
Definition: confini.c:4019
struct IniStatistics IniStatistics
Global statistics about an INI file.
Definition: confini.h:278
Definition: confini.h:288
size_t INI_GLOBAL_IMPLICIT_V_LEN
Length of the value assigned to implicit keys – this may be any unsigned number, independently of th...
Definition: confini.c:4099
Definition: confini.h:295
IniSectionPaths
Possible values of IniFormat::section_paths
Definition: confini.h:311
Definition: confini.h:304
char * ini_array_break(char *const ini_string, const char delimiter, const IniFormat format)
Replaces the first delimiter found (together with the spaces that surround it) with \0 ...
Definition: confini.c:3654
Definition: confini.h:298
Definition: confini.h:287
Definition: confini.h:272
long long int(*const ini_get_llint)(const char *ini_string)
Link to atoll()
Definition: confini.c:4086
IniCommentMarker
Possible values of IniFormat::semicolon_marker and IniFormat::hash_marker (i.e., meaning of /\s+[#;]/...
Definition: confini.h:303
char * value
Definition: confini.h:81
Definition: confini.h:307
size_t ini_array_collapse(char *const ini_string, const char delimiter, const IniFormat format)
Compresses the distribution of the data of a stringified INI array by removing all the white spaces t...
Definition: confini.c:3461
IniFormat ini_ntof(IniFormatNum format_id)
Constructs a new IniFormat according to an IniFormatNum
Definition: confini.c:3970
size_t d_len
Definition: confini.h:83
_Bool INI_GLOBAL_LOWERCASE_MODE
If set to TRUE, key and section names in case-insensitive INI formats will be dispatched lowercase...
Definition: confini.c:4095
Definition: confini.h:322
Definition: confini.h:296
uint32_t IniFormatNum
The unique ID number of an INI format (24-bit maximum)
Definition: confini.h:90
ConfiniInterruptNo
Error codes – the actual value of each constant should be considered opaque.
Definition: confini.h:271
_Bool ini_string_match_ii(const char *const ini_string_a, const char *const ini_string_b, const IniFormat format)
Compares two INI strings and checks if they match.
Definition: confini.c:2457
char * ini_array_release(char **ini_strptr, const char delimiter, const IniFormat format)
Replaces the first delimiter found (together with the spaces that surround it) with \0...
Definition: confini.c:3727
size_t at_len
Definition: confini.h:85
Definition: confini.h:283
Definition: confini.h:297
size_t dispatch_id
Definition: confini.h:86
long int(*const ini_get_lint)(const char *ini_string)
Link to atol()
Definition: confini.c:4084
void ini_global_set_implicit_value(char *const implicit_value, const size_t implicit_v_len)
Sets the value to be to be assigned to implicit keys.
Definition: confini.c:3926
const size_t members
Definition: confini.h:73
_Bool ini_string_match_si(const char *const simple_string, const char *const ini_string, const IniFormat format)
Compares a simple string and an INI string and and checks if they match.
Definition: confini.c:2295
Dispatch of a single INI node.
Definition: confini.h:77
const char * append_to
Definition: confini.h:82
Definition: confini.h:306
size_t ini_unquote(char *const ini_string, const IniFormat format)
Unescapes \\, \' and \" and removes all unescaped quotes (if single/double quotes are considered meta...
Definition: confini.c:2872
size_t ini_array_get_length(const char *const ini_string, const char delimiter, const IniFormat format)
Gets the length of a stringified INI array in number of members.
Definition: confini.c:3145
char * INI_GLOBAL_IMPLICIT_VALUE
Value to be assigned to implicit keys (default value: NULL)
Definition: confini.c:4097
Definition: confini.h:305
struct IniFormat IniFormat
24-bit bitfield representing the format of an INI file (INI dialect)
const IniFormat format
Definition: confini.h:78
size_t ini_array_shift(const char **const ini_strptr, const char delimiter, const IniFormat format)
Shifts the location pointed by ini_strptr to the next member of the INI array (without modifying the ...
Definition: confini.c:3369
Definition: confini.h:314
const IniFormat format
Definition: confini.h:71