summaryrefslogtreecommitdiff
path: root/ndb/tools
diff options
context:
space:
mode:
authorunknown <hartmut@mysql.com>2005-09-26 19:45:22 +0200
committerunknown <hartmut@mysql.com>2005-09-26 19:45:22 +0200
commit6483ec52461c2ae16ff09d47312d18319e3fb326 (patch)
treef4cde8f9cf9dd9f9329f4fec534cd24473b8f6c2 /ndb/tools
parentad8ff14165ed656aee697b49eac6c7e8cb5a5c00 (diff)
parentc8fde9f33ef53ca97714e72f8ab8a0cc34d65736 (diff)
downloadmariadb-git-6483ec52461c2ae16ff09d47312d18319e3fb326.tar.gz
Merge hholzgraefe@bk-internal.mysql.com:/home/bk/mysql-5.0
into mysql.com:/home/hartmut/projects/mysql/dev/5.0
Diffstat (limited to 'ndb/tools')
-rw-r--r--ndb/tools/ndb_config.cpp48
1 files changed, 45 insertions, 3 deletions
diff --git a/ndb/tools/ndb_config.cpp b/ndb/tools/ndb_config.cpp
index 725249a5af5..290dd440479 100644
--- a/ndb/tools/ndb_config.cpp
+++ b/ndb/tools/ndb_config.cpp
@@ -23,6 +23,8 @@
#include <my_getopt.h>
#include <mysql_version.h>
+#include <netdb.h>
+
#include <NdbOut.hpp>
#include <mgmapi.h>
#include <mgmapi_configuration.hpp>
@@ -127,6 +129,11 @@ struct Match
virtual int eval(NdbMgmHandle, const Iter&);
};
+struct HostMatch : public Match
+{
+ virtual int eval(NdbMgmHandle, const Iter&);
+};
+
struct Apply
{
Apply() {}
@@ -297,9 +304,10 @@ parse_where(Vector<Match*>& where, int &argc, char**& argv)
Match m;
if(g_host)
{
- m.m_key = CFG_NODE_HOST;
- m.m_value.assfmt("%s", g_host);
- where.push_back(new Match(m));
+ HostMatch *m = new HostMatch;
+ m->m_key = CFG_NODE_HOST;
+ m->m_value.assfmt("%s", g_host);
+ where.push_back(m);
}
if(g_type)
@@ -376,6 +384,40 @@ Match::eval(NdbMgmHandle h, const Iter& iter)
}
int
+HostMatch::eval(NdbMgmHandle h, const Iter& iter)
+{
+ const char* valc;
+
+ if(iter.get(m_key, &valc) == 0)
+ {
+ struct hostent *h1, *h2;
+
+ h1 = gethostbyname(m_value.c_str());
+ if (h1 == NULL) {
+ return 0;
+ }
+
+ h2 = gethostbyname(valc);
+ if (h2 == NULL) {
+ return 0;
+ }
+
+ if (h1->h_addrtype != h2->h_addrtype) {
+ return 0;
+ }
+
+ if (h1->h_length != h2->h_length)
+ {
+ return 0;
+ }
+
+ return 0 == memcmp(h1->h_addr, h2->h_addr, h1->h_length);
+ }
+
+ return 0;
+}
+
+int
Apply::apply(NdbMgmHandle h, const Iter& iter)
{
Uint32 val32;