3 #define DIRTY_HACK WORD
14 #include "ahuexception.hh"
18 #include "bindparser.hh"
20 #define WORD DIRTY_HACK
22 #define YYSTYPE char *
36 const char *bind_directory;
37 extern int linenumber;
38 static void yyerror(const char *str)
40 extern char *current_filename;
41 throw AhuException("Error in bind configuration '"+string(current_filename)+"' on line "+itoa(linenumber)+": "+str);
45 static BindParser *parent;
48 void BindParser::parse(const string &fname)
51 yyin=fopen(fname.c_str(),"r");
54 throw AhuException("Unable to open '"+fname+"': "+strerror(errno));
58 extern char *current_filename;
59 extern char *original_filename;
61 current_filename=original_filename=(char*)fname.c_str();
65 // cerr<<"Need to parse "<<d_zonedomains.size()<<" zone statements"<<endl;
68 void BindParser::setDirectory(const string &dir)
71 bind_directory=d_dir.c_str();
74 const string &BindParser::getDirectory()
79 const vector<BindDomainInfo>& BindParser::getDomains()
84 void BindParser::setVerbose(bool verbose)
89 void BindParser::commit(BindDomainInfo DI)
91 if(DI.filename[0]!='/')
92 DI.filename=d_dir+"/"+DI.filename;
95 cerr<<"Domain "<<DI.name<<" lives in file '"<<DI.filename<<"'"<<endl;
97 d_zonedomains.push_back(DI);
102 %token WORD QUOTEDWORD OBRACE EBRACE SEMICOLON ZONETOK FILETOK OPTIONSTOK
103 %token DIRECTORYTOK ACLTOK LOGGINGTOK CLASSTOK TYPETOK MASTERTOK
109 root_commands root_command SEMICOLON
112 root_command: command | acl_command | zone_command | options_command
117 commands command SEMICOLON
125 ZONETOK quotedname zone_block
128 parent->commit(s_di);
132 ZONETOK quotedname WORD zone_block
135 parent->commit(s_di);
142 OPTIONSTOK OBRACE options_commands EBRACE
144 LOGGINGTOK OBRACE options_commands EBRACE
148 ACLTOK quotedname acl_block | ACLTOK filename acl_block
151 acl_block: OBRACE acls EBRACE
165 options_command SEMICOLON options_commands
168 options_command: command | options_directory_command
171 options_directory_command: DIRECTORYTOK quotedname
173 parent->setDirectory($2);
183 term: WORD | block | quotedname
186 OBRACE commands EBRACE
190 OBRACE zone_commands EBRACE
195 zone_commands zone_command SEMICOLON
198 zone_command: command | zone_file_command | zone_type_command | zone_masters_command
201 zone_masters_command: MASTERTOK OBRACE masters EBRACE
206 masters master SEMICOLON
218 // printf("Found a filename: '%s'\n",$2);
226 // printf("Found a filename: '%s'\n",$2);