]> git.ipfire.org Git - thirdparty/pdns.git/blame - pdns/zoneparser-tng.hh
rec: ensure correct service user on debian
[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 */
f814d7c8
BH
22#ifndef PDNS_ZONEPARSER_TNG
23#define PDNS_ZONEPARSER_TNG
24#include <string>
25#include <cstdio>
125e4840 26#include <stdexcept>
bf503cc0 27#include <stack>
125e4840 28
10f4eea8 29#include "namespaces.hh"
f814d7c8 30
f814d7c8
BH
31class ZoneParserTNG
32{
33public:
ad2ad901 34 ZoneParserTNG(const string& fname, const DNSName& zname=DNSName("."), const string& reldir="");
675fa24c 35 ZoneParserTNG(const vector<string> zonedata, const DNSName& zname);
f814d7c8
BH
36
37 ~ZoneParserTNG();
a2e9e5a5 38 bool get(DNSResourceRecord& rr, std::string* comment=0);
125e4840 39 typedef runtime_error exception;
2e83ba09 40 typedef 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
f814d7c8 44private:
125e4840 45 bool getLine();
2e83ba09 46 bool getTemplateLine();
bf503cc0 47 void stackFile(const std::string& fname);
cfe397d5 48 unsigned makeTTLFromZone(const std::string& str);
644dd1da 49
415e9f3b
PL
50 struct filestate {
51 filestate(FILE* fp, string filename) : d_fp(fp), d_filename(filename), d_lineno(0){}
52 FILE *d_fp;
53 string d_filename;
54 int d_lineno;
55 };
56
da042e6e 57 string d_reldir;
f814d7c8 58 string d_line;
675fa24c
PD
59 DNSName d_prevqname;
60 DNSName d_zonename;
415e9f3b 61 string d_templateline;
0f0e73fe
MS
62 vector<string> d_zonedata;
63 vector<string>::iterator d_zonedataline;
415e9f3b
PL
64 std::stack<filestate> d_filestates;
65 parts_t d_templateparts;
125e4840 66 int d_defaultttl;
415e9f3b 67 uint32_t d_templatecounter, d_templatestop, d_templatestep;
df1d406a 68 bool d_havedollarttl;
0f0e73fe 69 bool d_fromfile;
f814d7c8
BH
70};
71
72#endif