From d27af79ee06388dc6d1ab31d95348a38cdfbeb91 Mon Sep 17 00:00:00 2001 From: brain Date: Fri, 5 Sep 2008 08:42:41 +0000 Subject: sql api and m_mysql compile fixes for windows git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@10393 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/modules/extra/m_mssql.cpp | 6 +++--- src/modules/extra/m_mysql.cpp | 6 +++--- src/modules/extra/m_pgsql.cpp | 10 +++++----- src/modules/extra/m_sqlauth.cpp | 2 +- src/modules/extra/m_sqlite3.cpp | 4 ++-- src/modules/extra/m_sqloper.cpp | 2 +- src/modules/extra/m_sqlv2.h | 18 +++++++++--------- src/modules/extra/m_testclient.cpp | 2 +- win/inspircd_win32wrapper.cpp | 9 +++++++++ win/inspircd_win32wrapper.h | 2 ++ 10 files changed, 36 insertions(+), 25 deletions(-) diff --git a/src/modules/extra/m_mssql.cpp b/src/modules/extra/m_mssql.cpp index fbcc83fe0..93f70a18e 100644 --- a/src/modules/extra/m_mssql.cpp +++ b/src/modules/extra/m_mssql.cpp @@ -307,7 +307,7 @@ class SQLConn : public classbase SQLerror Query(SQLrequest &req) { if (!sock) - return SQLerror(BAD_CONN, "Socket was NULL, check if SQL server is running."); + return SQLerror(SQL_BAD_CONN, "Socket was NULL, check if SQL server is running."); /* Pointer to the buffer we screw around with substitution in */ char* query; @@ -391,7 +391,7 @@ class SQLConn : public classbase delete[] query; delete res; free(msquery); - return SQLerror(QSEND_FAIL, error); + return SQLerror(SQL_QSEND_FAIL, error); } delete[] query; free(msquery); @@ -788,7 +788,7 @@ class ModuleMsSQL : public Module } else { - req->error.Id(BAD_DBID); + req->error.Id(SQL_BAD_DBID); return NULL; } } diff --git a/src/modules/extra/m_mysql.cpp b/src/modules/extra/m_mysql.cpp index 8b9ad0666..7b42e344d 100644 --- a/src/modules/extra/m_mysql.cpp +++ b/src/modules/extra/m_mysql.cpp @@ -426,7 +426,7 @@ class SQLConnection : public classbase { /* XXX: See /usr/include/mysql/mysqld_error.h for a list of * possible error numbers and error messages */ - SQLerror e(QREPLY_FAIL, ConvToStr(mysql_errno(&connection)) + std::string(": ") + mysql_error(&connection)); + SQLerror e(SQL_QREPLY_FAIL, ConvToStr(mysql_errno(&connection)) + std::string(": ") + mysql_error(&connection)); MySQLresult* r = new MySQLresult(Parent, req.GetSource(), e, req.id); r->dbid = this->GetID(); r->query = req.query.q; @@ -735,7 +735,7 @@ class Notifier : public BufferedSocket }; -ModuleSQL::ModuleSQL(InspIRCd* Me) : Module::Module(Me), rehashing(false) +ModuleSQL::ModuleSQL(InspIRCd* Me) : Module(Me), rehashing(false) { ServerInstance->Modules->UseInterface("SQLutils"); @@ -806,7 +806,7 @@ const char* ModuleSQL::OnRequest(Request* request) } else { - req->error.Id(BAD_DBID); + req->error.Id(SQL_BAD_DBID); } QueueMutex->Enable(false); diff --git a/src/modules/extra/m_pgsql.cpp b/src/modules/extra/m_pgsql.cpp index 6b8638b7b..455f9b7a2 100644 --- a/src/modules/extra/m_pgsql.cpp +++ b/src/modules/extra/m_pgsql.cpp @@ -468,7 +468,7 @@ class SQLConn : public EventHandler case PGRES_EMPTY_QUERY: case PGRES_BAD_RESPONSE: case PGRES_FATAL_ERROR: - reply.error.Id(QREPLY_FAIL); + reply.error.Id(SQL_QREPLY_FAIL); reply.error.Str(PQresultErrorMessage(result)); default:; /* No action, other values are not errors */ @@ -656,11 +656,11 @@ class SQLConn : public EventHandler else { delete[] query; - return SQLerror(QSEND_FAIL, PQerrorMessage(sql)); + return SQLerror(SQL_QSEND_FAIL, PQerrorMessage(sql)); } } } - return SQLerror(BAD_CONN, "Can't query until connection is complete"); + return SQLerror(SQL_BAD_CONN, "Can't query until connection is complete"); } SQLerror Query(const SQLrequest &req) @@ -919,11 +919,11 @@ class ModulePgSQL : public Module req->id = NewID(); req->error = iter->second->Query(*req); - return (req->error.Id() == NO_ERROR) ? sqlsuccess : NULL; + return (req->error.Id() == SQL_NO_ERROR) ? sqlsuccess : NULL; } else { - req->error.Id(BAD_DBID); + req->error.Id(SQL_BAD_DBID); return NULL; } } diff --git a/src/modules/extra/m_sqlauth.cpp b/src/modules/extra/m_sqlauth.cpp index 0660055d6..c81caa082 100644 --- a/src/modules/extra/m_sqlauth.cpp +++ b/src/modules/extra/m_sqlauth.cpp @@ -165,7 +165,7 @@ public: if(user) { - if(res->error.Id() == NO_ERROR) + if(res->error.Id() == SQL_NO_ERROR) { if(res->Rows()) { diff --git a/src/modules/extra/m_sqlite3.cpp b/src/modules/extra/m_sqlite3.cpp index c98e1ead1..1387adf2d 100644 --- a/src/modules/extra/m_sqlite3.cpp +++ b/src/modules/extra/m_sqlite3.cpp @@ -357,7 +357,7 @@ class SQLConn : public classbase sqlite3_free(errmsg); delete[] query; delete res; - return SQLerror(QSEND_FAIL, error); + return SQLerror(SQL_QSEND_FAIL, error); } delete[] query; @@ -653,7 +653,7 @@ class ModuleSQLite3 : public Module } else { - req->error.Id(BAD_DBID); + req->error.Id(SQL_BAD_DBID); return NULL; } } diff --git a/src/modules/extra/m_sqloper.cpp b/src/modules/extra/m_sqloper.cpp index cca53f8a7..7fe3d8aaa 100644 --- a/src/modules/extra/m_sqloper.cpp +++ b/src/modules/extra/m_sqloper.cpp @@ -196,7 +196,7 @@ public: if (user) { - if (res->error.Id() == NO_ERROR) + if (res->error.Id() == SQL_NO_ERROR) { if (res->Rows()) { diff --git a/src/modules/extra/m_sqlv2.h b/src/modules/extra/m_sqlv2.h index 4585caf8f..fc5faebaa 100644 --- a/src/modules/extra/m_sqlv2.h +++ b/src/modules/extra/m_sqlv2.h @@ -27,7 +27,7 @@ /** Defines the error types which SQLerror may be set to */ -enum SQLerrorNum { NO_ERROR, BAD_DBID, BAD_CONN, QSEND_FAIL, QREPLY_FAIL }; +enum SQLerrorNum { SQL_NO_ERROR, SQL_BAD_DBID, SQL_BAD_CONN, SQL_QSEND_FAIL, SQL_QREPLY_FAIL }; /** A list of format parameters for an SQLquery object. */ @@ -74,7 +74,7 @@ public: * @param i The error ID to set * @param s The (optional) error string to set */ - SQLerror(SQLerrorNum i = NO_ERROR, const std::string &s = "") + SQLerror(SQLerrorNum i = SQL_NO_ERROR, const std::string &s = "") : id(i), str(s) { } @@ -113,15 +113,15 @@ public: switch(id) { - case NO_ERROR: + case SQL_NO_ERROR: return "No error"; - case BAD_DBID: + case SQL_BAD_DBID: return "Invalid database ID"; - case BAD_CONN: + case SQL_BAD_CONN: return "Invalid connection"; - case QSEND_FAIL: + case SQL_QSEND_FAIL: return "Sending query failed"; - case QREPLY_FAIL: + case SQL_QREPLY_FAIL: return "Getting query result failed"; default: return "Unknown error"; @@ -220,7 +220,7 @@ public: * except in the case of an error. */ unsigned long id; - /** If an error occured, error.id will be any other value than NO_ERROR. + /** If an error occured, error.id will be any other value than SQL_NO_ERROR. */ SQLerror error; @@ -310,7 +310,7 @@ public: /** * The error (if any) which occured. * If an error occured the value of error.id will be any - * other value than NO_ERROR. + * other value than SQL_NO_ERROR. */ SQLerror error; /** diff --git a/src/modules/extra/m_testclient.cpp b/src/modules/extra/m_testclient.cpp index f4bd42f83..0981acc06 100644 --- a/src/modules/extra/m_testclient.cpp +++ b/src/modules/extra/m_testclient.cpp @@ -65,7 +65,7 @@ public: SQLresult* res = (SQLresult*)request; - if (res->error.Id() == NO_ERROR) + if (res->error.Id() == SQL_NO_ERROR) { if(res->Cols()) { diff --git a/win/inspircd_win32wrapper.cpp b/win/inspircd_win32wrapper.cpp index 7e72220e8..0b738d538 100644 --- a/win/inspircd_win32wrapper.cpp +++ b/win/inspircd_win32wrapper.cpp @@ -776,3 +776,12 @@ int getcpu() pclsObj->Release(); return -1; } + +void usleep(unsigned long usecs) +{ + if (usecs > 0UL) + { + unsigned long millis = ((usecs + 999UL) / 1000UL); + SleepEx(millis, false); + } +} diff --git a/win/inspircd_win32wrapper.h b/win/inspircd_win32wrapper.h index 2935ba5c9..8b7b7d924 100644 --- a/win/inspircd_win32wrapper.h +++ b/win/inspircd_win32wrapper.h @@ -220,6 +220,8 @@ CoreExport bool initwmi(); CoreExport void donewmi(); CoreExport int getcpu(); +CoreExport void usleep(unsigned long usecs); + #endif -- cgit v1.2.3