]> git.ipfire.org Git - thirdparty/pdns.git/blame - pdns/bindparserclasses.hh
Merge pull request #11431 from jroessler-ox/docs-kskzskroll-update
[thirdparty/pdns.git] / pdns / bindparserclasses.hh
CommitLineData
12c86877 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
12c86877
BH
23#include <string>
24#include <map>
25#include <vector>
27d94a79 26#include <set>
552ddf0c 27#include <stdio.h>
bf63a353 28#include <sys/stat.h>
12c86877 29
10f4eea8 30#include "namespaces.hh"
12c86877
BH
31
32class BindDomainInfo
33{
34public:
9d2b9f64 35 BindDomainInfo() : hadFileDirective(false), d_dev(0), d_ino(0)
c36285d0
BH
36 {}
37
12c86877
BH
38 void clear()
39 {
290a083d 40 name=DNSName();
41 filename=type="";
d525b58b 42 primaries.clear();
27d94a79 43 alsoNotify.clear();
c36285d0
BH
44 d_dev=0;
45 d_ino=0;
12c86877 46 }
efa2cfa0 47 DNSName name;
6051fa72 48 string viewName;
12c86877 49 string filename;
d525b58b 50 vector<ComboAddress> primaries;
27d94a79 51 set<string> alsoNotify;
973ad2b5 52 string type;
6808f3b5 53 bool hadFileDirective;
82f7b3cc
BH
54
55 dev_t d_dev;
56 ino_t d_ino;
57
58 bool operator<(const BindDomainInfo& b) const
59 {
faa05786 60 return pair(d_dev, d_ino) < pair(b.d_dev, b.d_ino);
82f7b3cc 61 }
12c86877
BH
62};
63
64extern const char *bind_directory;
2a95d1df 65extern FILE *yyin;
12c86877
BH
66class BindParser
67{
68 public:
2a95d1df 69 BindParser() : d_dir("."), d_verbose(false)
751f7add 70 {
2a95d1df 71 yyin=0;
751f7add
BH
72 extern int include_stack_ptr;
73 include_stack_ptr=0;
74
75 bind_directory=d_dir.c_str();
76 }
2a95d1df
BH
77 ~BindParser()
78 {
79 if(yyin) {
80 fclose(yyin);
81 yyin=0;
82 }
83 }
12c86877
BH
84 void parse(const string &fname);
85 void commit(BindDomainInfo DI);
86 void setDirectory(const string &dir);
87 const string &getDirectory();
88 const vector<BindDomainInfo>& getDomains();
89 void setVerbose(bool verbose);
27d94a79
BH
90 void addAlsoNotify(const string &host);
91 set<string> & getAlsoNotify() { return this->alsoNotify; }
12c86877
BH
92private:
93 string d_dir;
efa2cfa0 94 typedef map<DNSName,string> zonedomain_t;
27d94a79 95 set<string> alsoNotify;
12c86877 96 vector<BindDomainInfo> d_zonedomains;
2f0c3222 97 bool d_verbose;
12c86877 98};