xref: /freebsd/lib/libutil/property.3 (revision 2e3f49888ec8851bafb22011533217487764fdb0)
1.\"
2.\" Copyright (c) 1998 Jordan Hubbard
3.\"
4.\" All rights reserved.
5.\"
6.\" Redistribution and use in source and binary forms, with or without
7.\" modification, are permitted provided that the following conditions
8.\" are met:
9.\" 1. Redistributions of source code must retain the above copyright
10.\"    notice, this list of conditions and the following disclaimer.
11.\" 2. Redistributions in binary form must reproduce the above copyright
12.\"    notice, this list of conditions and the following disclaimer in the
13.\"    documentation and/or other materials provided with the distribution.
14.\"
15.\" THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY EXPRESS OR
16.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18.\" IN NO EVENT SHALL THE DEVELOPERS BE LIABLE FOR ANY DIRECT, INDIRECT,
19.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25.\" "
26.Dd October 7, 1998
27.Dt PROPERTIES 3
28.Os
29.Sh NAME
30.Nm properties_read ,
31.Nm property_find ,
32.Nm properties_free
33.Nd "functions to allow creating simple property lists from ASCII file data"
34.Sh LIBRARY
35.Lb libutil
36.Sh SYNOPSIS
37.In libutil.h
38.Ft properties
39.Fn properties_read "int fd"
40.Ft char *
41.Fn property_find "properties list" "const char *name"
42.Ft void
43.Fn properties_free "properties list"
44.Sh DESCRIPTION
45.Bd -literal
46typedef struct _properties {
47	struct _properties *next;
48	char *name;
49	char *value;
50} *properties;
51.Ed
52.Pp
53The function
54.Fn properties_read
55reads
56.Fa name = value
57pairs from the file descriptor passed in
58.Fa fd
59and returns the head of a new property list, assuming that the
60file's contents have been parsed properly, or NULL in case
61of error.
62.Pp
63The
64.Fn property_find
65function returns the associated value string for the property named
66.Fa name
67if found, otherwise NULL.
68The value returned may be up to
69.Dv PROPERTY_MAX_VALUE
70bytes in length.
71.Pp
72The
73.Fn properties_free
74function is used to free the structure returned by
75.Fn properties_read
76when it is no longer needed.
77.Sh FILE FORMAT
78Each property in the file is assumed to have the format of
79.Fa name = value
80where
81.Fa name
82is an alphanumeric string (and any punctuation not including the `=' character)
83and
84.Fa value
85is an arbitrary string of text terminated by a newline character.
86If newlines
87are desired, the entire value should be enclosed in { } (curly-bracket)
88characters.
89Any line beginning with a # or ; character is assumed to
90be a comment and will be ignored.
91.Sh AUTHORS
92.An Jordan Hubbard
93.Sh BUGS
94Simplistic.
95