config_open(3)

NAME
config_open, config_close, config_next, config_skip - read config files

SYNOPSIS
char *
config_open(const char *filename, int contlines);
void
config_close();
char *
config_next();
char *
config_skip(char **string);

DESCRIPTION
These functions are used to read config files with the following syntax:
•   All lines where the first ‘!isspace()’ is '#' are comments which are discarded.
•   If continuation-lines are enabled, any line starting with a ‘isspace()’ character is joined to the preceding line and blank lines are discarded.
•   An entry starts at the first ‘!isspace()’ character and ends at the first ‘\n’.

config_open() will open the specified filename and read it into a private malloced area, and close the file again. If contlines is non-zero, continuation lines will be allowed. In case of trouble, the name of the system-call causing the trouble will be returned. If successful, config_open() returns NULL.

config_close() will free the malloced area.

config_next() returns the next entry in the area. NULL is returned to indicate End-of-file. The returned string is null-terminated.

config_skip() returns the next word from the string *string. *string will be advanced to point to the next word. NULL is returned to indicate the end of the string.

AUTHOR
Poul-Henning Kamp <phk@login.dknet.dk>