]>
Commit | Line | Data |
---|---|---|
3248e962 | 1 | /* |
b8ae064d | 2 | * Copyright (C) 1996-2023 The Squid Software Foundation and contributors |
3248e962 CT |
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" | |
675b8408 | 14 | #include "debug/Stream.h" |
83b053a0 | 15 | #include "error/Error.h" |
3248e962 CT |
16 | #include "fatal.h" |
17 | #include "wordlist.h" | |
18 | ||
19 | bool | |
20 | ACLSquidErrorData::match(err_type err) | |
21 | { | |
22 | CbDataListIterator<err_type> iter(errors); | |
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 | ||
33 | SBufList | |
34 | ACLSquidErrorData::dump() const | |
35 | { | |
36 | SBufList sl; | |
37 | CbDataListIterator<err_type> iter(errors); | |
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 | |
48 | ACLSquidErrorData::parse() | |
49 | { | |
1dc0221b | 50 | while (const auto token = ConfigParser::strtokFile()) { |
3248e962 CT |
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 | |
64 | ACLSquidErrorData::empty() const | |
65 | { | |
66 | return errors.empty(); | |
67 | } | |
68 |