iniparser 4.3.2
iniParser is a simple C library offering ini file parsing services.
Loading...
Searching...
No Matches
iniparser.h
Go to the documentation of this file.
1/*-------------------------------------------------------------------------*/
7/*--------------------------------------------------------------------------*/
8
9#ifndef _INIPARSER_H_
10#define _INIPARSER_H_
11
12/*---------------------------------------------------------------------------
13 Includes
14 ---------------------------------------------------------------------------*/
15
16#include "dictionary.h"
17#include <stdint.h>
18
19/*
20 * iniparser_load_buffer() relies on fmemopen(). Expose it only when the
21 * platform's feature test macros make fmemopen() available (POSIX.1-2008).
22 * Callers that want this function must request the appropriate feature test
23 * macros (e.g. _POSIX_C_SOURCE >= 200809L or _GNU_SOURCE) before including
24 * any system header.
25 */
26#if defined(_GNU_SOURCE) \
27 || (defined(_POSIX_C_SOURCE) && (_POSIX_C_SOURCE - 0) >= 200809L)
28#define INIPARSER_HAVE_LOAD_BUFFER 1
29#endif
30
31#ifdef __cplusplus
32extern "C"
33{
34#endif
35
36/*-------------------------------------------------------------------------*/
44/*--------------------------------------------------------------------------*/
45void iniparser_set_error_callback(int (*errback)(const char *, ...));
46
47/*-------------------------------------------------------------------------*/
64/*--------------------------------------------------------------------------*/
65int iniparser_getnsec(const dictionary *d);
66
67/*-------------------------------------------------------------------------*/
80/*--------------------------------------------------------------------------*/
81const char *iniparser_getsecname(const dictionary *d, int n);
82
83/*-------------------------------------------------------------------------*/
98/*--------------------------------------------------------------------------*/
99void iniparser_dump_ini(const dictionary *d, FILE *f);
100
101/*-------------------------------------------------------------------------*/
111/*--------------------------------------------------------------------------*/
112void iniparser_dumpsection_ini(const dictionary *d, const char *s, FILE *f);
113
114/*-------------------------------------------------------------------------*/
125/*--------------------------------------------------------------------------*/
126void iniparser_dump(const dictionary *d, FILE *f);
127
128/*-------------------------------------------------------------------------*/
135/*--------------------------------------------------------------------------*/
136int iniparser_getsecnkeys(const dictionary *d, const char *s);
137
138/*-------------------------------------------------------------------------*/
153/*--------------------------------------------------------------------------*/
154const char **iniparser_getseckeys(const dictionary *d, const char *s,
155 const char **keys);
156
157/*-------------------------------------------------------------------------*/
172/*--------------------------------------------------------------------------*/
173const char *iniparser_getstring(const dictionary *d, const char *key,
174 const char *def);
175
176/*-------------------------------------------------------------------------*/
202/*--------------------------------------------------------------------------*/
203int iniparser_getint(const dictionary *d, const char *key, int notfound);
204
205/*-------------------------------------------------------------------------*/
229/*--------------------------------------------------------------------------*/
230long int iniparser_getlongint(const dictionary *d, const char *key,
231 long int notfound);
232
233/*-------------------------------------------------------------------------*/
260/*--------------------------------------------------------------------------*/
261int64_t iniparser_getint64(const dictionary *d, const char *key,
262 int64_t notfound);
263
264/*-------------------------------------------------------------------------*/
291/*--------------------------------------------------------------------------*/
292uint64_t iniparser_getuint64(const dictionary *d, const char *key,
293 uint64_t notfound);
294
295/*-------------------------------------------------------------------------*/
307/*--------------------------------------------------------------------------*/
308double iniparser_getdouble(const dictionary *d, const char *key,
309 double notfound);
310
311/*-------------------------------------------------------------------------*/
342/*--------------------------------------------------------------------------*/
343int iniparser_getboolean(const dictionary *d, const char *key, int notfound);
344
345/*-------------------------------------------------------------------------*/
357/*--------------------------------------------------------------------------*/
358int iniparser_set(dictionary *ini, const char *entry, const char *val);
359
360/*-------------------------------------------------------------------------*/
368/*--------------------------------------------------------------------------*/
369void iniparser_unset(dictionary *ini, const char *entry);
370
371/*-------------------------------------------------------------------------*/
382/*--------------------------------------------------------------------------*/
383int iniparser_find_entry(const dictionary *ini, const char *entry);
384
385/*-------------------------------------------------------------------------*/
409/*--------------------------------------------------------------------------*/
410dictionary *iniparser_load(const char *ininame);
411
412/*-------------------------------------------------------------------------*/
437/*--------------------------------------------------------------------------*/
438dictionary *iniparser_load_file(FILE *in, const char *ininame);
439
440#ifdef INIPARSER_HAVE_LOAD_BUFFER
441/*-------------------------------------------------------------------------*/
460/*--------------------------------------------------------------------------*/
461dictionary *iniparser_load_buffer(const char *buffer);
462#endif
463
464
465/*-------------------------------------------------------------------------*/
474/*--------------------------------------------------------------------------*/
475void iniparser_freedict(dictionary *d);
476
477#ifdef __cplusplus
478}
479#endif
480
481#endif
dictionary * iniparser_load(const char *ininame)
Parse an ini file and return an allocated dictionary object.
double iniparser_getdouble(const dictionary *d, const char *key, double notfound)
Get the string associated to a key, convert to a double.
void iniparser_unset(dictionary *ini, const char *entry)
Delete an entry in a dictionary.
void iniparser_set_error_callback(int(*errback)(const char *,...))
Configure a function to receive the error messages.
int iniparser_getsecnkeys(const dictionary *d, const char *s)
Get the number of keys in a section of a dictionary.
const char * iniparser_getsecname(const dictionary *d, int n)
Get name for section n in a dictionary.
void iniparser_dumpsection_ini(const dictionary *d, const char *s, FILE *f)
Save a dictionary section to a loadable ini file.
void iniparser_dump(const dictionary *d, FILE *f)
Dump a dictionary to an opened file pointer.
void iniparser_freedict(dictionary *d)
Free all memory associated to an ini dictionary.
int iniparser_getint(const dictionary *d, const char *key, int notfound)
Get the string associated to a key, convert to an int.
int64_t iniparser_getint64(const dictionary *d, const char *key, int64_t notfound)
Get the string associated to a key, convert to an int64_t.
uint64_t iniparser_getuint64(const dictionary *d, const char *key, uint64_t notfound)
Get the string associated to a key, convert to an uint64_t.
int iniparser_find_entry(const dictionary *ini, const char *entry)
Finds out if a given entry exists in a dictionary.
dictionary * iniparser_load_file(FILE *in, const char *ininame)
Parse an ini file and return an allocated dictionary object.
int iniparser_getnsec(const dictionary *d)
Get number of sections in a dictionary.
int iniparser_set(dictionary *ini, const char *entry, const char *val)
Set an entry in a dictionary.
long int iniparser_getlongint(const dictionary *d, const char *key, long int notfound)
Get the string associated to a key, convert to an long int.
const char ** iniparser_getseckeys(const dictionary *d, const char *s, const char **keys)
Get the number of keys in a section of a dictionary.
void iniparser_dump_ini(const dictionary *d, FILE *f)
Save a dictionary to a loadable ini file.
int iniparser_getboolean(const dictionary *d, const char *key, int notfound)
Get the string associated to a key, convert to a boolean.
const char * iniparser_getstring(const dictionary *d, const char *key, const char *def)
Get the string associated to a key.