]>
Commit | Line | Data |
---|---|---|
d295d770 | 1 | /* |
bbc27441 | 2 | * Copyright (C) 1996-2014 The Squid Software Foundation and contributors |
d295d770 | 3 | * |
bbc27441 AJ |
4 | * Squid software is distributed under GPLv2+ license and includes |
5 | * contributions from numerous individuals and organizations. | |
6 | * Please see the COPYING and CONTRIBUTORS files for details. | |
d295d770 | 7 | */ |
8 | ||
bbc27441 AJ |
9 | /* DEBUG: section 03 Configuration File Parsing */ |
10 | ||
f7f3304a | 11 | #include "squid.h" |
d295d770 | 12 | #include "MemBuf.h" |
602d9612 | 13 | #include "wordlist.h" |
d295d770 | 14 | |
15 | void | |
16 | wordlistDestroy(wordlist ** list) | |
17 | { | |
18 | wordlist *w = NULL; | |
19 | ||
20 | while ((w = *list) != NULL) { | |
21 | *list = w->next; | |
22 | safe_free(w->key); | |
23 | delete w; | |
24 | } | |
25 | ||
26 | *list = NULL; | |
27 | } | |
28 | ||
29 | const char * | |
30 | wordlistAdd(wordlist ** list, const char *key) | |
31 | { | |
32 | while (*list) | |
33 | list = &(*list)->next; | |
34 | ||
35 | *list = new wordlist; | |
36 | ||
37 | (*list)->key = xstrdup(key); | |
38 | ||
39 | (*list)->next = NULL; | |
40 | ||
41 | return (*list)->key; | |
42 | } | |
43 | ||
44 | void | |
45 | wordlistJoin(wordlist ** list, wordlist ** wl) | |
46 | { | |
47 | while (*list) | |
48 | list = &(*list)->next; | |
49 | ||
50 | *list = *wl; | |
51 | ||
52 | *wl = NULL; | |
53 | } | |
54 | ||
55 | void | |
56 | wordlistAddWl(wordlist ** list, wordlist * wl) | |
57 | { | |
58 | while (*list) | |
59 | list = &(*list)->next; | |
60 | ||
61 | for (; wl; wl = wl->next, list = &(*list)->next) { | |
62 | *list = new wordlist(); | |
63 | (*list)->key = xstrdup(wl->key); | |
64 | (*list)->next = NULL; | |
65 | } | |
66 | } | |
67 | ||
68 | void | |
69 | wordlistCat(const wordlist * w, MemBuf * mb) | |
70 | { | |
71 | while (NULL != w) { | |
72 | mb->Printf("%s\n", w->key); | |
73 | w = w->next; | |
74 | } | |
75 | } | |
76 | ||
77 | wordlist * | |
78 | wordlistDup(const wordlist * w) | |
79 | { | |
80 | wordlist *D = NULL; | |
81 | ||
82 | while (NULL != w) { | |
83 | wordlistAdd(&D, w->key); | |
84 | w = w->next; | |
85 | } | |
86 | ||
87 | return D; | |
88 | } | |
514fc315 FC |
89 | |
90 | SBufList | |
91 | ToSBufList(wordlist *wl) | |
92 | { | |
93 | SBufList rv; | |
94 | while (wl != NULL) { | |
95 | rv.push_back(SBuf(wl->key)); | |
96 | wl = wl->next; | |
97 | } | |
98 | return rv; | |
99 | } | |
f53969cc | 100 |