Imported Upstream version 2.1.9
[platform/upstream/gpg2.git] / common / strlist.h
1 /* strlist.h
2  *      Copyright (C) 1998, 2000, 2001, 2006 Free Software Foundation, Inc.
3  *
4  * This file is part of GnuPG.
5  *
6  * GnuPG is free software; you can redistribute it and/or modify it
7  * under the terms of either
8  *
9  *   - the GNU Lesser General Public License as published by the Free
10  *     Software Foundation; either version 3 of the License, or (at
11  *     your option) any later version.
12  *
13  * or
14  *
15  *   - the GNU General Public License as published by the Free
16  *     Software Foundation; either version 2 of the License, or (at
17  *     your option) any later version.
18  *
19  * or both in parallel, as here.
20  *
21  * GnuPG is distributed in the hope that it will be useful, but
22  * WITHOUT ANY WARRANTY; without even the implied warranty of
23  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
24  * General Public License for more details.
25  *
26  * You should have received a copies of the GNU General Public License
27  * and the GNU Lesser General Public License along with this program;
28  * if not, see <http://www.gnu.org/licenses/>.
29  */
30
31 #ifndef GNUPG_COMMON_STRLIST_H
32 #define GNUPG_COMMON_STRLIST_H
33
34 struct string_list
35 {
36   struct string_list *next;
37   unsigned int flags;
38   char d[1];
39 };
40 typedef struct string_list *strlist_t;
41
42 void    free_strlist (strlist_t sl);
43 strlist_t add_to_strlist (strlist_t *list, const char *string);
44 strlist_t add_to_strlist_try (strlist_t *list, const char *string);
45
46 strlist_t add_to_strlist2( strlist_t *list, const char *string, int is_utf8);
47
48 strlist_t append_to_strlist (strlist_t *list, const char *string);
49 strlist_t append_to_strlist2 (strlist_t *list, const char *string,
50                               int is_utf8);
51
52 strlist_t strlist_copy (strlist_t list);
53
54 strlist_t strlist_prev (strlist_t head, strlist_t node);
55 strlist_t strlist_last (strlist_t node);
56 char * strlist_pop (strlist_t *list);
57
58 strlist_t strlist_find (strlist_t haystack, const char *needle);
59 int strlist_length (strlist_t list);
60
61
62 #define FREE_STRLIST(a) do { free_strlist((a)); (a) = NULL ; } while(0)
63
64
65 #endif /*GNUPG_COMMON_STRLIST_H*/