BIND 10 trac2377, updated. ca3df534f52eeba02030280eee1e716b40bc5c88 [2377] Skeleton of the master loader
BIND 10 source code commits
bind10-changes at lists.isc.org
Fri Nov 30 15:23:02 UTC 2012
The branch, trac2377 has been updated
via ca3df534f52eeba02030280eee1e716b40bc5c88 (commit)
from b3ea5d687594f1ca20962f661e38065883e7e265 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit ca3df534f52eeba02030280eee1e716b40bc5c88
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date: Fri Nov 30 16:22:45 2012 +0100
[2377] Skeleton of the master loader
-----------------------------------------------------------------------
Summary of changes:
src/lib/dns/master_loader.cc | 59 +++++++++++++++++++++++++--
src/lib/dns/master_loader.h | 7 ++--
src/lib/dns/tests/master_loader_unittest.cc | 2 +
3 files changed, 61 insertions(+), 7 deletions(-)
-----------------------------------------------------------------------
diff --git a/src/lib/dns/master_loader.cc b/src/lib/dns/master_loader.cc
index 9f3b7ea..f9f3c03 100644
--- a/src/lib/dns/master_loader.cc
+++ b/src/lib/dns/master_loader.cc
@@ -13,10 +13,20 @@
// PERFORMANCE OF THIS SOFTWARE.
#include <dns/master_loader.h>
+#include <dns/master_lexer.h>
+#include <dns/name.h>
+#include <dns/rrttl.h>
+#include <dns/rrclass.h>
+#include <dns/rrtype.h>
+#include <dns/rrset.h>
+
+using std::string;
namespace isc {
namespace dns {
+typedef MasterLexer::Token MasterToken;
+
class MasterLoader::MasterLoaderImpl {
public:
MasterLoaderImpl(const char* master_file,
@@ -35,13 +45,54 @@ public:
lexer_.pushSource(master_file);
}
+ // Get a string token. Handle it as error if it is not string.
+ const string getString() {
+ // TODO: Use the wrapper version
+ const MasterToken token(lexer_.getNextToken());
+ if (token.getType() != MasterToken::STRING &&
+ token.getType() != MasterToken::QSTRING) {
+ assert(0); // Handle the error
+ }
+ return (token.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 31b04bf..61ac7af 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 <dns/name.h>
-#include <dns/rrclass.h>
-#include <dns/master_lexer.h>
#include <dns/master_loader_callbacks.h>
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 fa89bf0..688410b 100644
--- a/src/lib/dns/tests/master_loader_unittest.cc
+++ b/src/lib/dns/tests/master_loader_unittest.cc
@@ -16,6 +16,8 @@
#include <dns/master_loader.h>
#include <dns/rrtype.h>
#include <dns/rrset.h>
+#include <dns/rrclass.h>
+#include <dns/name.h>
#include <gtest/gtest.h>
#include <boost/bind.hpp>
More information about the bind10-changes
mailing list