Functions | |
int | iniparser_getnsec (dictionary *d) |
Get number of sections in a dictionary. | |
char * | iniparser_getsecname (dictionary *d, int n) |
Get name for section n in a dictionary. | |
void | iniparser_dump_ini (dictionary *d, FILE *f) |
Save a dictionary to a loadable ini file. | |
void | iniparser_dump (dictionary *d, FILE *f) |
Dump a dictionary to an opened file pointer. | |
char * | iniparser_getstr (dictionary *d, const char *key) |
Get the string associated to a key, return NULL if not found. | |
char * | iniparser_getstring (dictionary *d, const char *key, char *def) |
Get the string associated to a key. | |
int | iniparser_getint (dictionary *d, const char *key, int notfound) |
Get the string associated to a key, convert to an int. | |
double | iniparser_getdouble (dictionary *d, char *key, double notfound) |
Get the string associated to a key, convert to a double. | |
int | iniparser_getboolean (dictionary *d, const char *key, int notfound) |
Get the string associated to a key, convert to a boolean. | |
int | iniparser_setstr (dictionary *ini, char *entry, char *val) |
Set an entry in a dictionary. | |
void | iniparser_unset (dictionary *ini, char *entry) |
Delete an entry in a dictionary. | |
int | iniparser_find_entry (dictionary *ini, char *entry) |
Finds out if a given entry exists in a dictionary. | |
dictionary * | iniparser_load (const char *ininame) |
Parse an ini file and return an allocated dictionary object. | |
void | iniparser_freedict (dictionary *d) |
Free all memory associated to an ini dictionary. |
void iniparser_dump | ( | dictionary * | d, | |
FILE * | f | |||
) |
Dump a dictionary to an opened file pointer.
d | Dictionary to dump. | |
f | Opened file pointer to dump to. |
stderr
or stdout
as output files. This function is meant for debugging purposes mostly.
void iniparser_dump_ini | ( | dictionary * | d, | |
FILE * | f | |||
) |
Save a dictionary to a loadable ini file.
d | Dictionary to dump | |
f | Opened file pointer to dump to |
stderr
or stdout
as output files.
int iniparser_find_entry | ( | dictionary * | ini, | |
char * | entry | |||
) |
Finds out if a given entry exists in a dictionary.
ini | Dictionary to search | |
entry | Name of the entry to look for |
void iniparser_freedict | ( | dictionary * | d | ) |
Free all memory associated to an ini dictionary.
d | Dictionary to free |
int iniparser_getboolean | ( | dictionary * | d, | |
const char * | key, | |||
int | notfound | |||
) |
Get the string associated to a key, convert to a boolean.
d | Dictionary to search | |
key | Key string to look for | |
notfound | Value to return in case of error |
A true boolean is found if one of the following is matched:
A false boolean is found if one of the following is matched:
The notfound value returned if no boolean is identified, does not necessarily have to be 0 or 1.
double iniparser_getdouble | ( | dictionary * | d, | |
char * | key, | |||
double | notfound | |||
) |
Get the string associated to a key, convert to a double.
d | Dictionary to search | |
key | Key string to look for | |
notfound | Value to return in case of error |
int iniparser_getint | ( | dictionary * | d, | |
const char * | key, | |||
int | notfound | |||
) |
Get the string associated to a key, convert to an int.
d | Dictionary to search | |
key | Key string to look for | |
notfound | Value to return in case of error |
Supported values for integers include the usual C notation so decimal, octal (starting with 0) and hexadecimal (starting with 0x) are supported. Examples:
Warning: the conversion may overflow in various ways. Conversion is totally outsourced to strtol(), see the associated man page for overflow handling.
Credits: Thanks to A. Becker for suggesting strtol()
int iniparser_getnsec | ( | dictionary * | d | ) |
Get number of sections in a dictionary.
d | Dictionary to examine |
This clearly fails in the case a section name contains a colon, but this should simply be avoided.
This function returns -1 in case of error.
char* iniparser_getsecname | ( | dictionary * | d, | |
int | n | |||
) |
Get name for section n in a dictionary.
d | Dictionary to examine | |
n | Section number (from 0 to nsec-1). |
This function returns NULL in case of error.
char* iniparser_getstr | ( | dictionary * | d, | |
const char * | key | |||
) |
Get the string associated to a key, return NULL if not found.
d | Dictionary to search | |
key | Key string to look for |
This function is only provided for backwards compatibility with previous versions of iniparser. It is recommended to use iniparser_getstring() instead.
char* iniparser_getstring | ( | dictionary * | d, | |
const char * | key, | |||
char * | def | |||
) |
Get the string associated to a key.
d | Dictionary to search | |
key | Key string to look for | |
def | Default value to return if key not found. |
dictionary* iniparser_load | ( | const char * | ininame | ) |
Parse an ini file and return an allocated dictionary object.
ininame | Name of the ini file to read. |
The returned dictionary must be freed using iniparser_freedict().
int iniparser_setstr | ( | dictionary * | ini, | |
char * | entry, | |||
char * | val | |||
) |
Set an entry in a dictionary.
ini | Dictionary to modify. | |
entry | Entry to modify (entry name) | |
val | New value to associate to the entry. |
void iniparser_unset | ( | dictionary * | ini, | |
char * | entry | |||
) |
Delete an entry in a dictionary.
ini | Dictionary to modify | |
entry | Entry to delete (entry name) |