xref: /freebsd/lib/libutil/property.3 (revision fa9896e082a1046ff4fbc75fcba4d18d1f2efc19)
13b29c892SJordan K. Hubbard.\"
23b29c892SJordan K. Hubbard.\" Copyright (c) 1998 Jordan Hubbard
33b29c892SJordan K. Hubbard.\"
43b29c892SJordan K. Hubbard.\" All rights reserved.
53b29c892SJordan K. Hubbard.\"
63b29c892SJordan K. Hubbard.\" Redistribution and use in source and binary forms, with or without
73b29c892SJordan K. Hubbard.\" modification, are permitted provided that the following conditions
83b29c892SJordan K. Hubbard.\" are met:
93b29c892SJordan K. Hubbard.\" 1. Redistributions of source code must retain the above copyright
103b29c892SJordan K. Hubbard.\"    notice, this list of conditions and the following disclaimer.
113b29c892SJordan K. Hubbard.\" 2. Redistributions in binary form must reproduce the above copyright
123b29c892SJordan K. Hubbard.\"    notice, this list of conditions and the following disclaimer in the
133b29c892SJordan K. Hubbard.\"    documentation and/or other materials provided with the distribution.
143b29c892SJordan K. Hubbard.\"
153b29c892SJordan K. Hubbard.\" THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY EXPRESS OR
163b29c892SJordan K. Hubbard.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
173b29c892SJordan K. Hubbard.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
183b29c892SJordan K. Hubbard.\" IN NO EVENT SHALL THE DEVELOPERS BE LIABLE FOR ANY DIRECT, INDIRECT,
193b29c892SJordan K. Hubbard.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
203b29c892SJordan K. Hubbard.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
213b29c892SJordan K. Hubbard.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
223b29c892SJordan K. Hubbard.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
233b29c892SJordan K. Hubbard.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
243b29c892SJordan K. Hubbard.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
253b29c892SJordan K. Hubbard.\" "
263b29c892SJordan K. Hubbard.Dd October 7, 1998
2774804d58SMike Pritchard.Dt PROPERTIES 3
28aa12cea2SUlrich Spörlein.Os
293b29c892SJordan K. Hubbard.Sh NAME
303b29c892SJordan K. Hubbard.Nm properties_read ,
31799162a6SJoel Dahl.Nm property_find ,
323b29c892SJordan K. Hubbard.Nm properties_free
33f167d7fbSSheldon Hearn.Nd "functions to allow creating simple property lists from ASCII file data"
343dc329d1SAlexey Zelkin.Sh LIBRARY
353dc329d1SAlexey Zelkin.Lb libutil
363b29c892SJordan K. Hubbard.Sh SYNOPSIS
3732eef9aeSRuslan Ermilov.In libutil.h
383b29c892SJordan K. Hubbard.Ft properties
39475ae25aSJordan K. Hubbard.Fn properties_read "int fd"
403b29c892SJordan K. Hubbard.Ft char *
4119ee2ea5SBruce Evans.Fn property_find "properties list" "const char *name"
423b29c892SJordan K. Hubbard.Ft void
433b29c892SJordan K. Hubbard.Fn properties_free "properties list"
443b29c892SJordan K. Hubbard.Sh DESCRIPTION
45726b61abSRuslan Ermilov.Bd -literal
463b29c892SJordan K. Hubbardtypedef struct _properties {
473b29c892SJordan K. Hubbard	struct _properties *next;
483b29c892SJordan K. Hubbard	char *name;
493b29c892SJordan K. Hubbard	char *value;
503b29c892SJordan K. Hubbard} *properties;
51726b61abSRuslan Ermilov.Ed
52726b61abSRuslan Ermilov.Pp
533b29c892SJordan K. HubbardThe function
543b29c892SJordan K. Hubbard.Fn properties_read
553b29c892SJordan K. Hubbardreads
563b29c892SJordan K. Hubbard.Fa name = value
57475ae25aSJordan K. Hubbardpairs from the file descriptor passed in
58475ae25aSJordan K. Hubbard.Fa fd
593b29c892SJordan K. Hubbardand returns the head of a new property list, assuming that the
603b29c892SJordan K. Hubbardfile's contents have been parsed properly, or NULL in case
61efbcb4aeSJordan K. Hubbardof error.
623b29c892SJordan K. Hubbard.Pp
630552350eSPhilippe CharnierThe
643b29c892SJordan K. Hubbard.Fn property_find
650552350eSPhilippe Charnierfunction returns the associated value string for the property named
663b29c892SJordan K. Hubbard.Fa name
671a0a9345SRuslan Ermilovif found, otherwise NULL.
681a0a9345SRuslan ErmilovThe value returned may be up to
69f9f81f78SMurray Stokely.Dv PROPERTY_MAX_VALUE
70f9f81f78SMurray Stokelybytes in length.
713b29c892SJordan K. Hubbard.Pp
720552350eSPhilippe CharnierThe
733b29c892SJordan K. Hubbard.Fn properties_free
740552350eSPhilippe Charnierfunction is used to free the structure returned by
753b29c892SJordan K. Hubbard.Fn properties_read
763b29c892SJordan K. Hubbardwhen it is no longer needed.
77efbcb4aeSJordan K. Hubbard.Sh FILE FORMAT
78efbcb4aeSJordan K. HubbardEach property in the file is assumed to have the format of
79efbcb4aeSJordan K. Hubbard.Fa name = value
80efbcb4aeSJordan K. Hubbardwhere
81efbcb4aeSJordan K. Hubbard.Fa name
82efbcb4aeSJordan K. Hubbardis an alphanumeric string (and any punctuation not including the `=' character)
83efbcb4aeSJordan K. Hubbardand
84efbcb4aeSJordan K. Hubbard.Fa value
85*f6ac2391SJoel Dahlis an arbitrary string of text terminated by a newline character.
861a0a9345SRuslan ErmilovIf newlines
87efbcb4aeSJordan K. Hubbardare desired, the entire value should be enclosed in { } (curly-bracket)
881a0a9345SRuslan Ermilovcharacters.
891a0a9345SRuslan ErmilovAny line beginning with a # or ; character is assumed to
90efbcb4aeSJordan K. Hubbardbe a comment and will be ignored.
9174804d58SMike Pritchard.Sh AUTHORS
9274804d58SMike Pritchard.An Jordan Hubbard
9324a0682cSRuslan Ermilov.Sh BUGS
9424a0682cSRuslan ErmilovSimplistic.
95