summaryrefslogtreecommitdiffstats
path: root/lib/libc/gen/config_open.3
blob: 906859437f25a9b7705a78ed0b8977ea770ac116 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
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
.\" ----------------------------------------------------------------------------
.\" 
.\"  $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>
OpenPOWER on IntegriCloud