]> git.ipfire.org Git - thirdparty/pdns.git/blob - pdns/bindparserclasses.hh
Merge pull request #2632 from cmouse/goracle-transactions
[thirdparty/pdns.git] / pdns / 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 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 #ifndef BINDPARSER_HH
23 #define BINDPARSER_HH
24 #include <string>
25 #include <map>
26 #include <vector>
27 #include <set>
28 #include <stdio.h>
29 #include <sys/stat.h>
30
31 #include "namespaces.hh"
32
33 class BindDomainInfo
34 {
35 public:
36 BindDomainInfo() : d_dev(0), d_ino(0)
37 {}
38
39 void clear()
40 {
41 name=filename=type="";
42 masters.clear();
43 alsoNotify.clear();
44 d_dev=0;
45 d_ino=0;
46 }
47 DNSName name;
48 string viewName;
49 string filename;
50 vector<string> masters;
51 set<string> alsoNotify;
52 string type;
53
54 dev_t d_dev;
55 ino_t d_ino;
56
57 bool operator<(const BindDomainInfo& b) const
58 {
59 return make_pair(d_dev, d_ino) < make_pair(b.d_dev, b.d_ino);
60 }
61 };
62
63 extern const char *bind_directory;
64 extern FILE *yyin;
65 class BindParser
66 {
67 public:
68 BindParser() : d_dir("."), d_verbose(false)
69 {
70 yyin=0;
71 extern int include_stack_ptr;
72 include_stack_ptr=0;
73
74 bind_directory=d_dir.c_str();
75 }
76 ~BindParser()
77 {
78 if(yyin) {
79 fclose(yyin);
80 yyin=0;
81 }
82 }
83 void parse(const string &fname);
84 void commit(BindDomainInfo DI);
85 void setDirectory(const string &dir);
86 const string &getDirectory();
87 const vector<BindDomainInfo>& getDomains();
88 void setVerbose(bool verbose);
89 void addAlsoNotify(const string &host);
90 set<string> & getAlsoNotify() { return this->alsoNotify; }
91 private:
92 string d_dir;
93 typedef map<DNSName,string> zonedomain_t;
94 set<string> alsoNotify;
95 vector<BindDomainInfo> d_zonedomains;
96 bool d_verbose;
97 };
98
99 #endif /* BINDPARSER_HH */