summaryrefslogtreecommitdiffstats
path: root/lib/libc/gen/config_open.3
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libc/gen/config_open.3')
-rw-r--r--lib/libc/gen/config_open.373
1 files changed, 73 insertions, 0 deletions
diff --git a/lib/libc/gen/config_open.3 b/lib/libc/gen/config_open.3
new file mode 100644
index 0000000..f51bc6c
--- /dev/null
+++ b/lib/libc/gen/config_open.3
@@ -0,0 +1,73 @@
+.\" ----------------------------------------------------------------------------
+.\" "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 preceeding 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>
OpenPOWER on IntegriCloud