Parser.cc
Go to the documentation of this file.
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::Parser = NULL;
17 
18 std::list<ESIParser::Register *> &
20 {
21  static std::list<ESIParser::Register *> parsers;
22  return parsers;
23 }
24 
27 {
28  if (Parser == NULL) {
29  Parser = GetRegistry().front();
30 
31  // if type name matters, use it
32  if (strcasecmp(Type, "auto") != 0) {
33  for (auto *p : GetRegistry()) {
34  if (p && strcasecmp(p->name, Type) != 0)
35  Parser = p;
36  }
37  }
38 
39  if (Parser == NULL)
40  fatal ("Unknown ESI Parser type");
41  }
42 
43  return (Parser->newParser)(aClient);
44 }
45 
46 ESIParser::Register::Register(const char *_name, ESIParser::Pointer (*_newParser)(ESIParserClient *aClient)) : name(_name), newParser(_newParser)
47 {
48  ESIParser::GetRegistry().emplace_back(this);
49 }
50 
52 {
53  ESIParser::GetRegistry().remove(this);
54 }
55 
char * p
Definition: membanger.c:43
static char * Type
Definition: Parser.h:34
ESIParser::Pointer(* newParser)(ESIParserClient *aClient)
Definition: Parser.h:61
Register(const char *_name, ESIParser::Pointer(*_newParser)(ESIParserClient *aClient))
Definition: Parser.cc:46
static Register * Parser
Definition: Parser.h:46
Definition: cf_gen.cc:115
void fatal(const char *message)
Definition: fatal.cc:28
static Pointer NewParser(ESIParserClient *aClient)
Definition: Parser.cc:26
static std::list< Register * > & GetRegistry()
Definition: Parser.cc:19
#define NULL
Definition: types.h:166

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors