This commit was generated by cvs2svn to track changes on a CVS vendor
[unix-history] / lib / libutil / config_open.3
CommitLineData
c4d09a4c
CR
1.\" Copyright (c) 1994 Christoph M. Robitschko
2.\" All rights reserved.
3.\"
4.\" Redistribution and use in source and binary forms, with or without
5.\" modification, are permitted provided that the following conditions
6.\" are met:
7.\" 1. Redistributions of source code must retain the above copyright
8.\" notice, this list of conditions and the following disclaimer.
9.\" 2. Redistributions in binary form must reproduce the above copyright
10.\" notice, this list of conditions and the following disclaimer in the
11.\" documentation and/or other materials provided with the distribution.
12.\" 3. All advertising materials mentioning features or use of this software
13.\" must display the following acknowledgement:
14.\" This product includes software developed by Christoph M. Robitschko
15.\" 4. The name of the author may not be used to endorse or promote products
16.\" derived from this software withough specific prior written permission
17.\"
18.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
8ca81eb5
RG
28.\"
29.\" $Id$
30.\"
c4d09a4c
CR
31.Dd January 28, 1994
32.Dt config_open 3
33.Os FreeBSD
34.Sh NAME
35.Nm config_open ,
36.Nm config_close ,
37.Nm config_next ,
38.Nm config_skip
39.Nd read config files
40.Sh SYNOPSIS
41.Ft char *
42.Fn config_open "const char *filename" "int contlines"
43.Ft void
44.Fn config_close
45.Ft char *
46.Fn config_next
47.Ft char *
48.Fn config_skip "char **string"
49.Sh DESCRIPTION
50These functions are used to read config files with the following syntax:
51.Bl -bullet -compact
52.It
53Lines starting in
54.Sq #
55are comments.
56.It
57An entry starts with the first
58.Sq !isspace()
59character found.
60.It
61If continuation-lines are enabled, an entry ends before the first
62empty line or before the first line not starting in an
63.Sq isspace()
64character, whichever comes first.
65.It
66Otherwise, an entry ends at the first
67.Sq Li \en
68.Li .
69.El
70.Pp
71.Fn config_open
72will open the specified
73.Fa filename
74and read it into a private malloced area, and close the file again. If
75.Fa contlines
76is non-zero, continuation lines will be allowed.
77In case of trouble, the name of the system-call causing the trouble will
78be returned. If successful,
79.Fn config_open
80returns NULL.
81.Pp
82.Fn config_close
83will free the malloced area.
84.Pp
85.Fn config_next
86returns the next entry in the area. NULL is returned to indicate End-of-file.
87The returned string is null-terminated, and
88.Sq \en
89characters (if continuation lines are enabled) are converted to
90space characters.
91.Pp
92.Fn config_skip
93returns the next word from the string
94.Fa *string
95.Li .
96.Fa *string
97will be advanced to point to the next word.
98NULL is returned to indicate the end of the string.
99.Sh FILES
100.Pa /usr/lib/libutil.a
101The name of the library these functions are part of.
102.Sh AUTHOR
103Poul-Henning Kamp <phk@login.dkuug.dk>