14ce2d5b5SMike Smith.\" $NetBSD: stringlist.3,v 1.2 1997/04/09 08:59:25 kleink Exp $ 24ce2d5b5SMike Smith.\" 34ce2d5b5SMike Smith.\" Copyright (c) 1997 The NetBSD Foundation, Inc. 44ce2d5b5SMike Smith.\" All rights reserved. 54ce2d5b5SMike Smith.\" 64ce2d5b5SMike Smith.\" This file was contributed to The NetBSD Foundation by Luke Mewburn. 74ce2d5b5SMike Smith.\" 84ce2d5b5SMike Smith.\" Redistribution and use in source and binary forms, with or without 94ce2d5b5SMike Smith.\" modification, are permitted provided that the following conditions 104ce2d5b5SMike Smith.\" are met: 114ce2d5b5SMike Smith.\" 1. Redistributions of source code must retain the above copyright 124ce2d5b5SMike Smith.\" notice, this list of conditions and the following disclaimer. 134ce2d5b5SMike Smith.\" 2. Redistributions in binary form must reproduce the above copyright 144ce2d5b5SMike Smith.\" notice, this list of conditions and the following disclaimer in the 154ce2d5b5SMike Smith.\" documentation and/or other materials provided with the distribution. 164ce2d5b5SMike Smith.\" 3. All advertising materials mentioning features or use of this software 174ce2d5b5SMike Smith.\" must display the following acknowledgement: 184ce2d5b5SMike Smith.\" This product includes software developed by the NetBSD 194ce2d5b5SMike Smith.\" Foundation, Inc. and its contributors. 204ce2d5b5SMike Smith.\" 4. Neither the name of The NetBSD Foundation nor the names of its 214ce2d5b5SMike Smith.\" contributors may be used to endorse or promote products derived 224ce2d5b5SMike Smith.\" from this software without specific prior written permission. 234ce2d5b5SMike Smith.\" 244ce2d5b5SMike Smith.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 254ce2d5b5SMike Smith.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 264ce2d5b5SMike Smith.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 274ce2d5b5SMike Smith.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE 284ce2d5b5SMike Smith.\" LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 294ce2d5b5SMike Smith.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 304ce2d5b5SMike Smith.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 314ce2d5b5SMike Smith.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 324ce2d5b5SMike Smith.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 334ce2d5b5SMike Smith.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 344ce2d5b5SMike Smith.\" POSSIBILITY OF SUCH DAMAGE. 354ce2d5b5SMike Smith.\" 367f3dea24SPeter Wemm.\" $FreeBSD$ 37fbc400a6SNik Clayton.\" 384ce2d5b5SMike Smith.Dd February 24, 1997 39a307d598SRuslan Ermilov.Os 404ce2d5b5SMike Smith.Dt STRINGLIST 3 414ce2d5b5SMike Smith.Sh NAME 424ce2d5b5SMike Smith.Nm stringlist , 434ce2d5b5SMike Smith.Nm sl_init , 444ce2d5b5SMike Smith.Nm sl_add , 454ce2d5b5SMike Smith.Nm sl_free , 464ce2d5b5SMike Smith.Nm sl_find 474ce2d5b5SMike Smith.Nd stringlist manipulation functions 4825bb73e0SAlexey Zelkin.Sh LIBRARY 4925bb73e0SAlexey Zelkin.Lb libc 504ce2d5b5SMike Smith.Sh SYNOPSIS 5132eef9aeSRuslan Ermilov.In stringlist.h 524ce2d5b5SMike Smith.Ft StringList * 534ce2d5b5SMike Smith.Fn sl_init 544ce2d5b5SMike Smith.Ft void 554ce2d5b5SMike Smith.Fn sl_add "StringList *sl" "char *item" 564ce2d5b5SMike Smith.Ft void 574ce2d5b5SMike Smith.Fn sl_free "StringList *sl" "int freeall" 584ce2d5b5SMike Smith.Ft char * 594ce2d5b5SMike Smith.Fn sl_find "StringList *sl" "char *item" 604ce2d5b5SMike Smith.Sh DESCRIPTION 614ce2d5b5SMike SmithThe 624ce2d5b5SMike Smith.Nm 634ce2d5b5SMike Smithfunctions manipulate stringlists, which are lists of 644ce2d5b5SMike Smithstrings that extend automatically if necessary. 654ce2d5b5SMike Smith.Pp 664ce2d5b5SMike SmithThe 674ce2d5b5SMike Smith.Ar StringList 684ce2d5b5SMike Smithstructure has the following definition: 694ce2d5b5SMike Smith.Bd -literal -offset indent 704ce2d5b5SMike Smithtypedef struct _stringlist { 714ce2d5b5SMike Smith char **sl_str; 724ce2d5b5SMike Smith size_t sl_max; 734ce2d5b5SMike Smith size_t sl_cur; 744ce2d5b5SMike Smith} StringList; 754ce2d5b5SMike Smith.Ed 764ce2d5b5SMike Smith.Pp 774ce2d5b5SMike Smith.Bl -tag -width "sl_str" -offset indent 784ce2d5b5SMike Smith.It Ar sl_str 794ce2d5b5SMike Smitha pointer to the base of the array containing the list. 804ce2d5b5SMike Smith.It Ar sl_max 814ce2d5b5SMike Smiththe size of 824ce2d5b5SMike Smith.Ar sl_str . 834ce2d5b5SMike Smith.It Ar sl_cur 844ce2d5b5SMike Smiththe offset in 854ce2d5b5SMike Smith.Ar sl_str 864ce2d5b5SMike Smithof the current element. 874ce2d5b5SMike Smith.El 884ce2d5b5SMike Smith.Pp 894ce2d5b5SMike SmithThe following stringlist manipulation functions are available: 904ce2d5b5SMike Smith.Bl -tag -width "sl_init()" 914ce2d5b5SMike Smith.It Fn sl_init 924ce2d5b5SMike SmithCreate a stringlist. 934ce2d5b5SMike SmithReturns a pointer to a 944ce2d5b5SMike Smith.Ar StringList . 954ce2d5b5SMike Smith.It Fn sl_free 964ce2d5b5SMike SmithReleases memory occupied by 974ce2d5b5SMike Smith.Ar sl 984ce2d5b5SMike Smithand the 994ce2d5b5SMike Smith.Ar sl->sl_str 1004ce2d5b5SMike Smitharray. 1014ce2d5b5SMike SmithIf 1024ce2d5b5SMike Smith.Ar freeall 1034ce2d5b5SMike Smithis non-zero, then each of the items within 1044ce2d5b5SMike Smith.Ar sl->sl_str 1054ce2d5b5SMike Smithis released as well. 1064ce2d5b5SMike Smith.It Fn sl_add 1074ce2d5b5SMike SmithAdd 1084ce2d5b5SMike Smith.Ar item 1094ce2d5b5SMike Smithto 1104ce2d5b5SMike Smith.Ar sl->sl_str 1114ce2d5b5SMike Smithat 1124ce2d5b5SMike Smith.Ar sl->sl_cur , 1134ce2d5b5SMike Smithextending the size of 1144ce2d5b5SMike Smith.Ar sl->sl_str 1154ce2d5b5SMike Smith.It Fn sl_find 1164ce2d5b5SMike SmithFind 1174ce2d5b5SMike Smith.Ar item 1184ce2d5b5SMike Smithin 1194ce2d5b5SMike Smith.Ar sl , 1204ce2d5b5SMike Smithreturning NULL if it's not found. 1214ce2d5b5SMike Smith.El 1224ce2d5b5SMike Smith.Sh SEE ALSO 1234ce2d5b5SMike Smith.Xr free 3 , 1244ce2d5b5SMike Smith.Xr malloc 3 125