#include "m_sqlv2.h"
/* $ModDesc: MsSQL provider */
+/* $CompileFlags: exec("grep VERSION_NO /usr/include/tdsver.h 2>/dev/null | perl -e 'print "-D_TDSVER=".((<> =~ /freetds v(\d+\.\d+)/i) ? $1*100 : 0);'") */
/* $LinkerFlags: -ltds */
/* $ModDep: m_sqlv2.h */
{
private:
ModuleMsSQL* Parent;
- InspIRCd* Instance;
+ InspIRCd* ServerInstance;
public:
QueryThread(InspIRCd* si, ModuleMsSQL* mod)
- : Thread(), Parent(mod), Instance(si)
+ : Thread(), Parent(mod), ServerInstance(si)
{
}
~QueryThread() { }
virtual bool OnDataReady()
{
char data = 0;
- if (Instance->SE->Recv(this, &data, 1, 0) > 0)
+ if (ServerInstance->SE->Recv(this, &data, 1, 0) > 0)
{
Dispatch();
return true;
class MsSQLListener : public ListenSocketBase
{
ModuleMsSQL* Parent;
- insp_sockaddr sock_us;
+ irc::sockets::insp_sockaddr sock_us;
socklen_t uslen;
FileReader* index;
{
private:
ResultQueue results;
- InspIRCd* Instance;
+ InspIRCd* ServerInstance;
Module* mod;
SQLhost host;
TDSLOGIN* login;
QueryQueue queue;
SQLConn(InspIRCd* SI, Module* m, const SQLhost& hi)
- : Instance(SI), mod(m), host(hi), login(NULL), sock(NULL), context(NULL)
+ : ServerInstance(SI), mod(m), host(hi), login(NULL), sock(NULL), context(NULL)
{
if (OpenDB())
{
if (tds_process_simple_query(sock) != TDS_SUCCEED)
{
LoggingMutex->Lock();
- Instance->Logs->Log("m_mssql",DEFAULT, "WARNING: Could not select database " + host.name + " for DB with id: " + host.id);
+ ServerInstance->Logs->Log("m_mssql",DEFAULT, "WARNING: Could not select database " + host.name + " for DB with id: " + host.id);
LoggingMutex->Unlock();
CloseDB();
}
else
{
LoggingMutex->Lock();
- Instance->Logs->Log("m_mssql",DEFAULT, "WARNING: Could not select database " + host.name + " for DB with id: " + host.id);
+ ServerInstance->Logs->Log("m_mssql",DEFAULT, "WARNING: Could not select database " + host.name + " for DB with id: " + host.id);
LoggingMutex->Unlock();
CloseDB();
}
else
{
LoggingMutex->Lock();
- Instance->Logs->Log("m_mssql",DEFAULT, "WARNING: Could not connect to DB with id: " + host.id);
+ ServerInstance->Logs->Log("m_mssql",DEFAULT, "WARNING: Could not connect to DB with id: " + host.id);
LoggingMutex->Unlock();
CloseDB();
}
char* msquery = strdup(req.query.q.data());
LoggingMutex->Lock();
- Instance->Logs->Log("m_mssql",DEBUG,"doing Query: %s",msquery);
+ ServerInstance->Logs->Log("m_mssql",DEBUG,"doing Query: %s",msquery);
LoggingMutex->Unlock();
if (tds_submit_query(sock, msquery) != TDS_SUCCEED)
{
int tds_res;
while (tds_process_tokens(sock, &tds_res, NULL, TDS_TOKEN_RESULTS) == TDS_SUCCEED)
{
- //Instance->Logs->Log("m_mssql",DEBUG,"<******> result type: %d", tds_res);
- //Instance->Logs->Log("m_mssql",DEBUG,"AFFECTED ROWS: %d", sock->rows_affected);
+ //ServerInstance->Logs->Log("m_mssql",DEBUG,"<******> result type: %d", tds_res);
+ //ServerInstance->Logs->Log("m_mssql",DEBUG,"AFFECTED ROWS: %d", sock->rows_affected);
switch (tds_res)
{
case TDS_ROWFMT_RESULT:
unsigned char* src;
CONV_RESULT dres;
ctype = tds_get_conversion_type(col->column_type, col->column_size);
- src = &(sock->current_results->current_row[col->column_offset]);
+#if _TDSVER >= 82
+ src = col->column_data;
+#else
+ src = &(sock->current_results->current_row[col->column_offset]);
+#endif
srclen = col->column_cur_size;
tds_convert(sock->tds_ctx, ctype, (TDS_CHAR *) src, srclen, SYBCHAR, &dres);
data[j] = (char*)dres.ib;
{
SQLConn* sc = (SQLConn*)pContext->parent;
LoggingMutex->Lock();
- sc->Instance->Logs->Log("m_mssql", DEBUG, "Message for DB with id: %s -> %s", sc->host.id.c_str(), pMessage->message);
+ sc->ServerInstance->Logs->Log("m_mssql", DEBUG, "Message for DB with id: %s -> %s", sc->host.id.c_str(), pMessage->message);
LoggingMutex->Unlock();
return 0;
}
{
SQLConn* sc = (SQLConn*)pContext->parent;
LoggingMutex->Lock();
- sc->Instance->Logs->Log("m_mssql", DEFAULT, "Error for DB with id: %s -> %s", sc->host.id.c_str(), pMessage->message);
+ sc->ServerInstance->Logs->Log("m_mssql", DEFAULT, "Error for DB with id: %s -> %s", sc->host.id.c_str(), pMessage->message);
LoggingMutex->Unlock();
return 0;
}
return;
}
- insp_sockaddr addr;
+ irc::sockets::insp_sockaddr addr;
#ifdef IPV6
- insp_aton("::1", &addr.sin6_addr);
+ irc::sockets::insp_aton("::1", &addr.sin6_addr);
addr.sin6_family = AF_FAMILY;
addr.sin6_port = htons(listener->GetPort());
#else
- insp_inaddr ia;
- insp_aton("127.0.0.1", &ia);
+ irc::sockets::insp_inaddr ia;
+ irc::sockets::insp_aton("127.0.0.1", &ia);
addr.sin_family = AF_FAMILY;
addr.sin_addr = ia;
addr.sin_port = htons(listener->GetPort());
ClearAllConnections();
ServerInstance->SE->DelFd(listener);
- //listener->Close();
ServerInstance->BufferedSocketCull();
if (QueueFD >= 0)