]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
Merge #2428
authorMichal 'vorner' Vaner <michal.vaner@nic.cz>
Fri, 14 Dec 2012 09:36:17 +0000 (10:36 +0100)
committerMichal 'vorner' Vaner <michal.vaner@nic.cz>
Fri, 14 Dec 2012 09:36:17 +0000 (10:36 +0100)
$INCLUDE handling in the isc::dns::MasterLoader

Conflicts:
src/lib/dns/master_loader.cc

1  2 
src/lib/dns/master_lexer.cc
src/lib/dns/master_lexer.h
src/lib/dns/master_loader.cc
src/lib/dns/tests/master_lexer_unittest.cc
src/lib/dns/tests/master_loader_unittest.cc

Simple merge
Simple merge
index 941a100948749a627ca3e176495fd23ea0c8b279,e4b662c1e05231adb9b2cd6d93df862f63a11150..0a3db399cb56ab60ac4e4a9794c82243bc6eb3ef
@@@ -94,6 -116,74 +116,74 @@@ public
  
      bool loadIncremental(size_t count_limit);
  
 -                                       "Unexpected end ond of file");
+     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(),
++                                       "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_;