]> git.ipfire.org Git - thirdparty/pdns.git/blob - pdns/zoneparser-tng.hh
Merge pull request #1373 from cmouse/fix-issue-1371
[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 string& zname="", const string& reldir="");
36
37 ~ZoneParserTNG();
38 bool get(DNSResourceRecord& rr, std::string* comment=0);
39 typedef runtime_error exception;
40 typedef deque<pair<string::size_type, string::size_type> > parts_t;
41 private:
42 bool getLine();
43 bool getTemplateLine();
44 void stackFile(const std::string& fname);
45 unsigned makeTTLFromZone(const std::string& str);
46 string getLineOfFile();
47 string d_reldir;
48 string d_line;
49 string d_prevqname;
50 string d_zonename;
51 int d_defaultttl;
52 bool d_havedollarttl;
53 uint32_t d_templatecounter, d_templatestop, d_templatestep;
54 string d_templateline;
55 parts_t d_templateparts;
56
57 struct filestate {
58 filestate(FILE* fp, string filename) : d_fp(fp), d_filename(filename), d_lineno(0){}
59 FILE *d_fp;
60 string d_filename;
61 int d_lineno;
62 };
63 std::stack<filestate> d_filestates;
64 };
65
66 #endif