]> git.ipfire.org Git - thirdparty/squid.git/blame - src/format/Config.cc
SourceFormat Enforcement
[thirdparty/squid.git] / src / format / Config.cc
CommitLineData
bbc27441 1/*
ef57eb7b 2 * Copyright (C) 1996-2016 The Squid Software Foundation and contributors
bbc27441
AJ
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
f7f3304a 9#include "squid.h"
8a01b99e 10#include "cache_cf.h"
602d9612 11#include "ConfigParser.h"
af69c635 12#include "Debug.h"
31971e6a 13#include "format/Config.h"
31971e6a
AJ
14#include <list>
15
16Format::FmtConfig Format::TheConfig;
17
18void
19Format::FmtConfig::parseFormats()
20{
21 char *name, *def;
22
2eceb328 23 if ((name = ConfigParser::NextToken()) == NULL)
31971e6a
AJ
24 self_destruct();
25
2eceb328 26 if ((def = ConfigParser::NextQuotedOrToEol()) == NULL) {
31971e6a
AJ
27 self_destruct();
28 return;
29 }
30
31 debugs(3, 2, "Custom Format for '" << name << "' is '" << def << "'");
32
33 Format *nlf = new Format(name);
34
35 if (!nlf->parse(def)) {
36 self_destruct();
37 return;
38 }
39
40 // add to global config list
41 nlf->next = formats;
42 formats = nlf;
43}
44
45void
46Format::FmtConfig::registerTokens(const String &nsName, TokenTableEntry const *tokenArray)
47{
48 debugs(46, 2, HERE << " register format tokens for '" << nsName << "'");
49 if (tokenArray != NULL)
50 tokens.push_back(TokenNamespace(nsName, tokenArray));
51 else
fa84c01d 52 debugs(0, DBG_CRITICAL, "BUG: format tokens for '" << nsName << "' missing!");
31971e6a 53}
f53969cc 54