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 * ---------------------------------------------------
18 #include "configreader.h"
21 class ModuleTestClient : public Module
27 ModuleTestClient(InspIRCd* Me)
32 void Implements(char* List)
34 List[I_OnRequest] = List[I_OnBackgroundTimer] = 1;
37 virtual Version GetVersion()
39 return Version(1, 1, 0, 0, VF_VENDOR, API_VERSION);
42 virtual void OnBackgroundTimer(time_t foo)
44 Module* target = ServerInstance->FindFeature("SQL");
48 SQLrequest foo = SQLreq(this, target, "foo", "UPDATE rawr SET foo = '?' WHERE bar = 42", ConvToStr(time(NULL)));
52 ServerInstance->Log(DEBUG, "Sent query, got given ID %lu", foo.id);
56 ServerInstance->Log(DEBUG, "SQLrequest failed: %s", foo.error.Str());
61 virtual char* OnRequest(Request* request)
63 if(strcmp(SQLRESID, request->GetId()) == 0)
65 ServerInstance->Log(DEBUG, "Got SQL result (%s)", request->GetId());
67 SQLresult* res = (SQLresult*)request;
69 if (res->error.Id() == NO_ERROR)
73 ServerInstance->Log(DEBUG, "Got result with %d rows and %d columns", res->Rows(), res->Cols());
75 for (int r = 0; r < res->Rows(); r++)
77 ServerInstance->Log(DEBUG, "Row %d:", r);
79 for(int i = 0; i < res->Cols(); i++)
81 ServerInstance->Log(DEBUG, "\t[%s]: %s", res->ColName(i).c_str(), res->GetValue(r, i).d.c_str());
87 ServerInstance->Log(DEBUG, "%d rows affected in query", res->Rows());
92 ServerInstance->Log(DEBUG, "SQLrequest failed: %s", res->error.Str());
99 ServerInstance->Log(DEBUG, "Got unsupported API version string: %s", request->GetId());
104 virtual ~ModuleTestClient()
109 class ModuleTestClientFactory : public ModuleFactory
112 ModuleTestClientFactory()
116 ~ModuleTestClientFactory()
120 virtual Module * CreateModule(InspIRCd* Me)
122 return new ModuleTestClient(Me);
127 extern "C" void * init_module( void )
129 return new ModuleTestClientFactory;