From d73eb1493c734938a61697d4eef4b193a8ac8d2c Mon Sep 17 00:00:00 2001 From: Jan Willamowius Date: Sun, 5 Nov 2023 10:50:46 +0100 Subject: [PATCH] Win64 support --- GkClient.cxx | 2 +- GkStatus.cxx | 4 +- ProxyChannel.cxx | 10 ++--- ProxyChannel.h | 2 +- Toolkit.cxx | 10 ++--- config.h | 8 ++-- gk.cxx | 28 ++++++------ gk.h | 6 +-- gkacct.cxx | 4 +- gksql_firebird.cxx | 110 ++++++++++++++++++++++----------------------- gksql_mysql.cxx | 4 +- gksql_odbc.cxx | 4 +- gksql_sqlite.cxx | 4 +- h323util.cxx | 4 +- job.cxx | 4 +- syslogacct.cxx | 4 +- syslogacct.h | 4 +- yasocket.cxx | 18 ++++---- 18 files changed, 115 insertions(+), 115 deletions(-) diff --git a/GkClient.cxx b/GkClient.cxx index 620afdf9..d276f2e1 100644 --- a/GkClient.cxx +++ b/GkClient.cxx @@ -3,7 +3,7 @@ // GkClient.cxx // // Copyright (c) Citron Network Inc. 2001-2003 -// Copyright (c) 2002-2020, Jan Willamowius +// Copyright (c) 2002-2023, Jan Willamowius // // This work is published under the GNU Public License version 2 (GPLv2) // see file COPYING for details. diff --git a/GkStatus.cxx b/GkStatus.cxx index 1f6b6af4..b666be62 100644 --- a/GkStatus.cxx +++ b/GkStatus.cxx @@ -2,7 +2,7 @@ // // GkStatus.cxx // -// Copyright (c) 2000-2020, Jan Willamowius +// Copyright (c) 2000-2023, Jan Willamowius // // This work is published under the GNU Public License version 2 (GPLv2) // see file COPYING for details. @@ -15,7 +15,7 @@ #ifdef HAS_LIBSSH -#ifdef _WIN32 +#if _WIN32 || _WIN64 #pragma comment(lib, LIBSSH_LIB) #endif #include "libssh/libssh.h" diff --git a/ProxyChannel.cxx b/ProxyChannel.cxx index 538946ba..ac11bbf1 100644 --- a/ProxyChannel.cxx +++ b/ProxyChannel.cxx @@ -3,7 +3,7 @@ // ProxyChannel.cxx // // Copyright (c) Citron Network Inc. 2001-2002 -// Copyright (c) 2002-2021, Jan Willamowius +// Copyright (c) 2002-2023, Jan Willamowius // // This work is published under the GNU Public License version 2 (GPLv2) // see file COPYING for details. @@ -66,7 +66,7 @@ #include "h235/h235crypto.h" #endif -#ifdef _WIN32 +#if _WIN32 || _WIN64 #include # ifndef SHUT_RDWR # define SHUT_RDWR SD_BOTH @@ -480,7 +480,7 @@ bool IsOldH263(const H245_DataType & type) // send a UDP datagram and set the source IP (used only for RTP, RAS is using sockets bound to specific IPs) // the method is highly OS specific -#ifdef _WIN32 +#if _WIN32 || _WIN64 ssize_t UDPSendWithSourceIP(int fd, void * data, size_t len, const IPAndPortAddress & toAddress, PIPSocket::Address * gkIP) { #ifdef hasIPV6 @@ -18443,7 +18443,7 @@ bool ProxyHandler::BuildSelectList(SocketSelectList & slist) if (socket && !socket->IsBlocked()) { if (socket->IsSocketOpen()) { #ifndef LARGE_FDSET -#ifdef _WIN32 +#if _WIN32 || _WIN64 if (slist.GetSize() >= FD_SETSIZE) { PTRACE(0, "Proxy\tToo many sockets in this proxy handler " "(FD_SETSIZE=" << ((int)FD_SETSIZE) << ")"); @@ -18714,7 +18714,7 @@ void ProxyHandler::FlushSockets() } if (s->CanFlush()) { #ifndef LARGE_FDSET -#ifdef _WIN32 +#if _WIN32 || _WIN64 if (wlist.GetSize() >= FD_SETSIZE) { PTRACE(0, "Proxy\tToo many sockets in this proxy handler " "(limit=" << ((int)FD_SETSIZE) << ")"); diff --git a/ProxyChannel.h b/ProxyChannel.h index 170b7c79..75bacdf9 100644 --- a/ProxyChannel.h +++ b/ProxyChannel.h @@ -4,7 +4,7 @@ // ProxyChannel.h // // Copyright (c) Citron Network Inc. 2001-2003 -// Copyright (c) 2002-2021, Jan Willamowius +// Copyright (c) 2002-2023, Jan Willamowius // // This work is published under the GNU Public License version 2 (GPLv2) // see file COPYING for details. diff --git a/Toolkit.cxx b/Toolkit.cxx index 6b0c2d01..8ce3c94a 100644 --- a/Toolkit.cxx +++ b/Toolkit.cxx @@ -20,7 +20,7 @@ #include #include #include -#ifndef _WIN32 +#if !defined(_WIN32) && !defined(_WIN64) #include #endif // _WIN32 #include "stl_supp.h" @@ -1388,7 +1388,7 @@ PString Toolkit::GetTempDir() const { PString tmpdir; -#ifndef _WIN32 +#if !defined(_WIN32) && !defined(_WIN64) // check if the directory exists and is accessible (access rights) if (PFile::Exists("/tmp") && PFile::Access("/tmp", PFile::ReadWrite)) tmpdir = "/tmp"; @@ -1425,7 +1425,7 @@ void Toolkit::CreateConfig() PString tmpdir = GetTempDir(); -#ifdef _WIN32 +#if _WIN32 || _WIN64 if (tmpdir.IsEmpty()) if (PFile::Access(".", PFile::ReadWrite)) tmpdir = "."; @@ -1444,7 +1444,7 @@ void Toolkit::CreateConfig() PTRACE(5, "GK\tTrying file name "<< m_tmpconfig << " for temp config"); } while (PFile::Exists(m_tmpconfig)); -#ifdef _WIN32 +#if _WIN32 || _WIN64 if (PFile::Copy(m_ConfigFilePath, m_tmpconfig)) { #else if (symlink(m_ConfigFilePath, m_tmpconfig) == 0) { @@ -4051,7 +4051,7 @@ PString Toolkit::AsString( struct tm* tmptr = &_tm; time_t t = tm.GetTimeInSeconds(); -#ifndef _WIN32 +#if !defined(_WIN32) && !defined(_WIN64) if (localtime_r(&t, tmptr) != tmptr) { #else tmptr = localtime(&t); diff --git a/config.h b/config.h index c5d0b825..9dc9e137 100644 --- a/config.h +++ b/config.h @@ -19,7 +19,7 @@ #include #include "gnugkbuildopts.h" -#ifndef _WIN32 +#if !defined(_WIN32) && !defined(_WIN64) #define GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) #endif @@ -137,7 +137,7 @@ #if PTLIB_BUILD >= 6 #define hasLDAPStartTLS 1 #endif - #ifdef _WIN32 + #if _WIN32 || _WIN64 #define hasWorkerDeleteBug 1 #endif #endif @@ -155,7 +155,7 @@ #endif // bug with no trailing NULL bytes in BMP strings, fixed in PTLib 2.7.1 #if ((PTLIB_MINOR == 2) || (PTLIB_MINOR == 4 && PTLIB_BUILD <= 5) || (PTLIB_MINOR == 5 && PTLIB_BUILD <= 2) || (PTLIB_MINOR == 6 && PTLIB_BUILD <= 4)) - #ifdef _WIN32 + #if _WIN32 || _WIN64 #pragma message("PTLib with MD5 token bug") #else #warning "PTLib with MD5 token bug" @@ -174,7 +174,7 @@ #endif #if !defined(PWLIB_MAJOR) && !defined(PTLIB_MAJOR) - #if _WIN32 + #if _WIN32 || _WIN64 #pragma message ("warning: Can't detect PTLib version") #else #warning "Can't detect PTLib version" diff --git a/gk.cxx b/gk.cxx index d3e32aed..487bd3ac 100644 --- a/gk.cxx +++ b/gk.cxx @@ -2,7 +2,7 @@ // // gk.cxx for GNU Gatekeeper // -// Copyright (c) 2000-2022, Jan Willamowius +// Copyright (c) 2000-2023, Jan Willamowius // // This work is published under the GNU Public License version 2 (GPLv2) // see file COPYING for details. @@ -15,7 +15,7 @@ #include "config.h" #include #include -#ifndef _WIN32 +#if !defined(_WIN32) && !defined(_WIN64) #define HAS_SETUSERNAME #include #include @@ -25,7 +25,7 @@ #include #include #endif -#ifndef _WIN32 +#if !defined(_WIN32) && !defined(_WIN64) #include #endif #include @@ -52,7 +52,7 @@ using std::vector; PCREATE_PROCESS(Gatekeeper) -#if defined(_WIN32) && (_WIN32_WINNT >= WINDOWS_VISTA) +#if (defined(_WIN32) || defined(_WIN64)) && (_WIN32_WINNT >= WINDOWS_VISTA) LPFN_WSASENDMSG g_pfWSASendMsg = NULL; #endif @@ -442,7 +442,7 @@ const char * KnownConfigEntries[][2] = { #endif { "LogFile", "DeleteOnRotation" }, { "LogFile", "Filename" }, -#ifndef _WIN32 +#if !defined(_WIN32) && !defined(_WIN64) { "LogFile", "LogToSyslog" }, #endif { "LogFile", "Rotate" }, @@ -1018,7 +1018,7 @@ namespace { // keep the global objects private PTimedMutex ReloadMutex; -#ifndef _WIN32 +#if !defined(_WIN32) && !defined(_WIN64) PString pidfile("/var/run/gnugk.pid"); #endif @@ -1172,7 +1172,7 @@ void ExitGK() } -#ifndef _WIN32 +#if !defined(_WIN32) && !defined(_WIN64) class GnuGkToSyslog : public PSystemLogToSyslog { public: @@ -1262,7 +1262,7 @@ void ReloadHandler() } } -#ifdef _WIN32 +#if _WIN32 || _WIN64 BOOL WINAPI WinCtrlHandlerProc(DWORD dwCtrlType) { @@ -1493,7 +1493,7 @@ Gatekeeper::Gatekeeper(const char * _manuf, #endif { m_strictConfigCheck = false; -#ifdef _WIN32 +#if _WIN32 || _WIN64 // set data execution prevention (ignore if not available) SetDEP(PROCESS_DEP_ENABLE); InitializeRTPSending(); // check for Vista+ method @@ -1505,7 +1505,7 @@ Gatekeeper::Gatekeeper(const char * _manuf, savedArguments += GetArguments().GetParameter(i); savedArguments += " "; } -#ifndef _WIN32 +#if !defined(_WIN32) && !defined(_WIN64) // set startup arguments for service process GetArguments().Parse(GetArgumentsParseString()); if (GetArguments().HasOption("pid")) @@ -1591,7 +1591,7 @@ const PString Gatekeeper::GetArgumentsParseString() const bool Gatekeeper::InitHandlers(const PArgList & args) { -#ifdef _WIN32 +#if _WIN32 || _WIN64 SetConsoleCtrlHandler(WinCtrlHandlerProc, TRUE); #else struct sigaction sigact; @@ -1810,7 +1810,7 @@ void Gatekeeper::Main() ExitGK(); } -#ifndef _WIN32 +#if !defined(_WIN32) && !defined(_WIN64) if (GkConfig()->GetBoolean("LogFile", "LogToSyslog", false)) { PTrace::SetOptions(PTrace::SystemLogStream); PTrace::SetStream(new PSystemLog(PSystemLog::Debug6)); // Debug6 = don't filter more than the global trace level @@ -1965,7 +1965,7 @@ void Gatekeeper::Main() } #endif -#if defined(_WIN32) +#if _WIN32 || _WIN64 // 1) prevent CTRL_CLOSE_EVENT, CTRL_LOGOFF_EVENT and CTRL_SHUTDOWN_EVENT // dialog box from being displayed. // 2) set process shutdown priority - we want as much time as possible @@ -1983,7 +1983,7 @@ void Gatekeeper::Main() ShutdownHandler(); cerr << "done\n"; -#ifdef _WIN32 +#if _WIN32 || _WIN64 // remove control handler/close console SetConsoleCtrlHandler((PHANDLER_ROUTINE)WinCtrlHandlerProc, FALSE); FreeConsole(); diff --git a/gk.h b/gk.h index 52861608..f659edbe 100644 --- a/gk.h +++ b/gk.h @@ -2,7 +2,7 @@ // // gk.h gatekeeper process // -// Copyright (c) 2000-2015, Jan Willamowius +// Copyright (c) 2000-2023, Jan Willamowius // // This work is published under the GNU Public License version 2 (GPLv2) // see file COPYING for details. @@ -23,7 +23,7 @@ #include #endif -#ifdef _WIN32 +#if _WIN32 || _WIN64 #include #endif @@ -39,7 +39,7 @@ extern const char * KnownConfigEntries[][2]; // you must change PTLib 2.10.x / 2.11.x configure.ac to set WINVER = 0x0600 to enable #define WINDOWS_VISTA 0x0600 -#if defined(_WIN32) && (_WIN32_WINNT >= WINDOWS_VISTA) +#if (defined(_WIN32) || defined(_WIN64)) && (_WIN32_WINNT >= WINDOWS_VISTA) extern LPFN_WSASENDMSG g_pfWSASendMsg; #endif diff --git a/gkacct.cxx b/gkacct.cxx index 5af5c766..b58b60b3 100644 --- a/gkacct.cxx +++ b/gkacct.cxx @@ -5,7 +5,7 @@ * support for accounting to the gatekeeper. * * Copyright (c) 2003, Quarcom FHU, Michal Zygmuntowicz - * Copyright (c) 2005-2019, Jan Willamowius + * Copyright (c) 2005-2023, Jan Willamowius * * This work is published under the GNU Public License version 2 (GPLv2) * see file COPYING for details. @@ -15,7 +15,7 @@ */ // avoid warning in PTLib object.h -#if (!_WIN32) +#if (!_WIN32) && (!_WIN64) #define GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) #if (GCC_VERSION >= 40400) #pragma GCC diagnostic ignored "-Wstrict-overflow" diff --git a/gksql_firebird.cxx b/gksql_firebird.cxx index f5b1a73a..19cc4f70 100644 --- a/gksql_firebird.cxx +++ b/gksql_firebird.cxx @@ -4,7 +4,7 @@ * Firebird/Interbase driver module for GnuGk * * Copyright (c) 2006, Michal Zygmuntowicz - * Copyright (c) 2006-2013, Jan Willamowius + * Copyright (c) 2006-2023, Jan Willamowius * * This work is published under the GNU Public License version 2 (GPLv2) * see file COPYING for details. @@ -77,19 +77,19 @@ PString XSQLVARToPString(XSQLVAR *sqlvar) case SQL_TEXT: return PString(sqlvar->sqldata, sqlvar->sqllen); case SQL_SHORT: - return sqlvar->sqlscale < 0 - ? PString(PString::Decimal, *(int*)(sqlvar->sqldata) * pow(10.0, sqlvar->sqlscale), abs(sqlvar->sqlscale)) + return sqlvar->sqlscale < 0 + ? PString(PString::Decimal, *(int*)(sqlvar->sqldata) * pow(10.0, sqlvar->sqlscale), abs(sqlvar->sqlscale)) : PString(*(short*)(sqlvar->sqldata)); case SQL_LONG: return sqlvar->sqlscale < 0 - ? PString(PString::Decimal, *(long*)(sqlvar->sqldata) * pow(10.0, sqlvar->sqlscale), abs(sqlvar->sqlscale)) + ? PString(PString::Decimal, *(long*)(sqlvar->sqldata) * pow(10.0, sqlvar->sqlscale), abs(sqlvar->sqlscale)) : PString(*(long*)(sqlvar->sqldata)); case SQL_DOUBLE: - return sqlvar->sqlscale < 0 + return sqlvar->sqlscale < 0 ? PString(PString::Decimal, *(double*)(sqlvar->sqldata) * pow(10.0, sqlvar->sqlscale), abs(sqlvar->sqlscale)) : PString(PString::Printf, "%f", *(double*)(sqlvar->sqldata)); case SQL_INT64: - return sqlvar->sqlscale < 0 + return sqlvar->sqlscale < 0 ? PString(PString::Decimal, *(ISC_INT64*)(sqlvar->sqldata) * pow(10.0, sqlvar->sqlscale), abs(sqlvar->sqlscale)) : PString(*(ISC_INT64*)(sqlvar->sqldata)); case SQL_FLOAT: @@ -133,22 +133,22 @@ class GkIBSQLResult : public GkSQLResult /// SELECT type query result XSQLDA* selectResult = NULL ); - + virtual ~GkIBSQLResult(); - + /** @return Backend specific error message, if the query failed. - */ + */ virtual PString GetErrorMessage(); - + /** @return Backend specific error code, if the query failed. - */ + */ virtual long GetErrorCode(); - + /** Fetch a single row from the result set. After each row is fetched, cursor position is moved to a next row. - + @return True if the row has been fetched, false if no more rows are available. */ @@ -160,12 +160,12 @@ class GkIBSQLResult : public GkSQLResult /// array to be filled with string representations of the row fields ResultRow& result ); - + private: GkIBSQLResult(); GkIBSQLResult(const GkIBSQLResult&); GkIBSQLResult& operator=(const GkIBSQLResult&); - + protected: /// query result for SELECT type queries XSQLDA* m_sqlResult; @@ -190,7 +190,7 @@ class GkIBSQLConnection : public GkSQLConnection /// name to use in the log const char* name = "Firebird" ); - + virtual ~GkIBSQLConnection(); protected: @@ -220,16 +220,16 @@ class GkIBSQLConnection : public GkSQLConnection /** Create a new SQL connection using parameters stored in this object. When the connection is to be closed, the object is simply deleted using delete operator. - + @return - NULL if database connection could not be established + NULL if database connection could not be established or an object of IBSQLConnWrapper class. */ virtual SQLConnPtr CreateNewConnection( /// unique identifier for this connection int id ); - + /** Execute the query using specified SQL connection. @return @@ -243,7 +243,7 @@ class GkIBSQLConnection : public GkSQLConnection /// maximum time (ms) for the query execution, -1 means infinite long timeout = -1 ); - + /** Escape any special characters in the string, so it can be used in a SQL query. @return @@ -269,7 +269,7 @@ GkIBSQLResult::GkIBSQLResult( isc_stmt_handle stmt, /// SELECT type query result XSQLDA* selectResult - ) + ) : GkSQLResult(false), m_sqlResult(selectResult), m_tr(tr), m_stmt(stmt), m_sqlRow(-1), m_errorCode(0) { @@ -298,7 +298,7 @@ GkIBSQLResult::GkIBSQLResult( isc_stmt_handle stmt, /// SELECT type query result XSQLDA* selectResult - ) + ) : GkSQLResult(true), m_sqlResult(selectResult), m_tr(tr), m_stmt(stmt), m_sqlRow(-1), m_errorCode(errorCode), m_errorMessage(errorMsg) { @@ -307,7 +307,7 @@ GkIBSQLResult::GkIBSQLResult( GkIBSQLResult::~GkIBSQLResult() { ISC_STATUS status[20]; - + if (m_stmt != 0L) (*g_isc_dsql_free_statement)(status, &m_stmt, DSQL_drop); if (m_sqlResult != NULL) { @@ -337,7 +337,7 @@ PString GkIBSQLResult::GetErrorMessage() { return m_errorMessage; } - + long GkIBSQLResult::GetErrorCode() { return m_errorCode; @@ -350,15 +350,15 @@ bool GkIBSQLResult::FetchRow( { if (m_sqlResult == NULL || m_numRows <= 0) return false; - + if (m_sqlRow < 0) m_sqlRow = 0; - + if (m_sqlRow >= m_numRows) return false; - + ISC_STATUS retval; - ISC_STATUS status[20]; + ISC_STATUS status[20]; retval = (*g_isc_dsql_fetch)(status, &m_stmt, 1, m_sqlResult); if (status[0] == 1 && status[1] != 0) { m_numRows = m_sqlRow; @@ -370,7 +370,7 @@ bool GkIBSQLResult::FetchRow( const ISC_STATUS *pvector = status; (*g_fb_interpret)(errormsg, FB_BUFF_SIZE, &pvector); // fetch first error message only } else { - (*g_isc_sql_interprete)(static_cast(errcode), errormsg, FB_BUFF_SIZE); + (*g_isc_sql_interprete)(static_cast(errcode), errormsg, FB_BUFF_SIZE); } PTRACE(2, "Firebird\tFailed to fetch query row (" << errcode << "): SQL:" << errormsg); @@ -378,9 +378,9 @@ bool GkIBSQLResult::FetchRow( } return false; } - + result.SetSize(m_sqlResult->sqld); - + for (PINDEX i = 0; i < m_sqlResult->sqld; ++i) result[i] = XSQLVARToPString(&(m_sqlResult->sqlvar[i])); @@ -396,14 +396,14 @@ bool GkIBSQLResult::FetchRow( { if (m_sqlResult == NULL || m_numRows <= 0) return false; - + if (m_sqlRow < 0) m_sqlRow = 0; - + if (m_sqlRow >= m_numRows) return false; - ISC_STATUS retval; - ISC_STATUS status[20]; + ISC_STATUS retval; + ISC_STATUS status[20]; retval = (*g_isc_dsql_fetch)(status, &m_stmt, 1, m_sqlResult); if (status[0] == 1 && status[1] != 0) { m_numRows = m_sqlRow; @@ -415,7 +415,7 @@ bool GkIBSQLResult::FetchRow( const ISC_STATUS *pvector = status; (*g_fb_interpret)(errormsg, FB_BUFF_SIZE, &pvector); // fetch first error message only } else { - (*g_isc_sql_interprete)(static_cast(errcode), errormsg, FB_BUFF_SIZE); + (*g_isc_sql_interprete)(static_cast(errcode), errormsg, FB_BUFF_SIZE); } PTRACE(2, "Firebird\tFailed to fetch query row (" << errcode << "): SQL:" << errormsg); @@ -425,14 +425,14 @@ bool GkIBSQLResult::FetchRow( } result.resize(m_numFields); - + for (PINDEX i = 0; i < m_numFields; i++) { result[i].first = XSQLVARToPString(&(m_sqlResult->sqlvar[i])); result[i].second = PString(m_sqlResult->sqlvar[i].aliasname, m_sqlResult->sqlvar[i].aliasname_length); } - + m_sqlRow++; - + return true; } @@ -443,7 +443,7 @@ GkIBSQLConnection::GkIBSQLConnection( ) : GkSQLConnection(name) { } - + GkIBSQLConnection::~GkIBSQLConnection() { } @@ -461,7 +461,7 @@ GkSQLConnection::SQLConnPtr GkIBSQLConnection::CreateNewConnection( { if (!g_sharedLibrary.IsLoaded()) { if (m_library.IsEmpty()) { -#ifdef _WIN32 +#if _WIN32 || _WIN64 m_library = "fbclient" + g_sharedLibrary.GetExtension(); #else m_library = "libfbclient" + g_sharedLibrary.GetExtension(); @@ -501,9 +501,9 @@ GkSQLConnection::SQLConnPtr GkIBSQLConnection::CreateNewConnection( unsigned dpb_offset = 0; std::vector dpb(1); - + dpb[dpb_offset++] = isc_dpb_version1; - + if (!m_username) { dpb.resize(dpb.size() + 2 + m_username.GetLength()); dpb[dpb_offset++] = isc_dpb_user_name; @@ -512,34 +512,34 @@ GkSQLConnection::SQLConnPtr GkIBSQLConnection::CreateNewConnection( dpb_offset += m_username.GetLength(); } - if (!m_password) { + if (!m_password) { dpb.resize(dpb.size() + 2 + m_password.GetLength()); dpb[dpb_offset++] = isc_dpb_password; dpb[dpb_offset++] = m_password.GetLength(); memcpy(&(dpb[dpb_offset]), (const char*)m_password, m_password.GetLength()); dpb_offset += m_password.GetLength(); } - + ISC_STATUS status[20]; isc_db_handle conn = 0L; std::string dbname((const char*)m_database); - + if (!m_host) { dbname.insert(0, ":"); dbname.insert(0, (const char *)m_host); } - + (*g_isc_attach_database)(status, 0, const_cast(dbname.c_str()), &conn, dpb_offset, &(dpb[0])); if (status[0] == 1 && status[1] != 0) { char errormsg[FB_BUFF_SIZE]; const ISC_STATUS *pvector = status; (*g_fb_interpret)(errormsg, FB_BUFF_SIZE, &pvector); // fetch first error message only - PTRACE(2, GetName() << "\tFirebird connection to " << m_username << '@' << dbname + PTRACE(2, GetName() << "\tFirebird connection to " << m_username << '@' << dbname << " failed (isc_attach_database failed): " << errormsg); SNMP_TRAP(5, SNMPError, Database, GetName() + " connection failed"); return NULL; - } - + } + PTRACE(5, GetName() << "\tFirebird connection to " << m_username << '@' << dbname << " established successfully" ); @@ -561,14 +561,14 @@ GkSQLResult* GkIBSQLConnection::ExecuteQuery( ISC_STATUS status[20]; isc_tr_handle tr = 0L; isc_stmt_handle stmt = 0L; - + (*g_isc_start_transaction)(status, &tr, 1, &conn, 0, NULL); if (status[0] == 1 && status[1] != 0) { const ISC_STATUS *pvector = status; (*g_fb_interpret)(errormsg, FB_BUFF_SIZE, &pvector); // fetch first error message only return new GkIBSQLResult(status[1], errormsg); } - + (*g_isc_dsql_allocate_statement)(status, &conn, &stmt); if (status[0] == 1 && status[1] != 0) { long errorcode = (*g_isc_sqlcode)(status); @@ -588,7 +588,7 @@ GkSQLResult* GkIBSQLConnection::ExecuteQuery( memset(result, 0, XSQLDA_LENGTH(numcols)); result->version = SQLDA_VERSION1; result->sqln = numcols; - + (*g_isc_dsql_prepare)(status, &tr, &stmt, 0, const_cast(queryStr), SQL_DIALECT_CURRENT, result); if (status[0] == 1 && status[1] != 0) { long errorcode = (*g_isc_sqlcode)(status); @@ -602,7 +602,7 @@ GkSQLResult* GkIBSQLConnection::ExecuteQuery( Disconnect(); return new GkIBSQLResult(errorcode, errormsg, tr, stmt); } - + if (result->sqld > result->sqln) { numcols = result->sqld; delete [] reinterpret_cast(result); @@ -610,7 +610,7 @@ GkSQLResult* GkIBSQLConnection::ExecuteQuery( memset(result, 0, XSQLDA_LENGTH(numcols)); result->version = SQLDA_VERSION1; result->sqln = numcols; - + (*g_isc_dsql_describe)(status, &stmt, SQLDA_VERSION1, result); if (status[0] == 1 && status[1] != 0) { long errorcode = (*g_isc_sqlcode)(status); diff --git a/gksql_mysql.cxx b/gksql_mysql.cxx index 00e00e41..207f5992 100644 --- a/gksql_mysql.cxx +++ b/gksql_mysql.cxx @@ -4,7 +4,7 @@ * MySQL driver module for GnuGk * * Copyright (c) 2004, Michal Zygmuntowicz - * Copyright (c) 2006-2015, Jan Willamowius + * Copyright (c) 2006-2023, Jan Willamowius * * This work is published under the GNU Public License version 2 (GPLv2) * see file COPYING for details. @@ -324,7 +324,7 @@ GkSQLConnection::SQLConnPtr GkMySQLConnection::CreateNewConnection( { if (!g_sharedLibrary.IsLoaded()) { if (m_library.IsEmpty()) { -#ifdef _WIN32 +#if _WIN32 || _WIN64 m_library = "libmysql" + g_sharedLibrary.GetExtension(); #else m_library = "libmysqlclient" + g_sharedLibrary.GetExtension(); diff --git a/gksql_odbc.cxx b/gksql_odbc.cxx index 02aa1893..fead5f4e 100644 --- a/gksql_odbc.cxx +++ b/gksql_odbc.cxx @@ -3,7 +3,7 @@ * * native ODBC / unixODBC driver module for GnuGk * - * Copyright (c) 2008-2019, Jan Willamowius + * Copyright (c) 2008-2023, Jan Willamowius * * This work is published under the GNU Public License version 2 (GPLv2) * see file COPYING for details. @@ -413,7 +413,7 @@ GkSQLConnection::SQLConnPtr GkODBCConnection::CreateNewConnection( if (!g_sharedLibrary.IsLoaded()) { if (m_library.IsEmpty()) { -#ifdef _WIN32 +#if _WIN32 || _WIN64 m_library = "odbc32" + g_sharedLibrary.GetExtension(); #else m_library = "libodbc" + g_sharedLibrary.GetExtension(); diff --git a/gksql_sqlite.cxx b/gksql_sqlite.cxx index 6bea293c..3b0ac695 100644 --- a/gksql_sqlite.cxx +++ b/gksql_sqlite.cxx @@ -3,7 +3,7 @@ * * SQLite driver module for GnuGk * - * Copyright (c) 2007-2019, Jan Willamowius + * Copyright (c) 2007-2023, Jan Willamowius * * This work is published under the GNU Public License version 2 (GPLv2) * see file COPYING for details. @@ -297,7 +297,7 @@ GkSQLConnection::SQLConnPtr GkSQLiteConnection::CreateNewConnection( { if (!g_sharedLibrary.IsLoaded()) { if (m_library.IsEmpty()) { -#ifdef _WIN32 +#if _WIN32 || _WIN64 m_library = "sqlite3" + g_sharedLibrary.GetExtension(); #else m_library = "libsqlite3" + g_sharedLibrary.GetExtension(); diff --git a/h323util.cxx b/h323util.cxx index b818df62..64c633c9 100644 --- a/h323util.cxx +++ b/h323util.cxx @@ -2,7 +2,7 @@ // // H.323 utility functions // -// Copyright (c) 2000-2021, Jan Willamowius +// Copyright (c) 2000-2023, Jan Willamowius // // This work is published under the GNU Public License version 2 (GPLv2) // see file COPYING for details. @@ -26,7 +26,7 @@ #pragma GCC diagnostic ignored "-Wstrict-overflow" #endif -#if defined(_WIN32) && defined(hasIPV6) +#if (defined(_WIN32) || defined(_WIN64)) && defined(hasIPV6) // Windows doesn't have inet_ntop, so we fake it const char * inet_ntop(int family, const void *src, char *dst, socklen_t cnt) { diff --git a/job.cxx b/job.cxx index 583d660b..9952cc57 100644 --- a/job.cxx +++ b/job.cxx @@ -5,7 +5,7 @@ // Abstraction of threads' jobs // // Copyright (c) Citron Network Inc. 2002-2003 -// Copyright (c) 2006-2021, Jan Willamowius +// Copyright (c) 2006-2023, Jan Willamowius // // This work is published under the GNU Public License version 2 (GPLv2) // see file COPYING for details. @@ -141,7 +141,7 @@ Worker::Worker( m_idleTimeout(idleTimeout*1000), m_closed(false), m_job(NULL), m_id(0), m_agent(agent) { -#ifdef _WIN32 +#if _WIN32 || _WIN64 // on Windows srand() is thread-local, thus we must initialized every thread to make them at least slightly better // only used as fallback when OpenSSL isn't available, eg. for endpointIDs srand((unsigned int)time(NULL) * GetThreadId()); diff --git a/syslogacct.cxx b/syslogacct.cxx index eae196c5..d57e25cc 100644 --- a/syslogacct.cxx +++ b/syslogacct.cxx @@ -3,7 +3,7 @@ * * accounting module for GNU Gatekeeper for the syslog. * - * Copyright (c) 2006-2018, Jan Willamowius + * Copyright (c) 2006-2023, Jan Willamowius * * This work is published under the GNU Public License version 2 (GPLv2) * see file COPYING for details. @@ -12,7 +12,7 @@ * */ -#ifndef _WIN32 +#if !defined(_WIN32) && !defined(_WIN64) #include "config.h" #include diff --git a/syslogacct.h b/syslogacct.h index a84ae067..fdbfe122 100644 --- a/syslogacct.h +++ b/syslogacct.h @@ -3,7 +3,7 @@ * * accounting module for GNU Gatekeeper that send it's output to the syslog. * - * Copyright (c) 2006-2018, Jan Willamowius + * Copyright (c) 2006-2023, Jan Willamowius * * This work is published under the GNU Public License version 2 (GPLv2) * see file COPYING for details. @@ -15,7 +15,7 @@ #ifndef __SYSLOGACCT_H #define __SYSLOGACCT_H "@(#) $Id$" -#ifndef _WIN32 +#if !defined(_WIN32) && !defined(_WIN64) #include "gkacct.h" diff --git a/yasocket.cxx b/yasocket.cxx index 64840f4e..f5c48ebd 100644 --- a/yasocket.cxx +++ b/yasocket.cxx @@ -3,7 +3,7 @@ // yasocket.cxx // // Copyright (c) Citron Network Inc. 2002-2003 -// Copyright (c) 2004-2021, Jan Willamowius +// Copyright (c) 2004-2023, Jan Willamowius // // This work is published under the GNU Public License version 2 (GPLv2) // see file COPYING for details. @@ -24,7 +24,7 @@ #include "gnugkbuildopts.h" #include "ptbuildopts.h" // sets WINVER needed for WSAPoll -#ifdef _WIN32 +#if _WIN32 || _WIN64 # ifndef SHUT_RDWR # define SHUT_RDWR SD_BOTH # endif @@ -36,7 +36,7 @@ #endif // _WIN32 #ifdef LARGE_FDSET -#ifdef _WIN32 +#if _WIN32 || _WIN64 # include # define poll WSAPoll #else @@ -125,7 +125,7 @@ bool YaSocket::Close() so_linger.l_onoff = 0; so_linger.l_linger = 0; (void)::setsockopt(handle, SOL_SOCKET, SO_LINGER, (const char *)&so_linger, sizeof(so_linger)); -#ifdef _WIN32 +#if _WIN32 || _WIN64 ::closesocket(handle); #else ::close(handle); @@ -254,7 +254,7 @@ bool YaSocket::SetNonBlockingMode() { if (!IsOpen()) return false; -#ifdef _WIN32 +#if _WIN32 || _WIN64 u_long cmd = 1; if (ConvertOSError(::ioctlsocket(os_handle, FIONBIO, &cmd))) return true; @@ -460,7 +460,7 @@ bool YaTCPSocket::Connect(const Address & iface, WORD localPort, const Address & #endif // hasIPV6 int r = ::connect(os_handle, (struct sockaddr*)&peeraddr, addr_len); -#ifdef _WIN32 +#if _WIN32 || _WIN64 if ((r != 0) && (WSAGetLastError() != WSAEWOULDBLOCK)) #else if (r == 0 || errno != EINPROGRESS) @@ -480,7 +480,7 @@ bool YaTCPSocket::Connect(const Address & iface, WORD localPort, const Address & errno = optval; } else { if (r == 0) { -#ifdef _WIN32 +#if _WIN32 || _WIN64 errno = WSAETIMEDOUT; #else errno = ETIMEDOUT; @@ -1200,7 +1200,7 @@ void TCPServer::ReadSocket(IPSocket * socket) int rej = ::accept(socket->GetHandle(), NULL, NULL); if (rej >= 0) { ::shutdown(rej, SHUT_RDWR); -#if defined(_WIN32) +#if _WIN32 || _WIN64 ::closesocket(rej); #else ::close(rej); @@ -1223,7 +1223,7 @@ void TCPServer::ReadSocket(IPSocket * socket) int rej = ::accept(socket->GetHandle(), NULL, NULL); if (rej >= 0) { ::shutdown(rej, SHUT_RDWR); -#if defined(_WIN32) +#if _WIN32 || _WIN64 ::closesocket(rej); #else ::close(rej);