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