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