summaryrefslogtreecommitdiff
path: root/src/modules/netlib
diff options
context:
space:
mode:
Diffstat (limited to 'src/modules/netlib')
-rw-r--r--src/modules/netlib/netlib.cpp24
-rw-r--r--src/modules/netlib/netlibautoproxy.cpp8
-rw-r--r--src/modules/netlib/netlibbind.cpp16
-rw-r--r--src/modules/netlib/netlibhttp.cpp82
-rw-r--r--src/modules/netlib/netlibhttpproxy.cpp26
-rw-r--r--src/modules/netlib/netliblog.cpp140
-rw-r--r--src/modules/netlib/netlibopenconn.cpp72
-rw-r--r--src/modules/netlib/netlibopts.cpp16
-rw-r--r--src/modules/netlib/netlibpktrecver.cpp2
-rw-r--r--src/modules/netlib/netlibsecurity.cpp52
-rw-r--r--src/modules/netlib/netlibsock.cpp36
-rw-r--r--src/modules/netlib/netlibssl.cpp24
-rw-r--r--src/modules/netlib/netlibupnp.cpp20
13 files changed, 259 insertions, 259 deletions
diff --git a/src/modules/netlib/netlib.cpp b/src/modules/netlib/netlib.cpp
index 7e637b4b47..9c6f55aa11 100644
--- a/src/modules/netlib/netlib.cpp
+++ b/src/modules/netlib/netlib.cpp
@@ -133,7 +133,7 @@ static INT_PTR NetlibRegisterUser(WPARAM, LPARAM lParam)
struct NetlibUser *thisUser;
if (nlu == NULL || nlu->cbSize != sizeof(NETLIBUSER) || nlu->szSettingsModule == NULL
- || (!(nlu->flags&NUF_NOOPTIONS) && nlu->szDescriptiveName == NULL)
+ || ( !(nlu->flags&NUF_NOOPTIONS) && nlu->szDescriptiveName == NULL)
|| (nlu->flags&NUF_HTTPGATEWAY && (nlu->pfnHttpGatewayInit == NULL))) {
SetLastError(ERROR_INVALID_PARAMETER);
return 0;
@@ -174,7 +174,7 @@ static INT_PTR NetlibRegisterUser(WPARAM, LPARAM lParam)
thisUser->settings.proxyType=GetNetlibUserSettingInt(thisUser->user.szSettingsModule, "NLProxyType", PROXYTYPE_SOCKS5);
if (thisUser->user.flags&NUF_NOHTTPSOPTION && thisUser->settings.proxyType == PROXYTYPE_HTTPS)
thisUser->settings.proxyType=PROXYTYPE_HTTP;
- if (!(thisUser->user.flags&(NUF_HTTPCONNS|NUF_HTTPGATEWAY)) && thisUser->settings.proxyType == PROXYTYPE_HTTP) {
+ if ( !(thisUser->user.flags&(NUF_HTTPCONNS|NUF_HTTPGATEWAY)) && thisUser->settings.proxyType == PROXYTYPE_HTTP) {
thisUser->settings.useProxy=0;
thisUser->settings.proxyType=PROXYTYPE_SOCKS5;
}
@@ -232,7 +232,7 @@ void NetlibDoClose(NetlibConnection *nlc, bool noShutdown)
NetlibLogf(nlc->nlu, "(%p:%u) Connection closed internal", nlc, nlc->s);
if (nlc->hSsl)
{
- if (!noShutdown) si.shutdown(nlc->hSsl);
+ if ( !noShutdown) si.shutdown(nlc->hSsl);
si.sfree(nlc->hSsl);
nlc->hSsl = NULL;
}
@@ -286,7 +286,7 @@ INT_PTR NetlibCloseHandle(WPARAM wParam, LPARAM)
waitHandles[1]=nlc->hOkToCloseEvent;
waitHandles[2]=nlc->ncsRecv.hMutex;
waitHandles[3]=nlc->ncsSend.hMutex;
- waitResult=WaitForMultipleObjects( SIZEOF(waitHandles), waitHandles, TRUE, INFINITE);
+ waitResult=WaitForMultipleObjects(SIZEOF(waitHandles), waitHandles, TRUE, INFINITE);
if (waitResult<WAIT_OBJECT_0 || waitResult >= WAIT_OBJECT_0 + SIZEOF(waitHandles)) {
ReleaseMutex(hConnectionHeaderMutex);
SetLastError(ERROR_INVALID_PARAMETER); //already been closed
@@ -420,9 +420,9 @@ INT_PTR NetlibHttpUrlEncode(WPARAM, LPARAM lParam)
return (INT_PTR)(char*)NULL;
}
for (outputLen=0, pszIn=szInput;*pszIn;pszIn++) {
- if ((48 <= *pszIn && *pszIn <= 57) ||//0-9
- (65 <= *pszIn && *pszIn <= 90) ||//ABC...XYZ
- (97 <= *pszIn && *pszIn <= 122) ||//abc...xyz
+ if ((48 <= *pszIn && *pszIn <= 57) || //0-9
+ (65 <= *pszIn && *pszIn <= 90) || //ABC...XYZ
+ (97 <= *pszIn && *pszIn <= 122) || //abc...xyz
*pszIn == '-' || *pszIn == '_' || *pszIn == '.' || *pszIn == ' ') outputLen++;
else outputLen+=3;
}
@@ -432,9 +432,9 @@ INT_PTR NetlibHttpUrlEncode(WPARAM, LPARAM lParam)
return (INT_PTR)(unsigned char*)NULL;
}
for (pszOut=szOutput, pszIn=szInput;*pszIn;pszIn++) {
- if ((48 <= *pszIn && *pszIn <= 57) ||
- (65 <= *pszIn && *pszIn <= 90) ||
- (97 <= *pszIn && *pszIn <= 122) ||
+ if ((48 <= *pszIn && *pszIn <= 57) ||
+ (65 <= *pszIn && *pszIn <= 90) ||
+ (97 <= *pszIn && *pszIn <= 122) ||
*pszIn == '-' || *pszIn == '_' || *pszIn == '.') *pszOut++=*pszIn;
else if (*pszIn == ' ') *pszOut++='+';
else {
@@ -539,7 +539,7 @@ INT_PTR NetlibBase64Decode(WPARAM, LPARAM lParam)
void UnloadNetlibModule(void)
{
- if (!bModuleInitialized) return;
+ if ( !bModuleInitialized) return;
if (hConnectionHeaderMutex != NULL)
{
@@ -594,7 +594,7 @@ int LoadNetlibModule(void)
DWORD dwType = 0;
tGetProductInfo pGetProductInfo = (tGetProductInfo) GetProcAddress(GetModuleHandleA("kernel32"), "GetProductInfo");
if (pGetProductInfo != NULL) pGetProductInfo(6, 0, 0, 0, &dwType);
- switch( dwType )
+ switch(dwType)
{
case 0x01: // Vista Ultimate edition have connection limit of 25 / sec - plenty for Miranda
case 0x1c:
diff --git a/src/modules/netlib/netlibautoproxy.cpp b/src/modules/netlib/netlibautoproxy.cpp
index a3164216cd..37c3e88e22 100644
--- a/src/modules/netlib/netlibautoproxy.cpp
+++ b/src/modules/netlib/netlibautoproxy.cpp
@@ -90,7 +90,7 @@ BOOL __stdcall IsInNet(LPSTR lpszIPAddress, LPSTR lpszDest, LPSTR lpszMask)
dwDest = inet_addr(lpszDest);
dwMask = inet_addr(lpszMask);
- if ((dwDest == INADDR_NONE) ||
+ if ((dwDest == INADDR_NONE) ||
(dwIpAddr == INADDR_NONE) || ((dwIpAddr & dwMask) != dwDest))
return (FALSE);
@@ -234,9 +234,9 @@ static void NetlibInitAutoProxy(void)
{
if (bAutoProxyInit) return;
- if (!hModJS)
+ if ( !hModJS)
{
- if (!(hModJS = LoadLibraryA("jsproxy.dll")))
+ if ( !(hModJS = LoadLibraryA("jsproxy.dll")))
return;
pInternetInitializeAutoProxyDll = (pfnInternetInitializeAutoProxyDll)
@@ -269,7 +269,7 @@ static unsigned __stdcall NetlibIeProxyThread(void * arg)
IeProxyParam *param = (IeProxyParam*)arg;
param->szProxy = NULL;
- if (!bAutoProxyInit)
+ if ( !bAutoProxyInit)
{
WaitForSingleObject(hIeProxyMutex, INFINITE);
NetlibInitAutoProxy();
diff --git a/src/modules/netlib/netlibbind.cpp b/src/modules/netlib/netlibbind.cpp
index 22e3876e42..ada02da36e 100644
--- a/src/modules/netlib/netlibbind.cpp
+++ b/src/modules/netlib/netlibbind.cpp
@@ -82,7 +82,7 @@ bool BindSocketToPort(const char *szPorts, SOCKET s, SOCKET s6, int* portn)
++portnum;
if (s == INVALID_SOCKET) continue;
- if (!before && portnum <= *portn) continue;
+ if ( !before && portnum <= *portn) continue;
if (before && portnum >= *portn)
{
LeaveCriticalSection(&csNetlibUser);
@@ -163,7 +163,7 @@ static unsigned __stdcall NetlibBindAcceptThread(void* param)
}
char *szHostA = NetlibAddressToString(&sin);
- NetlibLogf(nlbp->nlu, "New incoming connection on port %u from %s (%p )", nlbp->wPort, szHostA, s);
+ NetlibLogf(nlbp->nlu, "New incoming connection on port %u from %s (%p)", nlbp->wPort, szHostA, s);
mir_free(szHostA);
nlc = (NetlibConnection*)mir_calloc(sizeof(NetlibConnection));
nlc->handleType = NLH_CONNECTION;
@@ -191,7 +191,7 @@ INT_PTR NetlibBindPort(WPARAM wParam, LPARAM lParam)
int foundPort = 0;
UINT dwThreadId;
- if (GetNetlibHandleType(nlu) != NLH_USER || !(nlu->user.flags & NUF_INCOMING) ||
+ if (GetNetlibHandleType(nlu) != NLH_USER || !(nlu->user.flags & NUF_INCOMING) ||
nlb == NULL || nlb->pfnNewConnection == NULL)
{
SetLastError(ERROR_INVALID_PARAMETER);
@@ -224,7 +224,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))
+ if ( !BindSocketToPort(nlu->settings.szIncomingPorts, nlbp->s, nlbp->s6, &nlu->outportnum))
{
NetlibLogf(nlu, "Netlib bind: Not enough ports for incoming connections specified");
SetLastError(WSAEADDRINUSE);
@@ -246,7 +246,7 @@ INT_PTR NetlibBindPort(WPARAM wParam, LPARAM lParam)
{
SOCKADDR_IN sin = {0};
int len = sizeof(sin);
- if (!getsockname(nlbp->s, (PSOCKADDR)&sin, &len))
+ if ( !getsockname(nlbp->s, (PSOCKADDR)&sin, &len))
sin6.sin6_port = sin.sin_port;
foundPort = 1;
}
@@ -254,7 +254,7 @@ INT_PTR NetlibBindPort(WPARAM wParam, LPARAM lParam)
if (bind(nlbp->s6, (PSOCKADDR)&sin6, sizeof(sin6)) == 0)
foundPort = 1;
}
- if (!foundPort)
+ if ( !foundPort)
{
NetlibLogf(nlu, "%s %d: %s() failed (%u)", __FILE__, __LINE__, "bind", WSAGetLastError());
closesocket(nlbp->s);
@@ -284,12 +284,12 @@ INT_PTR NetlibBindPort(WPARAM wParam, LPARAM lParam)
{
SOCKADDR_INET_M sin = {0};
int len = sizeof(sin);
- if (!getsockname(nlbp->s, (PSOCKADDR)&sin, &len))
+ if ( !getsockname(nlbp->s, (PSOCKADDR)&sin, &len))
{
nlb->wPort = ntohs(sin.Ipv4.sin_port);
nlb->dwInternalIP = ntohl(sin.Ipv4.sin_addr.S_un.S_addr);
}
- else if (!getsockname(nlbp->s6, (PSOCKADDR)&sin, &len))
+ else if ( !getsockname(nlbp->s6, (PSOCKADDR)&sin, &len))
nlb->wPort = ntohs(sin.Ipv6.sin6_port);
else
{
diff --git a/src/modules/netlib/netlibhttp.cpp b/src/modules/netlib/netlibhttp.cpp
index 708ebf962f..1805558ac3 100644
--- a/src/modules/netlib/netlibhttp.cpp
+++ b/src/modules/netlib/netlibhttp.cpp
@@ -50,7 +50,7 @@ struct ProxyAuth
mir_free(szServer);
mir_free(szMethod);
}
- static int Compare(const ProxyAuth* p1, const ProxyAuth* p2 )
+ static int Compare(const ProxyAuth* p1, const ProxyAuth* p2)
{ return lstrcmpiA(p1->szServer, p2->szServer); }
};
@@ -112,7 +112,7 @@ static int RecvWithTimeoutTime(struct NetlibConnection *nlc, unsigned dwTimeoutT
{
DWORD dwTimeNow;
- if (!si.pending(nlc->hSsl))
+ if ( !si.pending(nlc->hSsl))
{
while ((dwTimeNow = GetTickCount()) < dwTimeoutTime)
{
@@ -167,9 +167,9 @@ static char* NetlibHttpFindAuthHeader(NETLIBHTTPREQUEST *nlhrReply, const char *
}
}
- if (szNegoHdr && (!szProvider || !_stricmp(szProvider, "Negotiate"))) return szNegoHdr;
- if (szNtlmHdr && (!szProvider || !_stricmp(szProvider, "NTLM"))) return szNtlmHdr;
- if (!szProvider || !_stricmp(szProvider, "Basic")) return szBasicHdr;
+ if (szNegoHdr && ( !szProvider || !_stricmp(szProvider, "Negotiate"))) return szNegoHdr;
+ if (szNtlmHdr && ( !szProvider || !_stricmp(szProvider, "NTLM"))) return szNtlmHdr;
+ if ( !szProvider || !_stricmp(szProvider, "Basic")) return szBasicHdr;
return NULL;
}
@@ -215,7 +215,7 @@ static NetlibConnection* NetlibHttpProcessUrl(NETLIBHTTPREQUEST *nlhr, NetlibUse
bool httpProxy = !(nloc.flags & NLOCF_SSL) && nlc->proxyType == PROXYTYPE_HTTP;
bool sameHost = lstrcmpA(nlc->nloc.szHost, nloc.szHost) == 0 && nlc->nloc.wPort == nloc.wPort;
- if (!httpProxy && !sameHost)
+ if ( !httpProxy && !sameHost)
{
NetlibDoClose(nlc);
@@ -245,7 +245,7 @@ struct HttpSecurityContext
void Destroy(void)
{
- if (!m_hNtlmSecurity) return;
+ if ( !m_hNtlmSecurity) return;
NetlibDestroySecurityProvider(m_hNtlmSecurity);
m_hNtlmSecurity = NULL;
@@ -267,7 +267,7 @@ struct HttpSecurityContext
if (m_hNtlmSecurity)
{
bool newAuth = !m_szProvider || !szProvider || _stricmp(m_szProvider, szProvider);
- newAuth = newAuth || (m_szHost != szHost && (!m_szHost || !szHost || _stricmp(m_szHost, szHost)));
+ newAuth = newAuth || (m_szHost != szHost && ( !m_szHost || !szHost || _stricmp(m_szHost, szHost)));
if (newAuth)
Destroy();
}
@@ -307,7 +307,7 @@ struct HttpSecurityContext
szAuthHdr = NtlmCreateResponseFromChallenge(m_hNtlmSecurity,
szChallenge, szLogin, szPassw, true, complete);
- if (!szAuthHdr)
+ if ( !szAuthHdr)
{
NetlibLogf(NULL, "Security login %s failed, user: " TCHAR_STR_PARAM " pssw: " TCHAR_STR_PARAM,
szProvider, szLogin ? szLogin : _T("(no user)"), szPassw ? _T("(exist)") : _T("(no psw)"));
@@ -466,9 +466,9 @@ INT_PTR NetlibHttpSendRequest(WPARAM wParam, LPARAM lParam)
return SOCKET_ERROR;
}
- if (!nlc->usingHttpGateway)
+ if ( !nlc->usingHttpGateway)
{
- if (!NetlibEnterNestedCS(nlc, NLNCS_SEND))
+ if ( !NetlibEnterNestedCS(nlc, NLNCS_SEND))
return SOCKET_ERROR;
}
@@ -479,13 +479,13 @@ INT_PTR NetlibHttpSendRequest(WPARAM wParam, LPARAM lParam)
int count = 11;
while (--count)
{
- if (!NetlibReconnect(nlc))
+ if ( !NetlibReconnect(nlc))
{
bytesSent = SOCKET_ERROR;
break;
}
- if (!pszUrl)
+ if ( !pszUrl)
{
pszUrl = pszFullUrl;
if (nlhr->flags & (NLHRF_SMARTREMOVEHOST | NLHRF_REMOVEHOST | NLHRF_GENERATEHOST))
@@ -577,11 +577,11 @@ INT_PTR NetlibHttpSendRequest(WPARAM wParam, LPARAM lParam)
doneHostHeader = doneContentLengthHeader = doneProxyAuthHeader = doneAuthHeader = 0;
for (i=0; i < nlhr->headersCount; i++)
{
- if (!lstrcmpiA(nlhr->headers[i].szName, "Host")) doneHostHeader = 1;
- else if (!lstrcmpiA(nlhr->headers[i].szName, "Content-Length")) doneContentLengthHeader = 1;
- else if (!lstrcmpiA(nlhr->headers[i].szName, "Proxy-Authorization")) doneProxyAuthHeader = 1;
- else if (!lstrcmpiA(nlhr->headers[i].szName, "Authorization")) doneAuthHeader = 1;
- else if (!lstrcmpiA(nlhr->headers[i].szName, "Connection")) continue;
+ if ( !lstrcmpiA(nlhr->headers[i].szName, "Host")) doneHostHeader = 1;
+ else if ( !lstrcmpiA(nlhr->headers[i].szName, "Content-Length")) doneContentLengthHeader = 1;
+ else if ( !lstrcmpiA(nlhr->headers[i].szName, "Proxy-Authorization")) doneProxyAuthHeader = 1;
+ else if ( !lstrcmpiA(nlhr->headers[i].szName, "Authorization")) doneAuthHeader = 1;
+ else if ( !lstrcmpiA(nlhr->headers[i].szName, "Connection")) continue;
if (nlhr->headers[i].szValue == NULL) continue;
AppendToCharBuffer(&httpRequest, "%s: %s\r\n", nlhr->headers[i].szName, nlhr->headers[i].szValue);
}
@@ -603,13 +603,13 @@ INT_PTR NetlibHttpSendRequest(WPARAM wParam, LPARAM lParam)
if (bytesSent == SOCKET_ERROR) break;
//ntlm reply
- if (!doneContentLengthHeader || nlhr->requestType == REQUEST_HEAD)
+ if ( !doneContentLengthHeader || nlhr->requestType == REQUEST_HEAD)
{
int resultCode = 0;
DWORD fflags = MSG_PEEK | MSG_NODUMP | ((nlhr->flags & NLHRF_NOPROXY) ? MSG_RAW : 0);
DWORD dwTimeOutTime = hdrTimeout < 0 ? -1 : GetTickCount() + hdrTimeout;
- if (!HttpPeekFirstResponseLine(nlc, dwTimeOutTime, fflags, &resultCode, NULL, NULL))
+ if ( !HttpPeekFirstResponseLine(nlc, dwTimeOutTime, fflags, &resultCode, NULL, NULL))
{
NetlibLogf(nlc->nlu, "%s %d: %s Failed (%u %u)", __FILE__, __LINE__, "HttpPeekFirstResponseLine", GetLastError(), count);
DWORD err = GetLastError();
@@ -702,14 +702,14 @@ INT_PTR NetlibHttpSendRequest(WPARAM wParam, LPARAM lParam)
if (nlhrReply)
{
char *szAuthStr = NULL;
- if (!complete)
+ if ( !complete)
{
szAuthStr = NetlibHttpFindAuthHeader(nlhrReply, "WWW-Authenticate",
httpSecurity.m_szProvider);
if (szAuthStr)
{
char *szChallenge = strchr(szAuthStr, ' ');
- if (!szChallenge || !*lrtrimp(szChallenge)) complete = true;
+ if ( !szChallenge || !*lrtrimp(szChallenge)) complete = true;
}
}
if (complete && httpSecurity.m_hNtlmSecurity)
@@ -745,14 +745,14 @@ INT_PTR NetlibHttpSendRequest(WPARAM wParam, LPARAM lParam)
if (nlhrReply)
{
char *szAuthStr = NULL;
- if (!complete)
+ if ( !complete)
{
szAuthStr = NetlibHttpFindAuthHeader(nlhrReply, "Proxy-Authenticate",
httpSecurity.m_szProvider);
if (szAuthStr)
{
char *szChallenge = strchr(szAuthStr, ' ');
- if (!szChallenge || !*lrtrimp(szChallenge + 1)) complete = true;
+ if ( !szChallenge || !*lrtrimp(szChallenge + 1)) complete = true;
}
}
if (complete && httpSecurity.m_hNtlmSecurity)
@@ -807,7 +807,7 @@ INT_PTR NetlibHttpSendRequest(WPARAM wParam, LPARAM lParam)
mir_free(szHost);
mir_free(szNewUrl);
- if (!nlc->usingHttpGateway)
+ if ( !nlc->usingHttpGateway)
NetlibLeaveNestedCS(&nlc->ncsSend);
return bytesSent;
@@ -850,7 +850,7 @@ INT_PTR NetlibHttpRecvHeaders(WPARAM wParam, LPARAM lParam)
int headersCount = 0, bufferSize = 8192;
bool headersCompleted = false;
- if (!NetlibEnterNestedCS(nlc, NLNCS_RECV))
+ if ( !NetlibEnterNestedCS(nlc, NLNCS_RECV))
return 0;
dwRequestTimeoutTime = GetTickCount() + HTTPRECVDATATIMEOUT;
@@ -859,7 +859,7 @@ INT_PTR NetlibHttpRecvHeaders(WPARAM wParam, LPARAM lParam)
nlhr->nlc = nlc; // Needed to id connection in the protocol HTTP gateway wrapper functions
nlhr->requestType = REQUEST_RESPONSE;
- if (!HttpPeekFirstResponseLine(nlc, dwRequestTimeoutTime, lParam | MSG_PEEK,
+ if ( !HttpPeekFirstResponseLine(nlc, dwRequestTimeoutTime, lParam | MSG_PEEK,
&nlhr->resultCode, &nlhr->szResultDescr, &firstLineLength))
{
NetlibLeaveNestedCS(&nlc->ncsRecv);
@@ -880,7 +880,7 @@ INT_PTR NetlibHttpRecvHeaders(WPARAM wParam, LPARAM lParam)
// Make sure all headers arrived
bytesPeeked = 0;
- while (!headersCompleted)
+ while ( !headersCompleted)
{
if (bytesPeeked >= bufferSize)
{
@@ -985,12 +985,12 @@ INT_PTR NetlibHttpTransaction(WPARAM wParam, LPARAM lParam)
bool doneUserAgentHeader = NetlibHttpFindHeader(nlhr, "User-Agent") != NULL;
bool doneAcceptEncoding = NetlibHttpFindHeader(nlhr, "Accept-Encoding") != NULL;
- if (!doneUserAgentHeader || !doneAcceptEncoding)
+ if ( !doneUserAgentHeader || !doneAcceptEncoding)
{
nlhrSend.headers = (NETLIBHTTPHEADER*)mir_alloc(sizeof(NETLIBHTTPHEADER) * (nlhrSend.headersCount + 2));
memcpy(nlhrSend.headers, nlhr->headers, sizeof(NETLIBHTTPHEADER) * nlhr->headersCount);
}
- if (!doneUserAgentHeader)
+ if ( !doneUserAgentHeader)
{
char *pspace, szMirandaVer[64];
@@ -1007,7 +1007,7 @@ INT_PTR NetlibHttpTransaction(WPARAM wParam, LPARAM lParam)
else
mir_snprintf(szUserAgent, SIZEOF(szUserAgent), "Miranda/%s", szMirandaVer);
}
- if (!doneAcceptEncoding)
+ if ( !doneAcceptEncoding)
{
nlhrSend.headers[nlhrSend.headersCount].szName = "Accept-Encoding";
nlhrSend.headers[nlhrSend.headersCount].szValue = "deflate, gzip";
@@ -1015,11 +1015,11 @@ INT_PTR NetlibHttpTransaction(WPARAM wParam, LPARAM lParam)
}
if (NetlibHttpSendRequest((WPARAM)nlc, (LPARAM)&nlhrSend) == SOCKET_ERROR)
{
- if (!doneUserAgentHeader || !doneAcceptEncoding) mir_free(nlhrSend.headers);
+ if ( !doneUserAgentHeader || !doneAcceptEncoding) mir_free(nlhrSend.headers);
NetlibCloseHandle((WPARAM)nlc, 0);
return 0;
}
- if (!doneUserAgentHeader || !doneAcceptEncoding) mir_free(nlhrSend.headers);
+ if ( !doneUserAgentHeader || !doneAcceptEncoding) mir_free(nlhrSend.headers);
}
dflags = (nlhr->flags & NLHRF_DUMPASTEXT ? MSG_DUMPASTEXT:0) |
@@ -1173,10 +1173,10 @@ next:
for (i=0; i<nlhrReply->headersCount; i++)
{
- if (!lstrcmpiA(nlhrReply->headers[i].szName, "Content-Length"))
+ if ( !lstrcmpiA(nlhrReply->headers[i].szName, "Content-Length"))
dataLen = atoi(nlhrReply->headers[i].szValue);
- if (!lstrcmpiA(nlhrReply->headers[i].szName, "Content-Encoding"))
+ if ( !lstrcmpiA(nlhrReply->headers[i].szName, "Content-Encoding"))
{
cenc = i;
if (strstr(nlhrReply->headers[i].szValue, "gzip"))
@@ -1185,10 +1185,10 @@ next:
cenctype = 2;
}
- if (!lstrcmpiA(nlhrReply->headers[i].szName, "Connection"))
+ if ( !lstrcmpiA(nlhrReply->headers[i].szName, "Connection"))
close = !lstrcmpiA(nlhrReply->headers[i].szValue, "close");
- if (!lstrcmpiA(nlhrReply->headers[i].szName, "Transfer-Encoding") &&
+ if ( !lstrcmpiA(nlhrReply->headers[i].szName, "Transfer-Encoding") &&
!lstrcmpiA(nlhrReply->headers[i].szValue, "chunked"))
{
chunked = true;
@@ -1197,7 +1197,7 @@ next:
}
}
- if (nlhrReply->resultCode >= 200 && (dataLen > 0 || (!isConnect && dataLen < 0)))
+ if (nlhrReply->resultCode >= 200 && (dataLen > 0 || ( !isConnect && dataLen < 0)))
{
int recvResult, chunksz = -1;
int dataBufferAlloced;
@@ -1275,10 +1275,10 @@ next:
if (chunked)
{
- nlhrReply->headers[chunkhdr].szName = ( char* )mir_realloc(nlhrReply->headers[chunkhdr].szName, 16);
+ nlhrReply->headers[chunkhdr].szName = (char*)mir_realloc(nlhrReply->headers[chunkhdr].szName, 16);
lstrcpyA(nlhrReply->headers[chunkhdr].szName, "Content-Length");
- nlhrReply->headers[chunkhdr].szValue = ( char* )mir_realloc(nlhrReply->headers[chunkhdr].szValue, 16);
+ nlhrReply->headers[chunkhdr].szValue = (char*)mir_realloc(nlhrReply->headers[chunkhdr].szValue, 16);
mir_snprintf(nlhrReply->headers[chunkhdr].szValue, 16, "%u", nlhrReply->dataLength);
}
@@ -1324,7 +1324,7 @@ next:
if (close &&
(nlc->proxyType != PROXYTYPE_HTTP || nlc->nloc.flags & NLOCF_SSL) &&
- (!isConnect || nlhrReply->resultCode != 200))
+ ( !isConnect || nlhrReply->resultCode != 200))
NetlibDoClose(nlc);
return nlhrReply;
diff --git a/src/modules/netlib/netlibhttpproxy.cpp b/src/modules/netlib/netlibhttpproxy.cpp
index 6b48894d34..7e0472c155 100644
--- a/src/modules/netlib/netlibhttpproxy.cpp
+++ b/src/modules/netlib/netlibhttpproxy.cpp
@@ -41,7 +41,7 @@ static int HttpGatewayReadSetResult(NetlibConnection *nlc, char *buf, int num, i
int rbytes = nlc->dataBufferLen - bytes;
memcpy(buf, nlc->dataBuffer, bytes);
- if (!peek)
+ if ( !peek)
{
memmove(nlc->dataBuffer, nlc->dataBuffer + bytes, rbytes);
nlc->dataBufferLen = rbytes;
@@ -127,13 +127,13 @@ static bool NetlibHttpGatewaySend(struct NetlibConnection *nlc, RequestType reqT
bool sameHost = lstrcmpA(nlc->nloc.szHost, nloc.szHost) == 0 && nlc->nloc.wPort == nloc.wPort;
- if (!sameHost)
+ if ( !sameHost)
{
NetlibDoClose(nlc);
mir_free((char*)nlc->nloc.szHost);
nlc->nloc = nloc;
- if (!NetlibDoConnect(nlc))
+ if ( !NetlibDoConnect(nlc))
return false;
}
else
@@ -195,7 +195,7 @@ static bool NetlibHttpGatewayOscarPost(NetlibConnection *nlc, const char *buf, i
nlcSend.wProxyPort = nlc->wProxyPort;
nlcSend.proxyType = nlc->proxyType;
- if (!NetlibReconnect(&nlcSend)) return false;
+ if ( !NetlibReconnect(&nlcSend)) return false;
nlc->s2 = nlcSend.s;
nlcSend.hOkToCloseEvent = CreateEvent(NULL, TRUE, TRUE, NULL);
@@ -256,8 +256,8 @@ static bool NetlibHttpGatewayOscarPost(NetlibConnection *nlc, const char *buf, i
* with the new plugins that use this code.
*/
- p = ( NetlibHTTPProxyPacketQueue* )mir_alloc(sizeof(struct NetlibHTTPProxyPacketQueue));
- p->dataBuffer = ( PBYTE )mir_alloc(len);
+ p = (NetlibHTTPProxyPacketQueue*)mir_alloc(sizeof(struct NetlibHTTPProxyPacketQueue));
+ p->dataBuffer = (PBYTE)mir_alloc(len);
memcpy(p->dataBuffer, buf, len);
p->dataBufferLen = len;
p->next = NULL;
@@ -292,19 +292,19 @@ int NetlibHttpGatewayRecv(struct NetlibConnection *nlc, char *buf, int len, int
{
bool peek = (flags & MSG_PEEK) != 0;
- if (nlc->dataBufferLen != 0 && (!peek || nlc->dataBufferLen >= len))
+ if (nlc->dataBufferLen != 0 && ( !peek || nlc->dataBufferLen >= len))
{
return HttpGatewayReadSetResult(nlc, buf, len, peek);
}
- for (int retryCount = 0; retryCount < NETLIBHTTP_RETRYCOUNT; )
+ for (int retryCount = 0; retryCount < NETLIBHTTP_RETRYCOUNT;)
{
if (nlc->nlhpi.szHttpGetUrl == NULL && retryCount == 0)
{
if (nlc->pollingTimeout == 0) nlc->pollingTimeout = 30;
/* We Need to sleep/wait for the data to send before we do receive */
- for (int pollCount = nlc->pollingTimeout; pollCount--; )
+ for (int pollCount = nlc->pollingTimeout; pollCount--;)
{
if (nlc->pHttpProxyPacketQueue != NULL && GetTickCount() - nlc->lastPost > 1000)
break;
@@ -324,7 +324,7 @@ int NetlibHttpGatewayRecv(struct NetlibConnection *nlc, char *buf, int len, int
int numPackets = 0;
if (nlc->nlhpi.szHttpGetUrl)
{
- if (!NetlibHttpGatewaySend(nlc, reqOldGet, NULL, 0))
+ if ( !NetlibHttpGatewaySend(nlc, reqOldGet, NULL, 0))
{
if (GetLastError() == ERROR_ACCESS_DENIED || nlc->termRequested)
break;
@@ -335,7 +335,7 @@ int NetlibHttpGatewayRecv(struct NetlibConnection *nlc, char *buf, int len, int
}
else
{
- if (!NetlibHttpGatewayStdPost(nlc, numPackets))
+ if ( !NetlibHttpGatewayStdPost(nlc, numPackets))
{
if (GetLastError() == ERROR_ACCESS_DENIED || nlc->termRequested)
break;
@@ -451,7 +451,7 @@ int NetlibInitHttpConnection(struct NetlibConnection *nlc, struct NetlibUser *nl
return 0;
}
}
- if (!nlu->user.pfnHttpGatewayInit(nlc, nloc, nlhrReply))
+ if ( !nlu->user.pfnHttpGatewayInit(nlc, nloc, nlhrReply))
{
NetlibHttpFreeRequestStruct(0, (LPARAM)nlhrReply);
return 0;
@@ -481,7 +481,7 @@ INT_PTR NetlibHttpGatewaySetInfo(WPARAM wParam, LPARAM lParam)
NETLIBHTTPPROXYINFO *nlhpi=(NETLIBHTTPPROXYINFO*)lParam;
struct NetlibConnection *nlc=(struct NetlibConnection*)wParam;
- if (GetNetlibHandleType(nlc) != NLH_CONNECTION || nlhpi == NULL ||
+ if (GetNetlibHandleType(nlc) != NLH_CONNECTION || nlhpi == NULL ||
nlhpi->cbSize < (sizeof(NETLIBHTTPPROXYINFO) - sizeof(int)) ||
nlhpi->szHttpPostUrl == NULL)
{
diff --git a/src/modules/netlib/netliblog.cpp b/src/modules/netlib/netliblog.cpp
index 6f633a6622..5c4656fd90 100644
--- a/src/modules/netlib/netliblog.cpp
+++ b/src/modules/netlib/netliblog.cpp
@@ -59,10 +59,10 @@ static HANDLE hLogEvent = NULL;
static const TCHAR* szTimeFormats[] =
{
- _T( "No times" ),
- _T( "Standard hh:mm:ss times" ),
- _T( "Times in milliseconds" ),
- _T( "Times in microseconds" )
+ _T("No times"),
+ _T("Standard hh:mm:ss times"),
+ _T("Times in milliseconds"),
+ _T("Times in microseconds")
};
static INT_PTR CALLBACK LogOptionsDlgProc(HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lParam)
@@ -78,8 +78,8 @@ static INT_PTR CALLBACK LogOptionsDlgProc(HWND hwndDlg, UINT message, WPARAM wPa
CheckDlgButton(hwndDlg, IDC_TEXTDUMPS, logOptions.textDumps?BST_CHECKED:BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_AUTODETECTTEXT, logOptions.autoDetectText?BST_CHECKED:BST_UNCHECKED);
{ int i;
- for ( i=0; i < SIZEOF(szTimeFormats); i++ )
- SendDlgItemMessage(hwndDlg, IDC_TIMEFORMAT, CB_ADDSTRING, 0, (LPARAM)TranslateTS( szTimeFormats[i] ));
+ for (i=0; i < SIZEOF(szTimeFormats); i++)
+ SendDlgItemMessage(hwndDlg, IDC_TIMEFORMAT, CB_ADDSTRING, 0, (LPARAM)TranslateTS(szTimeFormats[i]));
}
SendDlgItemMessage(hwndDlg, IDC_TIMEFORMAT, CB_SETCURSEL, logOptions.timeFormat, 0);
CheckDlgButton(hwndDlg, IDC_SHOWNAMES, logOptions.showUser?BST_CHECKED:BST_UNCHECKED);
@@ -89,7 +89,7 @@ static INT_PTR CALLBACK LogOptionsDlgProc(HWND hwndDlg, UINT message, WPARAM wPa
SetDlgItemText(hwndDlg, IDC_PATH, logOptions.szFile);
CheckDlgButton(hwndDlg, IDC_SHOWTHISDLGATSTART, DBGetContactSettingByte(NULL, "Netlib", "ShowLogOptsAtStart", 0)?BST_CHECKED:BST_UNCHECKED);
{ DBVARIANT dbv;
- if (!DBGetContactSettingString(NULL, "Netlib", "RunAtStart", &dbv)) {
+ if ( !DBGetContactSettingString(NULL, "Netlib", "RunAtStart", &dbv)) {
SetDlgItemTextA(hwndDlg, IDC_RUNATSTART, dbv.pszVal);
DBFreeVariant(&dbv);
}
@@ -111,12 +111,12 @@ static INT_PTR CALLBACK LogOptionsDlgProc(HWND hwndDlg, UINT message, WPARAM wPa
{
tvis.item.pszText=netlibUser[i]->user.ptszDescriptiveName;
tvis.item.lParam=i;
- tvis.item.state=INDEXTOSTATEIMAGEMASK((netlibUser[i]->toLog) ? 2 : 1 );
+ tvis.item.state=INDEXTOSTATEIMAGEMASK((netlibUser[i]->toLog) ? 2 : 1);
TreeView_InsertItem(hwndFilter, &tvis);
}
tvis.item.lParam=-1;
tvis.item.pszText=TranslateT("(Miranda Core Logging)");
- tvis.item.state=INDEXTOSTATEIMAGEMASK((logOptions.toLog) ? 2 : 1 );
+ tvis.item.state=INDEXTOSTATEIMAGEMASK((logOptions.toLog) ? 2 : 1);
TreeView_InsertItem(hwndFilter, &tvis);
}
return TRUE;
@@ -178,9 +178,9 @@ static INT_PTR CALLBACK LogOptionsDlgProc(HWND hwndDlg, UINT message, WPARAM wPa
ofn.nMaxFile=SIZEOF(str)-2;
ofn.nMaxFileTitle=MAX_PATH;
if (LOWORD(wParam) == IDC_FILENAMEBROWSE) {
- if (!GetSaveFileName(&ofn)) return 1;
+ if ( !GetSaveFileName(&ofn)) return 1;
} else {
- if (!GetOpenFileName(&ofn)) return 1;
+ if ( !GetOpenFileName(&ofn)) return 1;
}
if (LOWORD(wParam) == IDC_RUNATSTARTBROWSE && _tcschr(str, ' ') != NULL) {
MoveMemory(str+1, str, SIZEOF(str)-2);
@@ -213,11 +213,11 @@ static INT_PTR CALLBACK LogOptionsDlgProc(HWND hwndDlg, UINT message, WPARAM wPa
EnterCriticalSection(&logOptions.cs);
mir_free(logOptions.szUserFile);
- GetWindowText(GetDlgItem(hwndDlg, IDC_FILENAME), str, MAX_PATH );
+ GetWindowText(GetDlgItem(hwndDlg, IDC_FILENAME), str, MAX_PATH);
logOptions.szUserFile = mir_tstrdup(str);
mir_free(logOptions.szFile);
- GetWindowText(GetDlgItem(hwndDlg, IDC_PATH), str, MAX_PATH );
+ GetWindowText(GetDlgItem(hwndDlg, IDC_PATH), str, MAX_PATH);
logOptions.szFile = mir_tstrdup(str);
logOptions.dumpRecv=IsDlgButtonChecked(hwndDlg, IDC_DUMPRECV);
@@ -248,13 +248,13 @@ static INT_PTR CALLBACK LogOptionsDlgProc(HWND hwndDlg, UINT message, WPARAM wPa
if (tvi.lParam == -1) {
logOptions.toLog = checked;
- if ( logOptions.save )
+ if (logOptions.save)
DBWriteContactSettingDword(NULL, "Netlib", "NLlog", checked);
}
else
if (tvi.lParam < netlibUser.getCount()) {
netlibUser[tvi.lParam]->toLog = checked;
- if ( logOptions.save )
+ if (logOptions.save)
DBWriteContactSettingDword(NULL, netlibUser[tvi.lParam]->user.szSettingsModule, "NLlog", checked);
}
@@ -262,7 +262,7 @@ static INT_PTR CALLBACK LogOptionsDlgProc(HWND hwndDlg, UINT message, WPARAM wPa
}
}
- if ( logOptions.save ) {
+ if (logOptions.save) {
DBWriteContactSettingByte(NULL, "Netlib", "DumpRecv", (BYTE)logOptions.dumpRecv);
DBWriteContactSettingByte(NULL, "Netlib", "DumpSent", (BYTE)logOptions.dumpSent);
DBWriteContactSettingByte(NULL, "Netlib", "DumpProxy", (BYTE)logOptions.dumpProxy);
@@ -318,7 +318,7 @@ static INT_PTR NetlibLog(WPARAM wParam, LPARAM lParam)
LARGE_INTEGER liTimeNow;
DWORD dwOriginalLastError;
- if (!bIsActive)
+ if ( !bIsActive)
return 0;
if ((nlu != NULL && GetNetlibHandleType(nlu) != NLH_USER) || pszMsg == NULL)
@@ -328,12 +328,12 @@ static INT_PTR NetlibLog(WPARAM wParam, LPARAM lParam)
}
if (nlu == NULL) /* if the Netlib user handle is NULL, just pretend its not */
{
- if (!logOptions.toLog)
+ if ( !logOptions.toLog)
return 1;
nlu = &nludummy;
nlu->user.szSettingsModule = "(NULL)";
}
- else if (!nlu->toLog)
+ else if ( !nlu->toLog)
return 1;
dwOriginalLastError = GetLastError();
@@ -383,7 +383,7 @@ static INT_PTR NetlibLog(WPARAM wParam, LPARAM lParam)
FILE *fp;
fp = _tfopen(logOptions.szFile, _T("ab"));
- if (!fp)
+ if ( !fp)
{
CreatePathToFileT(logOptions.szFile);
fp = _tfopen(logOptions.szFile, _T("at"));
@@ -420,10 +420,10 @@ void NetlibLogf(NetlibUser* nlu, const char *fmt, ...)
{
if (nlu == NULL)
{
- if (!logOptions.toLog)
+ if ( !logOptions.toLog)
return;
}
- else if (!nlu->toLog)
+ else if ( !nlu->toLog)
return;
va_list va;
@@ -454,12 +454,12 @@ void NetlibDumpData(struct NetlibConnection *nlc, PBYTE buf, int len, int sent,
return;
// Check user's log settings
- if (!(logOptions.toOutputDebugString ||
- ((THook*)hLogEvent)->subscriberCount ||
+ if ( !(logOptions.toOutputDebugString ||
+ ((THook*)hLogEvent)->subscriberCount ||
(logOptions.toFile && logOptions.szFile[0])))
return;
- if ((sent && !logOptions.dumpSent) ||
- (!sent && !logOptions.dumpRecv))
+ if ((sent && !logOptions.dumpSent) ||
+ ( !sent && !logOptions.dumpRecv))
return;
if ((flags & MSG_DUMPPROXY) && !logOptions.dumpProxy)
return;
@@ -475,15 +475,15 @@ void NetlibDumpData(struct NetlibConnection *nlc, PBYTE buf, int len, int sent,
// check filter settings
if (nlu == NULL)
{
- if (!logOptions.toLog)
+ if ( !logOptions.toLog)
return;
}
- else if (!nlu->toLog)
+ else if ( !nlu->toLog)
return;
- if (!logOptions.textDumps)
+ if ( !logOptions.textDumps)
isText = 0;
- else if (!(flags&MSG_DUMPASTEXT))
+ else if ( !(flags&MSG_DUMPASTEXT))
{
if (logOptions.autoDetectText)
{
@@ -502,12 +502,12 @@ void NetlibDumpData(struct NetlibConnection *nlc, PBYTE buf, int len, int sent,
}
// Text data
- if ( isText ) {
+ if (isText) {
int sz = titleLineLen + len + 1;
useStack = sz <= 8192;
szBuf = (char*)(useStack ? alloca(sz) : mir_alloc(sz));
- CopyMemory( szBuf, szTitleLine, titleLineLen );
- CopyMemory( szBuf + titleLineLen, (const char*)buf, len );
+ CopyMemory(szBuf, szTitleLine, titleLineLen);
+ CopyMemory(szBuf + titleLineLen, (const char*)buf, len);
szBuf[titleLineLen + len] = '\0';
}
// Binary data
@@ -520,14 +520,14 @@ void NetlibDumpData(struct NetlibConnection *nlc, PBYTE buf, int len, int sent,
szBuf = (char*)(useStack ? alloca(sz) : mir_alloc(sz));
CopyMemory(szBuf, szTitleLine, titleLineLen);
pszBuf = szBuf + titleLineLen;
- for ( line = 0;; line += 16 ) {
+ for (line = 0;; line += 16) {
colsInLine = min(16, len - line);
if (colsInLine == 16) {
PBYTE p = buf + line;
pszBuf += wsprintfA(
pszBuf, "%08X: %02X %02X %02X %02X-%02X %02X %02X %02X-%02X %02X %02X %02X-%02X %02X %02X %02X ",
- line, p[0], p[1], p[2], p[3], p[4], p[5], p[6], p[7], p[8], p[9], p[10], p[11], p[12], p[13], p[14], p[15] );
+ line, p[0], p[1], p[2], p[3], p[4], p[5], p[6], p[7], p[8], p[9], p[10], p[11], p[12], p[13], p[14], p[15]);
}
else {
pszBuf += wsprintfA(pszBuf, "%08X: ", line);
@@ -556,7 +556,7 @@ void NetlibDumpData(struct NetlibConnection *nlc, PBYTE buf, int len, int sent,
}
NetlibLog((WPARAM)nlu, (LPARAM)szBuf);
- if (!useStack) mir_free(szBuf);
+ if ( !useStack) mir_free(szBuf);
}
void NetlibLogInit(void)
@@ -564,30 +564,30 @@ void NetlibLogInit(void)
DBVARIANT dbv;
LARGE_INTEGER li;
- QueryPerformanceFrequency( &li );
+ QueryPerformanceFrequency(&li);
perfCounterFreq = li.QuadPart;
- QueryPerformanceCounter( &li );
+ QueryPerformanceCounter(&li);
mirandaStartTime = li.QuadPart;
- CreateServiceFunction( MS_NETLIB_LOGWIN, ShowOptions );
- CreateServiceFunction( MS_NETLIB_LOG, NetlibLog );
- CreateServiceFunction( MS_NETLIB_LOGW, NetlibLogW );
- hLogEvent = CreateHookableEvent( ME_NETLIB_FASTDUMP );
+ CreateServiceFunction(MS_NETLIB_LOGWIN, ShowOptions);
+ CreateServiceFunction(MS_NETLIB_LOG, NetlibLog);
+ CreateServiceFunction(MS_NETLIB_LOGW, NetlibLogW);
+ hLogEvent = CreateHookableEvent(ME_NETLIB_FASTDUMP);
InitializeCriticalSection(&logOptions.cs);
- logOptions.dumpRecv = DBGetContactSettingByte( NULL, "Netlib", "DumpRecv", 1 );
- logOptions.dumpSent = DBGetContactSettingByte( NULL, "Netlib", "DumpSent", 1 );
- logOptions.dumpProxy = DBGetContactSettingByte( NULL, "Netlib", "DumpProxy", 1 );
- logOptions.dumpSsl = DBGetContactSettingByte( NULL, "Netlib", "DumpSsl", 0 );
- logOptions.textDumps = DBGetContactSettingByte( NULL, "Netlib", "TextDumps", 1 );
- logOptions.autoDetectText = DBGetContactSettingByte( NULL, "Netlib", "AutoDetectText", 1 );
- logOptions.timeFormat = DBGetContactSettingByte( NULL, "Netlib", "TimeFormat", TIMEFORMAT_HHMMSS );
- logOptions.showUser = DBGetContactSettingByte( NULL, "Netlib", "ShowUser", 1 );
- logOptions.toOutputDebugString = DBGetContactSettingByte( NULL, "Netlib", "ToOutputDebugString", 0 );
- logOptions.toFile = DBGetContactSettingByte( NULL, "Netlib", "ToFile", 0 );
- logOptions.toLog = DBGetContactSettingDword( NULL, "Netlib", "NLlog", 1 );
-
- if (!DBGetContactSettingTString(NULL, "Netlib", "File", &dbv))
+ logOptions.dumpRecv = DBGetContactSettingByte(NULL, "Netlib", "DumpRecv", 1);
+ logOptions.dumpSent = DBGetContactSettingByte(NULL, "Netlib", "DumpSent", 1);
+ logOptions.dumpProxy = DBGetContactSettingByte(NULL, "Netlib", "DumpProxy", 1);
+ logOptions.dumpSsl = DBGetContactSettingByte(NULL, "Netlib", "DumpSsl", 0);
+ logOptions.textDumps = DBGetContactSettingByte(NULL, "Netlib", "TextDumps", 1);
+ logOptions.autoDetectText = DBGetContactSettingByte(NULL, "Netlib", "AutoDetectText", 1);
+ logOptions.timeFormat = DBGetContactSettingByte(NULL, "Netlib", "TimeFormat", TIMEFORMAT_HHMMSS);
+ logOptions.showUser = DBGetContactSettingByte(NULL, "Netlib", "ShowUser", 1);
+ logOptions.toOutputDebugString = DBGetContactSettingByte(NULL, "Netlib", "ToOutputDebugString", 0);
+ logOptions.toFile = DBGetContactSettingByte(NULL, "Netlib", "ToFile", 0);
+ logOptions.toLog = DBGetContactSettingDword(NULL, "Netlib", "NLlog", 1);
+
+ if ( !DBGetContactSettingTString(NULL, "Netlib", "File", &dbv))
{
logOptions.szUserFile = mir_tstrdup(dbv.ptszVal);
TCHAR *pszNewPath = Utils_ReplaceVarsT(dbv.ptszVal);
@@ -605,33 +605,33 @@ void NetlibLogInit(void)
logOptions.szFile = Utils_ReplaceVarsT(logOptions.szUserFile);
}
- if ( logOptions.toFile && logOptions.szFile[0] ) {
+ if (logOptions.toFile && logOptions.szFile[0]) {
FILE *fp;
- fp = _tfopen( logOptions.szFile, _T("wt"));
- if ( fp )
+ fp = _tfopen(logOptions.szFile, _T("wt"));
+ if (fp)
fclose(fp);
}
- if ( DBGetContactSettingByte( NULL, "Netlib", "ShowLogOptsAtStart", 0 ))
+ if (DBGetContactSettingByte(NULL, "Netlib", "ShowLogOptsAtStart", 0))
NetlibLogShowOptions();
- if ( !DBGetContactSettingTString( NULL, "Netlib", "RunAtStart", &dbv )) {
+ if ( !DBGetContactSettingTString(NULL, "Netlib", "RunAtStart", &dbv)) {
STARTUPINFO si = { 0 };
PROCESS_INFORMATION pi;
- si.cb = sizeof( si );
- if ( dbv.ptszVal[0] )
- CreateProcess( NULL, dbv.ptszVal, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi );
- DBFreeVariant( &dbv );
+ si.cb = sizeof(si);
+ if (dbv.ptszVal[0])
+ CreateProcess(NULL, dbv.ptszVal, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi);
+ DBFreeVariant(&dbv);
}
}
void NetlibLogShutdown(void)
{
bIsActive = FALSE;
- DestroyHookableEvent( hLogEvent ); hLogEvent = NULL;
- if ( IsWindow( logOptions.hwndOpts ))
- DestroyWindow( logOptions.hwndOpts );
- DeleteCriticalSection( &logOptions.cs );
- mir_free( logOptions.szFile );
- mir_free( logOptions.szUserFile );
+ DestroyHookableEvent(hLogEvent); hLogEvent = NULL;
+ if (IsWindow(logOptions.hwndOpts))
+ DestroyWindow(logOptions.hwndOpts);
+ DeleteCriticalSection(&logOptions.cs);
+ mir_free(logOptions.szFile);
+ mir_free(logOptions.szUserFile);
}
diff --git a/src/modules/netlib/netlibopenconn.cpp b/src/modules/netlib/netlibopenconn.cpp
index 5cc1e7635e..3bc19e684f 100644
--- a/src/modules/netlib/netlibopenconn.cpp
+++ b/src/modules/netlib/netlibopenconn.cpp
@@ -42,7 +42,7 @@ DWORD DnsLookup(struct NetlibUser *nlu, const char *szHost)
__try
{
host = gethostbyname(szHost);
- if ( host )
+ 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());
@@ -106,14 +106,14 @@ bool RecvUntilTimeout(struct NetlibConnection *nlc, char *buf, int len, int flag
len -= nReceived;
if (len <= 0) return true;
}
- SetLastError( ERROR_TIMEOUT );
+ SetLastError(ERROR_TIMEOUT);
return false;
}
static int NetlibInitSocks4Connection(NetlibConnection *nlc, NetlibUser *nlu, NETLIBOPENCONNECTION *nloc)
{
// http://www.socks.nec.com/protocol/socks4.protocol and http://www.socks.nec.com/protocol/socks4a.protocol
- if (!nloc->szHost || !nloc->szHost[0]) return 0;
+ if ( !nloc->szHost || !nloc->szHost[0]) return 0;
size_t nHostLen = strlen(nloc->szHost) + 1;
size_t nUserLen = nlu->settings.szProxyAuthUser ? strlen(nlu->settings.szProxyAuthUser) + 1 : 1;
@@ -130,7 +130,7 @@ static int NetlibInitSocks4Connection(NetlibConnection *nlc, NetlibUser *nlu, NE
//if cannot resolve host, try resolving through proxy (requires SOCKS4a)
DWORD ip = DnsLookup(nlu, nloc->szHost);
*(PDWORD)&pInit[4] = ip ? ip : 0x01000000;
- if (!ip)
+ if ( !ip)
{
memcpy(&pInit[len], nloc->szHost, nHostLen);
len += nHostLen;
@@ -143,7 +143,7 @@ static int NetlibInitSocks4Connection(NetlibConnection *nlc, NetlibUser *nlu, NE
}
char reply[8];
- if (!RecvUntilTimeout(nlc, reply, sizeof(reply), MSG_DUMPPROXY, RECV_DEFAULT_TIMEOUT))
+ if ( !RecvUntilTimeout(nlc, reply, sizeof(reply), MSG_DUMPPROXY, RECV_DEFAULT_TIMEOUT))
{
NetlibLogf(nlu, "%s %d: %s() failed (%u)", __FILE__, __LINE__, "RecvUntilTimeout", GetLastError());
return 0;
@@ -174,7 +174,7 @@ static int NetlibInitSocks5Connection(struct NetlibConnection *nlc, struct Netli
}
//confirmation of auth method
- if (!RecvUntilTimeout(nlc, (char*)buf, 2, MSG_DUMPPROXY, RECV_DEFAULT_TIMEOUT)) {
+ if ( !RecvUntilTimeout(nlc, (char*)buf, 2, MSG_DUMPPROXY, RECV_DEFAULT_TIMEOUT)) {
NetlibLogf(nlu, "%s %d: %s() failed (%u)", __FILE__, __LINE__, "RecvUntilTimeout", GetLastError());
return 0;
}
@@ -203,7 +203,7 @@ static int NetlibInitSocks5Connection(struct NetlibConnection *nlc, struct Netli
}
mir_free(pAuthBuf);
- if (!RecvUntilTimeout(nlc, (char*)buf, 2, MSG_DUMPPROXY, RECV_DEFAULT_TIMEOUT)) {
+ if ( !RecvUntilTimeout(nlc, (char*)buf, 2, MSG_DUMPPROXY, RECV_DEFAULT_TIMEOUT)) {
NetlibLogf(nlu, "%s %d: %s() failed (%u)", __FILE__, __LINE__, "RecvUntilTimeout", GetLastError());
return 0;
}
@@ -255,14 +255,14 @@ static int NetlibInitSocks5Connection(struct NetlibConnection *nlc, struct Netli
mir_free(pInit);
}
- if (!RecvUntilTimeout(nlc, (char*)buf, 5, MSG_DUMPPROXY, RECV_DEFAULT_TIMEOUT)) {
+ if ( !RecvUntilTimeout(nlc, (char*)buf, 5, MSG_DUMPPROXY, RECV_DEFAULT_TIMEOUT)) {
NetlibLogf(nlu, "%s %d: %s() failed (%u)", __FILE__, __LINE__, "RecvUntilTimeout", GetLastError());
return 0;
}
- if ( buf[0] != 5 || buf[1] ) {
+ if (buf[0] != 5 || buf[1]) {
const char* err = "Unknown response";
- if ( buf[0] != 5 )
+ if (buf[0] != 5)
SetLastError(ERROR_BAD_FORMAT);
else
{
@@ -284,7 +284,7 @@ static int NetlibInitSocks5Connection(struct NetlibConnection *nlc, struct Netli
}
{
int nRecvSize = 0;
- switch( buf[3] ) {
+ switch(buf[3]) {
case 1:// ipv4 addr
nRecvSize = 5;
break;
@@ -298,7 +298,7 @@ static int NetlibInitSocks5Connection(struct NetlibConnection *nlc, struct Netli
NetlibLogf(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)) {
+ if ( !RecvUntilTimeout(nlc, (char*)buf, nRecvSize, MSG_DUMPPROXY, RECV_DEFAULT_TIMEOUT)) {
NetlibLogf(nlu, "%s %d: %s() failed (%u)", __FILE__, __LINE__, "RecvUntilTimeout", GetLastError());
return 0;
}
@@ -404,7 +404,7 @@ static bool my_connectIPv4(NetlibConnection *nlc, NETLIBOPENCONNECTION * nloc)
if (nlc->proxyType)
{
- if (!nlc->szProxyServer) return false;
+ 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);
@@ -416,7 +416,7 @@ static bool my_connectIPv4(NetlibConnection *nlc, NETLIBOPENCONNECTION * nloc)
}
else
{
- if (!nloc || !nloc->szHost || nloc->szHost[0] == '[' || strchr(nloc->szHost, ':')) return false;
+ 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);
sin.sin_port = htons(nloc->wPort);
@@ -440,7 +440,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))
+ 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");
}
@@ -573,7 +573,7 @@ static bool my_connectIPv6(NetlibConnection *nlc, NETLIBOPENCONNECTION * nloc)
if (nlc->proxyType)
{
- if (!nlc->szProxyServer) return false;
+ 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);
@@ -589,7 +589,7 @@ static bool my_connectIPv6(NetlibConnection *nlc, NETLIBOPENCONNECTION * nloc)
}
else
{
- if (!nloc || !nloc->szHost) return false;
+ if ( !nloc || !nloc->szHost) return false;
NetlibLogf(nlc->nlu, "(%p) Connecting to server %s:%d....", nlc, nloc->szHost, nloc->wPort);
_itoa(nlc->nloc.wPort, szPort, 10);
@@ -617,7 +617,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))
+ if ( !BindSocketToPort(nlc->nlu->settings.szOutgoingPorts, s, s6, &nlc->nlu->inportnum))
NetlibLogf(nlc->nlu, "Netlib connect: Not enough ports for outgoing connections specified");
}
@@ -726,7 +726,7 @@ static int NetlibHttpFallbackToDirect(struct NetlibConnection *nlc, struct Netli
nlc->proxyAuthNeeded = false;
nlc->proxyType = 0;
mir_free(nlc->szProxyServer); nlc->szProxyServer = NULL;
- if (!my_connect(nlc, nloc))
+ if ( !my_connect(nlc, nloc))
{
NetlibLogf(nlu, "%s %d: %s() failed (%u)", __FILE__, __LINE__, "connect", WSAGetLastError());
return false;
@@ -763,13 +763,13 @@ bool NetlibDoConnect(NetlibConnection *nlc)
retry:
if (usingProxy)
{
- if (!my_connect(nlc, nloc))
+ if ( !my_connect(nlc, nloc))
{
usingProxy = false;
nlc->proxyType = 0;
}
}
- if (!usingProxy)
+ if ( !usingProxy)
{
my_connect(nlc, nloc);
}
@@ -779,7 +779,7 @@ retry:
if (usingProxy && (nlc->proxyType == PROXYTYPE_HTTPS || nlc->proxyType == PROXYTYPE_HTTP))
{
usingProxy = false;
- if (!NetlibHttpFallbackToDirect(nlc, nlu, nloc))
+ if ( !NetlibHttpFallbackToDirect(nlc, nlu, nloc))
{
NetlibLogf(nlu, "%s %d: %s() failed (%u)", __FILE__, __LINE__, "connect", WSAGetLastError());
return false;
@@ -801,44 +801,44 @@ retry:
if (usingProxy && !((nloc->flags & (NLOCF_HTTP | NLOCF_SSL)) == NLOCF_HTTP &&
(nlc->proxyType == PROXYTYPE_HTTP || nlc->proxyType == PROXYTYPE_HTTPS)))
{
- if (!WaitUntilWritable(nlc->s, 30000)) return false;
+ if ( !WaitUntilWritable(nlc->s, 30000)) return false;
switch (nlc->proxyType)
{
case PROXYTYPE_SOCKS4:
- if (!NetlibInitSocks4Connection(nlc, nlu, nloc)) return false;
+ if ( !NetlibInitSocks4Connection(nlc, nlu, nloc)) return false;
break;
case PROXYTYPE_SOCKS5:
- if (!NetlibInitSocks5Connection(nlc, nlu, nloc)) return false;
+ if ( !NetlibInitSocks5Connection(nlc, nlu, nloc)) return false;
break;
case PROXYTYPE_HTTPS:
nlc->proxyAuthNeeded = true;
- if (!NetlibInitHttpsConnection(nlc, nlu, nloc))
+ if ( !NetlibInitHttpsConnection(nlc, nlu, nloc))
{
usingProxy = false;
- if (!NetlibHttpFallbackToDirect(nlc, nlu, nloc))
+ if ( !NetlibHttpFallbackToDirect(nlc, nlu, nloc))
return false;
}
break;
case PROXYTYPE_HTTP:
nlc->proxyAuthNeeded = true;
- if (!(nlu->user.flags & NUF_HTTPGATEWAY || nloc->flags & NLOCF_HTTPGATEWAY) || nloc->flags & NLOCF_SSL)
+ if ( !(nlu->user.flags & NUF_HTTPGATEWAY || nloc->flags & NLOCF_HTTPGATEWAY) || nloc->flags & NLOCF_SSL)
{
//NLOCF_HTTP not specified and no HTTP gateway available: try HTTPS
- if (!NetlibInitHttpsConnection(nlc, nlu, nloc))
+ if ( !NetlibInitHttpsConnection(nlc, nlu, nloc))
{
//can't do HTTPS: try direct
usingProxy = false;
- if (!NetlibHttpFallbackToDirect(nlc, nlu, nloc))
+ if ( !NetlibHttpFallbackToDirect(nlc, nlu, nloc))
return false;
}
}
else
{
- if (!NetlibInitHttpConnection(nlc, nlu, nloc)) return false;
+ if ( !NetlibInitHttpConnection(nlc, nlu, nloc)) return false;
}
break;
@@ -850,7 +850,7 @@ retry:
}
else if (nloc->flags & NLOCF_HTTPGATEWAY)
{
- if (!NetlibInitHttpConnection(nlc, nlu, nloc)) return false;
+ if ( !NetlibInitHttpConnection(nlc, nlu, nloc)) return false;
nlc->usingDirectHttpGateway = true;
}
@@ -886,11 +886,11 @@ bool NetlibReconnect(NetlibConnection *nlc)
break;
}
- if (!opened)
+ if ( !opened)
NetlibDoClose(nlc, true);
}
- if (!opened)
+ if ( !opened)
{
if (Miranda_Terminated()) return false;
if (nlc->usingHttpGateway)
@@ -912,7 +912,7 @@ INT_PTR NetlibOpenConnection(WPARAM wParam, LPARAM lParam)
NetlibLogf(nlu, "Connection request to %s:%d (Flags %x)....", nloc->szHost, nloc->wPort, nloc->flags);
- if (GetNetlibHandleType(nlu) != NLH_USER || !(nlu->user.flags & NUF_OUTGOING) || nloc == NULL ||
+ if (GetNetlibHandleType(nlu) != NLH_USER || !(nlu->user.flags & NUF_OUTGOING) || nloc == NULL ||
(nloc->cbSize != NETLIBOPENCONNECTION_V1_SIZE && nloc->cbSize != sizeof(NETLIBOPENCONNECTION)) ||
nloc->szHost == NULL || nloc->wPort == 0)
{
@@ -934,7 +934,7 @@ INT_PTR NetlibOpenConnection(WPARAM wParam, LPARAM lParam)
NetlibInitializeNestedCS(&nlc->ncsSend);
NetlibInitializeNestedCS(&nlc->ncsRecv);
- if (!NetlibDoConnect(nlc))
+ if ( !NetlibDoConnect(nlc))
{
FreePartiallyInitedConnection(nlc);
return 0;
diff --git a/src/modules/netlib/netlibopts.cpp b/src/modules/netlib/netlibopts.cpp
index 7649ab4ab1..2ce5282f2b 100644
--- a/src/modules/netlib/netlibopts.cpp
+++ b/src/modules/netlib/netlibopts.cpp
@@ -167,7 +167,7 @@ static void ChangeSettingIntByCheckbox(HWND hwndDlg, UINT ctrlId, int iUser, int
if (iUser == -1)
{
for (i=0; i<tempSettings.getCount(); i++)
- if (!(tempSettings[i]->flags & NUF_NOOPTIONS))
+ if ( !(tempSettings[i]->flags & NUF_NOOPTIONS))
*(int*)(((PBYTE)&tempSettings[i]->settings) + memberOffset) = newValue;
}
else *(int*)(((PBYTE)&tempSettings[iUser]->settings) + memberOffset)=newValue;
@@ -185,7 +185,7 @@ static void ChangeSettingStringByEdit(HWND hwndDlg, UINT ctrlId, int iUser, int
if (iUser == -1)
{
for (i=0; i<tempSettings.getCount(); ++i)
- if (!(tempSettings[i]->flags & NUF_NOOPTIONS))
+ if ( !(tempSettings[i]->flags & NUF_NOOPTIONS))
{
ppszNew=(char**)(((PBYTE)&tempSettings[i]->settings)+memberOffset);
if (*ppszNew) mir_free(*ppszNew);
@@ -323,7 +323,7 @@ static INT_PTR CALLBACK DlgProcNetlibOpts(HWND hwndDlg, UINT msg, WPARAM wParam,
AddProxyTypeItem(hwndDlg, PROXYTYPE_SOCKS4, settings.proxyType);
AddProxyTypeItem(hwndDlg, PROXYTYPE_SOCKS5, settings.proxyType);
if (flags & (NUF_HTTPCONNS | NUF_HTTPGATEWAY)) AddProxyTypeItem(hwndDlg, PROXYTYPE_HTTP, settings.proxyType);
- if (!(flags & NUF_NOHTTPSOPTION)) AddProxyTypeItem(hwndDlg, PROXYTYPE_HTTPS, settings.proxyType);
+ if ( !(flags & NUF_NOHTTPSOPTION)) AddProxyTypeItem(hwndDlg, PROXYTYPE_HTTPS, settings.proxyType);
if (flags & (NUF_HTTPCONNS | NUF_HTTPGATEWAY) || !(flags & NUF_NOHTTPSOPTION))
AddProxyTypeItem(hwndDlg, PROXYTYPE_IE, settings.proxyType);
SetDlgItemTextA(hwndDlg, IDC_PROXYHOST, settings.szProxyServer?settings.szProxyServer:"");
@@ -364,7 +364,7 @@ static INT_PTR CALLBACK DlgProcNetlibOpts(HWND hwndDlg, UINT msg, WPARAM wParam,
int i;
for (i = 0; i < tempSettings.getCount(); ++i)
{
- if (!tempSettings[i]->settings.useProxy ||
+ if ( !tempSettings[i]->settings.useProxy ||
tempSettings[i]->flags & NUF_NOOPTIONS || !(tempSettings[i]->flags & NUF_OUTGOING))
continue;
@@ -472,7 +472,7 @@ static INT_PTR CALLBACK DlgProcNetlibOpts(HWND hwndDlg, UINT msg, WPARAM wParam,
if (iUser == -1)
{
for (i = 0; i < tempSettings.getCount(); ++i)
- if (!(tempSettings[i]->flags & NUF_NOOPTIONS))
+ if ( !(tempSettings[i]->flags & NUF_NOOPTIONS))
tempSettings[i]->settings.wProxyPort = newValue;
}
else tempSettings[iUser]->settings.wProxyPort = newValue;
@@ -536,7 +536,7 @@ int NetlibOptInitialise(WPARAM wParam, LPARAM)
int optionsCount = 0;
EnterCriticalSection(&csNetlibUser);
for (int i = 0; i < netlibUser.getCount(); ++i)
- if (!(netlibUser[i]->user.flags & NUF_NOOPTIONS)) ++optionsCount;
+ if ( !(netlibUser[i]->user.flags & NUF_NOOPTIONS)) ++optionsCount;
LeaveCriticalSection(&csNetlibUser);
if (optionsCount == 0) return 0;
@@ -550,7 +550,7 @@ int NetlibOptInitialise(WPARAM wParam, LPARAM)
odp.pfnDlgProc = DlgProcNetlibOpts;
odp.flags = ODPF_BOLDGROUPS;
odp.expertOnlyControls = expertOnlyControls;
- odp.nExpertOnlyControls = SIZEOF( expertOnlyControls );
- CallService( MS_OPT_ADDPAGE, wParam, ( LPARAM )&odp );
+ odp.nExpertOnlyControls = SIZEOF(expertOnlyControls);
+ Options_AddPage(wParam, &odp);
return 0;
}
diff --git a/src/modules/netlib/netlibpktrecver.cpp b/src/modules/netlib/netlibpktrecver.cpp
index 56f9b8ffae..d2b40559b3 100644
--- a/src/modules/netlib/netlibpktrecver.cpp
+++ b/src/modules/netlib/netlibpktrecver.cpp
@@ -73,7 +73,7 @@ INT_PTR NetlibPacketRecverGetMore(WPARAM wParam, LPARAM lParam)
nlpr->packetRecver.bytesAvailable-=nlprParam->bytesUsed;
}
if (nlprParam->dwTimeout != INFINITE) {
- if (!si.pending(nlpr->nlc->hSsl) && WaitUntilReadable(nlpr->nlc->s, nlprParam->dwTimeout) <= 0) {
+ if ( !si.pending(nlpr->nlc->hSsl) && WaitUntilReadable(nlpr->nlc->s, nlprParam->dwTimeout) <= 0) {
*nlprParam=nlpr->packetRecver;
return SOCKET_ERROR;
}
diff --git a/src/modules/netlib/netlibsecurity.cpp b/src/modules/netlib/netlibsecurity.cpp
index 46756ff3cc..9ff92944e3 100644
--- a/src/modules/netlib/netlibsecurity.cpp
+++ b/src/modules/netlib/netlibsecurity.cpp
@@ -123,7 +123,7 @@ HANDLE NetlibInitSecurityProvider(const TCHAR* szProvider, const TCHAR* szPrinci
WaitForSingleObject(hSecMutex, INFINITE);
- if (secCnt == 0 )
+ if (secCnt == 0)
{
LoadSecurityLibrary();
secCnt += g_hSecurity != NULL;
@@ -188,7 +188,7 @@ void NetlibDestroySecurityProvider(HANDLE hSecurity)
char* CompleteGssapi(HANDLE hSecurity, unsigned char *szChallenge, unsigned chlsz)
{
- if (!szChallenge || !szChallenge[0]) return NULL;
+ if ( !szChallenge || !szChallenge[0]) return NULL;
NtlmHandleType* hNtlm = (NtlmHandleType*)hSecurity;
unsigned char inDataBuffer[1024];
@@ -257,7 +257,7 @@ char* CompleteGssapi(HANDLE hSecurity, unsigned char *szChallenge, unsigned chls
nlb64.pbDecoded = response;
nlb64.cchEncoded = Netlib_GetBase64EncodedBufferSize(nlb64.cbDecoded);
nlb64.pszEncoded = (char*)alloca(nlb64.cchEncoded);
- if (!NetlibBase64Encode(0, (LPARAM)&nlb64)) return NULL;
+ if ( !NetlibBase64Encode(0, (LPARAM)&nlb64)) return NULL;
return mir_strdup(nlb64.pszEncoded);
}
@@ -287,7 +287,7 @@ char* NtlmCreateResponseFromChallenge(HANDLE hSecurity, const char *szChallenge,
nlb64.pszEncoded = (char*)szChallenge;
nlb64.cbDecoded = Netlib_GetBase64DecodedBufferSize(nlb64.cchEncoded);
nlb64.pbDecoded = (PBYTE)alloca(nlb64.cbDecoded);
- if (!NetlibBase64Decode(0, (LPARAM)&nlb64)) return NULL;
+ if ( !NetlibBase64Decode(0, (LPARAM)&nlb64)) return NULL;
if (isGSSAPI && complete)
return CompleteGssapi(hSecurity, nlb64.pbDecoded, nlb64.cbDecoded);
@@ -302,8 +302,8 @@ char* NtlmCreateResponseFromChallenge(HANDLE hSecurity, const char *szChallenge,
// try to decode the domain name from the NTLM challenge
if (login != NULL && login[0] != '\0' && !hNtlm->hasDomain)
{
- NtlmType2packet* pkt = ( NtlmType2packet* )nlb64.pbDecoded;
- if (!strncmp(pkt->sign, "NTLMSSP", 8) && pkt->type == 2)
+ NtlmType2packet* pkt = (NtlmType2packet*)nlb64.pbDecoded;
+ if ( !strncmp(pkt->sign, "NTLMSSP", 8) && pkt->type == 2)
{
wchar_t* domainName = (wchar_t*)&nlb64.pbDecoded[pkt->targetName.offset];
@@ -421,7 +421,7 @@ char* NtlmCreateResponseFromChallenge(HANDLE hSecurity, const char *szChallenge,
}
else
{
- if (!login || !psw) return NULL;
+ if ( !login || !psw) return NULL;
char *szLogin = mir_t2a(login);
char *szPassw = mir_t2a(psw);
@@ -439,7 +439,7 @@ char* NtlmCreateResponseFromChallenge(HANDLE hSecurity, const char *szChallenge,
nlb64.cchEncoded = Netlib_GetBase64EncodedBufferSize(nlb64.cbDecoded);
nlb64.pszEncoded = (char*)alloca(nlb64.cchEncoded);
- if (!NetlibBase64Encode(0, (LPARAM)&nlb64)) return NULL;
+ if ( !NetlibBase64Encode(0, (LPARAM)&nlb64)) return NULL;
char* result;
if (http)
@@ -466,7 +466,7 @@ static INT_PTR InitSecurityProviderService(WPARAM, LPARAM lParam)
static INT_PTR InitSecurityProviderService2(WPARAM, LPARAM lParam)
{
- NETLIBNTLMINIT2 *req = ( NETLIBNTLMINIT2* )lParam;
+ NETLIBNTLMINIT2 *req = (NETLIBNTLMINIT2*)lParam;
if (req->cbSize < sizeof(*req)) return 0;
HANDLE hSecurity;
@@ -481,26 +481,26 @@ static INT_PTR InitSecurityProviderService2(WPARAM, LPARAM lParam)
return (INT_PTR)hSecurity;
}
-static INT_PTR DestroySecurityProviderService( WPARAM, LPARAM lParam )
+static INT_PTR DestroySecurityProviderService(WPARAM, LPARAM lParam)
{
- NetlibDestroySecurityProvider(( HANDLE )lParam );
+ NetlibDestroySecurityProvider((HANDLE)lParam);
return 0;
}
-static INT_PTR NtlmCreateResponseService( WPARAM wParam, LPARAM lParam )
+static INT_PTR NtlmCreateResponseService(WPARAM wParam, LPARAM lParam)
{
- NETLIBNTLMREQUEST* req = ( NETLIBNTLMREQUEST* )lParam;
+ NETLIBNTLMREQUEST* req = (NETLIBNTLMREQUEST*)lParam;
unsigned complete;
- char* response = NtlmCreateResponseFromChallenge(( HANDLE )wParam, req->szChallenge,
- StrConvT(req->userName), StrConvT(req->password), false, complete );
+ char* response = NtlmCreateResponseFromChallenge((HANDLE)wParam, req->szChallenge,
+ StrConvT(req->userName), StrConvT(req->password), false, complete);
return (INT_PTR)response;
}
-static INT_PTR NtlmCreateResponseService2( WPARAM wParam, LPARAM lParam )
+static INT_PTR NtlmCreateResponseService2(WPARAM wParam, LPARAM lParam)
{
- NETLIBNTLMREQUEST2* req = ( NETLIBNTLMREQUEST2* )lParam;
+ NETLIBNTLMREQUEST2* req = (NETLIBNTLMREQUEST2*)lParam;
if (req->cbSize < sizeof(*req)) return 0;
char* response;
@@ -508,15 +508,15 @@ static INT_PTR NtlmCreateResponseService2( WPARAM wParam, LPARAM lParam )
if (req->flags & NNR_UNICODE)
{
- response = NtlmCreateResponseFromChallenge(( HANDLE )wParam, req->szChallenge,
- req->szUserName, req->szPassword, false, req->complete );
+ response = NtlmCreateResponseFromChallenge((HANDLE)wParam, req->szChallenge,
+ req->szUserName, req->szPassword, false, req->complete);
}
else
{
TCHAR *szLogin = mir_a2t((char*)req->szUserName);
TCHAR *szPassw = mir_a2t((char*)req->szPassword);
- response = NtlmCreateResponseFromChallenge(( HANDLE )wParam, req->szChallenge,
- szLogin, szPassw, false, req->complete );
+ response = NtlmCreateResponseFromChallenge((HANDLE)wParam, req->szChallenge,
+ szLogin, szPassw, false, req->complete);
mir_free(szLogin);
mir_free(szPassw);
}
@@ -529,11 +529,11 @@ void NetlibSecurityInit(void)
{
hSecMutex = CreateMutex(NULL, FALSE, NULL);
- CreateServiceFunction( MS_NETLIB_INITSECURITYPROVIDER, InitSecurityProviderService );
- CreateServiceFunction( MS_NETLIB_INITSECURITYPROVIDER2, InitSecurityProviderService2 );
- CreateServiceFunction( MS_NETLIB_DESTROYSECURITYPROVIDER, DestroySecurityProviderService );
- CreateServiceFunction( MS_NETLIB_NTLMCREATERESPONSE, NtlmCreateResponseService );
- CreateServiceFunction( MS_NETLIB_NTLMCREATERESPONSE2, NtlmCreateResponseService2 );
+ CreateServiceFunction(MS_NETLIB_INITSECURITYPROVIDER, InitSecurityProviderService);
+ CreateServiceFunction(MS_NETLIB_INITSECURITYPROVIDER2, InitSecurityProviderService2);
+ CreateServiceFunction(MS_NETLIB_DESTROYSECURITYPROVIDER, DestroySecurityProviderService);
+ CreateServiceFunction(MS_NETLIB_NTLMCREATERESPONSE, NtlmCreateResponseService);
+ CreateServiceFunction(MS_NETLIB_NTLMCREATERESPONSE2, NtlmCreateResponseService2);
}
void NetlibSecurityDestroy(void)
diff --git a/src/modules/netlib/netlibsock.cpp b/src/modules/netlib/netlibsock.cpp
index a4894a52ff..eabbc79484 100644
--- a/src/modules/netlib/netlibsock.cpp
+++ b/src/modules/netlib/netlibsock.cpp
@@ -37,12 +37,12 @@ INT_PTR NetlibSend(WPARAM wParam, LPARAM lParam)
return SOCKET_ERROR;
}
- if (!NetlibEnterNestedCS(nlc, NLNCS_SEND))
+ if ( !NetlibEnterNestedCS(nlc, NLNCS_SEND))
return SOCKET_ERROR;
if (nlc->usingHttpGateway && !(nlb->flags & MSG_RAW))
{
- if (!(nlb->flags & MSG_NOHTTPGATEWAYWRAP) && nlc->nlu->user.pfnHttpGatewayWrapSend)
+ if ( !(nlb->flags & MSG_NOHTTPGATEWAYWRAP) && nlc->nlu->user.pfnHttpGatewayWrapSend)
{
NetlibDumpData(nlc, (PBYTE)nlb->buf, nlb->len, 1, nlb->flags);
result = nlc->nlu->user.pfnHttpGatewayWrapSend((HANDLE)nlc, (PBYTE)nlb->buf, nlb->len, nlb->flags | MSG_NOHTTPGATEWAYWRAP, NetlibSend);
@@ -77,7 +77,7 @@ INT_PTR NetlibRecv(WPARAM wParam, LPARAM lParam)
return SOCKET_ERROR;
}
- if (!NetlibEnterNestedCS(nlc, NLNCS_RECV))
+ if ( !NetlibEnterNestedCS(nlc, NLNCS_RECV))
return SOCKET_ERROR;
if (nlc->usingHttpGateway && !(nlb->flags & MSG_RAW))
@@ -140,9 +140,9 @@ INT_PTR NetlibSelect(WPARAM, LPARAM lParam)
int pending = 0;
fd_set readfd, writefd, exceptfd;
WaitForSingleObject(hConnectionHeaderMutex, INFINITE);
- if (!ConnectionListToSocketList(nls->hReadConns, &readfd, pending)
- || !ConnectionListToSocketList(nls->hWriteConns, &writefd, pending)
- || !ConnectionListToSocketList(nls->hExceptConns, &exceptfd, pending))
+ if ( !ConnectionListToSocketList(nls->hReadConns, &readfd, pending)
+ || !ConnectionListToSocketList(nls->hWriteConns, &writefd, pending)
+ || !ConnectionListToSocketList(nls->hExceptConns, &exceptfd, pending))
{
ReleaseMutex(hConnectionHeaderMutex);
return SOCKET_ERROR;
@@ -170,9 +170,9 @@ INT_PTR NetlibSelectEx(WPARAM, LPARAM lParam)
int pending = 0;
fd_set readfd, writefd, exceptfd;
- if (!ConnectionListToSocketList(nls->hReadConns, &readfd, pending)
- || !ConnectionListToSocketList(nls->hWriteConns, &writefd, pending)
- || !ConnectionListToSocketList(nls->hExceptConns, &exceptfd, pending))
+ if ( !ConnectionListToSocketList(nls->hReadConns, &readfd, pending)
+ || !ConnectionListToSocketList(nls->hWriteConns, &writefd, pending)
+ || !ConnectionListToSocketList(nls->hExceptConns, &exceptfd, pending))
{
ReleaseMutex(hConnectionHeaderMutex);
return SOCKET_ERROR;
@@ -217,7 +217,7 @@ INT_PTR NetlibSelectEx(WPARAM, LPARAM lParam)
bool NetlibStringToAddress(const char* str, SOCKADDR_INET_M* addr)
{
- if (!str) return false;
+ if ( !str) return false;
if (MyWSAStringToAddress)
{
@@ -227,7 +227,7 @@ bool NetlibStringToAddress(const char* str, SOCKADDR_INET_M* addr)
else
{
unsigned iaddr = inet_addr(str);
- if (!iaddr) return false;
+ if ( !iaddr) return false;
addr->Ipv4.sin_addr.s_addr = iaddr;
addr->Ipv4.sin_family = AF_INET;
@@ -242,7 +242,7 @@ char* NetlibAddressToString(SOCKADDR_INET_M* addr)
if (MyWSAAddressToString)
{
DWORD len = sizeof(saddr);
- if (!MyWSAAddressToString((PSOCKADDR)addr, sizeof(*addr), NULL, saddr, &len))
+ if ( !MyWSAAddressToString((PSOCKADDR)addr, sizeof(*addr), NULL, saddr, &len))
return mir_strdup(saddr);
}
else if (addr->si_family == AF_INET)
@@ -261,12 +261,12 @@ char* NetlibAddressToString(SOCKADDR_INET_M* addr)
void NetlibGetConnectionInfo(NetlibConnection* nlc, NETLIBCONNINFO *connInfo)
{
- if (!nlc || !connInfo || connInfo->cbSize < sizeof(NETLIBCONNINFO)) return;
+ if ( !nlc || !connInfo || connInfo->cbSize < sizeof(NETLIBCONNINFO)) return;
SOCKADDR_INET_M sin = {0};
int len = sizeof(sin);
- if (!getsockname(nlc->s, (PSOCKADDR)&sin, &len))
+ if ( !getsockname(nlc->s, (PSOCKADDR)&sin, &len))
{
connInfo->wPort = ntohs(sin.Ipv4.sin_port);
connInfo->dwIpv4 = sin.si_family == AF_INET ? htonl(sin.Ipv4.sin_addr.s_addr) : 0;
@@ -299,9 +299,9 @@ static NETLIBIPLIST* GetMyIpv6(unsigned flags)
for (ai = air; ai; ai = ai->ai_next)
{
SOCKADDR_INET_M* iaddr = (SOCKADDR_INET_M*)ai->ai_addr;
- if (ai->ai_family == AF_INET ||
+ if (ai->ai_family == AF_INET ||
(ai->ai_family == AF_INET6 &&
- (!(flags & 1) || IsAddrGlobal(&iaddr->Ipv6.sin6_addr))))
+ ( !(flags & 1) || IsAddrGlobal(&iaddr->Ipv6.sin6_addr))))
++n;
}
@@ -312,9 +312,9 @@ static NETLIBIPLIST* GetMyIpv6(unsigned flags)
for (ai = air; ai; ai = ai->ai_next)
{
SOCKADDR_INET_M* iaddr = (SOCKADDR_INET_M*)ai->ai_addr;
- if (ai->ai_family == AF_INET ||
+ if (ai->ai_family == AF_INET ||
(ai->ai_family == AF_INET6 &&
- (!(flags & 1) || IsAddrGlobal(&iaddr->Ipv6.sin6_addr))))
+ ( !(flags & 1) || IsAddrGlobal(&iaddr->Ipv6.sin6_addr))))
{
char* szIp = NetlibAddressToString(iaddr);
diff --git a/src/modules/netlib/netlibssl.cpp b/src/modules/netlib/netlibssl.cpp
index 76c663d5ba..77c6bec8c9 100644
--- a/src/modules/netlib/netlibssl.cpp
+++ b/src/modules/netlib/netlibssl.cpp
@@ -146,7 +146,7 @@ static bool SSL_library_init(void)
WaitForSingleObject(g_hSslMutex, INFINITE);
- if (!bSslInitDone)
+ if ( !bSslInitDone)
{
g_hSchannel = LoadLibraryA("schannel.dll");
if (g_hSchannel)
@@ -197,12 +197,12 @@ void NetlibSslFree(SslHandle *ssl)
BOOL NetlibSslPending(SslHandle *ssl)
{
- return ssl != NULL && ( ssl->cbRecDataBuf != 0 || ssl->cbIoBuffer != 0 );
+ return ssl != NULL && (ssl->cbRecDataBuf != 0 || ssl->cbIoBuffer != 0);
}
static bool VerifyCertificate(SslHandle *ssl, PCSTR pszServerName, DWORD dwCertFlags)
{
- if (!fnCertGetCertificateChain)
+ if ( !fnCertGetCertificateChain)
return true;
static LPSTR rgszUsages[] =
@@ -238,7 +238,7 @@ static bool VerifyCertificate(SslHandle *ssl, PCSTR pszServerName, DWORD dwCertF
ChainPara.RequestedUsage.Usage.cUsageIdentifier = SIZEOF(rgszUsages);
ChainPara.RequestedUsage.Usage.rgpszUsageIdentifier = rgszUsages;
- if (!fnCertGetCertificateChain(NULL, pServerCert, NULL, pServerCert->hCertStore,
+ if ( !fnCertGetCertificateChain(NULL, pServerCert, NULL, pServerCert->hCertStore,
&ChainPara, 0, NULL, &pChainContext))
{
scRet = GetLastError();
@@ -255,7 +255,7 @@ static bool VerifyCertificate(SslHandle *ssl, PCSTR pszServerName, DWORD dwCertF
PolicyStatus.cbSize = sizeof(PolicyStatus);
- if (!fnCertVerifyCertificateChainPolicy(CERT_CHAIN_POLICY_SSL, pChainContext,
+ if ( !fnCertVerifyCertificateChainPolicy(CERT_CHAIN_POLICY_SSL, pChainContext,
&PolicyPara, &PolicyStatus))
{
scRet = GetLastError();
@@ -401,8 +401,8 @@ static SECURITY_STATUS ClientHandshakeLoop(SslHandle *ssl, BOOL fDoInitialRead)
// If success (or if the error was one of the special extended ones),
// send the contents of the output buffer to the server.
- if (scRet == SEC_E_OK ||
- scRet == SEC_I_CONTINUE_NEEDED ||
+ if (scRet == SEC_E_OK ||
+ scRet == SEC_I_CONTINUE_NEEDED ||
(FAILED(scRet) && (dwSSPIOutFlags & ISC_RET_EXTENDED_ERROR)))
{
if (OutBuffers[0].cbBuffer != 0 && OutBuffers[0].pvBuffer != NULL)
@@ -567,7 +567,7 @@ SslHandle *NetlibSslConnect(SOCKET s, const char* host, int verify)
DWORD dwFlags = 0;
- if (!host || inet_addr(host) != INADDR_NONE)
+ if ( !host || inet_addr(host) != INADDR_NONE)
dwFlags |= 0x00001000;
bool res = SSL_library_init();
@@ -575,7 +575,7 @@ SslHandle *NetlibSslConnect(SOCKET s, const char* host, int verify)
if (res) res = ClientConnect(ssl, host);
if (res && verify) res = VerifyCertificate(ssl, host, dwFlags);
- if (!res)
+ if ( !res)
{
NetlibSslFree(ssl);
ssl = NULL;
@@ -666,7 +666,7 @@ static int NetlibSslReadSetResult(SslHandle *ssl, char *buf, int num, int peek)
int rbytes = ssl->cbRecDataBuf - bytes;
memcpy(buf, ssl->pbRecDataBuf, bytes);
- if (!peek)
+ if ( !peek)
{
memmove(ssl->pbRecDataBuf, ssl->pbRecDataBuf + bytes, rbytes);
ssl->cbRecDataBuf = rbytes;
@@ -691,7 +691,7 @@ int NetlibSslRead(SslHandle *ssl, char *buf, int num, int peek)
if (num <= 0) return 0;
- if (ssl->state != sockOpen || (ssl->cbRecDataBuf != 0 && (!peek || ssl->cbRecDataBuf >= num)))
+ if (ssl->state != sockOpen || (ssl->cbRecDataBuf != 0 && ( !peek || ssl->cbRecDataBuf >= num)))
{
return NetlibSslReadSetResult(ssl, buf, num, peek);
}
@@ -783,7 +783,7 @@ int NetlibSslRead(SslHandle *ssl, char *buf, int num, int peek)
if (scRet == SEC_E_INCOMPLETE_MESSAGE)
continue;
- if ( scRet != SEC_E_OK && scRet != SEC_I_RENEGOTIATE && scRet != SEC_I_CONTEXT_EXPIRED)
+ if (scRet != SEC_E_OK && scRet != SEC_I_RENEGOTIATE && scRet != SEC_I_CONTEXT_EXPIRED)
{
ReportSslError(scRet, __LINE__);
ssl->state = sockError;
diff --git a/src/modules/netlib/netlibupnp.cpp b/src/modules/netlib/netlibupnp.cpp
index 12e0345c27..45009fa341 100644
--- a/src/modules/netlib/netlibupnp.cpp
+++ b/src/modules/netlib/netlibupnp.cpp
@@ -235,7 +235,7 @@ static void validateSocket(void)
break;
}
- if (!opened)
+ if ( !opened)
closeRouterConnection();
}
@@ -248,7 +248,7 @@ static int httpTransact(char* szUrl, char* szResult, int resSize, char* szAction
bool needClose;
const char* szPostHdr = soap_post_hdr;
- char* szData = ( char* )mir_alloc(4096);
+ char* szData = (char*)mir_alloc(4096);
char* szReq = NULL;
parseURL(szUrl, szHost, &sPort, szPath);
@@ -349,7 +349,7 @@ retrycon:
NetlibLogf(NULL, "UPnP connect timeout");
break;
}
- else if (!FD_ISSET(sock, &wfd))
+ else if ( !FD_ISSET(sock, &wfd))
{
closeRouterConnection();
NetlibLogf(NULL, "UPnP connect failed");
@@ -439,7 +439,7 @@ retrycon:
if (hdrend != NULL)
{
// Get packet size if provided
- if (txtParseParam(szResult, NULL, "Content-Length:", "\n", szRes, sizeof(szRes)) ||
+ if (txtParseParam(szResult, NULL, "Content-Length:", "\n", szRes, sizeof(szRes)) ||
txtParseParam(szResult, NULL, "CONTENT-LENGTH:", "\n", szRes, sizeof(szRes)))
{
// Add size of HTTP header to the packet size to compute full transmission size
@@ -554,7 +554,7 @@ static bool getUPnPURLs(char* szUrl, size_t sizeUrl)
txtParseParam(szData, szTemp, "<controlURL>", "</controlURL>", szUrl, sizeUrl);
// URL combining per RFC 2396
- if ( szUrl[0] != 0 )
+ if (szUrl[0] != 0)
{
if (strstr(szUrl, "://") != NULL) // absolute URI
rpth = szCtlUrl;
@@ -624,7 +624,7 @@ static void discoverUPnP(void)
{
while (he->h_addr_list[nip]) ++nip;
- ips = ( unsigned* )mir_alloc(nip * sizeof(unsigned));
+ ips = (unsigned*)mir_alloc(nip * sizeof(unsigned));
for (j = 0; j < nip; ++j)
ips[j] = *(unsigned*)he->h_addr_list[j];
@@ -661,7 +661,7 @@ static void discoverUPnP(void)
buf[buflen] = 0;
LongLog(buf);
- if (txtParseParam(buf, NULL, "LOCATION:", "\n", szUrl, sizeof(szUrl)) ||
+ if (txtParseParam(buf, NULL, "LOCATION:", "\n", szUrl, sizeof(szUrl)) ||
txtParseParam(buf, NULL, "Location:", "\n", szUrl, sizeof(szUrl)))
{
char age[30];
@@ -811,7 +811,7 @@ void NetlibUPnPCleanup(void*)
}
}
LeaveCriticalSection(&csNetlibUser);
- if (!incoming) return;
+ if ( !incoming) return;
}
if (findUPnPGateway())
@@ -840,10 +840,10 @@ void NetlibUPnPCleanup(void*)
if (httpTransact(szCtlUrl, szData, 4096, "GetGenericPortMappingEntry", ControlAction) != 200)
break;
- if (!txtParseParam(szData, "<NewPortMappingDescription", ">", "<", buf, sizeof(buf)) || strcmp(buf, "Miranda") != 0)
+ if ( !txtParseParam(szData, "<NewPortMappingDescription", ">", "<", buf, sizeof(buf)) || strcmp(buf, "Miranda") != 0)
continue;
- if (!txtParseParam(szData, "<NewInternalClient", ">", "<", buf, sizeof(buf)) || strcmp(buf, lip) != 0)
+ if ( !txtParseParam(szData, "<NewInternalClient", ">", "<", buf, sizeof(buf)) || strcmp(buf, lip) != 0)
continue;
if (txtParseParam(szData, "<NewExternalPort", ">", "<", buf, sizeof(buf)))