]> git.ipfire.org Git - thirdparty/pdns.git/blame - pdns/zoneparser-tng.hh
Merge pull request #9073 from pieterlexis/runtime-dirs-virtual-hosting
[thirdparty/pdns.git] / pdns / zoneparser-tng.hh
CommitLineData
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>
125e4840 27
10f4eea8 28#include "namespaces.hh"
f814d7c8 29
f814d7c8
BH
30class ZoneParserTNG
31{
32public:
020b94c9 33 ZoneParserTNG(const string& fname, const DNSName& zname=g_rootdnsname, const string& reldir="");
675fa24c 34 ZoneParserTNG(const vector<string> zonedata, const DNSName& zname);
f814d7c8
BH
35
36 ~ZoneParserTNG();
a2e9e5a5 37 bool get(DNSResourceRecord& rr, std::string* comment=0);
125e4840 38 typedef runtime_error exception;
2e83ba09 39 typedef deque<pair<string::size_type, string::size_type> > parts_t;
d16a2ccf 40 DNSName getZoneName();
c91effc8 41 string getLineOfFile(); // for error reporting purposes
42 pair<string,int> getLineNumAndFile(); // idem
91a862bf
RG
43 void disableGenerate()
44 {
45 d_generateEnabled = false;
46 }
ba3d53d1
RG
47 void setMaxGenerateSteps(size_t max)
48 {
49 d_maxGenerateSteps = max;
50 }
f814d7c8 51private:
125e4840 52 bool getLine();
2e83ba09 53 bool getTemplateLine();
bf503cc0 54 void stackFile(const std::string& fname);
cfe397d5 55 unsigned makeTTLFromZone(const std::string& str);
644dd1da 56
415e9f3b
PL
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
9bbcf03a 64 parts_t d_parts;
da042e6e 65 string d_reldir;
f814d7c8 66 string d_line;
675fa24c
PD
67 DNSName d_prevqname;
68 DNSName d_zonename;
415e9f3b 69 string d_templateline;
0f0e73fe
MS
70 vector<string> d_zonedata;
71 vector<string>::iterator d_zonedataline;
415e9f3b
PL
72 std::stack<filestate> d_filestates;
73 parts_t d_templateparts;
ba3d53d1 74 size_t d_maxGenerateSteps{0};
125e4840 75 int d_defaultttl;
415e9f3b 76 uint32_t d_templatecounter, d_templatestop, d_templatestep;
df1d406a 77 bool d_havedollarttl;
0f0e73fe 78 bool d_fromfile;
91a862bf 79 bool d_generateEnabled{true};
f814d7c8 80};