]> git.ipfire.org Git - thirdparty/squid.git/blob - src/esi/Parser.cc
Docs: Copyright updates for 2018 (#114)
[thirdparty/squid.git] / src / esi / Parser.cc
1 /*
2 * Copyright (C) 1996-2018 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 /* DEBUG: section 86 ESI processing */
10
11 #include "squid.h"
12 #include "esi/Parser.h"
13 #include "fatal.h"
14
15 char *ESIParser::Type = NULL;
16 ESIParser::Register *ESIParser::Parsers = NULL;
17 ESIParser::Register *ESIParser::Parser = NULL;
18
19 ESIParser::Pointer
20 ESIParser::NewParser(ESIParserClient *aClient)
21 {
22 if (Parser == NULL) {
23 Parser = Parsers;
24
25 while (Parser != NULL && strcasecmp(Parser->name, Type) != 0)
26 Parser = Parser->next;
27
28 if (Parser == NULL)
29 fatal ("Unknown ESI Parser type");
30 }
31
32 return (Parser->newParser)(aClient);
33 }
34
35 ESIParser::Register::Register(const char *_name, ESIParser::Pointer (*_newParser)(ESIParserClient *aClient)) : name(_name), newParser(_newParser)
36 {
37 this->next = ESIParser::Parsers;
38 ESIParser::Parsers = this;
39 }
40
41 ESIParser::Register::~Register()
42 {
43 // TODO: support random-order deregistration
44 assert(ESIParser::Parsers == this);
45 ESIParser::Parsers = next;
46 }
47