1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2007 InspIRCd Development Team
6 * See: http://www.inspircd.org/wiki/index.php/Credits
8 * This program is free but copyrighted software; see
9 * the file COPYING for details.
11 * ---------------------------------------------------
21 #include "configreader.h"
26 class ModuleTestClient : public Module
32 ModuleTestClient(InspIRCd* Me)
37 void Implements(char* List)
39 List[I_OnRequest] = List[I_OnBackgroundTimer] = 1;
42 virtual Version GetVersion()
44 return Version(1, 1, 0, 0, VF_VENDOR, API_VERSION);
47 virtual void OnBackgroundTimer(time_t foo)
49 Module* target = ServerInstance->FindFeature("SQL");
53 SQLrequest foo = SQLreq(this, target, "foo", "UPDATE rawr SET foo = '?' WHERE bar = 42", ConvToStr(time(NULL)));
57 ServerInstance->Log(DEBUG, "Sent query, got given ID %lu", foo.id);
61 ServerInstance->Log(DEBUG, "SQLrequest failed: %s", foo.error.Str());
66 virtual char* OnRequest(Request* request)
68 if(strcmp(SQLRESID, request->GetId()) == 0)
70 ServerInstance->Log(DEBUG, "Got SQL result (%s)", request->GetId());
72 SQLresult* res = (SQLresult*)request;
74 if (res->error.Id() == NO_ERROR)
78 ServerInstance->Log(DEBUG, "Got result with %d rows and %d columns", res->Rows(), res->Cols());
80 for (int r = 0; r < res->Rows(); r++)
82 ServerInstance->Log(DEBUG, "Row %d:", r);
84 for(int i = 0; i < res->Cols(); i++)
86 ServerInstance->Log(DEBUG, "\t[%s]: %s", res->ColName(i).c_str(), res->GetValue(r, i).d.c_str());
92 ServerInstance->Log(DEBUG, "%d rows affected in query", res->Rows());
97 ServerInstance->Log(DEBUG, "SQLrequest failed: %s", res->error.Str());
104 ServerInstance->Log(DEBUG, "Got unsupported API version string: %s", request->GetId());
109 virtual ~ModuleTestClient()
114 class ModuleTestClientFactory : public ModuleFactory
117 ModuleTestClientFactory()
121 ~ModuleTestClientFactory()
125 virtual Module * CreateModule(InspIRCd* Me)
127 return new ModuleTestClient(Me);
132 extern "C" void * init_module( void )
134 return new ModuleTestClientFactory;