Parcourir la source

[1976] A transitional class to wrap a client to list

Michal 'vorner' Vaner il y a 13 ans
Parent
commit
6a56ac9b0e
2 fichiers modifiés avec 34 ajouts et 1 suppressions
  1. 1 1
      src/bin/auth/Makefile.am
  2. 33 0
      src/bin/auth/list.h

+ 1 - 1
src/bin/auth/Makefile.am

@@ -49,7 +49,7 @@ b10_auth_SOURCES += command.cc command.h
 b10_auth_SOURCES += common.h common.cc
 b10_auth_SOURCES += statistics.cc statistics.h
 b10_auth_SOURCES += datasrc_configurator.h
-b10_auth_SOURCES += main.cc
+b10_auth_SOURCES += main.cc list.h
 # This is a temporary workaround for #1206, where the InMemoryClient has been
 # moved to an ldopened library. We could add that library to LDADD, but that
 # is nonportable. This should've been moot after #1207, but there is still

+ 33 - 0
src/bin/auth/list.h

@@ -0,0 +1,33 @@
+#include <datasrc/client_list.h>
+#include <datasrc/client.h>
+
+#include <dns/name.h>
+
+// Note: This file breaks almost every rule about how it should look like and
+// other formalities. However, it is only a transitional file and will be deleted
+// before the end of this branch.
+
+using namespace isc::datasrc;
+using namespace isc::dns;
+
+class SingletonList : public ClientList {
+public:
+    SingletonList(DataSourceClient& client) :
+        client_(client)
+    {}
+    virtual FindResult find(const Name& zone, bool exact, bool) const {
+        DataSourceClient::FindResult result(client_.findZone(zone));
+        switch (result.code) {
+            case result::SUCCESS:
+                return (FindResult(&client_, result.zone_finder, true));
+            case result::PARTIALMATCH:
+                if (!exact) {
+                    return (FindResult(&client_, result.zone_finder, false));
+                }
+            default:
+                return (FindResult());
+        }
+    }
+private:
+    DataSourceClient& client_;
+};