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 if(DI.filename[0]!='/')
93 DI.filename=d_dir+"/"+DI.filename;
96 cerr<<"Domain "<<DI.name.toStringNoDot()<<" lives in file '"<<DI.filename<<"'"<<endl;
98 d_zonedomains.push_back(DI);
103 %token AWORD QUOTEDWORD OBRACE EBRACE SEMICOLON ZONETOK FILETOK OPTIONSTOK
104 %token DIRECTORYTOK ACLTOK LOGGINGTOK CLASSTOK TYPETOK MASTERTOK ALSONOTIFYTOK
110 root_commands root_command SEMICOLON
113 root_command: command | acl_command | global_zone_command | global_options_command
118 commands command SEMICOLON
126 ZONETOK quotedname zone_block
128 s_di.name=DNSName($2);
130 parent->commit(s_di);
134 ZONETOK quotedname AWORD zone_block
136 s_di.name=DNSName($2);
138 parent->commit(s_di);
144 global_options_command:
145 OPTIONSTOK OBRACE options_commands EBRACE
147 LOGGINGTOK OBRACE options_commands EBRACE
152 ACLTOK quotedname acl_block | ACLTOK filename acl_block
155 acl_block: OBRACE acls EBRACE
169 options_command SEMICOLON options_commands
172 options_command: command | global_options_command
175 global_options_command: options_directory_command | also_notify_command
178 options_directory_command: DIRECTORYTOK quotedname
180 parent->setDirectory($2);
185 also_notify_command: ALSONOTIFYTOK OBRACE also_notify_list EBRACE
190 also_notify SEMICOLON also_notify_list
195 parent->addAlsoNotify($1);
204 term: AWORD | block | quotedname
207 OBRACE commands EBRACE
211 OBRACE zone_commands EBRACE
216 zone_commands zone_command SEMICOLON
220 * in global scope also_notify_command is used instead of zone_also_notify_command
222 zone_command: command | global_zone_command | zone_also_notify_command
225 /* zone commands that also are available at global scope */
226 global_zone_command: zone_file_command | zone_type_command | zone_masters_command
229 zone_masters_command: MASTERTOK OBRACE masters EBRACE
232 zone_also_notify_command: ALSONOTIFYTOK OBRACE zone_also_notify_list EBRACE
235 zone_also_notify_list:
237 zone_also_notify SEMICOLON zone_also_notify_list
240 zone_also_notify: AWORD
242 s_di.alsoNotify.insert($1);
249 masters master SEMICOLON
254 s_di.masters.push_back($1);
262 // printf("Found a filename: '%s'\n",$2);