6 #include "helperfuncs.h"
8 #include "configreader.h"
11 extern InspIRCd* ServerInstance;
13 class ModuleTestClient : public Module
19 ModuleTestClient(InspIRCd* Me)
24 void Implements(char* List)
26 List[I_OnRequest] = List[I_OnBackgroundTimer] = 1;
29 virtual Version GetVersion()
31 return Version(1, 0, 0, 0, VF_VENDOR);
34 virtual void OnBackgroundTimer(time_t foo)
36 Module* target = ServerInstance->FindFeature("SQL");
40 SQLrequest foo = SQLreq(this, target, "foo", "UPDATE rawr SET foo = '?' WHERE bar = 42", ConvToStr(time(NULL)));
44 log(DEBUG, "Sent query, got given ID %lu", foo.id);
48 log(DEBUG, "SQLrequest failed: %s", foo.error.Str());
53 virtual char* OnRequest(Request* request)
55 if(strcmp(SQLRESID, request->GetId()) == 0)
57 log(DEBUG, "Got SQL result (%s)", request->GetId());
59 SQLresult* res = (SQLresult*)request;
61 if (res->error.Id() == NO_ERROR)
65 log(DEBUG, "Got result with %d rows and %d columns", res->Rows(), res->Cols());
67 for (int r = 0; r < res->Rows(); r++)
69 log(DEBUG, "Row %d:", r);
71 for(int i = 0; i < res->Cols(); i++)
73 log(DEBUG, "\t[%s]: %s", res->ColName(i).c_str(), res->GetValue(r, i).d.c_str());
79 log(DEBUG, "%d rows affected in query", res->Rows());
84 log(DEBUG, "SQLrequest failed: %s", res->error.Str());
91 log(DEBUG, "Got unsupported API version string: %s", request->GetId());
96 virtual ~ModuleTestClient()
101 class ModuleTestClientFactory : public ModuleFactory
104 ModuleTestClientFactory()
108 ~ModuleTestClientFactory()
112 virtual Module * CreateModule(InspIRCd* Me)
114 return new ModuleTestClient(Me);
119 extern "C" void * init_module( void )
121 return new ModuleTestClientFactory;