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