From: Michal 'vorner' Vaner Date: Fri, 30 Nov 2012 15:22:45 +0000 (+0100) Subject: [2377] Skeleton of the master loader X-Git-Tag: bind10-1.0.0-beta-release~24^2~61 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=57fda3f1db7ebbc966ae1ab980409a923196ba5e;p=thirdparty%2Fkea.git [2377] Skeleton of the master loader --- diff --git a/src/lib/dns/master_loader.cc b/src/lib/dns/master_loader.cc index 9f3b7ea59d..042e2e7715 100644 --- a/src/lib/dns/master_loader.cc +++ b/src/lib/dns/master_loader.cc @@ -13,6 +13,14 @@ // PERFORMANCE OF THIS SOFTWARE. #include +#include +#include +#include +#include +#include +#include + +using std::string; namespace isc { namespace dns { @@ -35,13 +43,48 @@ public: lexer_.pushSource(master_file); } + // Get a string token. Handle it as error if it is not string. + const string getString() { + return (lexer_.getNextToken(MasterToken::QSTRING).getString()); + } + bool loadIncremental(size_t count_limit) { size_t count = 0; bool done = false; - do { - // Code goes here - } while (!done && (count_limit != 0 && ++count < count_limit)); - // add remaining rrset that was being built (TODO) + // TODO: Replace getNextToken with the wrapper version + while (!done && (count < count_limit)) { + // Skip all EOLNs and finish on EOF + bool empty = true; + do { + const MasterToken& empty_token(lexer_.getNextToken()); + if (empty_token.getType() == MasterToken::END_OF_FILE) { + // TODO: Check if this is the last source, possibly pop + return (true); + } + empty = empty_token.getType() == MasterToken::END_OF_LINE; + } while (empty); + // Return the last token, as it was not empty + lexer_.ungetToken(); + + const string name_string(getString()); + // TODO $ handling + const Name name(name_string); // TODO: Origin + // TODO: Some more flexibility. We don't allow omitting anything yet + + // The parameters + const RRTTL ttl(getString()); + const RRClass rrclass(getString()); + const RRType rrtype(getString()); + + // Create the RRset. We don't need the RRSIG, so we are good + // with the basic one + RRsetPtr rrset(new BasicRRset(name, rrclass, rrtype, ttl)); + + // TODO: Create the RData + + // OK now, so give the RRset with single RR to the caller + add_callback_(rrset); + } return (false); } diff --git a/src/lib/dns/master_loader.h b/src/lib/dns/master_loader.h index 31b04bf822..61ac7aff2f 100644 --- a/src/lib/dns/master_loader.h +++ b/src/lib/dns/master_loader.h @@ -15,13 +15,14 @@ #ifndef MASTER_LOADER_H #define MASTER_LOADER_H -#include -#include -#include #include namespace isc { namespace dns { + +class Name; +class RRClass; + class MasterLoader { public: enum Options { diff --git a/src/lib/dns/tests/master_loader_unittest.cc b/src/lib/dns/tests/master_loader_unittest.cc index fa89bf0955..688410ba7b 100644 --- a/src/lib/dns/tests/master_loader_unittest.cc +++ b/src/lib/dns/tests/master_loader_unittest.cc @@ -16,6 +16,8 @@ #include #include #include +#include +#include #include #include