10f38d8d9SDavid E. O'Brien.\" $NetBSD: stringlist.3,v 1.5 1999/03/22 19:44:46 garbled Exp $ 24ce2d5b5SMike Smith.\" 30f38d8d9SDavid E. O'Brien.\" Copyright (c) 1997, 1999 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.\" 174ce2d5b5SMike Smith.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 184ce2d5b5SMike Smith.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 194ce2d5b5SMike Smith.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 204ce2d5b5SMike Smith.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE 214ce2d5b5SMike Smith.\" LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 224ce2d5b5SMike Smith.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 234ce2d5b5SMike Smith.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 244ce2d5b5SMike Smith.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 254ce2d5b5SMike Smith.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 264ce2d5b5SMike Smith.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 274ce2d5b5SMike Smith.\" POSSIBILITY OF SUCH DAMAGE. 284ce2d5b5SMike Smith.\" 290f38d8d9SDavid E. O'Brien.Dd November 28, 1999 304ce2d5b5SMike Smith.Dt STRINGLIST 3 31aa12cea2SUlrich Spörlein.Os 324ce2d5b5SMike Smith.Sh NAME 334ce2d5b5SMike Smith.Nm stringlist , 344ce2d5b5SMike Smith.Nm sl_init , 354ce2d5b5SMike Smith.Nm sl_add , 364ce2d5b5SMike Smith.Nm sl_free , 374ce2d5b5SMike Smith.Nm sl_find 384ce2d5b5SMike Smith.Nd stringlist manipulation functions 3925bb73e0SAlexey Zelkin.Sh LIBRARY 4025bb73e0SAlexey Zelkin.Lb libc 414ce2d5b5SMike Smith.Sh SYNOPSIS 4232eef9aeSRuslan Ermilov.In stringlist.h 434ce2d5b5SMike Smith.Ft StringList * 444ce2d5b5SMike Smith.Fn sl_init 450f38d8d9SDavid E. O'Brien.Ft int 464ce2d5b5SMike Smith.Fn sl_add "StringList *sl" "char *item" 474ce2d5b5SMike Smith.Ft void 484ce2d5b5SMike Smith.Fn sl_free "StringList *sl" "int freeall" 494ce2d5b5SMike Smith.Ft char * 50*d001beb2SEitan Adler.Fn sl_find "StringList *sl" "const char *item" 514ce2d5b5SMike Smith.Sh DESCRIPTION 524ce2d5b5SMike SmithThe 534ce2d5b5SMike Smith.Nm 544ce2d5b5SMike Smithfunctions manipulate stringlists, which are lists of 554ce2d5b5SMike Smithstrings that extend automatically if necessary. 564ce2d5b5SMike Smith.Pp 574ce2d5b5SMike SmithThe 585c564baeSRuslan Ermilov.Vt StringList 594ce2d5b5SMike Smithstructure has the following definition: 604ce2d5b5SMike Smith.Bd -literal -offset indent 614ce2d5b5SMike Smithtypedef struct _stringlist { 624ce2d5b5SMike Smith char **sl_str; 634ce2d5b5SMike Smith size_t sl_max; 644ce2d5b5SMike Smith size_t sl_cur; 654ce2d5b5SMike Smith} StringList; 664ce2d5b5SMike Smith.Ed 674ce2d5b5SMike Smith.Bl -tag -width "sl_str" -offset indent 685c564baeSRuslan Ermilov.It Va sl_str 694ce2d5b5SMike Smitha pointer to the base of the array containing the list. 705c564baeSRuslan Ermilov.It Va sl_max 714ce2d5b5SMike Smiththe size of 725c564baeSRuslan Ermilov.Va sl_str . 735c564baeSRuslan Ermilov.It Va sl_cur 744ce2d5b5SMike Smiththe offset in 755c564baeSRuslan Ermilov.Va sl_str 764ce2d5b5SMike Smithof the current element. 774ce2d5b5SMike Smith.El 784ce2d5b5SMike Smith.Pp 794ce2d5b5SMike SmithThe following stringlist manipulation functions are available: 804ce2d5b5SMike Smith.Bl -tag -width "sl_init()" 814ce2d5b5SMike Smith.It Fn sl_init 824ce2d5b5SMike SmithCreate a stringlist. 834ce2d5b5SMike SmithReturns a pointer to a 840f38d8d9SDavid E. O'Brien.Vt StringList , 850f38d8d9SDavid E. O'Brienor 860f38d8d9SDavid E. O'Brien.Dv NULL 870f38d8d9SDavid E. O'Brienin case of failure. 884ce2d5b5SMike Smith.It Fn sl_free 894ce2d5b5SMike SmithReleases memory occupied by 905c564baeSRuslan Ermilov.Fa sl 914ce2d5b5SMike Smithand the 925c564baeSRuslan Ermilov.Fa sl->sl_str 934ce2d5b5SMike Smitharray. 944ce2d5b5SMike SmithIf 955c564baeSRuslan Ermilov.Fa freeall 964ce2d5b5SMike Smithis non-zero, then each of the items within 975c564baeSRuslan Ermilov.Fa sl->sl_str 984ce2d5b5SMike Smithis released as well. 994ce2d5b5SMike Smith.It Fn sl_add 1004ce2d5b5SMike SmithAdd 1015c564baeSRuslan Ermilov.Fa item 1024ce2d5b5SMike Smithto 1035c564baeSRuslan Ermilov.Fa sl->sl_str 1044ce2d5b5SMike Smithat 1055c564baeSRuslan Ermilov.Fa sl->sl_cur , 1064ce2d5b5SMike Smithextending the size of 1070f38d8d9SDavid E. O'Brien.Fa sl->sl_str . 108522ccf3fSRuslan ErmilovReturns zero upon success, \-1 upon failure. 1094ce2d5b5SMike Smith.It Fn sl_find 1104ce2d5b5SMike SmithFind 1115c564baeSRuslan Ermilov.Fa item 1124ce2d5b5SMike Smithin 1135c564baeSRuslan Ermilov.Fa sl , 11436a142c4SRuslan Ermilovreturning NULL if it is not found. 1154ce2d5b5SMike Smith.El 1164ce2d5b5SMike Smith.Sh SEE ALSO 1174ce2d5b5SMike Smith.Xr free 3 , 1184ce2d5b5SMike Smith.Xr malloc 3 1190f38d8d9SDavid E. O'Brien.Sh HISTORY 1200f38d8d9SDavid E. O'BrienThe 1210f38d8d9SDavid E. O'Brien.Nm 1220f38d8d9SDavid E. O'Brienfunctions appeared in 1230f38d8d9SDavid E. O'Brien.Fx 2.2.6 1240f38d8d9SDavid E. O'Brienand 1250f38d8d9SDavid E. O'Brien.Nx 1.3 . 126