11 #include "pdnsexception.hh"
12 #include "namespaces.hh"
16 #include "bindparserclasses.hh"
18 #define YYSTYPE char *
24 void yyrestart(FILE *);
33 const char *bind_directory;
34 extern int linenumber;
35 static void yyerror(const char *str)
37 extern char *current_filename;
38 throw PDNSException("Error in bind configuration '"+string(current_filename)+"' on line "+itoa(linenumber)+": "+str);
42 static BindParser *parent;
45 void BindParser::parse(const string &fname)
48 yyin=fopen(fname.c_str(),"r");
51 throw PDNSException("Unable to open '"+fname+"': "+strerror(errno));
55 extern char *current_filename;
56 extern char *original_filename;
58 current_filename=original_filename=(char*)fname.c_str();
62 // cerr<<"Need to parse "<<d_zonedomains.size()<<" zone statements"<<endl;
65 void BindParser::setDirectory(const string &dir)
68 bind_directory=d_dir.c_str();
71 void BindParser::addAlsoNotify(const string & host)
73 alsoNotify.insert(host);
76 const string &BindParser::getDirectory()
81 const vector<BindDomainInfo>& BindParser::getDomains()
86 void BindParser::setVerbose(bool verbose)
91 void BindParser::commit(BindDomainInfo DI)
93 DI.hadFileDirective = (DI.filename != "");
95 if(DI.filename[0]!='/')
96 DI.filename=d_dir+"/"+DI.filename;
99 cerr<<"Domain "<<DI.name.toStringNoDot()<<" lives in file '"<<DI.filename<<"'"<<endl;
101 d_zonedomains.push_back(DI);
106 %token AWORD QUOTEDWORD OBRACE EBRACE SEMICOLON ZONETOK FILETOK OPTIONSTOK
107 %token DIRECTORYTOK ACLTOK LOGGINGTOK CLASSTOK TYPETOK MASTERTOK ALSONOTIFYTOK
113 root_commands root_command SEMICOLON
116 root_command: command | acl_command | global_zone_command | global_options_command
121 commands command SEMICOLON
129 ZONETOK quotedname zone_block
131 s_di.name=DNSName($2);
133 parent->commit(s_di);
137 ZONETOK quotedname AWORD zone_block
139 s_di.name=DNSName($2);
141 parent->commit(s_di);
147 global_options_command:
148 OPTIONSTOK OBRACE options_commands EBRACE
150 LOGGINGTOK OBRACE options_commands EBRACE
155 ACLTOK quotedname acl_block | ACLTOK filename acl_block
158 acl_block: OBRACE acls EBRACE
172 options_command SEMICOLON options_commands
175 options_command: command | global_options_command
178 global_options_command: options_directory_command | also_notify_command
181 options_directory_command: DIRECTORYTOK quotedname
183 parent->setDirectory($2);
188 also_notify_command: ALSONOTIFYTOK OBRACE also_notify_list EBRACE
193 also_notify SEMICOLON also_notify_list
198 parent->addAlsoNotify($1);
207 term: AWORD | block | quotedname
210 OBRACE commands EBRACE
214 OBRACE zone_commands EBRACE
219 zone_commands zone_command SEMICOLON
223 * in global scope also_notify_command is used instead of zone_also_notify_command
225 zone_command: command | global_zone_command | zone_also_notify_command
228 /* zone commands that also are available at global scope */
229 global_zone_command: zone_file_command | zone_type_command | zone_masters_command
232 zone_masters_command: MASTERTOK OBRACE masters EBRACE
235 zone_also_notify_command: ALSONOTIFYTOK OBRACE zone_also_notify_list EBRACE
238 zone_also_notify_list:
240 zone_also_notify SEMICOLON zone_also_notify_list
243 zone_also_notify: AWORD
245 s_di.alsoNotify.insert($1);
252 masters master SEMICOLON
257 s_di.masters.push_back(ComboAddress($1, 53));
265 // printf("Found a filename: '%s'\n",$2);