]>
Commit | Line | Data |
---|---|---|
43ae1d95 | 1 | /* |
77b1029d | 2 | * Copyright (C) 1996-2020 The Squid Software Foundation and contributors |
43ae1d95 | 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. | |
43ae1d95 | 7 | */ |
8 | ||
bbc27441 AJ |
9 | /* DEBUG: section 86 ESI processing */ |
10 | ||
582c2af2 | 11 | #include "squid.h" |
f99c2cfe | 12 | #include "esi/Parser.h" |
582c2af2 | 13 | #include "fatal.h" |
43ae1d95 | 14 | |
15 | char *ESIParser::Type = NULL; | |
dd2bdef3 | 16 | ESIParser::Register *ESIParser::Parser = NULL; |
43ae1d95 | 17 | |
57b6788e AJ |
18 | std::list<ESIParser::Register *> & |
19 | ESIParser::GetRegistry() | |
20 | { | |
21 | static std::list<ESIParser::Register *> parsers; | |
22 | return parsers; | |
23 | } | |
24 | ||
43ae1d95 | 25 | ESIParser::Pointer |
26 | ESIParser::NewParser(ESIParserClient *aClient) | |
27 | { | |
c2d4889f | 28 | if (Parser == NULL) { |
57b6788e | 29 | Parser = GetRegistry().front(); |
964b44c3 | 30 | |
799b66d1 AJ |
31 | // if type name matters, use it |
32 | if (strcasecmp(Type, "auto") != 0) { | |
57b6788e AJ |
33 | for (auto *p : GetRegistry()) { |
34 | if (p && strcasecmp(p->name, Type) != 0) | |
35 | Parser = p; | |
36 | } | |
799b66d1 | 37 | } |
43ae1d95 | 38 | |
c2d4889f | 39 | if (Parser == NULL) |
40 | fatal ("Unknown ESI Parser type"); | |
41 | } | |
43ae1d95 | 42 | |
c2d4889f | 43 | return (Parser->newParser)(aClient); |
43ae1d95 | 44 | } |
7901db21 | 45 | |
af6a12ee AJ |
46 | ESIParser::Register::Register(const char *_name, ESIParser::Pointer (*_newParser)(ESIParserClient *aClient)) : name(_name), newParser(_newParser) |
47 | { | |
57b6788e | 48 | ESIParser::GetRegistry().emplace_back(this); |
7901db21 AR |
49 | } |
50 | ||
af6a12ee AJ |
51 | ESIParser::Register::~Register() |
52 | { | |
57b6788e | 53 | ESIParser::GetRegistry().remove(this); |
7901db21 | 54 | } |
f53969cc | 55 |