]> git.ipfire.org Git - thirdparty/pdns.git/blob - pdns/zoneparser-tng.hh
Merge remote-tracking branch 'main/master' into rpz
[thirdparty/pdns.git] / pdns / zoneparser-tng.hh
1 /*
2 PowerDNS Versatile Database Driven Nameserver
3 Copyright (C) 2005 - 2007 PowerDNS.COM BV
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License version 2
7 as published by the Free Software Foundation
8
9 Additionally, the license of this program contains a special
10 exception which allows to distribute the program in binary form when
11 it is linked against OpenSSL.
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 St, Fifth Floor, Boston, MA 02110-1301 USA
21 */
22
23 #ifndef PDNS_ZONEPARSER_TNG
24 #define PDNS_ZONEPARSER_TNG
25 #include <string>
26 #include <cstdio>
27 #include <stdexcept>
28 #include <stack>
29
30 #include "namespaces.hh"
31
32 class ZoneParserTNG
33 {
34 public:
35 ZoneParserTNG(const string& fname, const DNSName& zname=DNSName(), const string& reldir="");
36 ZoneParserTNG(const vector<string> zonedata, const DNSName& zname);
37
38 ~ZoneParserTNG();
39 bool get(DNSResourceRecord& rr, std::string* comment=0);
40 typedef runtime_error exception;
41 typedef deque<pair<string::size_type, string::size_type> > parts_t;
42 string getLineOfFile();
43 private:
44 bool getLine();
45 bool getTemplateLine();
46 void stackFile(const std::string& fname);
47 unsigned makeTTLFromZone(const std::string& str);
48
49 struct filestate {
50 filestate(FILE* fp, string filename) : d_fp(fp), d_filename(filename), d_lineno(0){}
51 FILE *d_fp;
52 string d_filename;
53 int d_lineno;
54 };
55
56 string d_reldir;
57 string d_line;
58 DNSName d_prevqname;
59 DNSName d_zonename;
60 string d_templateline;
61 vector<string> d_zonedata;
62 vector<string>::iterator d_zonedataline;
63 std::stack<filestate> d_filestates;
64 parts_t d_templateparts;
65 int d_defaultttl;
66 uint32_t d_templatecounter, d_templatestop, d_templatestep;
67 bool d_havedollarttl;
68 bool d_fromfile;
69 };
70
71 #endif