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 "log/Config.h"
14 
16 
17 void
19 {
20  char *name, *def;
21 
22  if (!(name = ConfigParser::NextToken())) {
23  debugs(3, DBG_CRITICAL, "FATAL: missing logformat details in " << cfg_filename << " line " << config_lineno);
24  self_destruct();
25  return;
26  }
27 
28  // check for re-definition of built-in formats
29  if (strcmp(name, "squid") == 0 ||
30  strcmp(name, "common") == 0 ||
31  strcmp(name, "combined") == 0 ||
32  strcmp(name, "useragent") == 0 ||
33  strcmp(name, "referrer") == 0) {
34  debugs(3, DBG_PARSE_NOTE(DBG_IMPORTANT), "ERROR: logformat " << name << " is already defined. Ignoring.");
35  return;
36  }
37 
38  // check for re-definition of custom formats
39  for (auto i = logformats; i ; i = i->next) {
40  if (strcmp(i->name, name) == 0) {
41  debugs(3, DBG_PARSE_NOTE(DBG_IMPORTANT), "ERROR: logformat " << name << " is already defined. Ignoring.");
42  return;
43  }
44  }
45 
46  ::Format::Format *nlf = new ::Format::Format(name);
47 
49  if (!(def = ConfigParser::NextQuotedOrToEol())) {
50  delete nlf;
51  self_destruct();
52  return;
53  }
55 
56  debugs(3, 2, "Log Format for '" << name << "' is '" << def << "'");
57 
58  if (!nlf->parse(def)) {
59  delete nlf;
60  self_destruct();
61  return;
62  }
63 
64  // add to global config list
65  nlf->next = logformats;
66  logformats = nlf;
67 }
68 
void parseFormats()
Definition: Config.cc:18
static void EnableMacros()
Allow macros inside quoted strings.
Definition: ConfigParser.h:123
::Format::Format * logformats
Linked list of custom log formats.
Definition: Config.h:31
void self_destruct(void)
Definition: cache_cf.cc:255
int i
Definition: membanger.c:49
#define DBG_CRITICAL
Definition: Debug.h:44
#define DBG_PARSE_NOTE(x)
Definition: Debug.h:49
static void DisableMacros()
Do not allow macros inside quoted strings.
Definition: ConfigParser.h:126
#define debugs(SECTION, LEVEL, CONTENT)
Definition: Debug.h:123
int config_lineno
#define DBG_IMPORTANT
Definition: Debug.h:45
const char * cfg_filename
static char * NextToken()
Format * next
Definition: Format.h:61
bool parse(const char *def)
Definition: Format.cc:65
static char * NextQuotedOrToEol()
LogConfig TheConfig
Definition: Config.cc:15

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors