11 #include "pdnsexception.hh"
12 #include "namespaces.hh"
16 #include "bindparserclasses.hh"
18 #define YYSTYPE char *
24 void yyrestart(FILE *);
34 const char *bind_directory;
35 extern int linenumber;
36 static void yyerror(const char *str)
38 extern char *current_filename;
39 throw PDNSException("Error in bind configuration '"+string(current_filename)+"' on line "+itoa(linenumber)+": "+str);
43 static BindParser *parent;
46 void BindParser::parse(const string &fname)
49 yyin=fopen(fname.c_str(),"r");
52 throw PDNSException("Unable to open '"+fname+"': "+strerror(errno));
56 extern char *current_filename;
57 extern char *original_filename;
59 current_filename=original_filename=(char*)fname.c_str();
63 // cerr<<"Need to parse "<<d_zonedomains.size()<<" zone statements"<<endl;
66 void BindParser::setDirectory(const string &dir)
69 bind_directory=d_dir.c_str();
72 void BindParser::addAlsoNotify(const string & host)
74 alsoNotify.insert(host);
77 const string &BindParser::getDirectory()
82 const vector<BindDomainInfo>& BindParser::getDomains()
87 void BindParser::setVerbose(bool verbose)
92 void BindParser::commit(BindDomainInfo DI)
94 DI.hadFileDirective = (DI.filename != "");
96 if(DI.filename[0]!='/')
97 DI.filename=d_dir+"/"+DI.filename;
100 cerr<<"Domain "<<DI.name.toStringNoDot()<<" lives in file '"<<DI.filename<<"'"<<endl;
102 d_zonedomains.push_back(DI);
107 %token AWORD QUOTEDWORD OBRACE EBRACE SEMICOLON ZONETOK FILETOK OPTIONSTOK
108 %token DIRECTORYTOK ACLTOK LOGGINGTOK CLASSTOK TYPETOK MASTERTOK ALSONOTIFYTOK
114 root_commands root_command SEMICOLON
117 root_command: command | acl_command | global_zone_command | global_options_command
122 commands command SEMICOLON
130 ZONETOK quotedname zone_block
132 s_di.name=DNSName($2);
134 parent->commit(s_di);
138 ZONETOK quotedname AWORD zone_block
140 s_di.name=DNSName($2);
142 parent->commit(s_di);
148 global_options_command:
149 OPTIONSTOK OBRACE options_commands EBRACE
151 LOGGINGTOK OBRACE options_commands EBRACE
156 ACLTOK quotedname acl_block | ACLTOK filename acl_block
159 acl_block: OBRACE acls EBRACE
173 options_command SEMICOLON options_commands
176 options_command: command | global_options_command
179 global_options_command: options_directory_command | also_notify_command
182 options_directory_command: DIRECTORYTOK quotedname
184 parent->setDirectory($2);
189 also_notify_command: ALSONOTIFYTOK OBRACE also_notify_list EBRACE
194 also_notify SEMICOLON also_notify_list
199 parent->addAlsoNotify($1);
208 term: AWORD | block | quotedname
211 OBRACE commands EBRACE
215 OBRACE zone_commands EBRACE
220 zone_commands zone_command SEMICOLON
224 * in global scope also_notify_command is used instead of zone_also_notify_command
226 zone_command: command | global_zone_command | zone_also_notify_command
229 /* zone commands that also are available at global scope */
230 global_zone_command: zone_file_command | zone_type_command | zone_masters_command
233 zone_masters_command: MASTERTOK OBRACE masters EBRACE
236 zone_also_notify_command: ALSONOTIFYTOK OBRACE zone_also_notify_list EBRACE
239 zone_also_notify_list:
241 zone_also_notify SEMICOLON zone_also_notify_list
244 zone_also_notify: AWORD
246 s_di.alsoNotify.insert($1);
253 masters master SEMICOLON
258 s_di.masters.push_back(ComboAddress($1, 53));
266 // printf("Found a filename: '%s'\n",$2);