freebsd-nq/lib/libc/gen/config_open.3
Jordan K. Hubbard 1130b656e5 Make the long-awaited change from $Id$ to $FreeBSD$
This will make a number of things easier in the future, as well as (finally!)
avoiding the Id-smashing problem which has plagued developers for so long.

Boy, I'm glad we're not using sup anymore.  This update would have been
insane otherwise.
1997-01-14 07:20:47 +00:00

74 lines
2.0 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
.\" ----------------------------------------------------------------------------
.\"
.\" $FreeBSD$
.\"
.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>