1/* GNU gettext - internationalization aids 2 Copyright (C) 1995-1996, 1998, 2000-2004 Free Software Foundation, Inc. 3 4 This file was written by Peter Miller <millerp@canb.auug.org.au> 5 6 This program is free software; you can redistribute it and/or modify 7 it under the terms of the GNU General Public License as published by 8 the Free Software Foundation; either version 2, or (at your option) 9 any later version. 10 11 This program is distributed in the hope that it will be useful, 12 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 GNU General Public License for more details. 15 16 You should have received a copy of the GNU General Public License 17 along with this program; if not, write to the Free Software Foundation, 18 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ 19 20#ifndef _STR_LIST_H 21#define _STR_LIST_H 1 22 23/* Get size_t and NULL. */ 24#include <stddef.h> 25 26/* Get bool. */ 27#include <stdbool.h> 28 29 30#ifdef __cplusplus 31extern "C" { 32#endif 33 34 35/* Type describing list of immutable strings, 36 implemented using a dynamic array. */ 37typedef struct string_list_ty string_list_ty; 38struct string_list_ty 39{ 40 const char **item; 41 size_t nitems; 42 size_t nitems_max; 43}; 44 45/* Initialize an empty list of strings. */ 46extern void string_list_init (string_list_ty *slp); 47 48/* Return a fresh, empty list of strings. */ 49extern string_list_ty *string_list_alloc (void); 50 51/* Append a single string to the end of a list of strings. */ 52extern void string_list_append (string_list_ty *slp, const char *s); 53 54/* Append a single string to the end of a list of strings, unless it is 55 already contained in the list. */ 56extern void string_list_append_unique (string_list_ty *slp, const char *s); 57 58/* Destroy a list of strings. */ 59extern void string_list_destroy (string_list_ty *slp); 60 61/* Free a list of strings. */ 62extern void string_list_free (string_list_ty *slp); 63 64/* Return a freshly allocated string obtained by concatenating all the 65 strings in the list. */ 66extern char *string_list_concat (const string_list_ty *slp); 67 68/* Return a freshly allocated string obtained by concatenating all the 69 strings in the list, and destroy the list. */ 70extern char *string_list_concat_destroy (string_list_ty *slp); 71 72/* Return a freshly allocated string obtained by concatenating all the 73 strings in the list, separated by the separator character, terminated 74 by the terminator character. The terminator character is not added if 75 drop_redundant_terminator is true and the last string already ends with 76 the terminator. */ 77extern char *string_list_join (const string_list_ty *slp, char separator, 78 char terminator, bool drop_redundant_terminator); 79 80/* Return 1 if s is contained in the list of strings, 0 otherwise. */ 81extern bool string_list_member (const string_list_ty *slp, const char *s); 82 83 84#ifdef __cplusplus 85} 86#endif 87 88 89#endif /* _STR_LIST_H */ 90