]> git.ipfire.org Git - thirdparty/squid.git/blob - src/acl/SslErrorData.cc
SourceFormat Enforcement
[thirdparty/squid.git] / src / acl / SslErrorData.cc
1 /*
2 * Copyright (C) 1996-2014 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/Checklist.h"
11 #include "acl/SslErrorData.h"
12 #include "cache_cf.h"
13 #include "wordlist.h"
14
15 ACLSslErrorData::ACLSslErrorData() : values (NULL)
16 {}
17
18 ACLSslErrorData::ACLSslErrorData(ACLSslErrorData const &old) : values (NULL)
19 {
20 assert (!old.values);
21 }
22
23 ACLSslErrorData::~ACLSslErrorData()
24 {
25 if (values)
26 delete values;
27 }
28
29 bool
30 ACLSslErrorData::match(const Ssl::CertErrors *toFind)
31 {
32 for (const Ssl::CertErrors *err = toFind; err; err = err->next ) {
33 if (values->findAndTune(err->element.code))
34 return true;
35 }
36 return false;
37 }
38
39 /* explicit instantiation required for some systems */
40 /** \cond AUTODOCS_IGNORE */
41 // AYJ: 2009-05-20 : Removing. clashes with template <int> instantiation for other ACLs.
42 // template cbdata_type Ssl::Errors::CBDATA_CbDataList;
43 /** \endcond */
44
45 SBufList
46 ACLSslErrorData::dump() const
47 {
48 SBufList sl;
49 Ssl::Errors *data = values;
50 while (data != NULL) {
51 sl.push_back(SBuf(Ssl::GetErrorName(data->element)));
52 data = data->next;
53 }
54 return sl;
55 }
56
57 void
58 ACLSslErrorData::parse()
59 {
60 Ssl::Errors **Tail;
61 char *t = NULL;
62
63 for (Tail = &values; *Tail; Tail = &((*Tail)->next));
64 while ((t = strtokFile())) {
65 Ssl::Errors *q = Ssl::ParseErrorString(t);
66 *(Tail) = q;
67 Tail = &q->tail()->next;
68 }
69 }
70
71 bool
72 ACLSslErrorData::empty() const
73 {
74 return values == NULL;
75 }
76
77 ACLSslErrorData *
78 ACLSslErrorData::clone() const
79 {
80 /* Splay trees don't clone yet. */
81 assert (!values);
82 return new ACLSslErrorData(*this);
83 }
84