SquidErrorData.cc
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1996-2021 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 #include "squid.h"
10 #include "acl/Data.h"
11 #include "acl/SquidErrorData.h"
12 #include "cache_cf.h"
13 #include "ConfigParser.h"
14 #include "Debug.h"
15 #include "error/Error.h"
16 #include "fatal.h"
17 #include "wordlist.h"
18 
19 bool
21 {
23  while (!iter.end()) {
24  err_type localErr = iter.next();
25  debugs(28, 4, "check (" << err << "):" << errorTypeName(err) << " against " << errorTypeName(localErr));
26  if (err == localErr)
27  return true;
28  }
29 
30  return false;
31 }
32 
35 {
36  SBufList sl;
38  while (!iter.end()) {
39  err_type err = iter.next();
40  const char *errName = errorTypeName(err);
41  sl.push_back(SBuf(errName));
42  }
43 
44  return sl;
45 }
46 
47 void
49 {
50  while (const auto token = ConfigParser::strtokFile()) {
51  err_type err = errorTypeByName(token);
52 
53  if (err < ERR_MAX)
54  errors.push_back(err);
55  else {
56  debugs(28, DBG_CRITICAL, "FATAL: Invalid squid error name");
57  if (!opt_parse_cfg_only)
58  self_destruct();
59  }
60  }
61 }
62 
63 bool
65 {
66  return errors.empty();
67 }
68 
virtual void parse()
static char * strtokFile()
Definition: ConfigParser.cc:63
std::list< SBuf > SBufList
Definition: forward.h:22
Definition: SBuf.h:87
CbDataList< C > * push_back(C const &)
Definition: CbDataList.h:160
#define DBG_CRITICAL
Definition: Debug.h:40
err_type
Definition: forward.h:14
void self_destruct(void)
Definition: cache_cf.cc:275
const char * errorTypeName(err_type err)
Definition: Error.h:53
#define debugs(SECTION, LEVEL, CONTENT)
Definition: Debug.h:123
virtual bool empty() const
err_type errorTypeByName(const char *name)
Definition: Error.h:43
const C & next()
Definition: CbDataList.h:55
@ ERR_MAX
Definition: forward.h:88
bool empty() const
Definition: CbDataList.h:193
int opt_parse_cfg_only
CbDataListContainer< err_type > errors
virtual bool match(err_type err)
virtual SBufList dump() const

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors