]> git.ipfire.org Git - thirdparty/pdns.git/blob - pdns/backends/bind/bindparserclasses.hh
10b0cfd6ae498caca681bbdb4b80f64a2772fa2d
[thirdparty/pdns.git] / pdns / backends / bind / bindparserclasses.hh
1 /*
2 PowerDNS Versatile Database Driven Nameserver
3 Copyright (C) 2002-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
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 */
19 #ifndef BINDPARSER_HH
20 #define BINDPARSER_HH
21 #include <string>
22 #include <map>
23 #include <vector>
24 #include <set>
25
26 #include "namespaces.hh"
27
28 class BindDomainInfo
29 {
30 public:
31 BindDomainInfo() : d_dev(0), d_ino(0)
32 {}
33
34 void clear()
35 {
36 name=filename=type="";
37 masters.clear();
38 alsoNotify.clear();
39 d_dev=0;
40 d_ino=0;
41 }
42 string name;
43 string viewName;
44 string filename;
45 vector<string> masters;
46 set<string> alsoNotify;
47 string type;
48
49 dev_t d_dev;
50 ino_t d_ino;
51
52 bool operator<(const BindDomainInfo& b) const
53 {
54 return make_pair(d_dev, d_ino) < make_pair(b.d_dev, b.d_ino);
55 }
56 };
57
58 extern const char *bind_directory;
59 extern FILE *yyin;
60 class BindParser
61 {
62 public:
63 BindParser() : d_dir("."), d_verbose(false)
64 {
65 yyin=0;
66 extern int include_stack_ptr;
67 include_stack_ptr=0;
68
69 bind_directory=d_dir.c_str();
70 }
71 ~BindParser()
72 {
73 if(yyin) {
74 fclose(yyin);
75 yyin=0;
76 }
77 }
78 void parse(const string &fname);
79 void commit(BindDomainInfo DI);
80 void setDirectory(const string &dir);
81 const string &getDirectory();
82 const vector<BindDomainInfo>& getDomains();
83 void setVerbose(bool verbose);
84 void addAlsoNotify(const string &host);
85 set<string> & getAlsoNotify() { return this->alsoNotify; }
86 private:
87 string d_dir;
88 bool d_verbose;
89 typedef map<string,string> zonedomain_t;
90 set<string> alsoNotify;
91 vector<BindDomainInfo> d_zonedomains;
92 };
93
94 #endif /* BINDPARSER_HH */