shithub: libini

ref: 6c63e71880f8bcdf597548e8bbaba165c4fe7d38
dir: /ini.man/

View raw version
.TH INI 2
.SH NAME
parseini \- parse ini files
.SH SYNOPSIS
.B #include <ini.h>
.PP
.B
.ta \w'char** 'u
int	parseini(char *file, void (*f)(char*, char*, char*), int forcelower)
.PP
.B
.ta \w'char** 'u
int	iniconfig(char *file, int forcelower)
.br
.B
int	freeini(int config)
.PP
.B
.ta \w'char** 'u
char*	getinivalue(int config, char *section, char *key)
.br
.B
char**	getiniarray(int config, char *section, char *key, int *num)
.PP
.SH DESCRIPTION
This library function provides simple parsing of INI files using
.IR bio (2).
For each key-value pair within the INI file it calls the provided callback function
.IR f .
.PP
The callback function gets the section, key and value as parameters.
.PP
The
.I forcelower
flag tells the function to return all strings as lowercase strings, which can be helpful for some cases.
Otherwise, all strings are returned as entered in the INI file.
.PP
.I Iniconfig
parses the given file into a convenient config database.
It returns the
.I id
of the parsed config file that's needed for future lookups.
It is possible to parse multiple INI files within one program this way.
.I Freeini
frees the whole loaded INI configuration specified by the
.I config
parameter.
.PP
The functions
.I getinivalue
and
.I getiniarray
can be used to fetch the parsed config values.
Both functions expect the configuration id received by the previous
.I iniconfig
call, as well as strings for
.I section
and
.IR key .
.PP
.I Getinivalue
returns the string value for the given combination.
.PP
.I Getiniarray
returns an array of all value strings for the given combination.
It sets
.I num
to the number of elements within this list.
.SH SOURCE
.B /sys/src/libini
.SH SEE ALSO
.IR bio (2)
.SH DIAGNOSTICS
.I Parseini
returns 0 on failure and sets
.IR errstr .
.SH BUGS
Sure.
.PP
.I Freeini
potentially leaks memory.