6 #include "helperfuncs.h"
8 #include "configreader.h"
11 class ModuleTestClient : public Module
17 ModuleTestClient(Server* Me)
18 : Module::Module(Me), Srv(Me)
22 void Implements(char* List)
24 List[I_OnRequest] = List[I_OnBackgroundTimer] = 1;
27 virtual Version GetVersion()
29 return Version(1, 0, 0, 0, VF_VENDOR);
32 virtual void OnBackgroundTimer(time_t foo)
34 Module* target = Srv->FindFeature("SQL");
38 SQLrequest foo = SQLreq(this, target, "foo", "UPDATE rawr SET foo = '?' WHERE bar = 42", ConvToStr(time(NULL)));
42 log(DEBUG, "Sent query, got given ID %lu", foo.id);
46 log(DEBUG, "SQLrequest failed: %s", foo.error.Str());
51 virtual char* OnRequest(Request* request)
53 if(strcmp(SQLRESID, request->GetData()) == 0)
55 log(DEBUG, "Got SQL result (%s)", request->GetData());
57 SQLresult* res = (SQLresult*)request;
59 if (res->error.Id() == NO_ERROR)
63 log(DEBUG, "Got result with %d rows and %d columns", res->Rows(), res->Cols());
65 for (int r = 0; r < res->Rows(); r++)
67 log(DEBUG, "Row %d:", r);
69 for(int i = 0; i < res->Cols(); i++)
71 log(DEBUG, "\t[%s]: %s", res->ColName(i).c_str(), res->GetValue(r, i).d.c_str());
77 log(DEBUG, "%d rows affected in query", res->Rows());
82 log(DEBUG, "SQLrequest failed: %s", res->error.Str());
89 log(DEBUG, "Got unsupported API version string: %s", request->GetData());
94 virtual ~ModuleTestClient()
99 class ModuleTestClientFactory : public ModuleFactory
102 ModuleTestClientFactory()
106 ~ModuleTestClientFactory()
110 virtual Module * CreateModule(Server* Me)
112 return new ModuleTestClient(Me);
117 extern "C" void * init_module( void )
119 return new ModuleTestClientFactory;