1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-22 11:17:19 +00:00
freebsd/lib/libc/gen/config_open.3
1997-02-22 15:12:41 +00:00

74 lines
1.9 KiB
Groff

.\" ----------------------------------------------------------------------------
.\" "THE BEER-WARE LICENSE" (Revision 42):
.\" <phk@login.dknet.dk> wrote this file. As long as you retain this notice you
.\" can do whatever you want with this stuff. If we meet some day, and you think
.\" this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
.\" ----------------------------------------------------------------------------
.\"
.\" $Id$
.\"
.Dd November 13, 1994
.Dt config_open 3
.Os FreeBSD
.Sh NAME
.Nm config_open ,
.Nm config_close ,
.Nm config_next ,
.Nm config_skip
.Nd read config files
.Sh SYNOPSIS
.Ft char *
.Fn config_open "const char *filename" "int contlines"
.Ft void
.Fn config_close
.Ft char *
.Fn config_next
.Ft char *
.Fn config_skip "char **string"
.Sh DESCRIPTION
These functions are used to read config files with the following syntax:
.Bl -bullet -compact
.It
All lines where the first
.Sq !isspace()
is '#' are comments which are discarded.
.It
If continuation-lines are enabled, any line starting with a
.Sq isspace()
character is joined to the preceding line and blank lines are discarded.
.It
An entry starts at the first
.Sq !isspace()
character and ends at the first
.Sq Li \en
.Li .
.El
.Pp
.Fn config_open
will open the specified
.Fa filename
and read it into a private malloced area, and close the file again. If
.Fa 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,
.Fn config_open
returns NULL.
.Pp
.Fn config_close
will free the malloced area.
.Pp
.Fn config_next
returns the next entry in the area. NULL is returned to indicate End-of-file.
The returned string is null-terminated.
.Pp
.Fn config_skip
returns the next word from the string
.Fa *string
.Li .
.Fa *string
will be advanced to point to the next word.
NULL is returned to indicate the end of the string.
.Sh AUTHOR
Poul-Henning Kamp <phk@login.dknet.dk>