#include <stdio.h>#include <stdlib.h>#include <string.h>#include <unistd.h>#include <ctype.h>


Go to the source code of this file.
Data Structures | |
| struct | _dictionary_ |
Typedefs | |
| typedef struct _dictionary_ | dictionary |
Functions | |
| void | iniparser_dump (dictionary *d, FILE *f) |
| Dump a dictionary to an opened file pointer. | |
| void | iniparser_dump_ini (dictionary *d, FILE *f) |
| Save a dictionary to a loadable ini file. | |
| int | iniparser_find_entry (dictionary *ini, char *entry) |
| Finds out if a given entry exists in a dictionary. | |
| void | iniparser_free (dictionary *d) |
| Free all memory associated to an ini dictionary. | |
| int | iniparser_getboolean (dictionary *d, char *key, int notfound) |
| Get the string associated to a key, convert to a boolean. | |
| double | iniparser_getdouble (dictionary *d, char *key, double notfound) |
| Get the string associated to a key, convert to a double. | |
| int | iniparser_getint (dictionary *d, char *key, int notfound) |
| Get the string associated to a key, convert to an int. | |
| char * | iniparser_getkey (dictionary *d, char *section, char *key) |
| 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. | |
| char * | iniparser_getstr (dictionary *d, char *key) |
| Get the string associated to a key, return NULL if not found. | |
| char * | iniparser_getstring (dictionary *d, char *key, char *def) |
| Get the string associated to a key. | |
| dictionary * | iniparser_new (char *ininame) |
| Parse an ini file and return an allocated dictionary object. | |
| 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. | |
| typedef struct _dictionary_ 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.
Definition at line 663 of file iniparser.c.
References dictionary_dump().
| 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.
Definition at line 681 of file iniparser.c.
References ASCIILINESZ, iniparser_getnsec(), iniparser_getsecname(), _dictionary_::key, NULL, _dictionary_::size, and _dictionary_::val.
| int iniparser_find_entry | ( | dictionary * | ini, | |
| char * | entry | |||
| ) |
Finds out if a given entry exists in a dictionary.
Definition at line 886 of file iniparser.c.
References INI_INVALID_KEY, and iniparser_getstring().
Referenced by mod_init().
| void iniparser_free | ( | dictionary * | d | ) |
Free all memory associated to an ini dictionary.
| d | Dictionary to free |
Definition at line 1018 of file iniparser.c.
References dictionary_del().
| int iniparser_getboolean | ( | dictionary * | d, | |
| 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.
Definition at line 855 of file iniparser.c.
References INI_INVALID_KEY, and iniparser_getstring().
Referenced by add_ld_session().
| 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 |
Definition at line 812 of file iniparser.c.
References INI_INVALID_KEY, and iniparser_getstring().
| int iniparser_getint | ( | dictionary * | d, | |
| 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 |
Definition at line 789 of file iniparser.c.
References INI_INVALID_KEY, and iniparser_getstring().
Referenced by add_ld_session().
| char* iniparser_getkey | ( | dictionary * | d, | |
| char * | section, | |||
| char * | key | |||
| ) |
| 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.
Definition at line 594 of file iniparser.c.
References _dictionary_::key, NULL, and _dictionary_::size.
Referenced by child_init(), iniparser_dump_ini(), and mod_init().
| 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.
Definition at line 627 of file iniparser.c.
References _dictionary_::key, NULL, and _dictionary_::size.
Referenced by child_init(), iniparser_dump_ini(), and mod_init().
| char* iniparser_getstr | ( | dictionary * | d, | |
| 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.
Definition at line 739 of file iniparser.c.
References iniparser_getstring(), and NULL.
| char* iniparser_getstring | ( | dictionary * | d, | |
| 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. |
Definition at line 760 of file iniparser.c.
References dictionary_get(), NULL, and strlwc().
Referenced by add_ld_session(), iniparser_find_entry(), iniparser_getboolean(), iniparser_getdouble(), iniparser_getint(), and iniparser_getstr().
| dictionary* iniparser_new | ( | 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_free().
Definition at line 951 of file iniparser.c.
References ASCIILINESZ, dictionary_new(), iniparser_add_entry(), NULL, strcrop(), strlwc(), and strskp().
Referenced by mod_init().
| 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. |
Definition at line 914 of file iniparser.c.
References dictionary_set(), and strlwc().
| void iniparser_unset | ( | dictionary * | ini, | |
| char * | entry | |||
| ) |
Delete an entry in a dictionary.
Definition at line 930 of file iniparser.c.
References dictionary_unset(), and strlwc().
1.5.6