From: Michal 'vorner' Vaner Date: Fri, 14 Dec 2012 09:36:17 +0000 (+0100) Subject: Merge #2428 X-Git-Tag: bind10-1.0.0-beta-release~24 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=a7e16e85fac60062df06be2f371868571d08e5ed;p=thirdparty%2Fkea.git Merge #2428 $INCLUDE handling in the isc::dns::MasterLoader Conflicts: src/lib/dns/master_loader.cc --- a7e16e85fac60062df06be2f371868571d08e5ed diff --cc src/lib/dns/master_loader.cc index 941a100948,e4b662c1e0..0a3db399cb --- a/src/lib/dns/master_loader.cc +++ b/src/lib/dns/master_loader.cc @@@ -94,6 -116,74 +116,74 @@@ public bool loadIncremental(size_t count_limit); + void doInclude() { + // First, get the filename to include + const string + filename(lexer_.getNextToken(MasterToken::QSTRING).getString()); + + // There could be an origin (or maybe not). So try looking + const MasterToken name_tok(lexer_.getNextToken(MasterToken::QSTRING, + true)); + + if (name_tok.getType() == MasterToken::QSTRING || + name_tok.getType() == MasterToken::STRING) { + // TODO: Handle the origin. Once we complete #2427. + } else { + // We return the newline there. This is because after we pop + // the source, we want to call eatUntilEOL and this would + // eat to the next one. + lexer_.ungetToken(); + } + + pushSource(filename); + } + + void handleDirective(const char* directive, size_t length) { + if (iequals(directive, "INCLUDE")) { + doInclude(); + } else if (iequals(directive, "ORIGIN")) { + // TODO: Implement + isc_throw(isc::NotImplemented, + "Origin directive not implemented yet"); + } else if (iequals(directive, "TTL")) { + // TODO: Implement + isc_throw(isc::NotImplemented, + "TTL directive not implemented yet"); + } else { + isc_throw(InternalException, "Unknown directive '" << + string(directive, directive + length) << "'"); + } + } + + void eatUntilEOL(bool reportExtra) { + // We want to continue. Try to read until the end of line + for (;;) { + const MasterToken& token(lexer_.getNextToken()); + switch (token.getType()) { + case MasterToken::END_OF_FILE: + callbacks_.warning(lexer_.getSourceName(), + lexer_.getSourceLine(), - "Unexpected end ond of file"); ++ "File does not end with newline"); + // We don't pop here. The End of file will stay there, + // and we'll handle it in the next iteration of + // loadIncremental properly. + return; + case MasterToken::END_OF_LINE: + // Found the end of the line. Good. + return; + default: + // Some other type of token. + if (reportExtra) { + reportExtra = false; + reportError(lexer_.getSourceName(), + lexer_.getSourceLine(), + "Extra tokens at the end of line"); + } + break; + } + } + } + private: MasterLexer lexer_; const Name zone_origin_;