amule: backport upstream patches

This commit is contained in:
CN_SZTL 2020-08-03 01:25:34 +08:00
parent ccf007d41f
commit 8dd61288a4
No known key found for this signature in database
GPG Key ID: 6850B6345C862176
4 changed files with 1074 additions and 0 deletions

View File

@ -0,0 +1,13 @@
diff --git a/src/UPnPBase.cpp b/src/UPnPBase.cpp
index 774ebfc32..28ca74729 100644
--- a/src/UPnPBase.cpp
+++ b/src/UPnPBase.cpp
@@ -828,7 +828,7 @@ m_WanService(NULL)
int ret;
char *ipAddress = NULL;
unsigned short port = 0;
- ret = UpnpInit(ipAddress, udpPort);
+ ret = UpnpInit2(ipAddress, udpPort);
if (ret != UPNP_E_SUCCESS) {
msg << "error(UpnpInit): Error code ";
goto error;

View File

@ -0,0 +1,318 @@
From e7bef4525c22b5624f05ba37c8e79fc60ca12453 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?D=C3=A9vai=20Tam=C3=A1s?= <gonosztopi@amule.org>
Date: Mon, 5 Aug 2019 18:29:08 +0200
Subject: [PATCH] Fix deprecation warnings about std::auto_ptr
std::auto_ptr is deprecated in C++11 and removed in C++17. std::unique_ptr
is an almost drop-in replacement for std::auto_ptr introduced in C++11
(with proper move operators).
To find out more about the background of removing std::auto_ptr and introducing std::unique_ptr,
see http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1856.html#20.4.5%20-%20Class%20template%20auto_ptr
---
src/SearchList.cpp | 4 +-
src/SearchList.h | 10 ++---
src/UPnPBase.cpp | 4 +-
src/UPnPBase.h | 6 ++-
src/libs/common/FileFunctions.cpp | 6 +--
src/libs/common/Makefile.am | 1 +
src/libs/common/SmartPtr.h | 64 +++++++++++++++++++++++++++++++
src/libs/ec/cpp/ECSocket.cpp | 4 +-
src/libs/ec/cpp/ECSocket.h | 7 ++--
src/libs/ec/cpp/RemoteConnect.cpp | 7 ++--
10 files changed, 90 insertions(+), 23 deletions(-)
create mode 100644 src/libs/common/SmartPtr.h
diff --git a/src/SearchList.cpp b/src/SearchList.cpp
index 342a18f0d..4935aeeeb 100644
--- a/src/SearchList.cpp
+++ b/src/SearchList.cpp
@@ -702,13 +702,13 @@ CSearchList::CMemFilePtr CSearchList::CreateSearchData(CSearchParams& params, Se
AddLogLineNS(CFormat(wxT("Error %u: %s\n")) % i % _astrParserErrors[i]);
}
- return CMemFilePtr(NULL);
+ return CMemFilePtr(nullptr);
}
if (iParseResult != 0) {
_astrParserErrors.Add(CFormat(wxT("Undefined error %i on search expression")) % iParseResult);
- return CMemFilePtr(NULL);
+ return CMemFilePtr(nullptr);
}
if (type == KadSearch && s_strCurKadKeyword != params.strKeyword) {
diff --git a/src/SearchList.h b/src/SearchList.h
index 6db7508a3..33428754c 100644
--- a/src/SearchList.h
+++ b/src/SearchList.h
@@ -26,10 +26,10 @@
#ifndef SEARCHLIST_H
#define SEARCHLIST_H
-#include "Timer.h" // Needed for CTimer
+#include "Timer.h" // Needed for CTimer
#include "ObservableQueue.h" // Needed for CQueueObserver
-#include "SearchFile.h" // Needed for CSearchFile
-#include <memory> // Do_not_auto_remove (lionel's Mac, 10.3)
+#include "SearchFile.h" // Needed for CSearchFile
+#include <common/SmartPtr.h> // Needed for CSmartPtr
class CMemFile;
@@ -187,8 +187,8 @@ class CSearchList : public wxEvtHandler
*/
bool AddToList(CSearchFile* toadd, bool clientResponse = false);
- //! This auto-pointer is used to safely prevent leaks.
- typedef std::auto_ptr<CMemFile> CMemFilePtr;
+ //! This smart pointer is used to safely prevent leaks.
+ typedef CSmartPtr<CMemFile> CMemFilePtr;
/** Create a basic search-packet for the given search-type. */
CMemFilePtr CreateSearchData(CSearchParams& params, SearchType type, bool supports64bit, bool& packetUsing64bit);
diff --git a/src/UPnPBase.cpp b/src/UPnPBase.cpp
index 774ebfc32..81cb98fb7 100644
--- a/src/UPnPBase.cpp
+++ b/src/UPnPBase.cpp
@@ -436,7 +436,7 @@ m_SCPDURL (IXML::Element::GetChildValueByTag(service, "SCPDURL")),
m_controlURL (IXML::Element::GetChildValueByTag(service, "controlURL")),
m_eventSubURL(IXML::Element::GetChildValueByTag(service, "eventSubURL")),
m_timeout(1801),
-m_SCPD(NULL)
+m_SCPD(nullptr)
{
std::ostringstream msg;
int errcode;
@@ -552,7 +552,7 @@ bool CUPnPService::Execute(
const std::vector<CUPnPArgumentValue> &ArgValue) const
{
std::ostringstream msg;
- if (m_SCPD.get() == NULL) {
+ if (m_SCPD.get() == nullptr) {
msg << "Service without SCPD Document, cannot execute action '" << ActionName <<
"' for service '" << GetServiceType() << "'.";
AddDebugLogLineN(logUPnP, msg);
diff --git a/src/UPnPBase.h b/src/UPnPBase.h
index efe63bf0f..7554d6609 100644
--- a/src/UPnPBase.h
+++ b/src/UPnPBase.h
@@ -32,10 +32,12 @@
#include <map>
#include <string>
#include <sstream>
-#include <memory>
#include "UPnPCompatibility.h"
+#include <common/SmartPtr.h> // Needed for CSmartPtr
+
+
extern std::string stdEmptyString;
@@ -327,7 +329,7 @@ class CUPnPService
std::string m_absEventSubURL;
int m_timeout;
Upnp_SID m_SID;
- std::auto_ptr<CUPnPSCPD> m_SCPD;
+ CSmartPtr<CUPnPSCPD> m_SCPD;
public:
CUPnPService(
diff --git a/src/libs/common/FileFunctions.cpp b/src/libs/common/FileFunctions.cpp
index 6d0db3496..447773c2e 100644
--- a/src/libs/common/FileFunctions.cpp
+++ b/src/libs/common/FileFunctions.cpp
@@ -34,11 +34,11 @@
#ifdef __WXMAC__
#include <zlib.h> // Do_not_auto_remove
#endif
-#include <memory> // Needed for std::auto_ptr
-#include <algorithm> // Needed for std::min
+#include <algorithm> // Needed for std::min
#include "FileFunctions.h"
#include "StringFunctions.h"
+#include "SmartPtr.h" // Needed for CSmartPtr
//
// This class assumes that the following line has been executed:
@@ -135,7 +135,7 @@ EFileType GuessFiletype(const wxString& file)
bool UnpackZipFile(const wxString& file, const wxChar* files[])
{
wxTempFile target(file);
- std::auto_ptr<wxZipEntry> entry;
+ CSmartPtr<wxZipEntry> entry;
wxFFileInputStream fileInputStream(file);
wxZipInputStream zip(fileInputStream);
bool run = true;
diff --git a/src/libs/common/Makefile.am b/src/libs/common/Makefile.am
index fbcbe6487..6656c2e16 100644
--- a/src/libs/common/Makefile.am
+++ b/src/libs/common/Makefile.am
@@ -24,6 +24,7 @@ noinst_HEADERS = \
MD5Sum.h \
MuleDebug.h \
Path.h \
+ SmartPtr.h \
strerror_r.h \
StringFunctions.h \
TextFile.h
diff --git a/src/libs/common/SmartPtr.h b/src/libs/common/SmartPtr.h
new file mode 100644
index 000000000..e5324c787
--- /dev/null
+++ b/src/libs/common/SmartPtr.h
@@ -0,0 +1,64 @@
+// -*- C++ -*-
+// This file is part of the aMule Project.
+//
+// Copyright (c) 2019 aMule Team ( admin@amule.org / http://www.amule.org )
+//
+// Any parts of this program derived from the xMule, lMule or eMule project,
+// or contributed by third-party developers are copyrighted by their
+// respective authors.
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+//
+
+#ifndef SMARTPTR_H
+#define SMARTPTR_H
+
+// std::auto_ptr is deprecated in C++11 and removed in C++17. We should use
+// std::unique_ptr instead, which was introduced in C++11.
+//
+// Considering the above, we shall use std::unique_ptr if we're using C++11 or
+// a later standard, and std::auto_ptr otherwise.
+
+#include <memory>
+
+#if __cplusplus >= 201103L
+
+// It seems like Apple has (or had, hopefully) a configuration where a new
+// clang compiler supporting C++11 is accompanied by an old c++ library not
+// supporting std::unique_ptr.
+// See https://stackoverflow.com/questions/31655462/no-type-named-unique-ptr-in-namespace-std-when-compiling-under-llvm-clang
+# ifdef __clang__
+# if __has_include(<forward_list>)
+ // either using libc++ or a libstdc++ that's
+ // new enough to have unique_ptr
+# define HAVE_UNIQUE_PTR 1
+# endif
+# else
+ // not clang, assume unique_ptr available
+# define HAVE_UNIQUE_PTR 1
+# endif
+
+#endif
+
+#ifdef HAVE_UNIQUE_PTR
+template<typename T> using CSmartPtr = std::unique_ptr<T>;
+#else
+# define CSmartPtr std::auto_ptr
+# define nullptr NULL
+#endif
+
+#undef HAVE_UNIQUE_PTR
+
+#endif /* SMARTPTR_H */
diff --git a/src/libs/ec/cpp/ECSocket.cpp b/src/libs/ec/cpp/ECSocket.cpp
index a0283cca3..daea1db52 100644
--- a/src/libs/ec/cpp/ECSocket.cpp
+++ b/src/libs/ec/cpp/ECSocket.cpp
@@ -397,10 +397,10 @@ void CECSocket::OnInput()
return;
}
} else {
- std::auto_ptr<const CECPacket> packet(ReadPacket());
+ CSmartPtr<const CECPacket> packet(ReadPacket());
m_curr_rx_data->Rewind();
if (packet.get()) {
- std::auto_ptr<const CECPacket> reply(OnPacketReceived(packet.get(), m_curr_packet_len));
+ CSmartPtr<const CECPacket> reply(OnPacketReceived(packet.get(), m_curr_packet_len));
if (reply.get()) {
SendPacket(reply.get());
}
diff --git a/src/libs/ec/cpp/ECSocket.h b/src/libs/ec/cpp/ECSocket.h
index 121e833f3..82b0c7be9 100644
--- a/src/libs/ec/cpp/ECSocket.h
+++ b/src/libs/ec/cpp/ECSocket.h
@@ -28,7 +28,6 @@
#include <deque> // Needed for std::deque
-#include <memory> // Needed for std::auto_ptr // Do_not_auto_remove (mingw-gcc-3.4.5)
#include <string>
#include <vector>
@@ -38,6 +37,8 @@
#include <wx/defs.h> // Needed for wx/debug.h
#include <wx/debug.h> // Needed for wxASSERT
+#include <common/SmartPtr.h> // Needed for CSmartPtr
+
enum ECSocketErrors {
EC_ERROR_NOERROR,
EC_ERROR_INVOP,
@@ -77,8 +78,8 @@ class CECSocket{
// zlib (deflation) buffers
std::vector<unsigned char> m_in_ptr;
std::vector<unsigned char> m_out_ptr;
- std::auto_ptr<CQueuedData> m_curr_rx_data;
- std::auto_ptr<CQueuedData> m_curr_tx_data;
+ CSmartPtr<CQueuedData> m_curr_rx_data;
+ CSmartPtr<CQueuedData> m_curr_tx_data;
// This transfer only
uint32_t m_rx_flags;
diff --git a/src/libs/ec/cpp/RemoteConnect.cpp b/src/libs/ec/cpp/RemoteConnect.cpp
index ed62abac0..79e908869 100644
--- a/src/libs/ec/cpp/RemoteConnect.cpp
+++ b/src/libs/ec/cpp/RemoteConnect.cpp
@@ -25,14 +25,13 @@
#include "RemoteConnect.h"
+#include <common/SmartPtr.h> // Needed for CSmartPtr
#include <common/MD5Sum.h>
#include <common/Format.h>
#include "../../../amuleIPV4Address.h"
#include <wx/intl.h>
-using std::auto_ptr;
-
DEFINE_LOCAL_EVENT_TYPE(wxEVT_EC_CONNECTION)
CECLoginPacket::CECLoginPacket(const wxString& client, const wxString& version,
@@ -139,14 +138,14 @@ bool CRemoteConnect::ConnectToCore(const wxString &host, int port,
// Otherwise we continue in OnConnect.
CECLoginPacket login_req(m_client, m_version, m_canZLIB, m_canUTF8numbers, m_canNotify);
- std::auto_ptr<const CECPacket> getSalt(SendRecvPacket(&login_req));
+ CSmartPtr<const CECPacket> getSalt(SendRecvPacket(&login_req));
m_ec_state = EC_REQ_SENT;
ProcessAuthPacket(getSalt.get());
CECAuthPacket passwdPacket(m_connectionPassword);
- std::auto_ptr<const CECPacket> reply(SendRecvPacket(&passwdPacket));
+ CSmartPtr<const CECPacket> reply(SendRecvPacket(&passwdPacket));
m_ec_state = EC_PASSWD_SENT;
return ProcessAuthPacket(reply.get());

View File

@ -0,0 +1,743 @@
From 3a77afb7dfe9bc81765629c5b4fa9fc4ae65b9a9 Mon Sep 17 00:00:00 2001
From: Pablo Barciela <scow@riseup.net>
Date: Sun, 10 May 2020 01:38:56 +0200
Subject: [PATCH] Fix -Wmissing-declarations warnings
---
src/DataToText.cpp | 1 +
src/DownloadListCtrl.cpp | 2 +-
src/DownloadQueue.cpp | 4 ++--
src/ECSpecialMuleTags.cpp | 2 +-
src/ED2KLinkParser.cpp | 24 ++++++++++++------------
src/FileDetailDialog.cpp | 6 +++---
src/GenericClientListCtrl.cpp | 2 +-
src/KnownFile.cpp | 2 +-
src/MuleTrayIcon.cpp | 2 +-
src/Parser.cpp | 1 -
src/Parser.y | 1 -
src/PrefsUnifiedDlg.cpp | 2 +-
src/Scanner.cpp | 3 +++
src/Scanner.l | 3 +++
src/SearchExpr.h | 2 ++
src/SearchListCtrl.cpp | 2 +-
src/SharedFileList.cpp | 6 +++---
src/Statistics.cpp | 6 +++---
src/TextClient.cpp | 4 +++-
src/ThreadScheduler.cpp | 2 +-
src/UPnPBase.cpp | 2 +-
src/amule.h | 3 +++
src/extern/wxWidgets/listctrl.cpp | 2 +-
src/libs/common/FileFunctions.cpp | 6 +++---
src/libs/common/MuleDebug.cpp | 2 +-
src/libs/common/Path.cpp | 12 ++++++------
src/libs/ec/cpp/ECSocket.cpp | 6 +++---
src/libs/ec/cpp/ECSpecialTags.cpp | 2 +-
src/webserver/src/WebServer.cpp | 8 ++++----
src/webserver/src/php_syntree.cpp | 10 +++++-----
30 files changed, 71 insertions(+), 59 deletions(-)
diff --git a/src/DataToText.cpp b/src/DataToText.cpp
index 34c9944d7..03307cbeb 100644
--- a/src/DataToText.cpp
+++ b/src/DataToText.cpp
@@ -24,6 +24,7 @@
#include <wx/intl.h>
+#include "DataToText.h"
#include "Constants.h"
#include <protocol/ed2k/ClientSoftware.h>
diff --git a/src/DownloadListCtrl.cpp b/src/DownloadListCtrl.cpp
index 5c5dd848b..fb2782c90 100644
--- a/src/DownloadListCtrl.cpp
+++ b/src/DownloadListCtrl.cpp
@@ -371,7 +371,7 @@ uint8 CDownloadListCtrl::GetCategory() const
* @param list A pointer to the list to gather items from.
* @return A list containing the selected items.
*/
-ItemList GetSelectedItems( CDownloadListCtrl* list)
+static ItemList GetSelectedItems( CDownloadListCtrl* list)
{
ItemList results;
diff --git a/src/DownloadQueue.cpp b/src/DownloadQueue.cpp
index 7033cd1eb..6a4eb2221 100644
--- a/src/DownloadQueue.cpp
+++ b/src/DownloadQueue.cpp
@@ -852,7 +852,7 @@ CUpDownClient* CDownloadQueue::GetDownloadClientByIP_UDP(uint32 dwIP, uint16 nUD
/**
* Checks if the specified server is the one we are connected to.
*/
-bool IsConnectedServer(const CServer* server)
+static bool IsConnectedServer(const CServer* server)
{
if (server && theApp->serverconnect->GetCurrentServer()) {
wxString srvAddr = theApp->serverconnect->GetCurrentServer()->GetAddress();
@@ -976,7 +976,7 @@ void CDownloadQueue::DoStopUDPRequests()
// Comparison function needed by sort. Returns true if file1 preceeds file2
-bool ComparePartFiles(const CPartFile* file1, const CPartFile* file2) {
+static bool ComparePartFiles(const CPartFile* file1, const CPartFile* file2) {
if (file1->GetDownPriority() != file2->GetDownPriority()) {
// To place high-priority files before low priority files we have to
// invert this test, since PR_LOW is lower than PR_HIGH, and since
diff --git a/src/ECSpecialMuleTags.cpp b/src/ECSpecialMuleTags.cpp
index 700f604d5..4bed2509b 100644
--- a/src/ECSpecialMuleTags.cpp
+++ b/src/ECSpecialMuleTags.cpp
@@ -346,7 +346,7 @@ CEC_Prefs_Packet::CEC_Prefs_Packet(uint32 selection, EC_DETAIL_LEVEL pref_detail
* @param applyFunc The function to use for applying the value
* @param tagName The name of the TAG that holds the boolean value
*/
-void ApplyBoolean(bool use_tag, const CECTag *thisTab, void (applyFunc)(bool), int tagName)
+static void ApplyBoolean(bool use_tag, const CECTag *thisTab, void (applyFunc)(bool), int tagName)
{
const CECTag *boolTag = thisTab->GetTagByName(tagName);
if (use_tag) {
diff --git a/src/ED2KLinkParser.cpp b/src/ED2KLinkParser.cpp
index e684d7ae1..8a5da3f12 100644
--- a/src/ED2KLinkParser.cpp
+++ b/src/ED2KLinkParser.cpp
@@ -46,7 +46,7 @@ const int versionRevision = 1;
using std::string;
-string GetLinksFilePath(const string& configDir)
+static string GetLinksFilePath(const string& configDir)
{
if (!configDir.empty()) {
#ifdef _WIN32
@@ -125,7 +125,7 @@ string GetLinksFilePath(const string& configDir)
* @param hex The hex-number, must be at most 2 digits long.
* @return The resulting char or \0 if conversion failed.
*/
-char HexToDec( const string& hex )
+static char HexToDec( const string& hex )
{
char result = 0;
@@ -152,7 +152,7 @@ char HexToDec( const string& hex )
* @param str The string to unescape.
* @return The unescaped version of the input string.
*/
-string Unescape( const string& str )
+static string Unescape( const string& str )
{
string result;
result.reserve( str.length() );
@@ -182,7 +182,7 @@ string Unescape( const string& str )
/**
* Returns the string with whitespace stripped from both ends.
*/
-string strip( const string& str )
+static string strip( const string& str )
{
size_t first = 0;
size_t last = str.length() - 1;
@@ -206,7 +206,7 @@ string strip( const string& str )
/**
* Returns true if the string is a valid number.
*/
-bool isNumber( const string& str )
+static bool isNumber( const string& str )
{
for ( size_t i = 0; i < str.length(); i++ ) {
if ( !isdigit( str.at(i) ) ) {
@@ -221,7 +221,7 @@ bool isNumber( const string& str )
/**
* Returns true if the string is a valid Base16 representation of a MD4 Hash.
*/
-bool isMD4Hash( const string& str )
+static bool isMD4Hash( const string& str )
{
for ( size_t i = 0; i < str.length(); i++ ) {
const char c = toupper( str.at(i) );
@@ -238,7 +238,7 @@ bool isMD4Hash( const string& str )
/**
* Returns a description of the current version of "ed2k".
*/
-string getVersion()
+static string getVersion()
{
std::ostringstream v;
@@ -254,7 +254,7 @@ string getVersion()
/**
* Helper-function for printing link-errors.
*/
-void badLink( const string& type, const string& err, const string& uri )
+static void badLink( const string& type, const string& err, const string& uri )
{
std::cout << "Invalid " << type << "-link, " + err << ":\n"
<< "\t" << uri << std::endl;
@@ -266,7 +266,7 @@ void badLink( const string& type, const string& err, const string& uri )
*
* If errors are detected, it will terminate the program.
*/
-void writeLink( const string& uri, const string& config_dir )
+static void writeLink( const string& uri, const string& config_dir )
{
// Attempt to lock the ED2KLinks file
static CFileLock lock(GetLinksFilePath(config_dir));
@@ -294,7 +294,7 @@ void writeLink( const string& uri, const string& config_dir )
* @param uri The URI to check.
* @return True if the URI was written, false otherwise.
*/
-bool checkFileLink( const string& uri )
+static bool checkFileLink( const string& uri )
{
if ( uri.substr( 0, 13 ) == "ed2k://|file|" ) {
size_t base_off = 12;
@@ -345,7 +345,7 @@ bool checkFileLink( const string& uri )
* @param uri The URI to check.
* @return True if the URI was written, false otherwise.
*/
-bool checkServerLink( const string& uri )
+static bool checkServerLink( const string& uri )
{
if ( uri.substr( 0, 15 ) == "ed2k://|server|" ) {
size_t base_off = 14;
@@ -388,7 +388,7 @@ bool checkServerLink( const string& uri )
* @param uri The URI to check.
* @return True if the URI was written, false otherwise.
*/
-bool checkServerListLink( const string& uri )
+static bool checkServerListLink( const string& uri )
{
if ( uri.substr( 0, 19 ) == "ed2k://|serverlist|" ) {
size_t base_off = 19;
diff --git a/src/FileDetailDialog.cpp b/src/FileDetailDialog.cpp
index dd50fdc40..62af93283 100644
--- a/src/FileDetailDialog.cpp
+++ b/src/FileDetailDialog.cpp
@@ -308,7 +308,7 @@ void CFileDetailDialog::OnBnClickedNextFile(wxCommandEvent&)
}
-bool IsDigit(const wxChar ch)
+static bool IsDigit(const wxChar ch)
{
switch (ch) {
case '0':
@@ -325,7 +325,7 @@ bool IsDigit(const wxChar ch)
return false;
}
-bool IsWordSeparator(const wxChar ch)
+static bool IsWordSeparator(const wxChar ch)
{
switch (ch) {
case '.':
@@ -343,7 +343,7 @@ bool IsWordSeparator(const wxChar ch)
return false;
}
-void ReplaceWord(wxString& str, const wxString& replaceFrom, const wxString& replaceTo, bool numbers = false)
+static void ReplaceWord(wxString& str, const wxString& replaceFrom, const wxString& replaceTo, bool numbers = false)
{
unsigned int i = 0;
unsigned int l = replaceFrom.Length();
diff --git a/src/GenericClientListCtrl.cpp b/src/GenericClientListCtrl.cpp
index 19d8b3b2c..2c89f5014 100644
--- a/src/GenericClientListCtrl.cpp
+++ b/src/GenericClientListCtrl.cpp
@@ -459,7 +459,7 @@ void CGenericClientListCtrl::ShowSources( const CKnownFileVector& files )
* @param list A pointer to the list to gather items from.
* @return A list containing the selected items of the choosen types.
*/
-ItemList GetSelectedItems( CGenericClientListCtrl* list )
+static ItemList GetSelectedItems( CGenericClientListCtrl* list )
{
ItemList results;
diff --git a/src/KnownFile.cpp b/src/KnownFile.cpp
index 0e3963005..576330060 100644
--- a/src/KnownFile.cpp
+++ b/src/KnownFile.cpp
@@ -1464,7 +1464,7 @@ void CKnownFile::ClearPriority() {
UpdateAutoUpPriority();
}
-void GuessAndRemoveExt(CPath& name)
+static void GuessAndRemoveExt(CPath& name)
{
wxString ext = name.GetExt();
diff --git a/src/MuleTrayIcon.cpp b/src/MuleTrayIcon.cpp
index 72a9f6515..8c32456bf 100644
--- a/src/MuleTrayIcon.cpp
+++ b/src/MuleTrayIcon.cpp
@@ -77,7 +77,7 @@ END_EVENT_TABLE()
/************ Constructor / Destructor **************/
/****************************************************/
-long GetSpeedFromString(wxString label){
+static long GetSpeedFromString(wxString label){
long temp;
label.Replace(_("kB/s"),wxT(""),TRUE);
label.Trim(FALSE);
diff --git a/src/Parser.cpp b/src/Parser.cpp
index 4d78febba..368dacdd9 100644
--- a/src/Parser.cpp
+++ b/src/Parser.cpp
@@ -83,7 +83,6 @@ static char THIS_FILE[] = __FILE__;
extern wxArrayString _astrParserErrors;
-void ParsedSearchExpression(const CSearchExpr* pexpr);
int yyerror(const char* errstr);
int yyerror(wxString errstr);
diff --git a/src/Parser.y b/src/Parser.y
index 443af7adb..9444052f7 100644
--- a/src/Parser.y
+++ b/src/Parser.y
@@ -13,7 +13,6 @@ static char THIS_FILE[] = __FILE__;
extern wxArrayString _astrParserErrors;
-void ParsedSearchExpression(const CSearchExpr* pexpr);
int yyerror(const char* errstr);
int yyerror(wxString errstr);
diff --git a/src/PrefsUnifiedDlg.cpp b/src/PrefsUnifiedDlg.cpp
index 66842fd05..157ac5c84 100644
--- a/src/PrefsUnifiedDlg.cpp
+++ b/src/PrefsUnifiedDlg.cpp
@@ -144,7 +144,7 @@ END_EVENT_TABLE()
* have no side-effects other than enabling/disabling other
* widgets in the preferences dialogs.
*/
-void SendCheckBoxEvent(wxWindow* parent, int id)
+static void SendCheckBoxEvent(wxWindow* parent, int id)
{
wxCheckBox* widget = CastByID(id, parent, wxCheckBox);
wxCHECK_RET(widget, wxT("Invalid widget in CreateEvent"));
diff --git a/src/Scanner.cpp b/src/Scanner.cpp
index 35478ac79..f4a461254 100644
--- a/src/Scanner.cpp
+++ b/src/Scanner.cpp
@@ -580,6 +580,9 @@ static void FatalLexError(yyconst char msg[]);
static char* _pszLexBuff;
static char* _pszLexStr;
+void LexInit(const wxString& pszInput);
+void LexFree();
+
#line 584 "Scanner.cpp"
#define INITIAL 0
diff --git a/src/Scanner.l b/src/Scanner.l
index 5adbaf465..dc7b01289 100644
--- a/src/Scanner.l
+++ b/src/Scanner.l
@@ -36,6 +36,9 @@ static void FatalLexError(yyconst char msg[]);
static char* _pszLexBuff;
static char* _pszLexStr;
+void LexInit(const wxString& pszInput);
+void LexFree();
+
%}
%option noyywrap
diff --git a/src/SearchExpr.h b/src/SearchExpr.h
index ef3c7f403..925039081 100644
--- a/src/SearchExpr.h
+++ b/src/SearchExpr.h
@@ -84,6 +84,8 @@ class CSearchExpr
wxArrayString m_aExpr;
};
+void ParsedSearchExpression(const CSearchExpr* pexpr);
+
#ifdef _MSC_VER
#define YY_NO_UNISTD_H
#define DEBUG_NEW new
diff --git a/src/SearchListCtrl.cpp b/src/SearchListCtrl.cpp
index 2e8e9d038..58108379f 100644
--- a/src/SearchListCtrl.cpp
+++ b/src/SearchListCtrl.cpp
@@ -799,7 +799,7 @@ void CSearchListCtrl::DownloadSelected(int category)
}
-const wxBrush& GetBrush(wxSystemColour index)
+static const wxBrush& GetBrush(wxSystemColour index)
{
return CMuleColour(index).GetBrush();
}
diff --git a/src/SharedFileList.cpp b/src/SharedFileList.cpp
index 04815d571..97a8eec03 100644
--- a/src/SharedFileList.cpp
+++ b/src/SharedFileList.cpp
@@ -380,7 +380,7 @@ void CSharedFileList::FindSharedFiles()
// Checks if the dir a is the same as b. If they are, then logs the message and returns true.
-bool CheckDirectory(const wxString& a, const CPath& b)
+static bool CheckDirectory(const wxString& a, const CPath& b)
{
if (CPath(a).IsSameDir(b)) {
AddLogLineC(CFormat( _("ERROR: Attempted to share %s") ) % a);
@@ -662,7 +662,7 @@ void CSharedFileList::RepublishFile(CKnownFile* pFile)
}
}
-uint8 GetRealPrio(uint8 in)
+static uint8 GetRealPrio(uint8 in)
{
switch(in) {
case 4 : return 0;
@@ -674,7 +674,7 @@ uint8 GetRealPrio(uint8 in)
return 0;
}
-bool SortFunc( const CKnownFile* fileA, const CKnownFile* fileB )
+static bool SortFunc( const CKnownFile* fileA, const CKnownFile* fileB )
{
return GetRealPrio(fileA->GetUpPriority()) < GetRealPrio(fileB->GetUpPriority());
}
diff --git a/src/Statistics.cpp b/src/Statistics.cpp
index 23ce7a2b0..663558235 100644
--- a/src/Statistics.cpp
+++ b/src/Statistics.cpp
@@ -286,7 +286,7 @@ CStatistics::~CStatistics()
}
-uint64_t ReadUInt64FromCfg(wxConfigBase* cfg, const wxString& key)
+static uint64_t ReadUInt64FromCfg(wxConfigBase* cfg, const wxString& key)
{
wxString buffer;
@@ -869,7 +869,7 @@ void CStatistics::RemoveSourceOrigin(unsigned origin)
--(*counter);
}
-uint32 GetSoftID(uint8 SoftType)
+static uint32 GetSoftID(uint8 SoftType)
{
// prevent appearing multiple tree entries with the same name
// this should be kept in sync with GetSoftName().
@@ -922,7 +922,7 @@ inline bool SupportsOSInfo(unsigned clientSoft)
}
// Do some random black magic to strings to get a relatively unique number for them.
-uint32 GetIdFromString(const wxString& str)
+static uint32 GetIdFromString(const wxString& str)
{
uint32 id = 0;
for (unsigned i = 0; i < str.Length(); ++i) {
diff --git a/src/TextClient.cpp b/src/TextClient.cpp
index 1e96db85b..50bd7ea45 100644
--- a/src/TextClient.cpp
+++ b/src/TextClient.cpp
@@ -629,7 +629,7 @@ void CamulecmdApp::ShowResults(CResultMap results_map)
// Formats a statistics (sub)tree to text
-wxString StatTree2Text(const CEC_StatTree_Node_Tag *tree, int depth)
+static wxString StatTree2Text(const CEC_StatTree_Node_Tag *tree, int depth)
{
if (!tree) {
return wxEmptyString;
@@ -1027,6 +1027,8 @@ int CamulecmdApp::OnRun()
return 0;
}
+// Stub functions needed by the linker in ASIO builds
+#include "GuiEvents.h"
namespace MuleNotify
{
void HandleNotification(const class CMuleNotiferBase&) {}
diff --git a/src/ThreadScheduler.cpp b/src/ThreadScheduler.cpp
index 8f7ebdce6..99a7ace71 100644
--- a/src/ThreadScheduler.cpp
+++ b/src/ThreadScheduler.cpp
@@ -121,7 +121,7 @@ bool CThreadScheduler::AddTask(CThreadTask* task, bool overwrite)
/** Returns string representation of error code. */
-wxString GetErrMsg(wxThreadError err)
+static wxString GetErrMsg(wxThreadError err)
{
switch (err) {
case wxTHREAD_NO_ERROR: return wxT("wxTHREAD_NO_ERROR");
diff --git a/src/UPnPBase.cpp b/src/UPnPBase.cpp
index 81cb98fb7..46ac7451e 100644
--- a/src/UPnPBase.cpp
+++ b/src/UPnPBase.cpp
@@ -63,7 +63,7 @@ const char s_deviceList[] = "deviceList";
/**
* Case insensitive std::string comparison
*/
-bool stdStringIsEqualCI(const std::string &s1, const std::string &s2)
+static bool stdStringIsEqualCI(const std::string &s1, const std::string &s2)
{
std::string ns1(s1);
std::string ns2(s2);
diff --git a/src/amule.h b/src/amule.h
index 240c02dd9..c778c3404 100644
--- a/src/amule.h
+++ b/src/amule.h
@@ -117,6 +117,9 @@ namespace Kademlia {
#define CONNECTED_KAD_FIREWALLED (1<<3)
+void OnShutdownSignal( int /* sig */ );
+
+
// Base class common to amule, aamuled and amulegui
class CamuleAppCommon
{
diff --git a/src/extern/wxWidgets/listctrl.cpp b/src/extern/wxWidgets/listctrl.cpp
index 921175972..b64af8625 100644
--- a/src/extern/wxWidgets/listctrl.cpp
+++ b/src/extern/wxWidgets/listctrl.cpp
@@ -4828,7 +4828,7 @@ int wxListMainWindow::GetItemWidthWithImage(wxListItem * item)
MuleListCtrlCompare list_ctrl_compare_func_2;
long list_ctrl_compare_data;
-int LINKAGEMODE list_ctrl_compare_func_1( wxListLineData **arg1, wxListLineData **arg2 )
+static int LINKAGEMODE list_ctrl_compare_func_1( wxListLineData **arg1, wxListLineData **arg2 )
{
wxListLineData *line1 = *arg1;
wxListLineData *line2 = *arg2;
diff --git a/src/libs/common/FileFunctions.cpp b/src/libs/common/FileFunctions.cpp
index 9e88b8a4b..b8f367cee 100644
--- a/src/libs/common/FileFunctions.cpp
+++ b/src/libs/common/FileFunctions.cpp
@@ -91,7 +91,7 @@ bool CDirIterator::HasSubDirs(const wxString& spec)
}
-EFileType GuessFiletype(const wxString& file)
+static EFileType GuessFiletype(const wxString& file)
{
wxFile archive(file, wxFile::read);
if (!archive.IsOpened()) {
@@ -132,7 +132,7 @@ EFileType GuessFiletype(const wxString& file)
* Replaces the zip-archive with "guarding.p2p" or "ipfilter.dat",
* if either of those files are found in the archive.
*/
-bool UnpackZipFile(const wxString& file, const wxChar* files[])
+static bool UnpackZipFile(const wxString& file, const wxChar* files[])
{
wxTempFile target(file);
CSmartPtr<wxZipEntry> entry;
@@ -174,7 +174,7 @@ bool UnpackZipFile(const wxString& file, const wxChar* files[])
/**
* Unpacks a GZip file and replaces the archive.
*/
-bool UnpackGZipFile(const wxString& file)
+static bool UnpackGZipFile(const wxString& file)
{
wxTempFile target(file);
diff --git a/src/libs/common/MuleDebug.cpp b/src/libs/common/MuleDebug.cpp
index 0ebf2ab07..e4381faad 100644
--- a/src/libs/common/MuleDebug.cpp
+++ b/src/libs/common/MuleDebug.cpp
@@ -286,7 +286,7 @@ void get_file_line_info(bfd *abfd, asection *section, void* _address)
#endif // HAVE_BFD
-wxString demangle(const wxString& function)
+static wxString demangle(const wxString& function)
{
#ifdef HAVE_CXXABI
wxString result;
diff --git a/src/libs/common/Path.cpp b/src/libs/common/Path.cpp
index 979f5590b..0e162bbc3 100644
--- a/src/libs/common/Path.cpp
+++ b/src/libs/common/Path.cpp
@@ -58,7 +58,7 @@ inline wxString DeepCopy(const wxString& str)
}
-wxString Demangle(const wxCharBuffer& fn, const wxString& filename)
+static wxString Demangle(const wxCharBuffer& fn, const wxString& filename)
{
wxString result = wxConvUTF8.cMB2WC(fn);
@@ -109,7 +109,7 @@ inline void DoSplitPath(const wxString& strPath, wxString* path, wxString* name)
/** Removes invalid chars from a filename. */
-wxString DoCleanup(const wxString& filename, bool keepSpaces, bool isFAT32)
+static wxString DoCleanup(const wxString& filename, bool keepSpaces, bool isFAT32)
{
wxString result;
for (size_t i = 0; i < filename.Length(); i++) {
@@ -148,7 +148,7 @@ wxString DoCleanup(const wxString& filename, bool keepSpaces, bool isFAT32)
/** Does the actual work of adding a postfix ... */
-wxString DoAddPostfix(const wxString& src, const wxString& postfix)
+static wxString DoAddPostfix(const wxString& src, const wxString& postfix)
{
wxFileName fn(src);
@@ -158,7 +158,7 @@ wxString DoAddPostfix(const wxString& src, const wxString& postfix)
}
/** Removes the last extension of a filename. */
-wxString DoRemoveExt(const wxString& path)
+static wxString DoRemoveExt(const wxString& path)
{
// Using wxFilename which handles paths, etc.
wxFileName tmp(path);
@@ -169,7 +169,7 @@ wxString DoRemoveExt(const wxString& path)
/** Readies a path for use with wxAccess.. */
-wxString DoCleanPath(const wxString& path)
+static wxString DoCleanPath(const wxString& path)
{
#ifdef __WINDOWS__
// stat fails on windows if there are trailing path-separators.
@@ -189,7 +189,7 @@ wxString DoCleanPath(const wxString& path)
/** Returns true if the two paths are equal. */
-bool IsSameAs(const wxString& a, const wxString& b)
+static bool IsSameAs(const wxString& a, const wxString& b)
{
// Cache the current directory
const wxString cwd = wxGetCwd();
diff --git a/src/libs/ec/cpp/ECSocket.cpp b/src/libs/ec/cpp/ECSocket.cpp
index 615f09f9a..2454fe9dc 100644
--- a/src/libs/ec/cpp/ECSocket.cpp
+++ b/src/libs/ec/cpp/ECSocket.cpp
@@ -76,7 +76,7 @@ static const struct utf8_table utf8_table[] =
{0, 0, 0, 0, 0, /* end of table */}
};
-int utf8_mbtowc(uint32_t *p, const unsigned char *s, int n)
+static int utf8_mbtowc(uint32_t *p, const unsigned char *s, int n)
{
uint32_t l;
int c0, nc;
@@ -106,7 +106,7 @@ int utf8_mbtowc(uint32_t *p, const unsigned char *s, int n)
return -1;
}
-int utf8_wctomb(unsigned char *s, uint32_t wc, int maxlen)
+static int utf8_wctomb(unsigned char *s, uint32_t wc, int maxlen)
{
uint32_t l;
int c, nc;
@@ -507,7 +507,7 @@ void CECSocket::WriteBufferToSocket(const void *buffer, size_t len)
// ZLib "error handler"
//
-void ShowZError(int zerror, z_streamp strm)
+static void ShowZError(int zerror, z_streamp strm)
{
const char *p = NULL;
diff --git a/src/libs/ec/cpp/ECSpecialTags.cpp b/src/libs/ec/cpp/ECSpecialTags.cpp
index 4c24ac418..256847adc 100644
--- a/src/libs/ec/cpp/ECSpecialTags.cpp
+++ b/src/libs/ec/cpp/ECSpecialTags.cpp
@@ -81,7 +81,7 @@ CEC_Search_Tag::CEC_Search_Tag(const wxString &name, EC_SEARCH_TYPE search_type,
}
}
-void FormatValue(CFormat& format, const CECTag* tag)
+static void FormatValue(CFormat& format, const CECTag* tag)
{
wxASSERT(tag->GetTagName() == EC_TAG_STAT_NODE_VALUE);
diff --git a/src/webserver/src/WebServer.cpp b/src/webserver/src/WebServer.cpp
index eb59a44c9..d5afdd015 100644
--- a/src/webserver/src/WebServer.cpp
+++ b/src/webserver/src/WebServer.cpp
@@ -80,7 +80,7 @@ wxString _SpecialChars(wxString str) {
return str;
}
-uint8 GetHigherPrio(uint32 prio, bool autoprio)
+static uint8 GetHigherPrio(uint32 prio, bool autoprio)
{
if (autoprio) {
return PR_LOW;
@@ -95,7 +95,7 @@ uint8 GetHigherPrio(uint32 prio, bool autoprio)
}
}
-uint8 GetHigherPrioShared(uint32 prio, bool autoprio)
+static uint8 GetHigherPrioShared(uint32 prio, bool autoprio)
{
if (autoprio) {
return PR_VERYLOW;
@@ -114,7 +114,7 @@ uint8 GetHigherPrioShared(uint32 prio, bool autoprio)
}
-uint8 GetLowerPrio(uint32 prio, bool autoprio)
+static uint8 GetLowerPrio(uint32 prio, bool autoprio)
{
if (autoprio) {
return PR_HIGH;
@@ -129,7 +129,7 @@ uint8 GetLowerPrio(uint32 prio, bool autoprio)
}
}
-uint8 GetLowerPrioShared(uint32 prio, bool autoprio)
+static uint8 GetLowerPrioShared(uint32 prio, bool autoprio)
{
if (autoprio) {
return PR_POWERSHARE;
diff --git a/src/webserver/src/php_syntree.cpp b/src/webserver/src/php_syntree.cpp
index cff918feb..e856924e0 100644
--- a/src/webserver/src/php_syntree.cpp
+++ b/src/webserver/src/php_syntree.cpp
@@ -51,7 +51,7 @@ PHP_SCOPE_STACK g_scope_stack = 0;
// Known named constant values
std::map<std::string, int> g_known_const;
-PHP_EXP_NODE *make_zero_exp_node()
+static PHP_EXP_NODE *make_zero_exp_node()
{
PHP_EXP_NODE *node = new PHP_EXP_NODE;
memset(node, 0, sizeof(PHP_EXP_NODE));
@@ -468,7 +468,7 @@ void func_scope_init(PHP_FUNC_PARAM_DEF *params, int param_count,
* 1. Memory will not leak
* 2. Next call may be using same params by-value, so it need independent varnode
*/
-void func_scope_copy_back(PHP_FUNC_PARAM_DEF *params, int param_count,
+static void func_scope_copy_back(PHP_FUNC_PARAM_DEF *params, int param_count,
PHP_SCOPE_TABLE_TYPE * /*scope_map*/, PHP_VALUE_NODE *arg_array,
std::map<std::string, PHP_VAR_NODE *> &saved_vars)
{
@@ -598,7 +598,7 @@ void add_class_2_scope(PHP_SCOPE_TABLE scope, PHP_SYN_NODE *class_node)
}
}
-PHP_SCOPE_ITEM *make_named_scope_item(PHP_SCOPE_TABLE scope, const char *name)
+static PHP_SCOPE_ITEM *make_named_scope_item(PHP_SCOPE_TABLE scope, const char *name)
{
PHP_SCOPE_TABLE_TYPE *scope_map = (PHP_SCOPE_TABLE_TYPE *)scope;
PHP_SCOPE_ITEM *it = new PHP_SCOPE_ITEM;
@@ -1212,7 +1212,7 @@ void php_engine_free()
* 1,2. Target is scalar variable or variable by name ${xxx}
* 3. Target is member of array.
*/
-void exp_set_ref(PHP_EXP_NODE *expr, PHP_VAR_NODE *var, PHP_VALUE_NODE *key)
+static void exp_set_ref(PHP_EXP_NODE *expr, PHP_VAR_NODE *var, PHP_VALUE_NODE *key)
{
switch ( expr->op ) {
case PHP_OP_VAR: {
@@ -1536,7 +1536,7 @@ PHP_VAR_NODE *php_expr_eval_lvalue(PHP_EXP_NODE *expr)
return lval_node;
}
-PHP_VALUE_TYPE cast_type_resolve(PHP_VALUE_NODE *op1, PHP_VALUE_NODE *op2)
+static PHP_VALUE_TYPE cast_type_resolve(PHP_VALUE_NODE *op1, PHP_VALUE_NODE *op2)
{
if ( (op1->type == PHP_VAL_FLOAT) || (op2->type == PHP_VAL_FLOAT) ) {
cast_value_fnum(op1);