Parser.cc
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1996-2017 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 
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 
42 {
43  // TODO: support random-order deregistration
44  assert(ESIParser::Parsers == this);
45  ESIParser::Parsers = next;
46 }
47 
#define assert(EX)
Definition: assert.h:17
static char * Type
Definition: Parser.h:32
ESIParser::Pointer(* newParser)(ESIParserClient *aClient)
Definition: Parser.h:61
Register(const char *_name, ESIParser::Pointer(*_newParser)(ESIParserClient *aClient))
Definition: Parser.cc:35
static Register * Parser
Definition: Parser.h:44
Definition: cf_gen.cc:115
void fatal(const char *message)
Definition: fatal.cc:39
static Pointer NewParser(ESIParserClient *aClient)
Definition: Parser.cc:20
Register * next
Definition: Parser.h:62
const char * name
Definition: Parser.h:60
static Register * Parsers
Definition: Parser.h:48
#define NULL
Definition: types.h:166

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors