Config.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 #include "squid.h"
10 #include "cache_cf.h"
11 #include "ConfigParser.h"
12 #include "Debug.h"
13 #include "format/Config.h"
14 #include <list>
15 
17 
18 void
20 {
21  char *name, *def;
22 
23  if ((name = ConfigParser::NextToken()) == nullptr) {
24  self_destruct();
25  return;
26  }
27 
28  if ((def = ConfigParser::NextQuotedOrToEol()) == nullptr) {
29  self_destruct();
30  return;
31  }
32 
33  debugs(3, 2, "Custom Format for '" << name << "' is '" << def << "'");
34 
35  Format *nlf = new Format(name);
36 
37  if (!nlf->parse(def)) {
38  self_destruct();
39  return;
40  }
41 
42  // add to global config list
43  nlf->next = formats;
44  formats = nlf;
45 }
46 
47 void
48 Format::FmtConfig::registerTokens(const SBuf &nsName, TokenTableEntry const *tokenArray)
49 {
50  debugs(46, 2, "register format tokens for '" << nsName << "'");
51  if (tokenArray)
52  tokens.emplace_back(TokenNamespace(nsName, tokenArray));
53  else
54  debugs(0, DBG_CRITICAL, "BUG: format tokens for '" << nsName << "' missing!");
55 }
56 
Definition: SBuf.h:87
void self_destruct(void)
Definition: cache_cf.cc:255
void parseFormats()
Parse a log format directive line (logfile_format)
Definition: Config.cc:19
One entry in a table of format tokens.
#define DBG_CRITICAL
Definition: Debug.h:44
#define debugs(SECTION, LEVEL, CONTENT)
Definition: Debug.h:123
static char * NextToken()
FmtConfig TheConfig
Definition: Config.cc:16
void registerTokens(const SBuf &nsName, TokenTableEntry const *tokenArray)
Definition: Config.cc:48
Format * next
Definition: Format.h:61
bool parse(const char *def)
Definition: Format.cc:65
static char * NextQuotedOrToEol()
Format * formats
Linked list of custom formats.
Definition: Config.h:61
struct tok tokens[]
Definition: parse.c:168

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors