xref: /dragonfly/lib/libutil/property.3 (revision 6b5c5d0d)
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.\" $FreeBSD: src/lib/libutil/property.3,v 1.8.2.7 2001/12/17 10:08:32 ru Exp $
27.\" $DragonFly: src/lib/libutil/property.3,v 1.5 2007/05/13 22:25:41 swildner Exp $
28.\" "
29.Dd October 7, 1998
30.Os
31.Dt PROPERTIES 3
32.Sh NAME
33.Nm properties_read ,
34.Nm property_find ,
35.Nm properties_free
36.Nd "functions to allow creating simple property lists from ASCII file data"
37.Sh LIBRARY
38.Lb libutil
39.Sh SYNOPSIS
40.In sys/types.h
41.In libutil.h
42.Ft properties
43.Fn properties_read "int fd"
44.Ft char *
45.Fn property_find "properties list" "const char *name"
46.Ft void
47.Fn properties_free "properties list"
48.Sh DESCRIPTION
49.Bd -literal
50typedef struct _properties {
51	struct _properties *next;
52	char *name;
53	char *value;
54} *properties;
55.Ed
56.Pp
57The function
58.Fn properties_read
59reads
60.Fa name = value
61pairs from the file descriptor passed in
62.Fa fd
63and returns the head of a new property list, assuming that the
64file's contents have been parsed properly, or NULL in case
65of error.
66.Pp
67.Fn property_find
68Returns the associated value string for the property named
69.Fa name
70if found, otherwise NULL.  The value returned may be up to
71.Dv PROPERTY_MAX_VALUE
72bytes in length.
73.Pp
74.Fn properties_free
75is used to free the structure returned by
76.Fn properties_read
77when it is no longer needed.
78.Sh FILE FORMAT
79Each property in the file is assumed to have the format of
80.Fa name = value
81where
82.Fa name
83is an alphanumeric string (and any punctuation not including the `=' character)
84and
85.Fa value
86is an arbitrary string of text terminated by a newline character.  If newlines
87are desired, the entire value should be enclosed in { } (curly-bracket)
88characters.  Any line beginning with a # or ; character is assumed to
89be a comment and will be ignored.
90.Sh SEE ALSO
91.Xr auth_getval 3
92.Sh AUTHORS
93.An Jordan Hubbard
94.Sh BUGS
95Simplistic.
96