11 #include "pdnsexception.hh"
12 #include "namespaces.hh"
15 #include "bindparserclasses.hh"
17 #define YYSTYPE char *
23 void yyrestart(FILE *);
32 const char *bind_directory;
33 extern int linenumber;
34 static void yyerror(const char *str)
36 extern char *current_filename;
37 throw PDNSException("Error in bind configuration '"+string(current_filename)+"' on line "+itoa(linenumber)+": "+str);
41 static BindParser *parent;
44 void BindParser::parse(const string &fname)
47 yyin=fopen(fname.c_str(),"r");
50 throw PDNSException("Unable to open '"+fname+"': "+strerror(errno));
54 extern char *current_filename;
55 extern char *original_filename;
57 current_filename=original_filename=(char*)fname.c_str();
61 // cerr<<"Need to parse "<<d_zonedomains.size()<<" zone statements"<<endl;
64 void BindParser::setDirectory(const string &dir)
67 bind_directory=d_dir.c_str();
70 void BindParser::addAlsoNotify(const string & host)
72 alsoNotify.insert(host);
75 const string &BindParser::getDirectory()
80 const vector<BindDomainInfo>& BindParser::getDomains()
85 void BindParser::setVerbose(bool verbose)
90 void BindParser::commit(BindDomainInfo DI)
92 DI.hadFileDirective = (DI.filename != "");
94 if(DI.filename[0]!='/')
95 DI.filename=d_dir+"/"+DI.filename;
98 cerr<<"Domain "<<DI.name.toStringNoDot()<<" lives in file '"<<DI.filename<<"'"<<endl;
100 d_zonedomains.push_back(DI);
105 %token AWORD QUOTEDWORD OBRACE EBRACE SEMICOLON ZONETOK FILETOK OPTIONSTOK
106 %token DIRECTORYTOK ACLTOK LOGGINGTOK CLASSTOK TYPETOK MASTERTOK ALSONOTIFYTOK
112 root_commands root_command SEMICOLON
115 root_command: command | acl_command | global_zone_command | global_options_command
120 commands command SEMICOLON
128 ZONETOK quotedname zone_block
130 s_di.name=DNSName($2);
132 parent->commit(s_di);
136 ZONETOK quotedname AWORD zone_block
138 s_di.name=DNSName($2);
140 parent->commit(s_di);
146 global_options_command:
147 OPTIONSTOK OBRACE options_commands EBRACE
149 LOGGINGTOK OBRACE options_commands EBRACE
154 ACLTOK quotedname acl_block | ACLTOK filename acl_block
157 acl_block: OBRACE acls EBRACE
171 options_command SEMICOLON options_commands
174 options_command: command | global_options_command
177 global_options_command: options_directory_command | also_notify_command
180 options_directory_command: DIRECTORYTOK quotedname
182 parent->setDirectory($2);
187 also_notify_command: ALSONOTIFYTOK OBRACE also_notify_list EBRACE
192 also_notify SEMICOLON also_notify_list
197 parent->addAlsoNotify($1);
206 term: AWORD | block | quotedname
209 OBRACE commands EBRACE
213 OBRACE zone_commands EBRACE
218 zone_commands zone_command SEMICOLON
222 * in global scope also_notify_command is used instead of zone_also_notify_command
224 zone_command: command | global_zone_command | zone_also_notify_command
227 /* zone commands that also are available at global scope */
228 global_zone_command: zone_file_command | zone_type_command | zone_masters_command
231 zone_masters_command: MASTERTOK OBRACE masters EBRACE
234 zone_also_notify_command: ALSONOTIFYTOK OBRACE zone_also_notify_list EBRACE
237 zone_also_notify_list:
239 zone_also_notify SEMICOLON zone_also_notify_list
242 zone_also_notify: AWORD
244 s_di.alsoNotify.insert($1);
251 masters master SEMICOLON
256 s_di.masters.push_back($1);
264 // printf("Found a filename: '%s'\n",$2);