]>
Commit | Line | Data |
---|---|---|
f814d7c8 | 1 | /* |
12471842 PL |
2 | * This file is part of PowerDNS or dnsdist. |
3 | * Copyright -- PowerDNS.COM B.V. and its contributors | |
4 | * | |
5 | * This program is free software; you can redistribute it and/or modify | |
6 | * it under the terms of version 2 of the GNU General Public License as | |
7 | * published by the Free Software Foundation. | |
8 | * | |
9 | * In addition, for the avoidance of any doubt, permission is granted to | |
10 | * link this program with OpenSSL and to (re)distribute the binaries | |
11 | * produced as the result of such linking. | |
12 | * | |
13 | * This program is distributed in the hope that it will be useful, | |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 | * GNU General Public License for more details. | |
17 | * | |
18 | * You should have received a copy of the GNU General Public License | |
19 | * along with this program; if not, write to the Free Software | |
20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | |
21 | */ | |
e8c59f2d | 22 | #pragma once |
f814d7c8 BH |
23 | #include <string> |
24 | #include <cstdio> | |
125e4840 | 25 | #include <stdexcept> |
bf503cc0 | 26 | #include <stack> |
dc593046 | 27 | #include <deque> |
125e4840 | 28 | |
10f4eea8 | 29 | #include "namespaces.hh" |
f814d7c8 | 30 | |
f814d7c8 BH |
31 | class ZoneParserTNG |
32 | { | |
33 | public: | |
1290c1d2 RP |
34 | ZoneParserTNG(const string& fname, DNSName zname=g_rootdnsname, string reldir="", bool upgradeContent=false); |
35 | ZoneParserTNG(const vector<string>& zonedata, DNSName zname, bool upgradeContent=false); | |
f814d7c8 BH |
36 | |
37 | ~ZoneParserTNG(); | |
a2e9e5a5 | 38 | bool get(DNSResourceRecord& rr, std::string* comment=0); |
125e4840 | 39 | typedef runtime_error exception; |
dc593046 | 40 | typedef std::deque<pair<string::size_type, string::size_type> > parts_t; |
d16a2ccf | 41 | DNSName getZoneName(); |
c91effc8 | 42 | string getLineOfFile(); // for error reporting purposes |
43 | pair<string,int> getLineNumAndFile(); // idem | |
91a862bf RG |
44 | void disableGenerate() |
45 | { | |
46 | d_generateEnabled = false; | |
47 | } | |
ba3d53d1 RG |
48 | void setMaxGenerateSteps(size_t max) |
49 | { | |
50 | d_maxGenerateSteps = max; | |
51 | } | |
e3fc3ebd OM |
52 | void setMaxIncludes(size_t max) |
53 | { | |
54 | d_maxIncludes = max; | |
55 | } | |
f814d7c8 | 56 | private: |
125e4840 | 57 | bool getLine(); |
2e83ba09 | 58 | bool getTemplateLine(); |
bf503cc0 | 59 | void stackFile(const std::string& fname); |
cfe397d5 | 60 | unsigned makeTTLFromZone(const std::string& str); |
644dd1da | 61 | |
415e9f3b | 62 | struct filestate { |
7d0fefb4 | 63 | filestate(FILE* fp, string filename) : d_fp(fp), d_filename(std::move(filename)), d_lineno(0){} |
415e9f3b PL |
64 | FILE *d_fp; |
65 | string d_filename; | |
66 | int d_lineno; | |
67 | }; | |
68 | ||
9bbcf03a | 69 | parts_t d_parts; |
da042e6e | 70 | string d_reldir; |
f814d7c8 | 71 | string d_line; |
675fa24c PD |
72 | DNSName d_prevqname; |
73 | DNSName d_zonename; | |
415e9f3b | 74 | string d_templateline; |
0f0e73fe MS |
75 | vector<string> d_zonedata; |
76 | vector<string>::iterator d_zonedataline; | |
415e9f3b PL |
77 | std::stack<filestate> d_filestates; |
78 | parts_t d_templateparts; | |
ba3d53d1 | 79 | size_t d_maxGenerateSteps{0}; |
e3fc3ebd | 80 | size_t d_maxIncludes{20}; |
125e4840 | 81 | int d_defaultttl; |
415e9f3b | 82 | uint32_t d_templatecounter, d_templatestop, d_templatestep; |
df1d406a | 83 | bool d_havedollarttl; |
0f0e73fe | 84 | bool d_fromfile; |
91a862bf | 85 | bool d_generateEnabled{true}; |
b4db4fe4 | 86 | bool d_upgradeContent; |
9da7b2be | 87 | bool d_templateCounterWrapped{false}; |
f814d7c8 | 88 | }; |