]> git.ipfire.org Git - thirdparty/squid.git/blob - src/format/Config.cc
SourceFormat Enforcement
[thirdparty/squid.git] / src / format / Config.cc
1 #include "squid.h"
2 #include "cache_cf.h"
3 #include "ConfigParser.h"
4 #include "Debug.h"
5 #include "format/Config.h"
6 #include <list>
7
8 Format::FmtConfig Format::TheConfig;
9
10 void
11 Format::FmtConfig::parseFormats()
12 {
13 char *name, *def;
14
15 if ((name = ConfigParser::NextToken()) == NULL)
16 self_destruct();
17
18 if ((def = ConfigParser::NextQuotedOrToEol()) == NULL) {
19 self_destruct();
20 return;
21 }
22
23 debugs(3, 2, "Custom Format for '" << name << "' is '" << def << "'");
24
25 Format *nlf = new Format(name);
26
27 if (!nlf->parse(def)) {
28 self_destruct();
29 return;
30 }
31
32 // add to global config list
33 nlf->next = formats;
34 formats = nlf;
35 }
36
37 void
38 Format::FmtConfig::registerTokens(const String &nsName, TokenTableEntry const *tokenArray)
39 {
40 debugs(46, 2, HERE << " register format tokens for '" << nsName << "'");
41 if (tokenArray != NULL)
42 tokens.push_back(TokenNamespace(nsName, tokenArray));
43 else
44 debugs(0, DBG_CRITICAL, "BUG: format tokens for '" << nsName << "' missing!");
45 }