diff options
author | George Hazan <ghazan@miranda.im> | 2017-01-11 22:23:57 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2017-01-11 22:24:06 +0300 |
commit | d958e3fb847813075cc059bd5a7aa28252982268 (patch) | |
tree | d9c02a7ddee830628248219e9c83c7de3c335140 /src/mir_app | |
parent | c8e1c429321ed8aa2efce0fc00b6dfd08f1b2735 (diff) |
strong typization - better typization
Diffstat (limited to 'src/mir_app')
-rw-r--r-- | src/mir_app/src/mir_app.def | 5 | ||||
-rw-r--r-- | src/mir_app/src/mir_app64.def | 5 | ||||
-rw-r--r-- | src/mir_app/src/netlib.cpp | 21 | ||||
-rw-r--r-- | src/mir_app/src/netlib.h | 1 | ||||
-rw-r--r-- | src/mir_app/src/netlibautoproxy.cpp | 8 | ||||
-rw-r--r-- | src/mir_app/src/netlibbind.cpp | 34 | ||||
-rw-r--r-- | src/mir_app/src/netlibhttp.cpp | 6 | ||||
-rw-r--r-- | src/mir_app/src/netlibhttpproxy.cpp | 4 | ||||
-rw-r--r-- | src/mir_app/src/netliblog.cpp | 59 | ||||
-rw-r--r-- | src/mir_app/src/netlibopenconn.cpp | 72 | ||||
-rw-r--r-- | src/mir_app/src/netlibpktrecver.cpp | 2 | ||||
-rw-r--r-- | src/mir_app/src/netlibsecurity.cpp | 4 | ||||
-rw-r--r-- | src/mir_app/src/netlibupnp.cpp | 16 | ||||
-rw-r--r-- | src/mir_app/src/proto_utils.cpp | 16 |
14 files changed, 131 insertions, 122 deletions
diff --git a/src/mir_app/src/mir_app.def b/src/mir_app/src/mir_app.def index 5c5bd98036..3c24d69dc5 100644 --- a/src/mir_app/src/mir_app.def +++ b/src/mir_app/src/mir_app.def @@ -348,3 +348,8 @@ Srmm_CreateToolbarIcons @348 Netlib_CloseHandle @349
Netlib_Recv @350
Netlib_Send @351
+Netlib_RegisterUser @352
+Netlib_Log @353
+Netlib_LogW @354
+Netlib_Logf @355
+Netlib_LogfW @356
diff --git a/src/mir_app/src/mir_app64.def b/src/mir_app/src/mir_app64.def index f0a887610b..b7a8c032e1 100644 --- a/src/mir_app/src/mir_app64.def +++ b/src/mir_app/src/mir_app64.def @@ -348,3 +348,8 @@ Srmm_CreateToolbarIcons @348 Netlib_CloseHandle @349
Netlib_Recv @350
Netlib_Send @351
+Netlib_RegisterUser @352
+Netlib_Log @353
+Netlib_LogW @354
+Netlib_Logf @355
+Netlib_LogfW @356
diff --git a/src/mir_app/src/netlib.cpp b/src/mir_app/src/netlib.cpp index 269c4ca5bf..71f1d5ea85 100644 --- a/src/mir_app/src/netlib.cpp +++ b/src/mir_app/src/netlib.cpp @@ -133,18 +133,16 @@ static char *GetNetlibUserSettingString(const char *szUserModule, const char *sz return szRet;
}
-static INT_PTR NetlibRegisterUser(WPARAM, LPARAM lParam)
+/////////////////////////////////////////////////////////////////////////////////////////
+
+MIR_APP_DLL(HNETLIBUSER) Netlib_RegisterUser(const NETLIBUSER *nlu)
{
- NETLIBUSER *nlu = (NETLIBUSER*)lParam;
- if (nlu == NULL || nlu->cbSize != sizeof(NETLIBUSER) || nlu->szSettingsModule == NULL ||
- (!(nlu->flags & NUF_NOOPTIONS) && nlu->szDescriptiveName == NULL) ||
- (nlu->flags & NUF_HTTPGATEWAY && (nlu->pfnHttpGatewayInit == NULL)))
- {
+ if (nlu == NULL || nlu->szSettingsModule == NULL || (!(nlu->flags & NUF_NOOPTIONS) && nlu->szDescriptiveName == NULL) || (nlu->flags & NUF_HTTPGATEWAY && (nlu->pfnHttpGatewayInit == NULL))) {
SetLastError(ERROR_INVALID_PARAMETER);
return 0;
}
- NetlibUser *thisUser = (NetlibUser*)mir_calloc(sizeof(NetlibUser));
+ HNETLIBUSER thisUser = (HNETLIBUSER)mir_calloc(sizeof(NetlibUser));
thisUser->handleType = NLH_USER;
thisUser->user = *nlu;
@@ -201,9 +199,11 @@ static INT_PTR NetlibRegisterUser(WPARAM, LPARAM lParam) mir_cslock lck(csNetlibUser);
netlibUser.insert(thisUser);
- return (INT_PTR)thisUser;
+ return thisUser;
}
+/////////////////////////////////////////////////////////////////////////////////////////
+
static INT_PTR NetlibGetUserSettings(WPARAM wParam, LPARAM lParam)
{
NETLIBUSERSETTINGS *nlus = (NETLIBUSERSETTINGS*)lParam;
@@ -234,7 +234,7 @@ void NetlibDoClose(NetlibConnection *nlc, bool noShutdown) {
if (nlc->s == INVALID_SOCKET) return;
- NetlibLogf(nlc->nlu, "(%p:%u) Connection closed internal", nlc, nlc->s);
+ Netlib_Logf(nlc->nlu, "(%p:%u) Connection closed internal", nlc, nlc->s);
if (nlc->hSsl) {
if (!noShutdown) sslApi.shutdown(nlc->hSsl);
sslApi.sfree(nlc->hSsl);
@@ -293,7 +293,7 @@ MIR_APP_DLL(int) Netlib_CloseHandle(HANDLE hNetlib) return 0;
}
- NetlibLogf(nlc->nlu, "(%p:%u) Connection closed", nlc, nlc->s);
+ Netlib_Logf(nlc->nlu, "(%p:%u) Connection closed", nlc, nlc->s);
delete nlc;
}
}
@@ -479,7 +479,6 @@ int LoadNetlibModule(void) hConnectionOpenMutex = connectionTimeout ? CreateMutex(NULL, FALSE, NULL) : NULL;
g_LastConnectionTick = GetTickCount();
- CreateServiceFunction(MS_NETLIB_REGISTERUSER, NetlibRegisterUser);
CreateServiceFunction(MS_NETLIB_GETUSERSETTINGS, NetlibGetUserSettings);
CreateServiceFunction(MS_NETLIB_SETUSERSETTINGS, NetlibSetUserSettings);
CreateServiceFunction(MS_NETLIB_BINDPORT, NetlibBindPort);
diff --git a/src/mir_app/src/netlib.h b/src/mir_app/src/netlib.h index dddb69c7ed..0e6281a935 100644 --- a/src/mir_app/src/netlib.h +++ b/src/mir_app/src/netlib.h @@ -234,7 +234,6 @@ INT_PTR NetlibHttpSetSticky(WPARAM wParam, LPARAM lParam); //netliblog.c
void NetlibLogShowOptions(void);
void NetlibDumpData(NetlibConnection *nlc, PBYTE buf, int len, int sent, int flags);
-void NetlibLogf(NetlibUser* nlu, const char *fmt, ...);
void NetlibLogInit(void);
void NetlibLogShutdown(void);
diff --git a/src/mir_app/src/netlibautoproxy.cpp b/src/mir_app/src/netlibautoproxy.cpp index 186d8de4df..3e2e070df9 100644 --- a/src/mir_app/src/netlibautoproxy.cpp +++ b/src/mir_app/src/netlibautoproxy.cpp @@ -282,12 +282,12 @@ static void NetlibIeProxyThread(void *arg) BOOL res;
char *loc = strstr(szAutoUrlStr, "file://");
if (loc || strstr(szAutoUrlStr, "://") == NULL) {
- NetlibLogf(NULL, "Autoproxy Init file: %s", loc);
+ Netlib_Logf(NULL, "Autoproxy Init file: %s", loc);
loc = loc ? loc + 7 : szAutoUrlStr;
res = pInternetInitializeAutoProxyDll(0, loc, NULL, NULL /*&HelperFunctions*/, NULL);
}
else {
- NetlibLogf(NULL, "Autoproxy Init %d", abuf.dwScriptBufferSize);
+ Netlib_Logf(NULL, "Autoproxy Init %d", abuf.dwScriptBufferSize);
if (abuf.dwScriptBufferSize)
res = pInternetInitializeAutoProxyDll(0, NULL, NULL, NULL /*&HelperFunctions*/, &abuf);
else
@@ -303,10 +303,10 @@ static void NetlibIeProxyThread(void *arg) param->szHost, (DWORD)mir_strlen(param->szHost), &proxy, &dwProxyLen))
param->szProxy = mir_strdup(lrtrim(proxy));
- NetlibLogf(NULL, "Autoproxy got response %s, Param: %s %s", param->szProxy, param->szUrl, param->szHost);
+ Netlib_Logf(NULL, "Autoproxy got response %s, Param: %s %s", param->szProxy, param->szUrl, param->szHost);
pInternetDeInitializeAutoProxyDll(NULL, 0);
}
- else NetlibLogf(NULL, "Autoproxy init failed");
+ else Netlib_Logf(NULL, "Autoproxy init failed");
}
char* NetlibGetIeProxy(char *szUrl)
diff --git a/src/mir_app/src/netlibbind.cpp b/src/mir_app/src/netlibbind.cpp index bf11f4737a..802c51b561 100644 --- a/src/mir_app/src/netlibbind.cpp +++ b/src/mir_app/src/netlibbind.cpp @@ -115,7 +115,7 @@ int NetlibFreeBoundPort(struct NetlibBoundPort *nlbp) closesocket(nlbp->s6);
if (nlbp->hThread)
WaitForSingleObject(nlbp->hThread, INFINITE);
- NetlibLogf(nlbp->nlu, "(%u) Port %u closed for incoming connections", nlbp->s, nlbp->wPort);
+ Netlib_Logf(nlbp->nlu, "(%u) Port %u closed for incoming connections", nlbp->s, nlbp->wPort);
mir_free(nlbp);
return 1;
}
@@ -123,7 +123,7 @@ int NetlibFreeBoundPort(struct NetlibBoundPort *nlbp) static void NetlibBindAcceptThread(void* param)
{
NetlibBoundPort *nlbp = (NetlibBoundPort*)param;
- NetlibLogf(nlbp->nlu, "(%u) Port %u opened for incoming connections", nlbp->s, nlbp->wPort);
+ Netlib_Logf(nlbp->nlu, "(%u) Port %u opened for incoming connections", nlbp->s, nlbp->wPort);
while (true) {
fd_set r;
@@ -133,7 +133,7 @@ static void NetlibBindAcceptThread(void* param) if (nlbp->s6 != INVALID_SOCKET)
FD_SET(nlbp->s6, &r);
if (select(0, &r, NULL, NULL, NULL) == SOCKET_ERROR) {
- NetlibLogf(nlbp->nlu, "NetlibBindAcceptThread (%p): select failed (%d)", nlbp->s, GetLastError());
+ Netlib_Logf(nlbp->nlu, "NetlibBindAcceptThread (%p): select failed (%d)", nlbp->s, GetLastError());
break;
}
@@ -145,20 +145,20 @@ static void NetlibBindAcceptThread(void* param) if (FD_ISSET(nlbp->s, &r)) {
s = accept(nlbp->s, (sockaddr*)&sin, &sinLen);
if (s == INVALID_SOCKET) {
- NetlibLogf(nlbp->nlu, "NetlibBindAcceptThread (%p): accept V4 failed (%d)", nlbp->s, GetLastError());
+ Netlib_Logf(nlbp->nlu, "NetlibBindAcceptThread (%p): accept V4 failed (%d)", nlbp->s, GetLastError());
break;
}
}
else if (FD_ISSET(nlbp->s6, &r)) {
s = accept(nlbp->s6, (sockaddr*)&sin, &sinLen);
if (s == INVALID_SOCKET) {
- NetlibLogf(nlbp->nlu, "NetlibBindAcceptThread (%p): accept V6 failed (%d)", nlbp->s, GetLastError());
+ Netlib_Logf(nlbp->nlu, "NetlibBindAcceptThread (%p): accept V6 failed (%d)", nlbp->s, GetLastError());
break;
}
}
else s = NULL;
- NetlibLogf(nlbp->nlu, "New incoming connection on port %u from %s (%p)", nlbp->wPort, ptrA(NetlibAddressToString(&sin)), s);
+ Netlib_Logf(nlbp->nlu, "New incoming connection on port %u from %s (%p)", nlbp->wPort, ptrA(NetlibAddressToString(&sin)), s);
NetlibConnection *nlc = new NetlibConnection();
nlc->nlu = nlbp->nlu;
@@ -171,7 +171,7 @@ static void NetlibBindAcceptThread(void* param) NetlibUPnPDeletePortMapping(nlbp->wExPort, "TCP");
nlbp->hThread = 0;
- NetlibLogf(nlbp->nlu, "NetlibBindAcceptThread: (%p) thread for port %u closed", nlbp->s, nlbp->wPort);
+ Netlib_Logf(nlbp->nlu, "NetlibBindAcceptThread: (%p) thread for port %u closed", nlbp->s, nlbp->wPort);
}
INT_PTR NetlibBindPort(WPARAM wParam, LPARAM lParam)
@@ -200,7 +200,7 @@ INT_PTR NetlibBindPort(WPARAM wParam, LPARAM lParam) nlbp->s6 = socket(PF_INET6, SOCK_STREAM, 0);
nlbp->pExtra = nlb->pExtra;
if (nlbp->s == INVALID_SOCKET && nlbp->s6 == INVALID_SOCKET) {
- NetlibLogf(nlu, "%s %d: %s() failed (%u)", __FILE__, __LINE__, "socket", WSAGetLastError());
+ Netlib_Logf(nlu, "%s %d: %s() failed (%u)", __FILE__, __LINE__, "socket", WSAGetLastError());
mir_free(nlbp);
return 0;
}
@@ -211,7 +211,7 @@ INT_PTR NetlibBindPort(WPARAM wParam, LPARAM lParam) they better have given wPort == 0, let's hope so */
if (nlu->settings.specifyIncomingPorts && nlu->settings.szIncomingPorts && nlb->wPort == 0) {
if (!BindSocketToPort(nlu->settings.szIncomingPorts, nlbp->s, nlbp->s6, &nlu->outportnum)) {
- NetlibLogf(nlu, "Netlib bind: Not enough ports for incoming connections specified");
+ Netlib_Logf(nlu, "Netlib bind: Not enough ports for incoming connections specified");
SetLastError(WSAEADDRINUSE);
}
else foundPort = 1;
@@ -220,7 +220,7 @@ INT_PTR NetlibBindPort(WPARAM wParam, LPARAM lParam) /* if ->wPort == 0 then they'll get any free port, otherwise they'll
be asking for whatever was in nlb->wPort*/
if (nlb->wPort != 0) {
- NetlibLogf(nlu, "%s %d: trying to bind port %d, this 'feature' can be abused, please be sure you want to allow it.", __FILE__, __LINE__, nlb->wPort);
+ Netlib_Logf(nlu, "%s %d: trying to bind port %d, this 'feature' can be abused, please be sure you want to allow it.", __FILE__, __LINE__, nlb->wPort);
sin.sin_port = htons(nlb->wPort);
sin6.sin6_port = htons(nlb->wPort);
}
@@ -239,7 +239,7 @@ INT_PTR NetlibBindPort(WPARAM wParam, LPARAM lParam) foundPort = 1;
}
if (!foundPort) {
- NetlibLogf(nlu, "%s %d: %s() failed (%u)", __FILE__, __LINE__, "bind", WSAGetLastError());
+ Netlib_Logf(nlu, "%s %d: %s() failed (%u)", __FILE__, __LINE__, "bind", WSAGetLastError());
LBL_Error:
closesocket(nlbp->s);
closesocket(nlbp->s6);
@@ -248,12 +248,12 @@ LBL_Error: }
if (nlbp->s != INVALID_SOCKET && listen(nlbp->s, 5)) {
- NetlibLogf(nlu, "%s %d: %s() failed (%u)", __FILE__, __LINE__, "listen", WSAGetLastError());
+ Netlib_Logf(nlu, "%s %d: %s() failed (%u)", __FILE__, __LINE__, "listen", WSAGetLastError());
goto LBL_Error;
}
if (nlbp->s6 != INVALID_SOCKET && listen(nlbp->s6, 5)) {
- NetlibLogf(nlu, "%s %d: %s() failed (%u)", __FILE__, __LINE__, "listen", WSAGetLastError());
+ Netlib_Logf(nlu, "%s %d: %s() failed (%u)", __FILE__, __LINE__, "listen", WSAGetLastError());
goto LBL_Error;
}
@@ -266,7 +266,7 @@ LBL_Error: else if (!getsockname(nlbp->s6, (PSOCKADDR)&sinm, &len))
nlb->wPort = ntohs(sinm.Ipv6.sin6_port);
else {
- NetlibLogf(nlu, "%s %d: %s() failed (%u)", __FILE__, __LINE__, "getsockname", WSAGetLastError());
+ Netlib_Logf(nlu, "%s %d: %s() failed (%u)", __FILE__, __LINE__, "getsockname", WSAGetLastError());
goto LBL_Error;
}
nlbp->wPort = nlb->wPort;
@@ -282,15 +282,15 @@ LBL_Error: DWORD extIP;
if (nlu->settings.enableUPnP && NetlibUPnPAddPortMapping(nlb->wPort, "TCP", &nlbp->wExPort, &extIP, true)) {
- NetlibLogf(NULL, "UPnP port mapping succeeded. Internal Port: %u External Port: %u\n", nlb->wPort, nlbp->wExPort);
+ Netlib_Logf(NULL, "UPnP port mapping succeeded. Internal Port: %u External Port: %u\n", nlb->wPort, nlbp->wExPort);
nlb->wExPort = nlbp->wExPort;
nlb->dwExternalIP = extIP;
}
else {
if (nlu->settings.enableUPnP)
- NetlibLogf(NULL, "UPnP port mapping failed. Internal Port: %u\n", nlb->wPort);
+ Netlib_Logf(NULL, "UPnP port mapping failed. Internal Port: %u\n", nlb->wPort);
else
- NetlibLogf(NULL, "UPnP disabled. Internal Port: %u\n", nlb->wPort);
+ Netlib_Logf(NULL, "UPnP disabled. Internal Port: %u\n", nlb->wPort);
nlbp->wExPort = 0;
nlb->wExPort = nlb->wPort;
diff --git a/src/mir_app/src/netlibhttp.cpp b/src/mir_app/src/netlibhttp.cpp index 4eaeb33475..e04e8a21d0 100644 --- a/src/mir_app/src/netlibhttp.cpp +++ b/src/mir_app/src/netlibhttp.cpp @@ -246,7 +246,7 @@ struct HttpSecurityContext PHOSTENT host = (ip == INADDR_NONE) ? gethostbyname(szHost) : gethostbyaddr((char*)&ip, 4, AF_INET);
szSpnStr.Format("HTTP/%s", host && host->h_name ? host->h_name : szHost);
_strlwr(szSpnStr.GetBuffer() + 5);
- NetlibLogf(nlu, "Host SPN: %s", szSpnStr);
+ Netlib_Logf(nlu, "Host SPN: %s", szSpnStr);
}
m_hNtlmSecurity = NetlibInitSecurityProvider(szProvider, szSpnStr.IsEmpty() ? NULL : szSpnStr.c_str());
if (m_hNtlmSecurity) {
@@ -267,7 +267,7 @@ struct HttpSecurityContext szAuthHdr = NtlmCreateResponseFromChallenge(m_hNtlmSecurity, szChallenge, szLogin, szPassw, true, complete);
if (!szAuthHdr)
- NetlibLogf(NULL, "Security login %s failed, user: %S pssw: %S", szProvider, szLogin ? szLogin.get() : L"(no user)", szPassw ? L"(exist)" : L"(no psw)");
+ Netlib_Logf(NULL, "Security login %s failed, user: %S pssw: %S", szProvider, szLogin ? szLogin.get() : L"(no user)", szPassw ? L"(exist)" : L"(no psw)");
else if (justCreated)
proxyAuthList.add(m_szHost, m_szProvider);
}
@@ -522,7 +522,7 @@ INT_PTR NetlibHttpSendRequest(WPARAM wParam, LPARAM lParam) DWORD dwTimeOutTime = hdrTimeout < 0 ? -1 : GetTickCount() + hdrTimeout;
if (!HttpPeekFirstResponseLine(nlc, dwTimeOutTime, fflags, &nlhr->resultCode, NULL, NULL)) {
DWORD err = GetLastError();
- NetlibLogf(nlu, "%s %d: %s Failed (%u %u)", __FILE__, __LINE__, "HttpPeekFirstResponseLine", err, count);
+ Netlib_Logf(nlu, "%s %d: %s Failed (%u %u)", __FILE__, __LINE__, "HttpPeekFirstResponseLine", err, count);
// connection died while we were waiting
if (GetNetlibHandleType(nlc) != NLH_CONNECTION) {
diff --git a/src/mir_app/src/netlibhttpproxy.cpp b/src/mir_app/src/netlibhttpproxy.cpp index 6caa8631bf..75c714a1c7 100644 --- a/src/mir_app/src/netlibhttpproxy.cpp +++ b/src/mir_app/src/netlibhttpproxy.cpp @@ -307,11 +307,11 @@ int NetlibHttpGatewayRecv(NetlibConnection *nlc, char *buf, int len, int flags) NetlibHttpFreeRequestStruct(0, (LPARAM)nlhrReply);
if (nlc->nlhpi.szHttpGetUrl && resultCode != 404) {
- NetlibLogf(nlu, "Error received from proxy, retrying");
+ Netlib_Logf(nlu, "Error received from proxy, retrying");
continue;
}
else {
- NetlibLogf(nlu, "Error received from proxy, retry attempts exceeded (%u)", retryCount);
+ Netlib_Logf(nlu, "Error received from proxy, retry attempts exceeded (%u)", retryCount);
SetLastError(ERROR_GEN_FAILURE);
return SOCKET_ERROR;
}
diff --git a/src/mir_app/src/netliblog.cpp b/src/mir_app/src/netliblog.cpp index d73c075a8a..d61f3ebe00 100644 --- a/src/mir_app/src/netliblog.cpp +++ b/src/mir_app/src/netliblog.cpp @@ -350,39 +350,58 @@ int NetlibLog_Worker(NetlibUser *nlu, const char *pszMsg, int flags) return 1;
}
-static INT_PTR NetlibLog(WPARAM wParam, LPARAM lParam)
+/////////////////////////////////////////////////////////////////////////////////////////
+
+MIR_APP_DLL(void) ProtoLogA(PROTO_INTERFACE *pThis, LPCSTR szFormat, va_list args)
{
- NetlibUser *nlu = (NetlibUser*)wParam;
- const char *pszMsg = (const char*)lParam;
- return NetlibLog_Worker(nlu, pszMsg, 0);
+ char buf[4096];
+ int res = _vsnprintf(buf, _countof(buf), szFormat, args);
+ NetlibLog_Worker(pThis ? pThis->m_hNetlibUser : NULL, (res != -1) ? buf : CMStringA().FormatV(szFormat, args), 0);
}
-static INT_PTR NetlibLogW(WPARAM wParam, LPARAM lParam)
+MIR_APP_DLL(void) ProtoLogW(PROTO_INTERFACE *pThis, LPCWSTR wszFormat, va_list args)
{
- NetlibUser *nlu = (NetlibUser*)wParam;
- const wchar_t *pwszMsg = (const wchar_t*)lParam;
- return NetlibLog_Worker(nlu, ptrA(Utf8EncodeW(pwszMsg)), 0);
+ WCHAR buf[4096];
+ int res = _vsnwprintf(buf, _countof(buf), wszFormat, args);
+ NetlibLog_Worker(pThis ? pThis->m_hNetlibUser : NULL, ptrA(Utf8EncodeW((res != -1) ? buf : CMStringW().FormatV(wszFormat, args))), 0);
}
-void NetlibLogf(NetlibUser* nlu, const char *fmt, ...)
-{
- if (nlu == NULL) {
- if (!logOptions.toLog)
- return;
- }
- else if (!nlu->toLog)
- return;
+/////////////////////////////////////////////////////////////////////////////////////////
+MIR_APP_DLL(int) Netlib_Logf(HNETLIBUSER hUser, const char *fmt, ...)
+{
va_list va;
- char szText[1024];
+ va_start(va, fmt);
+ char szText[8000];
+ mir_vsnprintf(szText, _countof(szText), fmt, va);
+ va_end(va);
+ return NetlibLog_Worker(hUser, szText, 0);
+}
+MIR_APP_DLL(int) Netlib_LogfW(HNETLIBUSER hUser, const wchar_t *fmt, ...)
+{
+ va_list va;
va_start(va, fmt);
- mir_vsnprintf(szText, sizeof(szText), fmt, va);
+ wchar_t szText[8000];
+ mir_vsnwprintf(szText, _countof(szText), fmt, va);
va_end(va);
+ return NetlibLog_Worker(hUser, ptrA(Utf8EncodeW(szText)), 0);
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
- NetlibLog_Worker(nlu, szText, 0);
+MIR_APP_DLL(int) Netlib_Log(HNETLIBUSER hUser, const char *pszStr)
+{
+ return NetlibLog_Worker(hUser, pszStr, 0);
}
+MIR_APP_DLL(int) Netlib_LogW(HNETLIBUSER hUser, const wchar_t *pwszStr)
+{
+ return NetlibLog_Worker(hUser, ptrA(Utf8EncodeW(pwszStr)), 0);
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
void NetlibDumpData(NetlibConnection *nlc, PBYTE buf, int len, int sent, int flags)
{
char szTitleLine[128];
@@ -504,8 +523,6 @@ void NetlibLogInit(void) mirandaStartTime = li.QuadPart;
CreateServiceFunction(MS_NETLIB_LOGWIN, ShowOptions);
- CreateServiceFunction(MS_NETLIB_LOG, NetlibLog);
- CreateServiceFunction(MS_NETLIB_LOGW, NetlibLogW);
hLogEvent = CreateHookableEvent(ME_NETLIB_FASTDUMP);
logOptions.dumpRecv = db_get_b(NULL, "Netlib", "DumpRecv", 1);
diff --git a/src/mir_app/src/netlibopenconn.cpp b/src/mir_app/src/netlibopenconn.cpp index 65482350ea..cbbf885d28 100644 --- a/src/mir_app/src/netlibopenconn.cpp +++ b/src/mir_app/src/netlibopenconn.cpp @@ -47,7 +47,7 @@ DWORD DnsLookup(NetlibUser *nlu, const char *szHost) if (host) return *(u_long*)host->h_addr_list[0]; - NetlibLogf(nlu, "%s %d: %s() for host %s failed (%u)", __FILE__, __LINE__, "gethostbyname", szHost, WSAGetLastError()); + Netlib_Logf(nlu, "%s %d: %s() for host %s failed (%u)", __FILE__, __LINE__, "gethostbyname", szHost, WSAGetLastError()); } __except(EXCEPTION_EXECUTE_HANDLER) {} @@ -136,13 +136,13 @@ static int NetlibInitSocks4Connection(NetlibConnection *nlc, NetlibUser *nlu, NE } if (Netlib_Send(nlc, pInit, (int)len, MSG_DUMPPROXY) == SOCKET_ERROR) { - NetlibLogf(nlu, "%s %d: %s() failed (%u)", __FILE__, __LINE__, "Netlib_Send", GetLastError()); + Netlib_Logf(nlu, "%s %d: %s() failed (%u)", __FILE__, __LINE__, "Netlib_Send", GetLastError()); return 0; } char reply[8]; if (!RecvUntilTimeout(nlc, reply, sizeof(reply), MSG_DUMPPROXY, RECV_DEFAULT_TIMEOUT)) { - NetlibLogf(nlu, "%s %d: %s() failed (%u)", __FILE__, __LINE__, "RecvUntilTimeout", GetLastError()); + Netlib_Logf(nlu, "%s %d: %s() failed (%u)", __FILE__, __LINE__, "RecvUntilTimeout", GetLastError()); return 0; } @@ -153,7 +153,7 @@ static int NetlibInitSocks4Connection(NetlibConnection *nlc, NetlibUser *nlu, NE case 93: SetLastError(ERROR_INVALID_ACCESS); break; default: SetLastError(ERROR_INVALID_DATA); break; } - NetlibLogf(nlu, "%s %d: Proxy connection failed (%x %u)", __FILE__, __LINE__, (BYTE)reply[1], GetLastError()); + Netlib_Logf(nlu, "%s %d: Proxy connection failed (%x %u)", __FILE__, __LINE__, (BYTE)reply[1], GetLastError()); return 0; } @@ -166,18 +166,18 @@ static int NetlibInitSocks5Connection(NetlibConnection *nlc, NetlibUser *nlu, NE buf[1] = 1; //one auth method buf[2] = nlu->settings.useProxyAuth?2:0; if (Netlib_Send(nlc, (char*)buf, 3, MSG_DUMPPROXY) == SOCKET_ERROR) { - NetlibLogf(nlu, "%s %d: %s() failed (%u)", __FILE__, __LINE__, "Netlib_Send", GetLastError()); + Netlib_Logf(nlu, "%s %d: %s() failed (%u)", __FILE__, __LINE__, "Netlib_Send", GetLastError()); return 0; } //confirmation of auth method if (!RecvUntilTimeout(nlc, (char*)buf, 2, MSG_DUMPPROXY, RECV_DEFAULT_TIMEOUT)) { - NetlibLogf(nlu, "%s %d: %s() failed (%u)", __FILE__, __LINE__, "RecvUntilTimeout", GetLastError()); + Netlib_Logf(nlu, "%s %d: %s() failed (%u)", __FILE__, __LINE__, "RecvUntilTimeout", GetLastError()); return 0; } if ((buf[1] != 0 && buf[1] != 2)) { SetLastError(ERROR_INVALID_ID_AUTHORITY); - NetlibLogf(nlu, "%s %d: %s() failed (%u)", __FILE__, __LINE__, "Netlib_Recv", GetLastError()); + Netlib_Logf(nlu, "%s %d: %s() failed (%u)", __FILE__, __LINE__, "Netlib_Recv", GetLastError()); return 0; } @@ -191,19 +191,19 @@ static int NetlibInitSocks5Connection(NetlibConnection *nlc, NetlibUser *nlu, NE pAuthBuf[2 + nUserLen] = (BYTE)nPassLen; memcpy(pAuthBuf + 3 + nUserLen, nlu->settings.szProxyAuthPassword, nPassLen); if (Netlib_Send(nlc, (char*)pAuthBuf, int(3 + nUserLen + nPassLen), MSG_DUMPPROXY) == SOCKET_ERROR) { - NetlibLogf(nlu, "%s %d: %s() failed (%u)", __FILE__, __LINE__, "Netlib_Send", GetLastError()); + Netlib_Logf(nlu, "%s %d: %s() failed (%u)", __FILE__, __LINE__, "Netlib_Send", GetLastError()); mir_free(pAuthBuf); return 0; } mir_free(pAuthBuf); if (!RecvUntilTimeout(nlc, (char*)buf, 2, MSG_DUMPPROXY, RECV_DEFAULT_TIMEOUT)) { - NetlibLogf(nlu, "%s %d: %s() failed (%u)", __FILE__, __LINE__, "RecvUntilTimeout", GetLastError()); + Netlib_Logf(nlu, "%s %d: %s() failed (%u)", __FILE__, __LINE__, "RecvUntilTimeout", GetLastError()); return 0; } if (buf[1]) { SetLastError(ERROR_ACCESS_DENIED); - NetlibLogf(nlu, "%s %d: %s() failed (%u)", __FILE__, __LINE__, "RecvUntilTimeout", GetLastError()); + Netlib_Logf(nlu, "%s %d: %s() failed (%u)", __FILE__, __LINE__, "RecvUntilTimeout", GetLastError()); return 0; } } @@ -236,14 +236,14 @@ static int NetlibInitSocks5Connection(NetlibConnection *nlc, NetlibUser *nlu, NE } *(PWORD)(pInit + 4 + nHostLen) = htons(nloc->wPort); if (Netlib_Send(nlc, (char*)pInit, int(6 + nHostLen), MSG_DUMPPROXY) == SOCKET_ERROR) { - NetlibLogf(nlu, "%s %d: %s() failed (%u)", __FILE__, __LINE__, "Netlib_Send", GetLastError()); + Netlib_Logf(nlu, "%s %d: %s() failed (%u)", __FILE__, __LINE__, "Netlib_Send", GetLastError()); mir_free(pInit); return 0; } mir_free(pInit); if (!RecvUntilTimeout(nlc, (char*)buf, 5, MSG_DUMPPROXY, RECV_DEFAULT_TIMEOUT)) { - NetlibLogf(nlu, "%s %d: %s() failed (%u)", __FILE__, __LINE__, "RecvUntilTimeout", GetLastError()); + Netlib_Logf(nlu, "%s %d: %s() failed (%u)", __FILE__, __LINE__, "RecvUntilTimeout", GetLastError()); return 0; } @@ -264,7 +264,7 @@ static int NetlibInitSocks5Connection(NetlibConnection *nlc, NetlibUser *nlu, NE default: SetLastError(ERROR_INVALID_DATA); break; } } - NetlibLogf(nlu, "%s %d: Proxy conection failed. %s.", __FILE__, __LINE__, err); + Netlib_Logf(nlu, "%s %d: Proxy conection failed. %s.", __FILE__, __LINE__, err); return 0; } @@ -280,11 +280,11 @@ static int NetlibInitSocks5Connection(NetlibConnection *nlc, NetlibUser *nlu, NE nRecvSize = 17; break; default: - NetlibLogf(nlu, "%s %d: %s() unknown address type (%u)", __FILE__, __LINE__, "NetlibInitSocks5Connection", (int)buf[3]); + Netlib_Logf(nlu, "%s %d: %s() unknown address type (%u)", __FILE__, __LINE__, "NetlibInitSocks5Connection", (int)buf[3]); return 0; } if (!RecvUntilTimeout(nlc, (char*)buf, nRecvSize, MSG_DUMPPROXY, RECV_DEFAULT_TIMEOUT)) { - NetlibLogf(nlu, "%s %d: %s() failed (%u)", __FILE__, __LINE__, "RecvUntilTimeout", GetLastError()); + Netlib_Logf(nlu, "%s %d: %s() failed (%u)", __FILE__, __LINE__, "RecvUntilTimeout", GetLastError()); return 0; } @@ -330,7 +330,7 @@ static bool NetlibInitHttpsConnection(NetlibConnection *nlc, NetlibUser *nlu, NE } NetlibHttpSetLastErrorUsingHttpResult(nlhrReply->resultCode); - NetlibLogf(nlu, "%s %d: %s request failed (%u %s)", __FILE__, __LINE__, nlu->settings.proxyType == PROXYTYPE_HTTP ? "HTTP" : "HTTPS", nlhrReply->resultCode, nlhrReply->szResultDescr); + Netlib_Logf(nlu, "%s %d: %s request failed (%u %s)", __FILE__, __LINE__, nlu->settings.proxyType == PROXYTYPE_HTTP ? "HTTP" : "HTTPS", nlhrReply->resultCode, nlhrReply->szResultDescr); NetlibHttpFreeRequestStruct(0, (LPARAM)nlhrReply); return 0; } @@ -378,16 +378,16 @@ static bool my_connectIPv4(NetlibConnection *nlc, NETLIBOPENCONNECTION *nloc) if (!nlc->szProxyServer) return false; if (nloc) - NetlibLogf(nlc->nlu, "(%p) Connecting to proxy %s:%d for %s:%d ....", nlc, nlc->szProxyServer, nlc->wProxyPort, nloc->szHost, nloc->wPort); + Netlib_Logf(nlc->nlu, "(%p) Connecting to proxy %s:%d for %s:%d ....", nlc, nlc->szProxyServer, nlc->wProxyPort, nloc->szHost, nloc->wPort); else - NetlibLogf(nlc->nlu, "(%p) Connecting to proxy %s:%d ....", nlc, nlc->szProxyServer, nlc->wProxyPort); + Netlib_Logf(nlc->nlu, "(%p) Connecting to proxy %s:%d ....", nlc, nlc->szProxyServer, nlc->wProxyPort); sin.sin_port = htons(nlc->wProxyPort); he = gethostbyname(nlc->szProxyServer); } else { if (!nloc || !nloc->szHost || nloc->szHost[0] == '[' || strchr(nloc->szHost, ':')) return false; - NetlibLogf(nlc->nlu, "(%p) Connecting to server %s:%d....", nlc, nloc->szHost, nloc->wPort); + Netlib_Logf(nlc->nlu, "(%p) Connecting to server %s:%d....", nlc, nloc->szHost, nloc->wPort); sin.sin_port = htons(nloc->wPort); he = gethostbyname(nloc->szHost); @@ -397,7 +397,7 @@ static bool my_connectIPv4(NetlibConnection *nlc, NETLIBOPENCONNECTION *nloc) sin.sin_addr.s_addr = *(u_long*)*har; char* szIp = NetlibAddressToString((SOCKADDR_INET_M*)&sin); - NetlibLogf(nlc->nlu, "(%p) Connecting to ip %s ....", nlc, szIp); + Netlib_Logf(nlc->nlu, "(%p) Connecting to ip %s ....", nlc, szIp); mir_free(szIp); retry: @@ -411,7 +411,7 @@ retry: if (nlc->nlu->settings.specifyOutgoingPorts && nlc->nlu->settings.szOutgoingPorts && nlc->nlu->settings.szOutgoingPorts[0]) { if (!BindSocketToPort(nlc->nlu->settings.szOutgoingPorts, nlc->s, INVALID_SOCKET, &nlc->nlu->inportnum)) - NetlibLogf(nlc->nlu, "Netlib connect: Not enough ports for outgoing connections specified"); + Netlib_Logf(nlc->nlu, "Netlib connect: Not enough ports for outgoing connections specified"); } // try a connect @@ -531,11 +531,11 @@ static bool my_connectIPv6(NetlibConnection *nlc, NETLIBOPENCONNECTION *nloc) if (!nlc->szProxyServer) return false; - NetlibLogf(nlc->nlu, "(%p) Connecting to proxy %s:%d for %s:%d ....", nlc, nlc->szProxyServer, nlc->wProxyPort, nloc->szHost, nloc->wPort); + Netlib_Logf(nlc->nlu, "(%p) Connecting to proxy %s:%d for %s:%d ....", nlc, nlc->szProxyServer, nlc->wProxyPort, nloc->szHost, nloc->wPort); _itoa(nlc->wProxyPort, szPort, 10); if (GetAddrInfoA(nlc->szProxyServer, szPort, &hints, &air)) { - NetlibLogf(nlc->nlu, "%s %d: %s() for host %s failed (%u)", __FILE__, __LINE__, "getaddrinfo", nlc->szProxyServer, WSAGetLastError()); + Netlib_Logf(nlc->nlu, "%s %d: %s() for host %s failed (%u)", __FILE__, __LINE__, "getaddrinfo", nlc->szProxyServer, WSAGetLastError()); return false; } } @@ -543,18 +543,18 @@ static bool my_connectIPv6(NetlibConnection *nlc, NETLIBOPENCONNECTION *nloc) if (!nloc->szHost) return false; - NetlibLogf(nlc->nlu, "(%p) Connecting to server %s:%d....", nlc, nloc->szHost, nloc->wPort); + Netlib_Logf(nlc->nlu, "(%p) Connecting to server %s:%d....", nlc, nloc->szHost, nloc->wPort); _itoa(nlc->nloc.wPort, szPort, 10); if (GetAddrInfoA(nlc->nloc.szHost, szPort, &hints, &air)) { - NetlibLogf(nlc->nlu, "%s %d: %s() for host %s failed (%u)", __FILE__, __LINE__, "getaddrinfo", nlc->nloc.szHost, WSAGetLastError()); + Netlib_Logf(nlc->nlu, "%s %d: %s() for host %s failed (%u)", __FILE__, __LINE__, "getaddrinfo", nlc->nloc.szHost, WSAGetLastError()); return false; } } for (ai = air; ai && !Miranda_IsTerminated(); ai = ai->ai_next) { - NetlibLogf(nlc->nlu, "(%p) Connecting to ip %s ....", nlc, ptrA(NetlibAddressToString((SOCKADDR_INET_M*)ai->ai_addr))); + Netlib_Logf(nlc->nlu, "(%p) Connecting to ip %s ....", nlc, ptrA(NetlibAddressToString((SOCKADDR_INET_M*)ai->ai_addr))); retry: nlc->s = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol); if (nlc->s == INVALID_SOCKET) { @@ -572,7 +572,7 @@ retry: SOCKET s = ai->ai_family == AF_INET ? nlc->s : INVALID_SOCKET; SOCKET s6 = ai->ai_family == AF_INET6 ? nlc->s : INVALID_SOCKET; if (!BindSocketToPort(nlc->nlu->settings.szOutgoingPorts, s, s6, &nlc->nlu->inportnum)) - NetlibLogf(nlc->nlu, "Netlib connect: Not enough ports for outgoing connections specified"); + Netlib_Logf(nlc->nlu, "Netlib connect: Not enough ports for outgoing connections specified"); } // try a connect @@ -662,13 +662,13 @@ static int NetlibHttpFallbackToDirect(NetlibConnection *nlc, NetlibUser *nlu, NE { NetlibDoClose(nlc, true); - NetlibLogf(nlu, "Fallback to direct connection"); + Netlib_Logf(nlu, "Fallback to direct connection"); nlc->proxyAuthNeeded = false; nlc->proxyType = 0; replaceStr(nlc->szProxyServer, NULL); if (!my_connect(nlc, nloc)) { - NetlibLogf(nlu, "%s %d: %s() failed (%u)", __FILE__, __LINE__, "connect", WSAGetLastError()); + Netlib_Logf(nlu, "%s %d: %s() failed (%u)", __FILE__, __LINE__, "connect", WSAGetLastError()); return false; } return true; @@ -703,7 +703,7 @@ bool NetlibDoConnect(NetlibConnection *nlc) if (usingProxy && (nlc->proxyType == PROXYTYPE_HTTPS || nlc->proxyType == PROXYTYPE_HTTP)) { usingProxy = false; nlc->proxyType = 0; - NetlibLogf(nlu, "Fallback to direct connection"); + Netlib_Logf(nlu, "Fallback to direct connection"); continue; } if (nlu->settings.useProxy && !usingProxy && nlu->settings.proxyType == PROXYTYPE_IE && !forceHttps) { @@ -713,7 +713,7 @@ bool NetlibDoConnect(NetlibConnection *nlc) continue; } } - NetlibLogf(nlu, "%s %d: %s() failed (%u)", __FILE__, __LINE__, "connect", WSAGetLastError()); + Netlib_Logf(nlu, "%s %d: %s() failed (%u)", __FILE__, __LINE__, "connect", WSAGetLastError()); return false; } @@ -768,7 +768,7 @@ bool NetlibDoConnect(NetlibConnection *nlc) nlc->usingDirectHttpGateway = true; } - NetlibLogf(nlu, "(%d) Connected to %s:%d", nlc->s, nloc->szHost, nloc->wPort); + Netlib_Logf(nlu, "(%d) Connected to %s:%d", nlc->s, nloc->szHost, nloc->wPort); if (NLOCF_SSL & nloc->flags) return NetlibStartSsl((WPARAM)nlc, 0) != 0; @@ -828,7 +828,7 @@ INT_PTR NetlibOpenConnection(WPARAM wParam, LPARAM lParam) if (GetNetlibHandleType(nlu) != NLH_USER || !(nlu->user.flags & NUF_OUTGOING)) return 0; - NetlibLogf(nlu, "Connection request to %s:%d (Flags %x)....", nloc->szHost, nloc->wPort, nloc->flags); + Netlib_Logf(nlu, "Connection request to %s:%d (Flags %x)....", nloc->szHost, nloc->wPort, nloc->flags); NetlibConnection *nlc = new NetlibConnection(); nlc->nlu = nlu; @@ -861,13 +861,13 @@ INT_PTR NetlibStartSsl(WPARAM wParam, LPARAM lParam) NETLIBSSL *sp = (NETLIBSSL*)lParam; const char *szHost = sp ? sp->host : nlc->nloc.szHost; - NetlibLogf(nlc->nlu, "(%d %s) Starting SSL negotiation", nlc->s, szHost); + Netlib_Logf(nlc->nlu, "(%d %s) Starting SSL negotiation", nlc->s, szHost); nlc->hSsl = sslApi.connect(nlc->s, szHost, nlc->nlu->settings.validateSSL); if (nlc->hSsl == NULL) - NetlibLogf(nlc->nlu, "(%d %s) Failure to negotiate SSL connection", nlc->s, szHost); + Netlib_Logf(nlc->nlu, "(%d %s) Failure to negotiate SSL connection", nlc->s, szHost); else - NetlibLogf(nlc->nlu, "(%d %s) SSL negotiation successful", nlc->s, szHost); + Netlib_Logf(nlc->nlu, "(%d %s) SSL negotiation successful", nlc->s, szHost); return nlc->hSsl != NULL; } diff --git a/src/mir_app/src/netlibpktrecver.cpp b/src/mir_app/src/netlibpktrecver.cpp index 5281cc5dab..fafee80be3 100644 --- a/src/mir_app/src/netlibpktrecver.cpp +++ b/src/mir_app/src/netlibpktrecver.cpp @@ -66,7 +66,7 @@ INT_PTR NetlibPacketRecverGetMore(WPARAM wParam, LPARAM lParam) if (nlprParam->bytesUsed == 0) {
if (nlpr->packetRecver.bytesAvailable == nlpr->packetRecver.bufferSize) {
nlpr->packetRecver.bytesAvailable = 0;
- NetlibLogf(nlpr->nlc->nlu, "Packet recver: packet overflowed buffer, ditching");
+ Netlib_Logf(nlpr->nlc->nlu, "Packet recver: packet overflowed buffer, ditching");
}
}
else {
diff --git a/src/mir_app/src/netlibsecurity.cpp b/src/mir_app/src/netlibsecurity.cpp index 436dcdd78e..2cc0ba9f73 100644 --- a/src/mir_app/src/netlibsecurity.cpp +++ b/src/mir_app/src/netlibsecurity.cpp @@ -70,7 +70,7 @@ static void ReportSecError(SECURITY_STATUS scRet, int line) char *p = strchr(szMsgBuf, 13); if (p) *p = 0;
- NetlibLogf(NULL, "Security error 0x%x on line %u (%s)", scRet, line, szMsgBuf);
+ Netlib_Logf(NULL, "Security error 0x%x on line %u (%s)", scRet, line, szMsgBuf);
}
HANDLE NetlibInitSecurityProvider(const wchar_t* szProvider, const wchar_t* szPrincipal)
@@ -275,7 +275,7 @@ char* NtlmCreateResponseFromChallenge(HANDLE hSecurity, const char *szChallenge, if (login != NULL && login[0] != '\0') {
memset(&auth, 0, sizeof(auth));
- NetlibLogf(NULL, "Security login requested, user: %S pssw: %s", login, psw ? "(exist)" : "(no psw)");
+ Netlib_Logf(NULL, "Security login requested, user: %S pssw: %s", login, psw ? "(exist)" : "(no psw)");
const wchar_t* loginName = login;
const wchar_t* domainName = wcschr(login, '\\');
diff --git a/src/mir_app/src/netlibupnp.cpp b/src/mir_app/src/netlibupnp.cpp index 38ef8b6406..776b0574f6 100644 --- a/src/mir_app/src/netlibupnp.cpp +++ b/src/mir_app/src/netlibupnp.cpp @@ -192,7 +192,7 @@ void parseURL(char* szUrl, char* szHost, unsigned short* sPort, char* szPath) static void LongLog(char* szData)
{
- CallService(MS_NETLIB_LOG, 0, (LPARAM)szData);
+ Netlib_Logf(0, szData);
}
static void closeRouterConnection(void)
@@ -297,7 +297,7 @@ retrycon: enetaddr.sin_addr.s_addr = *(unsigned*)he->h_addr_list[0];
}
- NetlibLogf(NULL, "UPnP HTTP connection Host: %s Port: %u", szHost, sPort);
+ Netlib_Logf(NULL, "UPnP HTTP connection Host: %s Port: %u", szHost, sPort);
FD_ZERO(&rfd); FD_ZERO(&wfd); FD_ZERO(&efd);
FD_SET(sock, &rfd); FD_SET(sock, &wfd); FD_SET(sock, &efd);
@@ -315,18 +315,18 @@ retrycon: // Socket connection failed
if (err != WSAEWOULDBLOCK) {
closeRouterConnection();
- NetlibLogf(NULL, "UPnP connect failed %d", err);
+ Netlib_Logf(NULL, "UPnP connect failed %d", err);
break;
}
// Wait for socket to connect
else if (select(1, &rfd, &wfd, &efd, &tv) != 1) {
closeRouterConnection();
- NetlibLogf(NULL, "UPnP connect timeout");
+ Netlib_Logf(NULL, "UPnP connect timeout");
break;
}
else if (!FD_ISSET(sock, &wfd)) {
closeRouterConnection();
- NetlibLogf(NULL, "UPnP connect failed");
+ Netlib_Logf(NULL, "UPnP connect failed");
break;
}
}
@@ -362,7 +362,7 @@ retrycon: // Wait for the next packet
if (select(1, &rfd, NULL, NULL, &tv) != 1) {
closeRouterConnection();
- NetlibLogf(NULL, "UPnP recieve timeout");
+ Netlib_Logf(NULL, "UPnP recieve timeout");
break;
}
@@ -458,7 +458,7 @@ retry: goto retrycon;
}
else
- NetlibLogf(NULL, "UPnP send failed %d", WSAGetLastError());
+ Netlib_Logf(NULL, "UPnP send failed %d", WSAGetLastError());
}
}
txtParseParam(szResult, "HTTP", " ", " ", szRes, sizeof(szRes));
@@ -655,7 +655,7 @@ static bool findUPnPGateway(void) discoverUPnP();
lastDiscTime = curTime;
- NetlibLogf(NULL, "UPnP Gateway detected %d, Control URL: %s", gatewayFound, szCtlUrl);
+ Netlib_Logf(NULL, "UPnP Gateway detected %d, Control URL: %s", gatewayFound, szCtlUrl);
}
ReleaseMutex(portListMutex);
diff --git a/src/mir_app/src/proto_utils.cpp b/src/mir_app/src/proto_utils.cpp index e2b58dea08..94e54a0ed3 100644 --- a/src/mir_app/src/proto_utils.cpp +++ b/src/mir_app/src/proto_utils.cpp @@ -54,22 +54,6 @@ MIR_APP_DLL(void) Proto_EnumProtocols(int *nProtos, PROTOCOLDESCRIPTOR ***pProto /////////////////////////////////////////////////////////////////////////////////////////
-MIR_APP_DLL(void) ProtoLogA(struct PROTO_INTERFACE *pThis, LPCSTR szFormat, va_list args)
-{
- char buf[4096];
- int res = _vsnprintf(buf, _countof(buf), szFormat, args);
- CallService(MS_NETLIB_LOG, (WPARAM)(pThis ? pThis->m_hNetlibUser : NULL), (LPARAM)((res != -1) ? buf : CMStringA().FormatV(szFormat, args)));
-}
-
-MIR_APP_DLL(void) ProtoLogW(struct PROTO_INTERFACE *pThis, LPCWSTR wszFormat, va_list args)
-{
- WCHAR buf[4096];
- int res = _vsnwprintf(buf, _countof(buf), wszFormat, args);
- CallService(MS_NETLIB_LOGW, (WPARAM)(pThis ? pThis->m_hNetlibUser : NULL), (LPARAM)((res != -1) ? buf : CMStringW().FormatV(wszFormat, args)));
-}
-
-/////////////////////////////////////////////////////////////////////////////////////////
-
MIR_APP_DLL(INT_PTR) ProtoBroadcastAck(const char *szModule, MCONTACT hContact, int type, int result, HANDLE hProcess, LPARAM lParam)
{
ACKDATA ack = { sizeof(ACKDATA), szModule, hContact, type, result, hProcess, lParam };
|