1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2009 InspIRCd Development Team
6 * See: http://wiki.inspircd.org/Credits
8 * This program is free but copyrighted software; see
9 * the file COPYING for details.
11 * ---------------------------------------------------
17 class ModuleTestClient : public Module
23 ModuleTestClient(InspIRCd* Me)
26 Implementation eventlist[] = { I_OnRequest, I_OnBackgroundTimer };
27 ServerInstance->Modules->Attach(eventlist, this, 2);
31 virtual Version GetVersion()
33 return Version("$Id$", VF_VENDOR, API_VERSION);
36 virtual void OnBackgroundTimer(time_t)
38 Module* target = ServerInstance->Modules->FindFeature("SQL");
42 SQLrequest foo = SQLrequest(this, target, "foo",
43 SQLquery("UPDATE rawr SET foo = '?' WHERE bar = 42") % ServerInstance->Time());
47 ServerInstance->Logs->Log("m_testclient.so", DEBUG, "Sent query, got given ID %lu", foo.id);
51 ServerInstance->Logs->Log("m_testclient.so", DEBUG, "SQLrequest failed: %s", foo.error.Str());
56 virtual const char* OnRequest(Request* request)
58 if(strcmp(SQLRESID, request->GetId()) == 0)
60 ServerInstance->Logs->Log("m_testclient.so", DEBUG, "Got SQL result (%s)", request->GetId());
62 SQLresult* res = (SQLresult*)request;
64 if (res->error.Id() == SQL_NO_ERROR)
68 ServerInstance->Logs->Log("m_testclient.so", DEBUG, "Got result with %d rows and %d columns", res->Rows(), res->Cols());
70 for (int r = 0; r < res->Rows(); r++)
72 ServerInstance->Logs->Log("m_testclient.so", DEBUG, "Row %d:", r);
74 for(int i = 0; i < res->Cols(); i++)
76 ServerInstance->Logs->Log("m_testclient.so", DEBUG, "\t[%s]: %s", res->ColName(i).c_str(), res->GetValue(r, i).d.c_str());
82 ServerInstance->Logs->Log("m_testclient.so", DEBUG, "%d rows affected in query", res->Rows());
87 ServerInstance->Logs->Log("m_testclient.so", DEBUG, "SQLrequest failed: %s", res->error.Str());
94 ServerInstance->Logs->Log("m_testclient.so", DEBUG, "Got unsupported API version string: %s", request->GetId());
99 virtual ~ModuleTestClient()
104 MODULE_INIT(ModuleTestClient)