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