wordlist.cc
Go to the documentation of this file.
1/*
2 * Copyright (C) 1996-2022 The Squid Software Foundation and contributors
3 *
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.
7 */
8
9/* DEBUG: section 03 Configuration File Parsing */
10
11#include "squid.h"
12#include "MemBuf.h"
13#include "wordlist.h"
14
15void
17{
18 while (*list != nullptr) {
19 const char *k = wordlistChopHead(list);
20 safe_free(k);
21 }
23
24const char *
25wordlistAdd(wordlist ** list, const char *key)
26{
27 while (*list)
28 list = &(*list)->next;
29
30 *list = new wordlist(key);
31 return (*list)->key;
32}
33
34void
35wordlistCat(const wordlist * w, MemBuf * mb)
36{
37 while (nullptr != w) {
38 mb->appendf("%s\n", w->key);
39 w = w->next;
40 }
41}
42
45{
46 SBufList rv;
47 while (wl != nullptr) {
48 rv.push_back(SBuf(wl->key));
49 wl = wl->next;
50 }
51 return rv;
52}
53
54char *
56{
57 if (*wl == nullptr)
58 return nullptr;
59
60 wordlist *w = *wl;
61 char *rv = w->key;
62 *wl = w->next;
63 delete w;
64 return rv;
65}
66
Definition: MemBuf.h:24
void appendf(const char *fmt,...) PRINTF_FORMAT_ARG2
Append operation with printf-style arguments.
Definition: Packable.h:61
Definition: SBuf.h:94
char * key
Definition: wordlist.h:32
wordlist * next
Definition: wordlist.h:33
std::list< SBuf > SBufList
Definition: forward.h:23
SBufList ToSBufList(wordlist *wl)
convert a wordlist to a SBufList
Definition: wordlist.cc:44
const char * wordlistAdd(wordlist **list, const char *key)
Definition: wordlist.cc:25
void wordlistDestroy(wordlist **list)
destroy a wordlist
Definition: wordlist.cc:16
char * wordlistChopHead(wordlist **wl)
Definition: wordlist.cc:55
void wordlistCat(const wordlist *w, MemBuf *mb)
Definition: wordlist.cc:35
#define safe_free(x)
Definition: xalloc.h:73

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors