1236769Sobrien/* $NetBSD: strlist.h,v 1.3 2009/01/16 21:15:34 dsl Exp $ */ 2236769Sobrien 3236769Sobrien/*- 4236769Sobrien * Copyright (c) 2008 - 2009 The NetBSD Foundation, Inc. 5236769Sobrien * All rights reserved. 6236769Sobrien * 7236769Sobrien * This code is derived from software contributed to The NetBSD Foundation 8236769Sobrien * by David Laight. 9236769Sobrien * 10236769Sobrien * Redistribution and use in source and binary forms, with or without 11236769Sobrien * modification, are permitted provided that the following conditions 12236769Sobrien * are met: 13236769Sobrien * 1. Redistributions of source code must retain the above copyright 14236769Sobrien * notice, this list of conditions and the following disclaimer. 15236769Sobrien * 2. Redistributions in binary form must reproduce the above copyright 16236769Sobrien * notice, this list of conditions and the following disclaimer in the 17236769Sobrien * documentation and/or other materials provided with the distribution. 18236769Sobrien * 3. Neither the name of The NetBSD Foundation nor the names of its 19236769Sobrien * contributors may be used to endorse or promote products derived 20236769Sobrien * from this software without specific prior written permission. 21236769Sobrien * 22236769Sobrien * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 23236769Sobrien * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 24236769Sobrien * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 25236769Sobrien * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 26236769Sobrien * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 27236769Sobrien * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 28236769Sobrien * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 29236769Sobrien * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 30236769Sobrien * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 31236769Sobrien * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 32236769Sobrien * POSSIBILITY OF SUCH DAMAGE. 33236769Sobrien */ 34236769Sobrien 35236769Sobrien#ifndef _STRLIST_H 36236769Sobrien#define _STRLIST_H 37236769Sobrien 38236769Sobrientypedef struct { 39236769Sobrien char *si_str; 40236769Sobrien unsigned int si_info; 41236769Sobrien} strlist_item_t; 42236769Sobrien 43236769Sobrientypedef struct { 44236769Sobrien unsigned int sl_num; 45236769Sobrien unsigned int sl_max; 46236769Sobrien strlist_item_t *sl_items; 47236769Sobrien} strlist_t; 48236769Sobrien 49236769Sobrienvoid strlist_init(strlist_t *); 50236769Sobrienvoid strlist_clean(strlist_t *); 51236769Sobrienvoid strlist_add_str(strlist_t *, char *, unsigned int); 52236769Sobrien 53236769Sobrien#define strlist_num(sl) ((sl)->sl_num) 54236769Sobrien#define strlist_str(sl, n) ((sl)->sl_items[n].si_str) 55236769Sobrien#define strlist_info(sl, n) ((sl)->sl_items[n].si_info) 56236769Sobrien#define strlist_set_info(sl, n, v) ((void)((sl)->sl_items[n].si_info = (v))) 57236769Sobrien 58236769Sobrien#define STRLIST_FOREACH(v, sl, index) \ 59236769Sobrien if ((sl)->sl_items != NULL) \ 60236769Sobrien for (index = 0; (v = strlist_str(sl, index)) != NULL; index++) 61236769Sobrien 62236769Sobrien#endif /* _STRLIST_H */ 63