X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fextra%2Fm_testclient.cpp;h=10229dd992d9c3f94ac061e7e42af8676a2ab34e;hb=0b29e01eb5169f5e547b87c32de8e452ba3eff17;hp=069c21c0b60217cbb6ccb2a8c214d856a9ebeb45;hpb=2c6c072c1f5f19d1471feb43fa94bba0030e5fb6;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/extra/m_testclient.cpp b/src/modules/extra/m_testclient.cpp index 069c21c0b..10229dd99 100644 --- a/src/modules/extra/m_testclient.cpp +++ b/src/modules/extra/m_testclient.cpp @@ -8,14 +8,16 @@ #include "configreader.h" #include "m_sqlv2.h" + + class ModuleTestClient : public Module { private: - Server* Srv; + public: - ModuleTestClient(Server* Me) - : Module::Module(Me), Srv(Me) + ModuleTestClient(InspIRCd* Me) + : Module::Module(Me) { } @@ -31,11 +33,11 @@ public: virtual void OnBackgroundTimer(time_t foo) { - Module* target = Srv->FindFeature("SQL"); + Module* target = ServerInstance->FindFeature("SQL"); if(target) { - SQLrequest foo = SQLreq(this, target, "foo", "SELECT foo, bar FROM ?", "rawr"); + SQLrequest foo = SQLreq(this, target, "foo", "UPDATE rawr SET foo = '?' WHERE bar = 42", ConvToStr(time(NULL))); if(foo.Send()) { @@ -50,28 +52,43 @@ public: virtual char* OnRequest(Request* request) { - if(strcmp(SQLRESID, request->GetData()) == 0) + if(strcmp(SQLRESID, request->GetId()) == 0) { - log(DEBUG, "Got SQL result (%s)", request->GetData()); + log(DEBUG, "Got SQL result (%s)", request->GetId()); SQLresult* res = (SQLresult*)request; - - log(DEBUG, "Got result with %d rows and %d columns", res->Rows(), res->Cols()); - - for (int r = 0; r < res->Rows(); r++) + + if (res->error.Id() == NO_ERROR) { - log(DEBUG, "Row %d:", r); - - for(int i = 0; i < res->Cols(); i++) + if(res->Cols()) { - log(DEBUG, "\t[%s]: %s", res->ColName(i).c_str(), res->GetValue(r, i).d.c_str()); + log(DEBUG, "Got result with %d rows and %d columns", res->Rows(), res->Cols()); + + for (int r = 0; r < res->Rows(); r++) + { + log(DEBUG, "Row %d:", r); + + for(int i = 0; i < res->Cols(); i++) + { + log(DEBUG, "\t[%s]: %s", res->ColName(i).c_str(), res->GetValue(r, i).d.c_str()); + } + } + } + else + { + log(DEBUG, "%d rows affected in query", res->Rows()); } } + else + { + log(DEBUG, "SQLrequest failed: %s", res->error.Str()); + + } return SQLSUCCESS; } - log(DEBUG, "Got unsupported API version string: %s", request->GetData()); + log(DEBUG, "Got unsupported API version string: %s", request->GetId()); return NULL; } @@ -92,7 +109,7 @@ class ModuleTestClientFactory : public ModuleFactory { } - virtual Module * CreateModule(Server* Me) + virtual Module * CreateModule(InspIRCd* Me) { return new ModuleTestClient(Me); }