Parser.cc
Go to the documentation of this file.
1/*
2 * Copyright (C) 1996-2023 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 "debug/Stream.h"
13#include "esi/Parser.h"
14#include "fatal.h"
15
16char *ESIParser::Type = nullptr;
18
19std::list<ESIParser::Register *> &
21{
22 static std::list<ESIParser::Register *> parsers;
23 return parsers;
24}
25
28{
29 if (!Parser) {
30 // if esi_parser is configured, use that
31 const char *selectParserName = Type;
32 if (!selectParserName || strcasecmp(selectParserName, "auto") == 0) {
33#if HAVE_LIBXML2
34 // libxml2 is the more secure. prefer when possible
35 selectParserName = "libxml2";
36#else
37 // expat is more widely available
38 selectParserName = "expat";
39#endif
40 }
41
42 for (auto *p : GetRegistry()) {
43 if (p && strcasecmp(p->name, selectParserName) == 0)
44 Parser = p;
45 }
46
47 if (!Parser)
48 fatalf("Unknown ESI Parser type '%s'", selectParserName);
49 debugs(86, 2, "selected ESI parser: " << Parser->name);
50 }
51
52 return (Parser->newParser)(aClient);
53}
54
55ESIParser::Register::Register(const char *_name, ESIParser::Pointer (*_newParser)(ESIParserClient *aClient)) : name(_name), newParser(_newParser)
56{
57 ESIParser::GetRegistry().emplace_back(this);
58}
59
61{
62 ESIParser::GetRegistry().remove(this);
63}
64
Register(const char *_name, ESIParser::Pointer(*_newParser)(ESIParserClient *aClient))
Definition: Parser.cc:55
static Register * Parser
Definition: Parser.h:49
static char * Type
Definition: Parser.h:34
static std::list< Register * > & GetRegistry()
Definition: Parser.cc:20
static Pointer NewParser(ESIParserClient *aClient)
Definition: Parser.cc:27
#define debugs(SECTION, LEVEL, CONTENT)
Definition: Stream.h:194
void fatalf(const char *fmt,...)
Definition: fatal.cc:68
Generic protocol-agnostic parsing tools.
Definition: RequestParser.h:15

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors