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