amule: bump to latest git HEAD

This commit is contained in:
CN_SZTL 2020-08-03 02:08:04 +08:00
parent 3bd2ec289e
commit ee399ad3ba
No known key found for this signature in database
GPG Key ID: 6850B6345C862176
8 changed files with 1 additions and 1601 deletions

View File

@ -10,7 +10,7 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=aMule
PKG_VERSION:=2.3.2
PKG_RELEASE:=3
PKG_REV=4b87b20
PKG_REV=ae8e867
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-r$(PKG_REV).tar.bz2

View File

@ -1,365 +0,0 @@
diff -Naur a/m4/libupnp.m4 b/m4/libupnp.m4
--- a/m4/libupnp.m4 2016-10-06 18:49:44.000000000 +0800
+++ b/m4/libupnp.m4 2019-12-11 22:13:19.008225399 +0800
@@ -45,11 +45,16 @@
dnl Test for --with-libupnp-prefix
AC_ARG_WITH(
- [libupnp-prefix],
- [AS_HELP_STRING(
+ [libupnp-prefix],[
+ AS_HELP_STRING(
[--with-libupnp-prefix=PREFIX],
- [UPnP library location])],
- [export PKG_CONFIG_PATH=$withval/lib/pkgconfig])
+ [UPnP library location])],[
+ AS_IF([test -d "$withval/lib64/pkgconfig"],[
+ export PKG_CONFIG_PATH=$withval/lib64/pkgconfig
+ ],[
+ export PKG_CONFIG_PATH=$withval/lib/pkgconfig
+ ])
+ ])
dnl Check for libupnp >= MIN_LIBUPNP_VERSION
AS_IF([test $cross_compiling = no], [
diff -Naur a/src/UPnPBase.cpp b/src/UPnPBase.cpp
--- a/src/UPnPBase.cpp 2016-10-06 18:49:44.000000000 +0800
+++ b/src/UPnPBase.cpp 2019-12-11 22:15:04.536768532 +0800
@@ -1127,7 +1127,11 @@
// This function is static
+#if UPNP_VERSION >= 10800
+int CUPnPControlPoint::Callback(Upnp_EventType_e EventType, const void *Event, void * /*Cookie*/)
+#else
int CUPnPControlPoint::Callback(Upnp_EventType EventType, void *Event, void * /*Cookie*/)
+#endif
{
std::ostringstream msg;
std::ostringstream msg2;
@@ -1149,24 +1153,47 @@
msg2<< "UPNP_DISCOVERY_SEARCH_RESULT: ";
// UPnP Discovery
upnpDiscovery:
+#if UPNP_VERSION >= 10800
+ UpnpDiscovery *d_event = (UpnpDiscovery *)Event;
+#else
struct Upnp_Discovery *d_event = (struct Upnp_Discovery *)Event;
+#endif
IXML_Document *doc = NULL;
+#if UPNP_VERSION >= 10800
+ int errCode = UpnpDiscovery_get_ErrCode(d_event);
+ if (errCode != UPNP_E_SUCCESS) {
+ msg << UpnpGetErrorMessage(errCode) << ".";
+#else
int ret;
if (d_event->ErrCode != UPNP_E_SUCCESS) {
msg << UpnpGetErrorMessage(d_event->ErrCode) << ".";
+#endif
AddDebugLogLineC(logUPnP, msg);
}
// Get the XML tree device description in doc
+#if UPNP_VERSION >= 10800
+ const char *location = UpnpDiscovery_get_Location_cstr(d_event);
+ int ret = UpnpDownloadXmlDoc(location, &doc);
+#else
ret = UpnpDownloadXmlDoc(d_event->Location, &doc);
+#endif
if (ret != UPNP_E_SUCCESS) {
msg << "Error retrieving device description from " <<
+#if UPNP_VERSION >= 10800
+ location << ": " <<
+#else
d_event->Location << ": " <<
+#endif
UpnpGetErrorMessage(ret) <<
"(" << ret << ").";
AddDebugLogLineC(logUPnP, msg);
} else {
msg2 << "Retrieving device description from " <<
+#if UPNP_VERSION >= 10800
+ location << ".";
+#else
d_event->Location << ".";
+#endif
AddDebugLogLineN(logUPnP, msg2);
}
if (doc) {
@@ -1194,8 +1221,14 @@
AddDebugLogLineC(logUPnP, msg);
}
// Add the root device to our list
+#if UPNP_VERSION >= 10800
+ int expires = UpnpDiscovery_get_Expires(d_event);
+ upnpCP->AddRootDevice(rootDevice, urlBase,
+ location, expires);
+#else
upnpCP->AddRootDevice(rootDevice, urlBase,
d_event->Location, d_event->Expires);
+#endif
}
// Free the XML doc tree
IXML::Document::Free(doc);
@@ -1216,28 +1249,62 @@
case UPNP_DISCOVERY_ADVERTISEMENT_BYEBYE: {
//fprintf(stderr, "Callback: UPNP_DISCOVERY_ADVERTISEMENT_BYEBYE\n");
// UPnP Device Removed
+#if UPNP_VERSION >= 10800
+ UpnpDiscovery *dab_event = (UpnpDiscovery *)Event;
+ int errCode = UpnpDiscovery_get_ErrCode(dab_event);
+ if (errCode != UPNP_E_SUCCESS) {
+#else
struct Upnp_Discovery *dab_event = (struct Upnp_Discovery *)Event;
if (dab_event->ErrCode != UPNP_E_SUCCESS) {
+#endif
msg << "error(UPNP_DISCOVERY_ADVERTISEMENT_BYEBYE): " <<
+#if UPNP_VERSION >= 10800
+ UpnpGetErrorMessage(errCode) <<
+#else
UpnpGetErrorMessage(dab_event->ErrCode) <<
+#endif
".";
AddDebugLogLineC(logUPnP, msg);
}
+#if UPNP_VERSION >= 10800
+ std::string devType = UpnpDiscovery_get_DeviceType_cstr(dab_event);
+#else
std::string devType = dab_event->DeviceType;
+#endif
// Check for an InternetGatewayDevice and removes it from the list
+
std::transform(devType.begin(), devType.end(), devType.begin(), tolower);
+
if (stdStringIsEqualCI(devType, UPnP::Device::IGW)) {
+#if UPNP_VERSION >= 10800
+ const char *deviceID =
+ UpnpDiscovery_get_DeviceID_cstr(dab_event);
+ upnpCP->RemoveRootDevice(deviceID);
+#else
upnpCP->RemoveRootDevice(dab_event->DeviceId);
+#endif
}
break;
}
case UPNP_EVENT_RECEIVED: {
//fprintf(stderr, "Callback: UPNP_EVENT_RECEIVED\n");
// Event reveived
+#if UPNP_VERSION >= 10800
+ UpnpEvent *e_event = (UpnpEvent *)Event;
+ int eventKey = UpnpEvent_get_EventKey(e_event);
+ IXML_Document *changedVariables =
+ UpnpEvent_get_ChangedVariables(e_event);
+ const std::string sid = UpnpEvent_get_SID_cstr(e_event);
+#else
struct Upnp_Event *e_event = (struct Upnp_Event *)Event;
const std::string Sid = e_event->Sid;
+#endif
// Parses the event
+#if UPNP_VERSION >= 10800
+ upnpCP->OnEventReceived(sid, eventKey, changedVariables);
+#else
upnpCP->OnEventReceived(Sid, e_event->EventKey, e_event->ChangedVariables);
+#endif
break;
}
case UPNP_EVENT_SUBSCRIBE_COMPLETE:
@@ -1252,24 +1319,42 @@
//fprintf(stderr, "Callback: UPNP_EVENT_RENEWAL_COMPLETE\n");
msg << "error(UPNP_EVENT_RENEWAL_COMPLETE): ";
upnpEventRenewalComplete:
+#if UPNP_VERSION >= 10800
+ UpnpEventSubscribe *es_event = (UpnpEventSubscribe *)Event;
+ int errCode = UpnpEventSubscribe_get_ErrCode(es_event);
+ if (errCode != UPNP_E_SUCCESS) {
+#else
struct Upnp_Event_Subscribe *es_event =
(struct Upnp_Event_Subscribe *)Event;
if (es_event->ErrCode != UPNP_E_SUCCESS) {
+#endif
msg << "Error in Event Subscribe Callback";
+#if UPNP_VERSION >= 10800
+ UPnP::ProcessErrorMessage(msg.str(), errCode, NULL, NULL);
+#else
UPnP::ProcessErrorMessage(
msg.str(), es_event->ErrCode, NULL, NULL);
+#endif
} else {
#if 0
+#if UPNP_VERSION >= 10800
+
+ const UpnpString *publisherUrl =
+ UpnpEventSubscribe_get_PublisherUrl(es_event);
+ const char *sid = UpnpEvent_get_SID_cstr(es_event);
+ int timeOut = UpnpEvent_get_TimeOut(es_event);
+ TvCtrlPointHandleSubscribeUpdate(
+ publisherUrl, sid, timeOut);
+#else
TvCtrlPointHandleSubscribeUpdate(
GET_UPNP_STRING(es_event->PublisherUrl),
es_event->Sid,
es_event->TimeOut );
#endif
+#endif
}
-
break;
}
-
case UPNP_EVENT_AUTORENEWAL_FAILED:
//fprintf(stderr, "Callback: UPNP_EVENT_AUTORENEWAL_FAILED\n");
msg << "error(UPNP_EVENT_AUTORENEWAL_FAILED): ";
@@ -1280,29 +1365,56 @@
msg << "error(UPNP_EVENT_SUBSCRIPTION_EXPIRED): ";
msg2 << "UPNP_EVENT_SUBSCRIPTION_EXPIRED: ";
upnpEventSubscriptionExpired:
+#if UPNP_VERSION >= 10800
+ UpnpEventSubscribe *es_event = (UpnpEventSubscribe *)Event;
+#else
struct Upnp_Event_Subscribe *es_event =
(struct Upnp_Event_Subscribe *)Event;
+#endif
Upnp_SID newSID;
memset(newSID, 0, sizeof(Upnp_SID));
int TimeOut = 1801;
+#if UPNP_VERSION >= 10800
+ const char *publisherUrl =
+ UpnpEventSubscribe_get_PublisherUrl_cstr(es_event);
+#endif
int ret = UpnpSubscribe(
upnpCP->m_UPnPClientHandle,
+#if UPNP_VERSION >= 10800
+ publisherUrl,
+#else
GET_UPNP_STRING(es_event->PublisherUrl),
+#endif
&TimeOut,
newSID);
if (ret != UPNP_E_SUCCESS) {
msg << "Error Subscribing to EventURL";
+#if UPNP_VERSION >= 10800
+ int errCode = UpnpEventSubscribe_get_ErrCode(es_event);
+#endif
UPnP::ProcessErrorMessage(
+#if UPNP_VERSION >= 10800
+ msg.str(), errCode, NULL, NULL);
+#else
msg.str(), es_event->ErrCode, NULL, NULL);
+#endif
} else {
ServiceMap::iterator it =
+#if UPNP_VERSION >= 10800
+ upnpCP->m_ServiceMap.find(publisherUrl);
+#else
upnpCP->m_ServiceMap.find(GET_UPNP_STRING(es_event->PublisherUrl));
+#endif
if (it != upnpCP->m_ServiceMap.end()) {
CUPnPService &service = *(it->second);
service.SetTimeout(TimeOut);
service.SetSID(newSID);
msg2 << "Re-subscribed to EventURL '" <<
+#if UPNP_VERSION >= 10800
+ publisherUrl <<
+#else
GET_UPNP_STRING(es_event->PublisherUrl) <<
+#endif
"' with SID == '" <<
newSID << "'.";
AddDebugLogLineC(logUPnP, msg2);
@@ -1321,17 +1433,34 @@
case UPNP_CONTROL_ACTION_COMPLETE: {
//fprintf(stderr, "Callback: UPNP_CONTROL_ACTION_COMPLETE\n");
// This is here if we choose to do this asynchronously
+#if UPNP_VERSION >= 10800
+ UpnpActionComplete *a_event = (UpnpActionComplete *)Event;
+ int errCode = UpnpActionComplete_get_ErrCode(a_event);
+ IXML_Document *actionResult =
+ UpnpActionComplete_get_ActionResult(a_event);
+ if (errCode != UPNP_E_SUCCESS) {
+#else
struct Upnp_Action_Complete *a_event =
(struct Upnp_Action_Complete *)Event;
if (a_event->ErrCode != UPNP_E_SUCCESS) {
+#endif
UPnP::ProcessErrorMessage(
"UpnpSendActionAsync",
+#if UPNP_VERSION >= 10800
+ errCode, NULL,
+ actionResult);
+#else
a_event->ErrCode, NULL,
a_event->ActionResult);
+#endif
} else {
// Check the response document
UPnP::ProcessActionResponse(
+#if UPNP_VERSION >= 10800
+ actionResult,
+#else
a_event->ActionResult,
+#endif
"<UpnpSendActionAsync>");
}
/* No need for any processing here, just print out results.
@@ -1342,22 +1471,43 @@
case UPNP_CONTROL_GET_VAR_COMPLETE: {
//fprintf(stderr, "Callback: UPNP_CONTROL_GET_VAR_COMPLETE\n");
msg << "error(UPNP_CONTROL_GET_VAR_COMPLETE): ";
+#if UPNP_VERSION >= 10800
+ UpnpStateVarComplete *sv_event = (UpnpStateVarComplete *)Event;
+ int errCode = UpnpStateVarComplete_get_ErrCode(sv_event);
+ if (errCode != UPNP_E_SUCCESS) {
+#else
struct Upnp_State_Var_Complete *sv_event =
(struct Upnp_State_Var_Complete *)Event;
if (sv_event->ErrCode != UPNP_E_SUCCESS) {
+#endif
msg << "m_UpnpGetServiceVarStatusAsync";
UPnP::ProcessErrorMessage(
+#if UPNP_VERSION >= 10800
+ msg.str(), errCode, NULL, NULL);
+#else
msg.str(), sv_event->ErrCode, NULL, NULL);
+#endif
} else {
#if 0
// Warning: The use of UpnpGetServiceVarStatus and
// UpnpGetServiceVarStatusAsync is deprecated by the
// UPnP forum.
+#if UPNP_VERSION >= 10800
+ const char *ctrlUrl =
+ UpnpStateVarComplete_get_CtrlUrl(sv_event);
+ const char *stateVarName =
+ UpnpStateVarComplete_get_StateVarName(sv_event);
+ const DOMString currentVal =
+ UpnpStateVarComplete_get_CurrentVal(sv_event);
+ TvCtrlPointHandleGetVar(
+ ctrlUrl, stateVarName, currentVal);
+#else
TvCtrlPointHandleGetVar(
sv_event->CtrlUrl,
sv_event->StateVarName,
sv_event->CurrentVal );
#endif
+#endif
}
break;
}
diff -Naur a/src/UPnPBase.h b/src/UPnPBase.h
--- a/src/UPnPBase.h 2016-10-06 18:49:44.000000000 +0800
+++ b/src/UPnPBase.h 2019-12-11 22:16:28.165063153 +0800
@@ -489,9 +489,15 @@
// Callback function
static int Callback(
+ #if UPNP_VERSION >= 10800
+ Upnp_EventType_e EventType,
+ const void *Event,
+ void *Cookie);
+ #else
Upnp_EventType EventType,
void* Event,
void* Cookie);
+ #endif
private:
void OnEventReceived(

View File

@ -1,174 +0,0 @@
diff --git a/src/SearchList.cpp b/src/SearchList.cpp
index 32b28e9..342a18f 100644
--- a/src/SearchList.cpp
+++ b/src/SearchList.cpp
@@ -75,7 +75,7 @@ void ParsedSearchExpression(const CSearchExpr* pexpr)
int iOpNot = 0;
for (unsigned int i = 0; i < pexpr->m_aExpr.GetCount(); i++) {
- wxString str(pexpr->m_aExpr[i]);
+ const wxString& str = pexpr->m_aExpr[i];
if (str == SEARCHOPTOK_AND) {
iOpAnd++;
} else if (str == SEARCHOPTOK_OR) {
@@ -108,6 +108,25 @@ void ParsedSearchExpression(const CSearchExpr* pexpr)
// optimize search expression, if no OR nor NOT specified
if (iOpAnd > 0 && iOpOr == 0 && iOpNot == 0) {
+ // figure out if we can use a better keyword than the one the user selected
+ // for example most user will search like this "The oxymoronaccelerator 2", which would ask the node which indexes "the"
+ // This causes higher traffic for such nodes and makes them a viable target to attackers, while the kad result should be
+ // the same or even better if we ask the node which indexes the rare keyword "oxymoronaccelerator", so we try to rearrange
+ // keywords and generally assume that the longer keywords are rarer
+ if (/*thePrefs::GetRearrangeKadSearchKeywords() &&*/ !s_strCurKadKeyword.IsEmpty()) {
+ for (unsigned int i = 0; i < pexpr->m_aExpr.GetCount(); i++) {
+ if (pexpr->m_aExpr[i] != SEARCHOPTOK_AND) {
+ if (pexpr->m_aExpr[i] != s_strCurKadKeyword
+ && pexpr->m_aExpr[i].find_first_of(Kademlia::CSearchManager::GetInvalidKeywordChars()) == wxString::npos
+ && pexpr->m_aExpr[i].Find('"') != 0 // no quoted expressions as keyword
+ && pexpr->m_aExpr[i].length() >= 3
+ && s_strCurKadKeyword.length() < pexpr->m_aExpr[i].length())
+ {
+ s_strCurKadKeyword = pexpr->m_aExpr[i];
+ }
+ }
+ }
+ }
wxString strAndTerms;
for (unsigned int i = 0; i < pexpr->m_aExpr.GetCount(); i++) {
if (pexpr->m_aExpr[i] != SEARCHOPTOK_AND) {
@@ -285,7 +304,7 @@ void CSearchList::RemoveResults(long searchID)
}
-wxString CSearchList::StartNewSearch(uint32* searchID, SearchType type, const CSearchParams& params)
+wxString CSearchList::StartNewSearch(uint32* searchID, SearchType type, CSearchParams& params)
{
// Check that we can actually perform the specified desired search.
if ((type == KadSearch) && !Kademlia::CKademlia::IsRunning()) {
@@ -306,6 +325,16 @@ wxString CSearchList::StartNewSearch(uint32* searchID, SearchType type, const CS
m_resultType.Clear();
}
+ if (type == KadSearch) {
+ Kademlia::WordList words;
+ Kademlia::CSearchManager::GetWords(params.searchString, &words);
+ if (!words.empty()) {
+ params.strKeyword = words.front();
+ } else {
+ return _("No keyword for Kad search - aborting");
+ }
+ }
+
bool supports64bit = type == KadSearch ? true : theApp->serverconnect->GetCurrentServer() != NULL && (theApp->serverconnect->GetCurrentServer()->GetTCPFlags() & SRV_TCPFLG_LARGEFILES);
bool packetUsing64bit;
@@ -332,8 +361,7 @@ wxString CSearchList::StartNewSearch(uint32* searchID, SearchType type, const CS
// searchstring will get tokenized there
// The tab must be created with the Kad search ID, so searchID is updated.
- Kademlia::CSearch* search = Kademlia::CSearchManager::PrepareFindKeywords(
- params.searchString, data->GetLength(), data->GetRawBuffer(), *searchID);
+ Kademlia::CSearch* search = Kademlia::CSearchManager::PrepareFindKeywords(params.strKeyword, data->GetLength(), data->GetRawBuffer(), *searchID);
*searchID = search->GetSearchID();
m_currentSearch = *searchID;
@@ -632,7 +660,7 @@ void CSearchList::StopSearch(bool globalOnly)
}
-CSearchList::CMemFilePtr CSearchList::CreateSearchData(const CSearchParams& params, SearchType WXUNUSED(type), bool supports64bit, bool& packetUsing64bit)
+CSearchList::CMemFilePtr CSearchList::CreateSearchData(CSearchParams& params, SearchType type, bool supports64bit, bool& packetUsing64bit)
{
// Count the number of used parameters
unsigned int parametercount = 0;
@@ -659,14 +687,16 @@ CSearchList::CMemFilePtr CSearchList::CreateSearchData(const CSearchParams& para
_astrParserErrors.Empty();
_SearchExpr.m_aExpr.Empty();
+ s_strCurKadKeyword.Clear();
+ if (type == KadSearch) {
+ wxASSERT( !params.strKeyword.IsEmpty() );
+ s_strCurKadKeyword = params.strKeyword;
+ }
+
LexInit(params.searchString);
int iParseResult = yyparse();
LexFree();
-#ifdef __DEBUG__
- AddLogLineNS(CFormat(wxT("Search parsing result for \"%s\": %i"))
- % params.searchString % iParseResult);
-#endif
if (_astrParserErrors.GetCount() > 0) {
for (unsigned int i=0; i < _astrParserErrors.GetCount(); ++i) {
AddLogLineNS(CFormat(wxT("Error %u: %s\n")) % i % _astrParserErrors[i]);
@@ -681,21 +711,13 @@ CSearchList::CMemFilePtr CSearchList::CreateSearchData(const CSearchParams& para
return CMemFilePtr(NULL);
}
- #ifdef __DEBUG__
- wxString mes(wxT("Search expression:"));
- for (unsigned int i = 0; i < _SearchExpr.m_aExpr.GetCount(); i++) {
- mes << wxT(" ") << _SearchExpr.m_aExpr[i];
+ if (type == KadSearch && s_strCurKadKeyword != params.strKeyword) {
+ AddDebugLogLineN(logSearch, CFormat(wxT("Keyword was rearranged, using '%s' instead of '%s'")) % s_strCurKadKeyword % params.strKeyword);
+ params.strKeyword = s_strCurKadKeyword;
}
- AddLogLineNS(mes);
- AddLogLineNS(CFormat(wxT("Expression count: %i")) % _SearchExpr.m_aExpr.GetCount());
- #endif
parametercount += _SearchExpr.m_aExpr.GetCount();
- #ifdef __DEBUG__
- AddLogLineNS(CFormat(wxT("Parameters: %i")) % parametercount);
- #endif
-
/* Leave the unicode comment there, please... */
CSearchExprTarget target(data.get(), true /*I assume everyone is unicoded */ ? utf8strRaw : utf8strNone, supports64bit, packetUsing64bit);
diff --git a/src/SearchList.h b/src/SearchList.h
index 35b0fc6..6db7508 100644
--- a/src/SearchList.h
+++ b/src/SearchList.h
@@ -64,6 +64,8 @@ class CSearchList : public wxEvtHandler
//! The actual string to search for.
wxString searchString;
+ //! The keyword selected for Kad search
+ wxString strKeyword;
//! The type of files to search for (may be empty), one of ED2KFTSTR_*
wxString typeText;
//! The filename extension. May be empty.
@@ -90,7 +92,7 @@ class CSearchList : public wxEvtHandler
* @param params The search parameters, see CSearchParams.
* @return An empty string on success, otherwise an error-message.
*/
- wxString StartNewSearch(uint32* searchID, SearchType type, const CSearchParams& params);
+ wxString StartNewSearch(uint32* searchID, SearchType type, CSearchParams& params);
/** Stops the current search (global or Kad), if any is in progress. */
void StopSearch(bool globalOnly = false);
@@ -189,7 +191,7 @@ class CSearchList : public wxEvtHandler
typedef std::auto_ptr<CMemFile> CMemFilePtr;
/** Create a basic search-packet for the given search-type. */
- CMemFilePtr CreateSearchData(const CSearchParams& params, SearchType type, bool supports64bit, bool& packetUsing64bit);
+ CMemFilePtr CreateSearchData(CSearchParams& params, SearchType type, bool supports64bit, bool& packetUsing64bit);
//! Timer used for global search intervals.
diff --git a/src/kademlia/kademlia/SearchManager.cpp b/src/kademlia/kademlia/SearchManager.cpp
index e7f25d4..f9ee924 100644
--- a/src/kademlia/kademlia/SearchManager.cpp
+++ b/src/kademlia/kademlia/SearchManager.cpp
@@ -127,7 +127,7 @@ CSearch* CSearchManager::PrepareFindKeywords(const wxString& keyword, uint32_t s
wxString wstrKeyword = s->m_words.front();
- AddLogLineNS(CFormat(_("Keyword for search: %s")) % wstrKeyword);
+ AddDebugLogLineN(logSearch, CFormat(wxT("Keyword for search: %s")) % wstrKeyword);
// Kry - I just decided to assume everyone is unicoded
// GonoszTopi - seconded

View File

@ -1,318 +0,0 @@
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

@ -1,743 +0,0 @@
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);