summaryrefslogtreecommitdiff
path: root/src/modules/netlib
diff options
context:
space:
mode:
Diffstat (limited to 'src/modules/netlib')
-rw-r--r--src/modules/netlib/netlib.cpp164
-rw-r--r--src/modules/netlib/netlib.h4
-rw-r--r--src/modules/netlib/netlibautoproxy.cpp12
-rw-r--r--src/modules/netlib/netlibbind.cpp4
-rw-r--r--src/modules/netlib/netlibhttp.cpp23
-rw-r--r--src/modules/netlib/netlibhttpproxy.cpp36
-rw-r--r--src/modules/netlib/netliblog.cpp106
-rw-r--r--src/modules/netlib/netlibopenconn.cpp40
-rw-r--r--src/modules/netlib/netlibopts.cpp134
-rw-r--r--src/modules/netlib/netlibpktrecver.cpp32
-rw-r--r--src/modules/netlib/netlibsecurity.cpp6
-rw-r--r--src/modules/netlib/netlibsock.cpp10
-rw-r--r--src/modules/netlib/netlibssl.cpp116
-rw-r--r--src/modules/netlib/netlibupnp.cpp50
14 files changed, 368 insertions, 369 deletions
diff --git a/src/modules/netlib/netlib.cpp b/src/modules/netlib/netlib.cpp
index bd72a8374b..670a882d90 100644
--- a/src/modules/netlib/netlib.cpp
+++ b/src/modules/netlib/netlib.cpp
@@ -28,7 +28,7 @@ static BOOL bModuleInitialized = FALSE;
HANDLE hConnectionHeaderMutex, hConnectionOpenMutex;
DWORD g_LastConnectionTick;
int connectionTimeout;
-HANDLE hSendEvent=NULL, hRecvEvent=NULL;
+HANDLE hSendEvent = NULL, hRecvEvent = NULL;
typedef BOOL (WINAPI *tGetProductInfo)(DWORD, DWORD, DWORD, DWORD, PDWORD);
@@ -53,9 +53,9 @@ void NetlibFreeUserSettingsStruct(NETLIBUSERSETTINGS *settings)
void NetlibInitializeNestedCS(struct NetlibNestedCriticalSection *nlncs)
{
- nlncs->dwOwningThreadId= 0;
- nlncs->lockCount=0;
- nlncs->hMutex=CreateMutex(NULL, FALSE, NULL);
+ nlncs->dwOwningThreadId = 0;
+ nlncs->lockCount = 0;
+ nlncs->hMutex = CreateMutex(NULL, FALSE, NULL);
}
void NetlibDeleteNestedCS(struct NetlibNestedCriticalSection *nlncs)
@@ -66,7 +66,7 @@ void NetlibDeleteNestedCS(struct NetlibNestedCriticalSection *nlncs)
int NetlibEnterNestedCS(struct NetlibConnection *nlc, int which)
{
struct NetlibNestedCriticalSection *nlncs;
- DWORD dwCurrentThreadId=GetCurrentThreadId();
+ DWORD dwCurrentThreadId = GetCurrentThreadId();
WaitForSingleObject(hConnectionHeaderMutex, INFINITE);
if (nlc == NULL || nlc->handleType != NLH_CONNECTION) {
@@ -84,8 +84,8 @@ int NetlibEnterNestedCS(struct NetlibConnection *nlc, int which)
ResetEvent(nlc->hOkToCloseEvent);
ReleaseMutex(hConnectionHeaderMutex);
WaitForSingleObject(nlncs->hMutex, INFINITE);
- nlncs->dwOwningThreadId=dwCurrentThreadId;
- nlncs->lockCount=1;
+ nlncs->dwOwningThreadId = dwCurrentThreadId;
+ nlncs->lockCount = 1;
if (InterlockedDecrement(&nlc->dontCloseNow) == 0)
SetEvent(nlc->hOkToCloseEvent);
return 1;
@@ -94,7 +94,7 @@ int NetlibEnterNestedCS(struct NetlibConnection *nlc, int which)
void NetlibLeaveNestedCS(struct NetlibNestedCriticalSection *nlncs)
{
if (--nlncs->lockCount == 0) {
- nlncs->dwOwningThreadId=0;
+ nlncs->dwOwningThreadId = 0;
ReleaseMutex(nlncs->hMutex);
}
}
@@ -120,7 +120,7 @@ static char *GetNetlibUserSettingString(const char *szUserModule, const char *sz
else {
char *szRet;
if (decode) CallService(MS_DB_CRYPT_DECODESTRING, strlen(dbv.pszVal) + 1, (LPARAM)dbv.pszVal);
- szRet=mir_strdup(dbv.pszVal);
+ szRet = mir_strdup(dbv.pszVal);
DBFreeVariant(&dbv);
if (szRet == NULL) SetLastError(ERROR_OUTOFMEMORY);
return szRet;
@@ -129,7 +129,7 @@ static char *GetNetlibUserSettingString(const char *szUserModule, const char *sz
static INT_PTR NetlibRegisterUser(WPARAM, LPARAM lParam)
{
- NETLIBUSER *nlu=(NETLIBUSER*)lParam;
+ 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))) {
@@ -155,42 +155,42 @@ static INT_PTR NetlibRegisterUser(WPARAM, LPARAM lParam)
if (nlu->szDescriptiveName) {
thisUser->user.ptszDescriptiveName = (thisUser->user.flags&NUF_UNICODE ? mir_u2t((WCHAR*)nlu->ptszDescriptiveName) : mir_a2t(nlu->szDescriptiveName));
}
- if ((thisUser->user.szSettingsModule=mir_strdup(nlu->szSettingsModule)) == NULL
+ if ((thisUser->user.szSettingsModule = mir_strdup(nlu->szSettingsModule)) == NULL
|| (nlu->szDescriptiveName && thisUser->user.ptszDescriptiveName == NULL)
- || (nlu->szHttpGatewayUserAgent && (thisUser->user.szHttpGatewayUserAgent=mir_strdup(nlu->szHttpGatewayUserAgent)) == NULL))
+ || (nlu->szHttpGatewayUserAgent && (thisUser->user.szHttpGatewayUserAgent = mir_strdup(nlu->szHttpGatewayUserAgent)) == NULL))
{
mir_free(thisUser);
SetLastError(ERROR_OUTOFMEMORY);
return 0;
}
if (nlu->szHttpGatewayHello)
- thisUser->user.szHttpGatewayHello=mir_strdup(nlu->szHttpGatewayHello);
+ thisUser->user.szHttpGatewayHello = mir_strdup(nlu->szHttpGatewayHello);
else
- thisUser->user.szHttpGatewayHello=NULL;
+ thisUser->user.szHttpGatewayHello = NULL;
- thisUser->settings.cbSize=sizeof(NETLIBUSERSETTINGS);
- thisUser->settings.useProxy=GetNetlibUserSettingInt(thisUser->user.szSettingsModule, "NLUseProxy", 0);
- thisUser->settings.proxyType=GetNetlibUserSettingInt(thisUser->user.szSettingsModule, "NLProxyType", PROXYTYPE_SOCKS5);
+ thisUser->settings.cbSize = sizeof(NETLIBUSERSETTINGS);
+ thisUser->settings.useProxy = GetNetlibUserSettingInt(thisUser->user.szSettingsModule, "NLUseProxy", 0);
+ 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;
+ 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;
+ thisUser->settings.useProxy = 0;
+ thisUser->settings.proxyType = PROXYTYPE_SOCKS5;
}
- thisUser->settings.szProxyServer=GetNetlibUserSettingString(thisUser->user.szSettingsModule, "NLProxyServer", 0);
- thisUser->settings.wProxyPort=GetNetlibUserSettingInt(thisUser->user.szSettingsModule, "NLProxyPort", 1080);
- thisUser->settings.useProxyAuth=GetNetlibUserSettingInt(thisUser->user.szSettingsModule, "NLUseProxyAuth", 0);
- thisUser->settings.szProxyAuthUser=GetNetlibUserSettingString(thisUser->user.szSettingsModule, "NLProxyAuthUser", 0);
- thisUser->settings.szProxyAuthPassword=GetNetlibUserSettingString(thisUser->user.szSettingsModule, "NLProxyAuthPassword", 1);
- thisUser->settings.dnsThroughProxy=GetNetlibUserSettingInt(thisUser->user.szSettingsModule, "NLDnsThroughProxy", 1);
- thisUser->settings.specifyIncomingPorts=GetNetlibUserSettingInt(thisUser->user.szSettingsModule, "NLSpecifyIncomingPorts", 0);
- thisUser->settings.szIncomingPorts=GetNetlibUserSettingString(thisUser->user.szSettingsModule, "NLIncomingPorts", 0);
- thisUser->settings.specifyOutgoingPorts=GetNetlibUserSettingInt(thisUser->user.szSettingsModule, "NLSpecifyOutgoingPorts", 0);
- thisUser->settings.szOutgoingPorts=GetNetlibUserSettingString(thisUser->user.szSettingsModule, "NLOutgoingPorts", 0);
- thisUser->settings.enableUPnP=GetNetlibUserSettingInt(thisUser->user.szSettingsModule, "NLEnableUPnP", 1); //default to on
- thisUser->settings.validateSSL=GetNetlibUserSettingInt(thisUser->user.szSettingsModule, "NLValidateSSL", 0);
-
- thisUser->toLog=GetNetlibUserSettingInt(thisUser->user.szSettingsModule, "NLlog", 1);
+ thisUser->settings.szProxyServer = GetNetlibUserSettingString(thisUser->user.szSettingsModule, "NLProxyServer", 0);
+ thisUser->settings.wProxyPort = GetNetlibUserSettingInt(thisUser->user.szSettingsModule, "NLProxyPort", 1080);
+ thisUser->settings.useProxyAuth = GetNetlibUserSettingInt(thisUser->user.szSettingsModule, "NLUseProxyAuth", 0);
+ thisUser->settings.szProxyAuthUser = GetNetlibUserSettingString(thisUser->user.szSettingsModule, "NLProxyAuthUser", 0);
+ thisUser->settings.szProxyAuthPassword = GetNetlibUserSettingString(thisUser->user.szSettingsModule, "NLProxyAuthPassword", 1);
+ thisUser->settings.dnsThroughProxy = GetNetlibUserSettingInt(thisUser->user.szSettingsModule, "NLDnsThroughProxy", 1);
+ thisUser->settings.specifyIncomingPorts = GetNetlibUserSettingInt(thisUser->user.szSettingsModule, "NLSpecifyIncomingPorts", 0);
+ thisUser->settings.szIncomingPorts = GetNetlibUserSettingString(thisUser->user.szSettingsModule, "NLIncomingPorts", 0);
+ thisUser->settings.specifyOutgoingPorts = GetNetlibUserSettingInt(thisUser->user.szSettingsModule, "NLSpecifyOutgoingPorts", 0);
+ thisUser->settings.szOutgoingPorts = GetNetlibUserSettingString(thisUser->user.szSettingsModule, "NLOutgoingPorts", 0);
+ thisUser->settings.enableUPnP = GetNetlibUserSettingInt(thisUser->user.szSettingsModule, "NLEnableUPnP", 1); //default to on
+ thisUser->settings.validateSSL = GetNetlibUserSettingInt(thisUser->user.szSettingsModule, "NLValidateSSL", 0);
+
+ thisUser->toLog = GetNetlibUserSettingInt(thisUser->user.szSettingsModule, "NLlog", 1);
mir_cslock lck(csNetlibUser);
netlibUser.insert(thisUser);
@@ -199,21 +199,21 @@ static INT_PTR NetlibRegisterUser(WPARAM, LPARAM lParam)
static INT_PTR NetlibGetUserSettings(WPARAM wParam, LPARAM lParam)
{
- NETLIBUSERSETTINGS *nlus=(NETLIBUSERSETTINGS*)lParam;
- struct NetlibUser *nlu=(struct NetlibUser*)wParam;
+ NETLIBUSERSETTINGS *nlus = (NETLIBUSERSETTINGS*)lParam;
+ struct NetlibUser *nlu = (struct NetlibUser*)wParam;
if (GetNetlibHandleType(nlu) != NLH_USER || nlus == NULL || nlus->cbSize != sizeof(NETLIBUSERSETTINGS)) {
SetLastError(ERROR_INVALID_PARAMETER);
return 0;
}
- *nlus=nlu->settings;
+ *nlus = nlu->settings;
return 1;
}
static INT_PTR NetlibSetUserSettings(WPARAM wParam, LPARAM lParam)
{
- NETLIBUSERSETTINGS *nlus=(NETLIBUSERSETTINGS*)lParam;
- struct NetlibUser *nlu=(struct NetlibUser*)wParam;
+ NETLIBUSERSETTINGS *nlus = (NETLIBUSERSETTINGS*)lParam;
+ struct NetlibUser *nlu = (struct NetlibUser*)wParam;
if (GetNetlibHandleType(nlu) != NLH_USER || nlus == NULL || nlus->cbSize != sizeof(NETLIBUSERSETTINGS)) {
SetLastError(ERROR_INVALID_PARAMETER);
@@ -244,7 +244,7 @@ INT_PTR NetlibCloseHandle(WPARAM wParam, LPARAM)
{
case NLH_USER:
{
- struct NetlibUser *nlu=(struct NetlibUser*)wParam;
+ struct NetlibUser *nlu = (struct NetlibUser*)wParam;
{
mir_cslock lck(csNetlibUser);
int i = netlibUser.getIndex(nlu);
@@ -261,7 +261,7 @@ INT_PTR NetlibCloseHandle(WPARAM wParam, LPARAM)
break;
}
case NLH_CONNECTION:
- { struct NetlibConnection *nlc=(struct NetlibConnection*)wParam;
+ { struct NetlibConnection *nlc = (struct NetlibConnection*)wParam;
HANDLE waitHandles[4];
DWORD waitResult;
@@ -280,17 +280,17 @@ INT_PTR NetlibCloseHandle(WPARAM wParam, LPARAM)
}
ReleaseMutex(hConnectionHeaderMutex);
- waitHandles[0]=hConnectionHeaderMutex;
- waitHandles[1]=nlc->hOkToCloseEvent;
- waitHandles[2]=nlc->ncsRecv.hMutex;
- waitHandles[3]=nlc->ncsSend.hMutex;
- waitResult=WaitForMultipleObjects(SIZEOF(waitHandles), waitHandles, TRUE, INFINITE);
+ waitHandles[0] = hConnectionHeaderMutex;
+ waitHandles[1] = nlc->hOkToCloseEvent;
+ waitHandles[2] = nlc->ncsRecv.hMutex;
+ waitHandles[3] = nlc->ncsSend.hMutex;
+ 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
return 0;
}
- nlc->handleType=0;
+ nlc->handleType = 0;
mir_free(nlc->nlhpi.szHttpPostUrl);
mir_free(nlc->nlhpi.szHttpGetUrl);
mir_free(nlc->dataBuffer);
@@ -308,7 +308,7 @@ INT_PTR NetlibCloseHandle(WPARAM wParam, LPARAM)
case NLH_BOUNDPORT:
return NetlibFreeBoundPort((struct NetlibBoundPort*)wParam);
case NLH_PACKETRECVER:
- { struct NetlibPacketRecver *nlpr=(struct NetlibPacketRecver*)wParam;
+ { struct NetlibPacketRecver *nlpr = (struct NetlibPacketRecver*)wParam;
mir_free(nlpr->packetRecver.buffer);
break;
}
@@ -406,10 +406,10 @@ INT_PTR NetlibShutdown(WPARAM wParam, LPARAM)
return 0;
}
-static const char szHexDigits[]="0123456789ABCDEF";
+static const char szHexDigits[] = "0123456789ABCDEF";
INT_PTR NetlibHttpUrlEncode(WPARAM, LPARAM lParam)
{
- unsigned char *szOutput, *szInput=(unsigned char*)lParam;
+ unsigned char *szOutput, *szInput = (unsigned char*)lParam;
unsigned char *pszIn, *pszOut;
int outputLen;
@@ -417,19 +417,19 @@ INT_PTR NetlibHttpUrlEncode(WPARAM, LPARAM lParam)
SetLastError(ERROR_INVALID_PARAMETER);
return (INT_PTR)(char*)NULL;
}
- for (outputLen=0, pszIn=szInput;*pszIn;pszIn++) {
+ 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
*pszIn == '-' || *pszIn == '_' || *pszIn == '.' || *pszIn == ' ') outputLen++;
else outputLen+=3;
}
- szOutput=(unsigned char*)HeapAlloc(GetProcessHeap(), 0, outputLen+1);
+ szOutput = (unsigned char*)HeapAlloc(GetProcessHeap(), 0, outputLen+1);
if (szOutput == NULL) {
SetLastError(ERROR_OUTOFMEMORY);
return (INT_PTR)(unsigned char*)NULL;
}
- for (pszOut=szOutput, pszIn=szInput;*pszIn;pszIn++) {
+ for (pszOut = szOutput, pszIn = szInput;*pszIn;pszIn++) {
if ((48 <= *pszIn && *pszIn <= 57) ||
(65 <= *pszIn && *pszIn <= 90) ||
(97 <= *pszIn && *pszIn <= 122) ||
@@ -441,14 +441,14 @@ INT_PTR NetlibHttpUrlEncode(WPARAM, LPARAM lParam)
*pszOut++=szHexDigits[*pszIn&0xF];
}
}
- *pszOut='\0';
+ *pszOut = '\0';
return (INT_PTR)szOutput;
}
-static const char base64chars[]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
+static const char base64chars[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
INT_PTR NetlibBase64Encode(WPARAM, LPARAM lParam)
{
- NETLIBBASE64 *nlb64=(NETLIBBASE64*)lParam;
+ NETLIBBASE64 *nlb64 = (NETLIBBASE64*)lParam;
int iIn;
char *pszOut;
PBYTE pbIn;
@@ -461,35 +461,35 @@ INT_PTR NetlibBase64Encode(WPARAM, LPARAM lParam)
SetLastError(ERROR_BUFFER_OVERFLOW);
return 0;
}
- nlb64->cchEncoded=Netlib_GetBase64EncodedBufferSize(nlb64->cbDecoded);
- for (iIn=0, pbIn=nlb64->pbDecoded, pszOut=nlb64->pszEncoded;iIn<nlb64->cbDecoded;iIn+=3, pbIn+=3, pszOut+=4) {
- pszOut[0]=base64chars[pbIn[0]>>2];
+ nlb64->cchEncoded = Netlib_GetBase64EncodedBufferSize(nlb64->cbDecoded);
+ for (iIn = 0, pbIn = nlb64->pbDecoded, pszOut = nlb64->pszEncoded;iIn<nlb64->cbDecoded;iIn+=3, pbIn+=3, pszOut+=4) {
+ pszOut[0] = base64chars[pbIn[0]>>2];
if (nlb64->cbDecoded-iIn == 1) {
- pszOut[1]=base64chars[(pbIn[0]&3)<<4];
- pszOut[2]='=';
- pszOut[3]='=';
+ pszOut[1] = base64chars[(pbIn[0]&3)<<4];
+ pszOut[2] = '=';
+ pszOut[3] = '=';
pszOut+=4;
break;
}
- pszOut[1]=base64chars[((pbIn[0]&3)<<4)|(pbIn[1]>>4)];
+ pszOut[1] = base64chars[((pbIn[0]&3)<<4)|(pbIn[1]>>4)];
if (nlb64->cbDecoded-iIn == 2) {
- pszOut[2]=base64chars[(pbIn[1]&0xF)<<2];
- pszOut[3]='=';
+ pszOut[2] = base64chars[(pbIn[1]&0xF)<<2];
+ pszOut[3] = '=';
pszOut+=4;
break;
}
- pszOut[2]=base64chars[((pbIn[1]&0xF)<<2)|(pbIn[2]>>6)];
- pszOut[3]=base64chars[pbIn[2]&0x3F];
+ pszOut[2] = base64chars[((pbIn[1]&0xF)<<2)|(pbIn[2]>>6)];
+ pszOut[3] = base64chars[pbIn[2]&0x3F];
}
- pszOut[0]='\0';
+ pszOut[0] = '\0';
return 1;
}
static BYTE Base64CharToInt(char c)
{
- if (c>='A' && c<='Z') return c-'A';
- if (c>='a' && c<='z') return c-'a'+26;
- if (c>='0' && c<='9') return c-'0'+52;
+ if (c>='A' && c <= 'Z') return c-'A';
+ if (c>='a' && c <= 'z') return c-'a'+26;
+ if (c>='0' && c <= '9') return c-'0'+52;
if (c == '+') return 62;
if (c == '/') return 63;
if (c == '=') return 64;
@@ -498,7 +498,7 @@ static BYTE Base64CharToInt(char c)
INT_PTR NetlibBase64Decode(WPARAM, LPARAM lParam)
{
- NETLIBBASE64 *nlb64=(NETLIBBASE64*)lParam;
+ NETLIBBASE64 *nlb64 = (NETLIBBASE64*)lParam;
char *pszIn;
PBYTE pbOut;
BYTE b1, b2, b3, b4;
@@ -516,21 +516,21 @@ INT_PTR NetlibBase64Decode(WPARAM, LPARAM lParam)
SetLastError(ERROR_BUFFER_OVERFLOW);
return 0;
}
- nlb64->cbDecoded=Netlib_GetBase64DecodedBufferSize(nlb64->cchEncoded);
- for (iIn=0, pszIn=nlb64->pszEncoded, pbOut=nlb64->pbDecoded;iIn<nlb64->cchEncoded;iIn+=4, pszIn+=4, pbOut+=3) {
- b1=Base64CharToInt(pszIn[0]);
- b2=Base64CharToInt(pszIn[1]);
- b3=Base64CharToInt(pszIn[2]);
- b4=Base64CharToInt(pszIn[3]);
+ nlb64->cbDecoded = Netlib_GetBase64DecodedBufferSize(nlb64->cchEncoded);
+ for (iIn = 0, pszIn = nlb64->pszEncoded, pbOut = nlb64->pbDecoded;iIn<nlb64->cchEncoded;iIn+=4, pszIn+=4, pbOut+=3) {
+ b1 = Base64CharToInt(pszIn[0]);
+ b2 = Base64CharToInt(pszIn[1]);
+ b3 = Base64CharToInt(pszIn[2]);
+ b4 = Base64CharToInt(pszIn[3]);
if (b1 == 255 || b1 == 64 || b2 == 255 || b2 == 64 || b3 == 255 || b4 == 255) {
SetLastError(ERROR_INVALID_DATA);
return 0;
}
- pbOut[0]=(b1<<2)|(b2>>4);
+ pbOut[0] = (b1<<2)|(b2>>4);
if (b3 == 64) {nlb64->cbDecoded-=2; break;}
- pbOut[1]=(b2<<4)|(b3>>2);
+ pbOut[1] = (b2<<4)|(b3>>2);
if (b4 == 64) {nlb64->cbDecoded--; break;}
- pbOut[2]=b4|(b3<<6);
+ pbOut[2] = b4|(b3<<6);
}
return 1;
}
@@ -574,7 +574,7 @@ int LoadNetlibModule(void)
HookEvent(ME_OPT_INITIALISE, NetlibOptInitialise);
InitializeCriticalSection(&csNetlibUser);
- hConnectionHeaderMutex=CreateMutex(NULL, FALSE, NULL);
+ hConnectionHeaderMutex = CreateMutex(NULL, FALSE, NULL);
NetlibLogInit();
connectionTimeout = 0;
diff --git a/src/modules/netlib/netlib.h b/src/modules/netlib/netlib.h
index f152eafe10..f20d123fee 100644
--- a/src/modules/netlib/netlib.h
+++ b/src/modules/netlib/netlib.h
@@ -210,10 +210,10 @@ char* NtlmCreateResponseFromChallenge(HANDLE hSecurity, const char *szChallenge
static __inline INT_PTR NLSend(struct NetlibConnection *nlc, const char *buf, int len, int flags) {
- NETLIBBUFFER nlb={(char*)buf, len, flags};
+ NETLIBBUFFER nlb = {(char*)buf, len, flags};
return NetlibSend((WPARAM)nlc, (LPARAM)&nlb);
}
static __inline INT_PTR NLRecv(struct NetlibConnection *nlc, char *buf, int len, int flags) {
- NETLIBBUFFER nlb={buf, len, flags};
+ NETLIBBUFFER nlb = {buf, len, flags};
return NetlibRecv((WPARAM)nlc, (LPARAM)&nlb);
}
diff --git a/src/modules/netlib/netlibautoproxy.cpp b/src/modules/netlib/netlibautoproxy.cpp
index 37c3e88e22..e0428bf687 100644
--- a/src/modules/netlib/netlibautoproxy.cpp
+++ b/src/modules/netlib/netlibautoproxy.cpp
@@ -325,7 +325,7 @@ char* NetlibGetIeProxy(char *szUrl)
if (bEnabled)
{
- for (int i = 0; i < proxyBypass.getCount(); ++i)
+ for (int i=0; i < proxyBypass.getCount(); ++i)
{
if (strcmp(proxyBypass[i], "<local>") == 0)
{
@@ -399,9 +399,9 @@ void NetlibLoadIeProxy(void)
if (szProxyEnd) *szProxyEnd = 0;
int ind = -1;
- if (strncmp(szProxy, "http=", 5) == 0) { ind = 0; szProxy += 5; }
- else if (strncmp(szProxy, "https=", 6) == 0) { ind = 1; szProxy += 6; }
- else if (strncmp(szProxy, "socks=", 6) == 0) { ind = 2; szProxy += 6; }
+ if (strncmp(szProxy, "http = ", 5) == 0) { ind = 0; szProxy += 5; }
+ else if (strncmp(szProxy, "https = ", 6) == 0) { ind = 1; szProxy += 6; }
+ else if (strncmp(szProxy, "socks = ", 6) == 0) { ind = 2; szProxy += 6; }
else if (strchr(szProxy, '=')) ind = -2;
if (ind != -2)
@@ -447,10 +447,10 @@ void NetlibUnloadIeProxy(void)
{
int i;
- for (i = 0; i < 3; ++i)
+ for (i=0; i < 3; ++i)
mir_free(szProxyHost[i]);
- for (i = 0; i < proxyBypass.getCount(); ++i)
+ for (i=0; i < proxyBypass.getCount(); ++i)
mir_free(proxyBypass[i]);
proxyBypass.destroy();
diff --git a/src/modules/netlib/netlibbind.cpp b/src/modules/netlib/netlibbind.cpp
index 582358b619..7bb862f284 100644
--- a/src/modules/netlib/netlibbind.cpp
+++ b/src/modules/netlib/netlibbind.cpp
@@ -43,13 +43,13 @@ bool BindSocketToPort(const char *szPorts, SOCKET s, SOCKET s6, int* portn)
*portn = num % *portn;
}
- bool before=false;
+ bool before = false;
while (true) {
const char *psz;
char *pszEnd;
int portMin, portMax, port, portnum = 0;
- for (psz=szPorts;*psz;) {
+ for (psz = szPorts;*psz;) {
while (*psz == ' ' || *psz == ',') psz++;
portMin = strtol(psz, &pszEnd, 0);
if (pszEnd == psz)
diff --git a/src/modules/netlib/netlibhttp.cpp b/src/modules/netlib/netlibhttp.cpp
index 7296b339bd..8a87d330d0 100644
--- a/src/modules/netlib/netlibhttp.cpp
+++ b/src/modules/netlib/netlibhttp.cpp
@@ -138,7 +138,7 @@ static int RecvWithTimeoutTime(struct NetlibConnection *nlc, unsigned dwTimeoutT
static char* NetlibHttpFindHeader(NETLIBHTTPREQUEST *nlhrReply, const char *hdr)
{
- for (int i = 0; i < nlhrReply->headersCount; i++)
+ for (int i=0; i < nlhrReply->headersCount; i++)
{
if (_stricmp(nlhrReply->headers[i].szName, hdr) == 0)
{
@@ -154,7 +154,7 @@ static char* NetlibHttpFindAuthHeader(NETLIBHTTPREQUEST *nlhrReply, const char *
char *szNegoHdr = NULL;
char *szNtlmHdr = NULL;
- for (int i = 0; i < nlhrReply->headersCount; i++)
+ for (int i=0; i < nlhrReply->headersCount; i++)
{
if (_stricmp(nlhrReply->headers[i].szName, hdr) == 0)
{
@@ -423,12 +423,12 @@ static int SendHttpRequestAndData(struct NetlibConnection *nlc, struct Resizable
INT_PTR NetlibHttpSendRequest(WPARAM wParam, LPARAM lParam)
{
- struct NetlibConnection *nlc=(struct NetlibConnection*)wParam;
- NETLIBHTTPREQUEST *nlhr=(NETLIBHTTPREQUEST*)lParam;
+ struct NetlibConnection *nlc = (struct NetlibConnection*)wParam;
+ NETLIBHTTPREQUEST *nlhr = (NETLIBHTTPREQUEST*)lParam;
NETLIBHTTPREQUEST *nlhrReply = NULL;
HttpSecurityContext httpSecurity;
- struct ResizableCharBuffer httpRequest={0};
+ struct ResizableCharBuffer httpRequest = {0};
const char *pszRequest, *pszUrl, *pszFullUrl;
char *szHost = NULL, *szNewUrl = NULL;
char *pszProxyAuthHdr = NULL, *pszAuthHdr = NULL;
@@ -531,7 +531,7 @@ INT_PTR NetlibHttpSendRequest(WPARAM wParam, LPARAM lParam)
if (phost)
{
phost += 3;
- size_t len = phost - pszUrl;
+ size_t len = phost - pszUrl;
memcpy(szNewUrl, pszUrl, len);
szNewUrl[len] = 0;
}
@@ -806,7 +806,7 @@ INT_PTR NetlibHttpSendRequest(WPARAM wParam, LPARAM lParam)
INT_PTR NetlibHttpFreeRequestStruct(WPARAM, LPARAM lParam)
{
- NETLIBHTTPREQUEST *nlhr=(NETLIBHTTPREQUEST*)lParam;
+ NETLIBHTTPREQUEST *nlhr = (NETLIBHTTPREQUEST*)lParam;
if (nlhr == NULL || nlhr->cbSize != sizeof(NETLIBHTTPREQUEST) || nlhr->requestType != REQUEST_RESPONSE)
{
@@ -950,7 +950,7 @@ INT_PTR NetlibHttpRecvHeaders(WPARAM wParam, LPARAM lParam)
INT_PTR NetlibHttpTransaction(WPARAM wParam, LPARAM lParam)
{
- NetlibUser *nlu = (NetlibUser*)wParam;
+ NetlibUser *nlu = (NetlibUser*)wParam;
NETLIBHTTPREQUEST *nlhr = (NETLIBHTTPREQUEST*)lParam, *nlhrReply;
DWORD dflags, hflags;
@@ -989,10 +989,10 @@ INT_PTR NetlibHttpTransaction(WPARAM wParam, LPARAM lParam)
nlhrSend.headers[nlhrSend.headersCount].szValue = szUserAgent;
++nlhrSend.headersCount;
CallService(MS_SYSTEM_GETVERSIONTEXT, SIZEOF(szMirandaVer), (LPARAM)szMirandaVer);
- pspace=strchr(szMirandaVer, ' ');
+ pspace = strchr(szMirandaVer, ' ');
if (pspace)
{
- *pspace++ = '\0';
+ *pspace++='\0';
mir_snprintf(szUserAgent, SIZEOF(szUserAgent), "Miranda/%s (%s)", szMirandaVer, pspace);
}
else
@@ -1099,8 +1099,7 @@ char* gzip_decode(char *gzip_data, int *len_ptr, int window)
gzip_len = gzip_err == Z_STREAM_END ? zstr.total_out : -1;
- if (gzip_len <= 0)
- {
+ if (gzip_len <= 0) {
mir_free(output_data);
output_data = NULL;
}
diff --git a/src/modules/netlib/netlibhttpproxy.cpp b/src/modules/netlib/netlibhttpproxy.cpp
index 77a70a1dce..7c1ddd53c9 100644
--- a/src/modules/netlib/netlibhttpproxy.cpp
+++ b/src/modules/netlib/netlibhttpproxy.cpp
@@ -81,7 +81,7 @@ static bool NetlibHttpGatewaySend(struct NetlibConnection *nlc, RequestType reqT
{
case reqHelloGet:
nlhrSend.requestType = REQUEST_GET;
- nlhrSend.szUrl=nlc->nlu->user.szHttpGatewayHello;
+ nlhrSend.szUrl = nlc->nlu->user.szHttpGatewayHello;
break;
case reqOldGet:
@@ -136,13 +136,13 @@ static bool NetlibHttpGatewaySend(struct NetlibConnection *nlc, RequestType reqT
nlhrSend.headersCount = 3;
nlhrSend.headers = (NETLIBHTTPHEADER*)alloca(sizeof(NETLIBHTTPHEADER) * nlhrSend.headersCount);
- nlhrSend.headers[0].szName = "User-Agent";
+ nlhrSend.headers[0].szName = "User-Agent";
nlhrSend.headers[0].szValue = nlc->nlu->user.szHttpGatewayUserAgent;
- nlhrSend.headers[1].szName = "Cache-Control";
+ nlhrSend.headers[1].szName = "Cache-Control";
nlhrSend.headers[1].szValue = "no-cache, no-store ";
- nlhrSend.headers[2].szName = "Pragma";
+ nlhrSend.headers[2].szName = "Pragma";
nlhrSend.headers[2].szValue = "no-cache";
-// nlhrSend.headers[3].szName = "Accept-Encoding";
+// nlhrSend.headers[3].szName = "Accept-Encoding";
// nlhrSend.headers[3].szValue = "deflate, gzip";
return NetlibHttpSendRequest((WPARAM)nlc, (LPARAM)&nlhrSend) != SOCKET_ERROR;
@@ -179,19 +179,19 @@ static bool NetlibHttpGatewayOscarPost(NetlibConnection *nlc, const char *buf, i
NETLIBHTTPREQUEST *nlhrReply = NULL;
NetlibConnection nlcSend = {0};
- nlcSend.handleType = NLH_CONNECTION;
- nlcSend.nlu = nlc->nlu;
- nlcSend.nlhpi = nlc->nlhpi;
- nlcSend.s = nlc->s2;
+ nlcSend.handleType = NLH_CONNECTION;
+ nlcSend.nlu = nlc->nlu;
+ nlcSend.nlhpi = nlc->nlhpi;
+ nlcSend.s = nlc->s2;
nlcSend.usingHttpGateway = nlc->usingHttpGateway;
- nlcSend.szProxyServer = nlc->szProxyServer;
- nlcSend.wProxyPort = nlc->wProxyPort;
- nlcSend.proxyType = nlc->proxyType;
+ nlcSend.szProxyServer = nlc->szProxyServer;
+ nlcSend.wProxyPort = nlc->wProxyPort;
+ nlcSend.proxyType = nlc->proxyType;
if ( !NetlibReconnect(&nlcSend)) return false;
nlc->s2 = nlcSend.s;
- nlcSend.hOkToCloseEvent = CreateEvent(NULL, TRUE, TRUE, NULL);
+ nlcSend.hOkToCloseEvent = CreateEvent(NULL, TRUE, TRUE, NULL);
NetlibInitializeNestedCS(&nlcSend.ncsRecv);
NetlibInitializeNestedCS(&nlcSend.ncsSend);
@@ -404,7 +404,7 @@ int NetlibInitHttpConnection(struct NetlibConnection *nlc, struct NetlibUser *nl
{
NETLIBHTTPREQUEST *nlhrReply = NULL;
- nlc->nlhpi.firstGetSequence = 1;
+ nlc->nlhpi.firstGetSequence = 1;
nlc->nlhpi.firstPostSequence = 1;
if (nlu->user.szHttpGatewayHello != NULL)
@@ -449,8 +449,8 @@ int NetlibInitHttpConnection(struct NetlibConnection *nlc, struct NetlibUser *nl
INT_PTR NetlibHttpGatewaySetInfo(WPARAM wParam, LPARAM lParam)
{
- NETLIBHTTPPROXYINFO *nlhpi=(NETLIBHTTPPROXYINFO*)lParam;
- struct NetlibConnection *nlc=(struct NetlibConnection*)wParam;
+ NETLIBHTTPPROXYINFO *nlhpi = (NETLIBHTTPPROXYINFO*)lParam;
+ struct NetlibConnection *nlc = (struct NetlibConnection*)wParam;
if (GetNetlibHandleType(nlc) != NLH_CONNECTION || nlhpi == NULL ||
nlhpi->cbSize < (sizeof(NETLIBHTTPPROXYINFO) - sizeof(int)) ||
@@ -467,7 +467,7 @@ INT_PTR NetlibHttpGatewaySetInfo(WPARAM wParam, LPARAM lParam)
memcpy(&nlc->nlhpi, nlhpi, min(nlhpi->cbSize, sizeof(*nlhpi)));
if (nlc->nlhpi.combinePackets == 0) nlc->nlhpi.combinePackets = 1;
- nlc->nlhpi.szHttpGetUrl = mir_strdup(nlc->nlhpi.szHttpGetUrl);
+ nlc->nlhpi.szHttpGetUrl = mir_strdup(nlc->nlhpi.szHttpGetUrl);
nlc->nlhpi.szHttpPostUrl = mir_strdup(nlc->nlhpi.szHttpPostUrl);
return 1;
@@ -485,7 +485,7 @@ INT_PTR NetlibHttpSetSticky(WPARAM wParam, LPARAM lParam)
INT_PTR NetlibHttpSetPollingTimeout(WPARAM wParam, LPARAM lParam)
{
int oldTimeout;
- struct NetlibConnection *nlc=(struct NetlibConnection*)wParam;
+ struct NetlibConnection *nlc = (struct NetlibConnection*)wParam;
if (GetNetlibHandleType(nlc) != NLH_CONNECTION) return -1;
oldTimeout = nlc->pollingTimeout;
nlc->pollingTimeout = lParam;
diff --git a/src/modules/netlib/netliblog.cpp b/src/modules/netlib/netliblog.cpp
index 2e9f7a4365..ff352b5b55 100644
--- a/src/modules/netlib/netliblog.cpp
+++ b/src/modules/netlib/netliblog.cpp
@@ -57,7 +57,7 @@ static __int64 mirandaStartTime, perfCounterFreq;
static int bIsActive = TRUE;
static HANDLE hLogEvent = NULL;
-static const TCHAR* szTimeFormats[] =
+static const TCHAR* szTimeFormats[] =
{
_T("No times"),
_T("Standard hh:mm:ss times"),
@@ -69,7 +69,7 @@ static INT_PTR CALLBACK LogOptionsDlgProc(HWND hwndDlg, UINT message, WPARAM wPa
{
switch(message) {
case WM_INITDIALOG:
- logOptions.hwndOpts=hwndDlg;
+ logOptions.hwndOpts = hwndDlg;
TranslateDialogDefault(hwndDlg);
CheckDlgButton(hwndDlg, IDC_DUMPRECV, logOptions.dumpRecv?BST_CHECKED:BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_DUMPSENT, logOptions.dumpSent?BST_CHECKED:BST_UNCHECKED);
@@ -102,21 +102,21 @@ static INT_PTR CALLBACK LogOptionsDlgProc(HWND hwndDlg, UINT message, WPARAM wPa
SetWindowLongPtr(hwndFilter, GWL_STYLE, GetWindowLongPtr(hwndFilter, GWL_STYLE) | (TVS_NOHSCROLL | TVS_CHECKBOXES));
- tvis.hParent=NULL;
- tvis.hInsertAfter=TVI_SORT;
- tvis.item.mask=TVIF_PARAM|TVIF_TEXT|TVIF_STATE;
- tvis.item.stateMask=TVIS_STATEIMAGEMASK;
+ tvis.hParent = NULL;
+ tvis.hInsertAfter = TVI_SORT;
+ tvis.item.mask = TVIF_PARAM|TVIF_TEXT|TVIF_STATE;
+ tvis.item.stateMask = TVIS_STATEIMAGEMASK;
- for (i = 0; i < netlibUser.getCount(); ++i)
+ for (i=0; i < netlibUser.getCount(); ++i)
{
- tvis.item.pszText=netlibUser[i]->user.ptszDescriptiveName;
- tvis.item.lParam=i;
- tvis.item.state=INDEXTOSTATEIMAGEMASK((netlibUser[i]->toLog) ? 2 : 1);
+ tvis.item.pszText = netlibUser[i]->user.ptszDescriptiveName;
+ tvis.item.lParam = i;
+ 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.lParam = -1;
+ tvis.item.pszText = TranslateT("(Miranda Core Logging)");
+ tvis.item.state = INDEXTOSTATEIMAGEMASK((logOptions.toLog) ? 2 : 1);
TreeView_InsertItem(hwndFilter, &tvis);
}
return TRUE;
@@ -154,29 +154,29 @@ static INT_PTR CALLBACK LogOptionsDlgProc(HWND hwndDlg, UINT message, WPARAM wPa
case IDC_FILENAMEBROWSE:
case IDC_RUNATSTARTBROWSE:
{ TCHAR str[MAX_PATH+2];
- OPENFILENAME ofn={0};
+ OPENFILENAME ofn = {0};
TCHAR filter[512], *pfilter;
GetWindowText(GetWindow((HWND)lParam, GW_HWNDPREV), str, SIZEOF(str));
- ofn.lStructSize=OPENFILENAME_SIZE_VERSION_400;
- ofn.hwndOwner=hwndDlg;
- ofn.Flags=OFN_HIDEREADONLY | OFN_DONTADDTORECENT;
+ ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400;
+ ofn.hwndOwner = hwndDlg;
+ ofn.Flags = OFN_HIDEREADONLY | OFN_DONTADDTORECENT;
if (LOWORD(wParam) == IDC_FILENAMEBROWSE) {
- ofn.lpstrTitle=TranslateT("Select where log file will be created");
+ ofn.lpstrTitle = TranslateT("Select where log file will be created");
} else {
ofn.Flags|=OFN_PATHMUSTEXIST|OFN_FILEMUSTEXIST;
- ofn.lpstrTitle=TranslateT("Select program to be run");
+ ofn.lpstrTitle = TranslateT("Select program to be run");
}
_tcscpy(filter, TranslateT("All Files"));
_tcscat(filter, _T(" (*)"));
- pfilter=filter+lstrlen(filter)+1;
+ pfilter = filter+lstrlen(filter)+1;
_tcscpy(pfilter, _T("*"));
- pfilter=pfilter+lstrlen(pfilter)+1;
- *pfilter='\0';
- ofn.lpstrFilter=filter;
- ofn.lpstrFile=str;
- ofn.nMaxFile=SIZEOF(str)-2;
- ofn.nMaxFileTitle=MAX_PATH;
+ pfilter = pfilter+lstrlen(pfilter)+1;
+ *pfilter = '\0';
+ ofn.lpstrFilter = filter;
+ ofn.lpstrFile = str;
+ ofn.nMaxFile = SIZEOF(str)-2;
+ ofn.nMaxFileTitle = MAX_PATH;
if (LOWORD(wParam) == IDC_FILENAMEBROWSE) {
if ( !GetSaveFileName(&ofn)) return 1;
} else {
@@ -184,7 +184,7 @@ static INT_PTR CALLBACK LogOptionsDlgProc(HWND hwndDlg, UINT message, WPARAM wPa
}
if (LOWORD(wParam) == IDC_RUNATSTARTBROWSE && _tcschr(str, ' ') != NULL) {
MoveMemory(str+1, str, SIZEOF(str)-2);
- str[0]='"';
+ str[0] = '"';
lstrcat(str, _T("\""));
}
SetWindowText(GetWindow((HWND)lParam, GW_HWNDPREV), str);
@@ -192,10 +192,10 @@ static INT_PTR CALLBACK LogOptionsDlgProc(HWND hwndDlg, UINT message, WPARAM wPa
}
case IDC_RUNNOW:
{ TCHAR str[MAX_PATH+1];
- STARTUPINFO si={0};
+ STARTUPINFO si = {0};
PROCESS_INFORMATION pi;
GetDlgItemText(hwndDlg, IDC_RUNATSTART, str, MAX_PATH);
- si.cb=sizeof(si);
+ si.cb = sizeof(si);
if (str[0]) CreateProcess(NULL, str, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi);
}
break;
@@ -220,24 +220,24 @@ static INT_PTR CALLBACK LogOptionsDlgProc(HWND hwndDlg, UINT message, WPARAM wPa
GetWindowText(GetDlgItem(hwndDlg, IDC_PATH), str, MAX_PATH);
logOptions.szFile = mir_tstrdup(str);
- logOptions.dumpRecv=IsDlgButtonChecked(hwndDlg, IDC_DUMPRECV);
- logOptions.dumpSent=IsDlgButtonChecked(hwndDlg, IDC_DUMPSENT);
- logOptions.dumpProxy=IsDlgButtonChecked(hwndDlg, IDC_DUMPPROXY);
- logOptions.dumpSsl=IsDlgButtonChecked(hwndDlg, IDC_DUMPSSL);
- logOptions.textDumps=IsDlgButtonChecked(hwndDlg, IDC_TEXTDUMPS);
- logOptions.autoDetectText=IsDlgButtonChecked(hwndDlg, IDC_AUTODETECTTEXT);
- logOptions.timeFormat=SendDlgItemMessage(hwndDlg, IDC_TIMEFORMAT, CB_GETCURSEL, 0, 0);
- logOptions.showUser=IsDlgButtonChecked(hwndDlg, IDC_SHOWNAMES);
- logOptions.toOutputDebugString=IsDlgButtonChecked(hwndDlg, IDC_TOOUTPUTDEBUGSTRING);
- logOptions.toFile=IsDlgButtonChecked(hwndDlg, IDC_TOFILE);
+ logOptions.dumpRecv = IsDlgButtonChecked(hwndDlg, IDC_DUMPRECV);
+ logOptions.dumpSent = IsDlgButtonChecked(hwndDlg, IDC_DUMPSENT);
+ logOptions.dumpProxy = IsDlgButtonChecked(hwndDlg, IDC_DUMPPROXY);
+ logOptions.dumpSsl = IsDlgButtonChecked(hwndDlg, IDC_DUMPSSL);
+ logOptions.textDumps = IsDlgButtonChecked(hwndDlg, IDC_TEXTDUMPS);
+ logOptions.autoDetectText = IsDlgButtonChecked(hwndDlg, IDC_AUTODETECTTEXT);
+ logOptions.timeFormat = SendDlgItemMessage(hwndDlg, IDC_TIMEFORMAT, CB_GETCURSEL, 0, 0);
+ logOptions.showUser = IsDlgButtonChecked(hwndDlg, IDC_SHOWNAMES);
+ logOptions.toOutputDebugString = IsDlgButtonChecked(hwndDlg, IDC_TOOUTPUTDEBUGSTRING);
+ logOptions.toFile = IsDlgButtonChecked(hwndDlg, IDC_TOFILE);
}
{
HWND hwndFilter = GetDlgItem(logOptions.hwndOpts, IDC_FILTER);
- TVITEM tvi={0};
+ TVITEM tvi = {0};
BOOL checked;
- tvi.mask=TVIF_HANDLE|TVIF_PARAM|TVIF_STATE|TVIF_TEXT;
- tvi.hItem=TreeView_GetRoot(hwndFilter);
+ tvi.mask = TVIF_HANDLE|TVIF_PARAM|TVIF_STATE|TVIF_TEXT;
+ tvi.hItem = TreeView_GetRoot(hwndFilter);
while (tvi.hItem)
{
@@ -256,7 +256,7 @@ static INT_PTR CALLBACK LogOptionsDlgProc(HWND hwndDlg, UINT message, WPARAM wPa
DBWriteContactSettingDword(NULL, netlibUser[tvi.lParam]->user.szSettingsModule, "NLlog", checked);
}
- tvi.hItem=TreeView_GetNextSibling(hwndFilter, tvi.hItem);
+ tvi.hItem = TreeView_GetNextSibling(hwndFilter, tvi.hItem);
}
}
@@ -288,7 +288,7 @@ static INT_PTR CALLBACK LogOptionsDlgProc(HWND hwndDlg, UINT message, WPARAM wPa
break;
case WM_DESTROY:
ImageList_Destroy(TreeView_GetImageList(GetDlgItem(hwndDlg, IDC_FILTER), TVSIL_STATE));
- logOptions.hwndOpts=NULL;
+ logOptions.hwndOpts = NULL;
break;
}
return FALSE;
@@ -297,7 +297,7 @@ static INT_PTR CALLBACK LogOptionsDlgProc(HWND hwndDlg, UINT message, WPARAM wPa
void NetlibLogShowOptions(void)
{
if (logOptions.hwndOpts == NULL)
- logOptions.hwndOpts=CreateDialog(hInst, MAKEINTRESOURCE(IDD_NETLIBLOGOPTS), NULL, LogOptionsDlgProc);
+ logOptions.hwndOpts = CreateDialog(hInst, MAKEINTRESOURCE(IDD_NETLIBLOGOPTS), NULL, LogOptionsDlgProc);
SetForegroundWindow(logOptions.hwndOpts);
}
@@ -365,7 +365,7 @@ static INT_PTR NetlibLog(WPARAM wParam, LPARAM lParam)
(logOptions.showUser && logOptions.timeFormat) ? " " : "",
logOptions.showUser ? nlu->user.szSettingsModule : "");
else
- szHead[0]=0;
+ szHead[0] = 0;
if (logOptions.toOutputDebugString) {
if (szHead[0])
@@ -428,7 +428,7 @@ void NetlibLogf(NetlibUser* nlu, const char *fmt, ...)
void NetlibDumpData(struct NetlibConnection *nlc, PBYTE buf, int len, int sent, int flags)
{
- int isText=1;
+ int isText = 1;
char szTitleLine[128];
char *szBuf;
int titleLineLen;
@@ -474,7 +474,7 @@ void NetlibDumpData(struct NetlibConnection *nlc, PBYTE buf, int len, int sent,
if (logOptions.autoDetectText)
{
int i;
- for (i = 0; i<len; i++)
+ for (i=0; i<len; i++)
{
if ((buf[i]<' ' && buf[i] != '\t' && buf[i] != '\r' && buf[i] != '\n') || buf[i]>=0x80)
{
@@ -526,17 +526,17 @@ void NetlibDumpData(struct NetlibConnection *nlc, PBYTE buf, int len, int sent,
lstrcpyA(pszBuf, " ");
pszBuf += 3;
}
- *pszBuf++ = ' ';
+ *pszBuf++=' ';
}
for (col = 0; col < colsInLine; col++)
- *pszBuf++ = buf[line+col]<' '?'.':(char)buf[line+col];
+ *pszBuf++=buf[line+col]<' '?'.':(char)buf[line+col];
- if (len-line<=16)
+ if (len-line <= 16)
break;
- *pszBuf++ = '\r'; // End each line with a break
- *pszBuf++ = '\n'; // End each line with a break
+ *pszBuf++='\r'; // End each line with a break
+ *pszBuf++='\n'; // End each line with a break
}
*pszBuf = '\0';
}
diff --git a/src/modules/netlib/netlibopenconn.cpp b/src/modules/netlib/netlibopenconn.cpp
index 15623461c6..1f23c7e197 100644
--- a/src/modules/netlib/netlibopenconn.cpp
+++ b/src/modules/netlib/netlibopenconn.cpp
@@ -59,7 +59,7 @@ int WaitUntilReadable(SOCKET s, DWORD dwTimeout, bool check)
if (s == INVALID_SOCKET) return SOCKET_ERROR;
- tv.tv_sec = dwTimeout / 1000;
+ tv.tv_sec = dwTimeout / 1000;
tv.tv_usec = (dwTimeout % 1000) * 1000;
FD_ZERO(&readfd);
@@ -160,9 +160,9 @@ static int NetlibInitSocks5Connection(struct NetlibConnection *nlc, struct Netli
//rfc1928
BYTE buf[258];
- buf[0]=5; //yep, socks5
- buf[1]=1; //one auth method
- buf[2]=nlu->settings.useProxyAuth?2:0;
+ buf[0] = 5; //yep, socks5
+ buf[1] = 1; //one auth method
+ buf[2] = nlu->settings.useProxyAuth?2:0;
if (NLSend(nlc, (char*)buf, 3, MSG_DUMPPROXY) == SOCKET_ERROR) {
NetlibLogf(nlu, "%s %d: %s() failed (%u)", __FILE__, __LINE__, "NLSend", GetLastError());
return 0;
@@ -183,13 +183,13 @@ static int NetlibInitSocks5Connection(struct NetlibConnection *nlc, struct Netli
int nUserLen, nPassLen;
PBYTE pAuthBuf;
- nUserLen=lstrlenA(nlu->settings.szProxyAuthUser);
- nPassLen=lstrlenA(nlu->settings.szProxyAuthPassword);
- pAuthBuf=(PBYTE)mir_alloc(3+nUserLen+nPassLen);
- pAuthBuf[0]=1; //auth version
- pAuthBuf[1]=nUserLen;
+ nUserLen = lstrlenA(nlu->settings.szProxyAuthUser);
+ nPassLen = lstrlenA(nlu->settings.szProxyAuthPassword);
+ pAuthBuf = (PBYTE)mir_alloc(3+nUserLen+nPassLen);
+ pAuthBuf[0] = 1; //auth version
+ pAuthBuf[1] = nUserLen;
memcpy(pAuthBuf+2, nlu->settings.szProxyAuthUser, nUserLen);
- pAuthBuf[2+nUserLen]=nPassLen;
+ pAuthBuf[2+nUserLen] = nPassLen;
memcpy(pAuthBuf+3+nUserLen, nlu->settings.szProxyAuthPassword, nPassLen);
if (NLSend(nlc, (char*)pAuthBuf, 3+nUserLen+nPassLen, MSG_DUMPPROXY) == SOCKET_ERROR) {
NetlibLogf(nlu, "%s %d: %s() failed (%u)", __FILE__, __LINE__, "NLSend", GetLastError());
@@ -225,20 +225,20 @@ static int NetlibInitSocks5Connection(struct NetlibConnection *nlc, struct Netli
return 0;
nHostLen = 4;
}
- pInit=(PBYTE)mir_alloc(6+nHostLen);
- pInit[0]=5; //SOCKS5
- pInit[1]= nloc->flags & NLOCF_UDP ? 3 : 1; //connect or UDP
- pInit[2]=0; //reserved
+ pInit = (PBYTE)mir_alloc(6+nHostLen);
+ pInit[0] = 5; //SOCKS5
+ pInit[1] = nloc->flags & NLOCF_UDP ? 3 : 1; //connect or UDP
+ pInit[2] = 0; //reserved
if (hostIP == INADDR_NONE) { //DNS lookup through proxy
- pInit[3]=3;
- pInit[4]=nHostLen-1;
+ pInit[3] = 3;
+ pInit[4] = nHostLen-1;
memcpy(pInit+5, nloc->szHost, nHostLen-1);
}
else {
- pInit[3]=1;
- *(PDWORD)(pInit+4)=hostIP;
+ pInit[3] = 1;
+ *(PDWORD)(pInit+4) = hostIP;
}
- *(PWORD)(pInit+4+nHostLen)=htons(nloc->wPort);
+ *(PWORD)(pInit+4+nHostLen) = htons(nloc->wPort);
if (NLSend(nlc, (char*)pInit, 6+nHostLen, MSG_DUMPPROXY) == SOCKET_ERROR) {
NetlibLogf(nlu, "%s %d: %s() failed (%u)", __FILE__, __LINE__, "NLSend", GetLastError());
mir_free(pInit);
@@ -345,7 +345,7 @@ static bool NetlibInitHttpsConnection(struct NetlibConnection *nlc, struct Netli
static void FreePartiallyInitedConnection(struct NetlibConnection *nlc)
{
- DWORD dwOriginalLastError=GetLastError();
+ DWORD dwOriginalLastError = GetLastError();
if (nlc->s != INVALID_SOCKET) closesocket(nlc->s);
mir_free(nlc->nlhpi.szHttpPostUrl);
diff --git a/src/modules/netlib/netlibopts.cpp b/src/modules/netlib/netlibopts.cpp
index a8dc2b77b0..86fc34a6b5 100644
--- a/src/modules/netlib/netlibopts.cpp
+++ b/src/modules/netlib/netlibopts.cpp
@@ -32,7 +32,7 @@ struct NetlibTempSettings
static LIST <NetlibTempSettings> tempSettings(5);
-static const UINT outgoingConnectionsControls[] =
+static const UINT outgoingConnectionsControls[] =
{
IDC_STATIC12,
IDC_USEPROXY,
@@ -45,28 +45,28 @@ static const UINT outgoingConnectionsControls[] =
IDC_PORTSRANGEO,
IDC_STATIC54,
IDC_VALIDATESSL};
-static const UINT useProxyControls[]={
+static const UINT useProxyControls[] = {
IDC_STATIC21, IDC_PROXYTYPE,
IDC_STATIC22, IDC_PROXYHOST, IDC_STATIC23, IDC_PROXYPORT, IDC_STOFTENPORT,
IDC_PROXYAUTH,
IDC_STATIC31, IDC_PROXYUSER, IDC_STATIC32, IDC_PROXYPASS,
IDC_PROXYDNS};
-static const UINT specifyOPortsControls[]={
+static const UINT specifyOPortsControls[] = {
IDC_PORTSRANGEO,
IDC_STATIC54
};
-static const UINT incomingConnectionsControls[]={
+static const UINT incomingConnectionsControls[] = {
IDC_STATIC43,
IDC_SPECIFYPORTS,
IDC_PORTSRANGE,
IDC_STATIC52,
IDC_ENABLEUPNP};
-static const UINT specifyPortsControls[]={
+static const UINT specifyPortsControls[] = {
IDC_PORTSRANGE,
IDC_STATIC52};
-static const TCHAR* szProxyTypes[]={_T("<mixed>"), _T("SOCKS4"), _T("SOCKS5"), _T("HTTP"), _T("HTTPS"), _T("Internet Explorer")};
-static const WORD oftenProxyPorts[]={1080, 1080, 1080, 8080, 8080, 8080};
+static const TCHAR* szProxyTypes[] = {_T("<mixed>"), _T("SOCKS4"), _T("SOCKS5"), _T("HTTP"), _T("HTTPS"), _T("Internet Explorer")};
+static const WORD oftenProxyPorts[] = {1080, 1080, 1080, 8080, 8080, 8080};
#define M_REFRESHALL (WM_USER+100)
#define M_REFRESHENABLING (WM_USER+101)
@@ -93,68 +93,68 @@ static void AddProxyTypeItem(HWND hwndDlg, int type, int selectType)
static void CopySettingsStruct(NETLIBUSERSETTINGS *dest, NETLIBUSERSETTINGS *source)
{
- *dest=*source;
- if (dest->szIncomingPorts) dest->szIncomingPorts=mir_strdup(dest->szIncomingPorts);
- if (dest->szOutgoingPorts) dest->szOutgoingPorts=mir_strdup(dest->szOutgoingPorts);
- if (dest->szProxyAuthPassword) dest->szProxyAuthPassword=mir_strdup(dest->szProxyAuthPassword);
- if (dest->szProxyAuthUser) dest->szProxyAuthUser=mir_strdup(dest->szProxyAuthUser);
- if (dest->szProxyServer) dest->szProxyServer=mir_strdup(dest->szProxyServer);
+ *dest = *source;
+ if (dest->szIncomingPorts) dest->szIncomingPorts = mir_strdup(dest->szIncomingPorts);
+ if (dest->szOutgoingPorts) dest->szOutgoingPorts = mir_strdup(dest->szOutgoingPorts);
+ if (dest->szProxyAuthPassword) dest->szProxyAuthPassword = mir_strdup(dest->szProxyAuthPassword);
+ if (dest->szProxyAuthUser) dest->szProxyAuthUser = mir_strdup(dest->szProxyAuthUser);
+ if (dest->szProxyServer) dest->szProxyServer = mir_strdup(dest->szProxyServer);
}
static void CombineSettingsStrings(char **dest, char **source)
{
- if (*dest != NULL && (*source == NULL || lstrcmpiA(*dest, *source))) {mir_free(*dest); *dest=NULL;}
+ if (*dest != NULL && (*source == NULL || lstrcmpiA(*dest, *source))) {mir_free(*dest); *dest = NULL;}
}
static void CombineSettingsStructs(NETLIBUSERSETTINGS *dest, DWORD *destFlags, NETLIBUSERSETTINGS *source, DWORD sourceFlags)
{
if (sourceFlags&NUF_OUTGOING) {
if (*destFlags&NUF_OUTGOING) {
- if (dest->validateSSL != source->validateSSL) dest->validateSSL=2;
- if (dest->useProxy != source->useProxy) dest->useProxy=2;
- if (dest->proxyType != source->proxyType) dest->proxyType=0;
+ if (dest->validateSSL != source->validateSSL) dest->validateSSL = 2;
+ if (dest->useProxy != source->useProxy) dest->useProxy = 2;
+ if (dest->proxyType != source->proxyType) dest->proxyType = 0;
CombineSettingsStrings(&dest->szProxyServer, &source->szProxyServer);
- if (dest->wProxyPort != source->wProxyPort) dest->wProxyPort=0;
- if (dest->useProxyAuth != source->useProxyAuth) dest->useProxyAuth=2;
+ if (dest->wProxyPort != source->wProxyPort) dest->wProxyPort = 0;
+ if (dest->useProxyAuth != source->useProxyAuth) dest->useProxyAuth = 2;
CombineSettingsStrings(&dest->szProxyAuthUser, &source->szProxyAuthUser);
CombineSettingsStrings(&dest->szProxyAuthPassword, &source->szProxyAuthPassword);
- if (dest->dnsThroughProxy != source->dnsThroughProxy) dest->dnsThroughProxy=2;
- if (dest->specifyOutgoingPorts != source->specifyOutgoingPorts) dest->specifyOutgoingPorts=2;
+ if (dest->dnsThroughProxy != source->dnsThroughProxy) dest->dnsThroughProxy = 2;
+ if (dest->specifyOutgoingPorts != source->specifyOutgoingPorts) dest->specifyOutgoingPorts = 2;
CombineSettingsStrings(&dest->szOutgoingPorts, &source->szOutgoingPorts);
}
else {
- dest->validateSSL=source->validateSSL;
- dest->useProxy=source->useProxy;
- dest->proxyType=source->proxyType;
- dest->szProxyServer=source->szProxyServer;
- if (dest->szProxyServer) dest->szProxyServer=mir_strdup(dest->szProxyServer);
- dest->wProxyPort=source->wProxyPort;
- dest->useProxyAuth=source->useProxyAuth;
- dest->szProxyAuthUser=source->szProxyAuthUser;
- if (dest->szProxyAuthUser) dest->szProxyAuthUser=mir_strdup(dest->szProxyAuthUser);
- dest->szProxyAuthPassword=source->szProxyAuthPassword;
- if (dest->szProxyAuthPassword) dest->szProxyAuthPassword=mir_strdup(dest->szProxyAuthPassword);
- dest->dnsThroughProxy=source->dnsThroughProxy;
- dest->specifyOutgoingPorts=source->specifyOutgoingPorts;
- dest->szOutgoingPorts=source->szOutgoingPorts;
- if (dest->szOutgoingPorts) dest->szOutgoingPorts=mir_strdup(dest->szOutgoingPorts);
+ dest->validateSSL = source->validateSSL;
+ dest->useProxy = source->useProxy;
+ dest->proxyType = source->proxyType;
+ dest->szProxyServer = source->szProxyServer;
+ if (dest->szProxyServer) dest->szProxyServer = mir_strdup(dest->szProxyServer);
+ dest->wProxyPort = source->wProxyPort;
+ dest->useProxyAuth = source->useProxyAuth;
+ dest->szProxyAuthUser = source->szProxyAuthUser;
+ if (dest->szProxyAuthUser) dest->szProxyAuthUser = mir_strdup(dest->szProxyAuthUser);
+ dest->szProxyAuthPassword = source->szProxyAuthPassword;
+ if (dest->szProxyAuthPassword) dest->szProxyAuthPassword = mir_strdup(dest->szProxyAuthPassword);
+ dest->dnsThroughProxy = source->dnsThroughProxy;
+ dest->specifyOutgoingPorts = source->specifyOutgoingPorts;
+ dest->szOutgoingPorts = source->szOutgoingPorts;
+ if (dest->szOutgoingPorts) dest->szOutgoingPorts = mir_strdup(dest->szOutgoingPorts);
}
}
if (sourceFlags&NUF_INCOMING) {
if (*destFlags&NUF_INCOMING) {
- if (dest->enableUPnP != source->enableUPnP) dest->enableUPnP=2;
- if (dest->specifyIncomingPorts != source->specifyIncomingPorts) dest->specifyIncomingPorts=2;
+ if (dest->enableUPnP != source->enableUPnP) dest->enableUPnP = 2;
+ if (dest->specifyIncomingPorts != source->specifyIncomingPorts) dest->specifyIncomingPorts = 2;
CombineSettingsStrings(&dest->szIncomingPorts, &source->szIncomingPorts);
}
else {
- dest->enableUPnP=source->enableUPnP;
- dest->specifyIncomingPorts=source->specifyIncomingPorts;
- dest->szIncomingPorts=source->szIncomingPorts;
- if (dest->szIncomingPorts) dest->szIncomingPorts=mir_strdup(dest->szIncomingPorts);
+ dest->enableUPnP = source->enableUPnP;
+ dest->specifyIncomingPorts = source->specifyIncomingPorts;
+ dest->szIncomingPorts = source->szIncomingPorts;
+ if (dest->szIncomingPorts) dest->szIncomingPorts = mir_strdup(dest->szIncomingPorts);
}
}
if ((*destFlags&NUF_NOHTTPSOPTION) != (sourceFlags&NUF_NOHTTPSOPTION))
- *destFlags=(*destFlags|sourceFlags)&~NUF_NOHTTPSOPTION;
+ *destFlags = (*destFlags|sourceFlags)&~NUF_NOHTTPSOPTION;
else *destFlags|=sourceFlags;
}
@@ -167,26 +167,26 @@ static void ChangeSettingIntByCheckbox(HWND hwndDlg, UINT ctrlId, int iUser, int
if ( !(tempSettings[i]->flags & NUF_NOOPTIONS))
*(int*)(((PBYTE)&tempSettings[i]->settings) + memberOffset) = newValue;
}
- else *(int*)(((PBYTE)&tempSettings[iUser]->settings) + memberOffset)=newValue;
+ else *(int*)(((PBYTE)&tempSettings[iUser]->settings) + memberOffset) = newValue;
SendMessage(hwndDlg, M_REFRESHENABLING, 0, 0);
}
static void ChangeSettingStringByEdit(HWND hwndDlg, UINT ctrlId, int iUser, int memberOffset)
{
- int newValueLen=GetWindowTextLength(GetDlgItem(hwndDlg, ctrlId));
- char *szNewValue=(char*)mir_alloc(newValueLen+1);
+ int newValueLen = GetWindowTextLength(GetDlgItem(hwndDlg, ctrlId));
+ char *szNewValue = (char*)mir_alloc(newValueLen+1);
GetDlgItemTextA(hwndDlg, ctrlId, szNewValue, newValueLen+1);
if (iUser == -1) {
for (int i=0; i<tempSettings.getCount(); ++i)
if ( !(tempSettings[i]->flags & NUF_NOOPTIONS)) {
- char **ppszNew=(char**)(((PBYTE)&tempSettings[i]->settings)+memberOffset);
+ char **ppszNew = (char**)(((PBYTE)&tempSettings[i]->settings)+memberOffset);
mir_free(*ppszNew);
*ppszNew = mir_strdup(szNewValue);
}
mir_free(szNewValue);
}
else {
- char **ppszNew=(char**)(((PBYTE)&tempSettings[iUser]->settings)+memberOffset);
+ char **ppszNew = (char**)(((PBYTE)&tempSettings[iUser]->settings)+memberOffset);
mir_free(*ppszNew);
*ppszNew = szNewValue;
}
@@ -240,13 +240,13 @@ void NetlibSaveUserSettingsStruct(const char *szSettingsModule, NETLIBUSERSETTIN
continue;
CombineSettingsStructs(&combinedSettings, &flags, &thisUser->settings, thisUser->user.flags);
}
- if (combinedSettings.validateSSL == 2) combinedSettings.validateSSL=0;
- if (combinedSettings.useProxy == 2) combinedSettings.useProxy=0;
- if (combinedSettings.proxyType == 0) combinedSettings.proxyType=PROXYTYPE_SOCKS5;
- if (combinedSettings.useProxyAuth == 2) combinedSettings.useProxyAuth=0;
- if (combinedSettings.dnsThroughProxy == 2) combinedSettings.dnsThroughProxy=1;
- if (combinedSettings.enableUPnP == 2) combinedSettings.enableUPnP=1;
- if (combinedSettings.specifyIncomingPorts == 2) combinedSettings.specifyIncomingPorts=0;
+ if (combinedSettings.validateSSL == 2) combinedSettings.validateSSL = 0;
+ if (combinedSettings.useProxy == 2) combinedSettings.useProxy = 0;
+ if (combinedSettings.proxyType == 0) combinedSettings.proxyType = PROXYTYPE_SOCKS5;
+ if (combinedSettings.useProxyAuth == 2) combinedSettings.useProxyAuth = 0;
+ if (combinedSettings.dnsThroughProxy == 2) combinedSettings.dnsThroughProxy = 1;
+ if (combinedSettings.enableUPnP == 2) combinedSettings.enableUPnP = 1;
+ if (combinedSettings.specifyIncomingPorts == 2) combinedSettings.specifyIncomingPorts = 0;
WriteSettingsStructToDb("Netlib", &combinedSettings, flags);
NetlibFreeUserSettingsStruct(&combinedSettings);
}
@@ -289,8 +289,8 @@ static INT_PTR CALLBACK DlgProcNetlibOpts(HWND hwndDlg, UINT msg, WPARAM wParam,
DWORD flags = 0;
if (iUser == -1) {
- settings.cbSize=sizeof(settings);
- for (int i = 0; i < tempSettings.getCount(); ++i) {
+ settings.cbSize = sizeof(settings);
+ for (int i=0; i < tempSettings.getCount(); ++i) {
if (tempSettings[i]->flags & NUF_NOOPTIONS) continue;
CombineSettingsStructs(&settings, &flags, &tempSettings[i]->settings, tempSettings[i]->flags);
}
@@ -344,24 +344,24 @@ static INT_PTR CALLBACK DlgProcNetlibOpts(HWND hwndDlg, UINT msg, WPARAM wParam,
int enableAuth = 0, enableUser = 0, enablePass = 0, enableServer = 1;
EnableMultipleControls(hwndDlg, useProxyControls, SIZEOF(useProxyControls), TRUE);
if (selectedProxyType == 0) {
- for (int i = 0; i < tempSettings.getCount(); ++i) {
+ for (int i=0; i < tempSettings.getCount(); ++i) {
if ( !tempSettings[i]->settings.useProxy ||
tempSettings[i]->flags & NUF_NOOPTIONS || !(tempSettings[i]->flags & NUF_OUTGOING))
continue;
- if (tempSettings[i]->settings.proxyType == PROXYTYPE_SOCKS4) enableUser=1;
+ if (tempSettings[i]->settings.proxyType == PROXYTYPE_SOCKS4) enableUser = 1;
else {
enableAuth = 1;
if (tempSettings[i]->settings.useProxyAuth)
- enableUser=enablePass=1;
+ enableUser = enablePass = 1;
}
}
}
else {
- if (selectedProxyType == PROXYTYPE_SOCKS4) enableUser=1;
+ if (selectedProxyType == PROXYTYPE_SOCKS4) enableUser = 1;
else {
- if (selectedProxyType == PROXYTYPE_IE) enableServer=0;
- enableAuth=1;
+ if (selectedProxyType == PROXYTYPE_IE) enableServer = 0;
+ enableAuth = 1;
if (IsDlgButtonChecked(hwndDlg, IDC_PROXYAUTH) != BST_UNCHECKED)
enableUser = enablePass = 1;
}
@@ -397,7 +397,7 @@ static INT_PTR CALLBACK DlgProcNetlibOpts(HWND hwndDlg, UINT msg, WPARAM wParam,
int newValue = SendDlgItemMessage(hwndDlg, IDC_PROXYTYPE, CB_GETITEMDATA, SendDlgItemMessage(hwndDlg, IDC_PROXYTYPE, CB_GETCURSEL, 0, 0), 0);
if (iUser == -1) {
if (newValue == 0) return 0;
- for (int i = 0; i < tempSettings.getCount(); ++i) {
+ for (int i=0; i < tempSettings.getCount(); ++i) {
if (tempSettings[i]->flags & NUF_NOOPTIONS) continue;
if (newValue == PROXYTYPE_HTTP && !(tempSettings[i]->flags & (NUF_HTTPCONNS|NUF_HTTPGATEWAY)))
tempSettings[i]->settings.proxyType = PROXYTYPE_HTTPS;
@@ -444,7 +444,7 @@ static INT_PTR CALLBACK DlgProcNetlibOpts(HWND hwndDlg, UINT msg, WPARAM wParam,
{
int newValue = GetDlgItemInt(hwndDlg, LOWORD(wParam), NULL, FALSE);
if (iUser == -1) {
- for (int i = 0; i < tempSettings.getCount(); ++i)
+ for (int i=0; i < tempSettings.getCount(); ++i)
if ( !(tempSettings[i]->flags & NUF_NOOPTIONS))
tempSettings[i]->settings.wProxyPort = newValue;
}
@@ -498,13 +498,13 @@ static INT_PTR CALLBACK DlgProcNetlibOpts(HWND hwndDlg, UINT msg, WPARAM wParam,
return FALSE;
}
-static UINT expertOnlyControls[]={IDC_LOGOPTIONS};
+static UINT expertOnlyControls[] = {IDC_LOGOPTIONS};
int NetlibOptInitialise(WPARAM wParam, LPARAM)
{
int optionsCount = 0;
{
mir_cslock lck(csNetlibUser);
- for (int i = 0; i < netlibUser.getCount(); ++i)
+ for (int i=0; i < netlibUser.getCount(); ++i)
if ( !(netlibUser[i]->user.flags & NUF_NOOPTIONS))
++optionsCount;
}
diff --git a/src/modules/netlib/netlibpktrecver.cpp b/src/modules/netlib/netlibpktrecver.cpp
index d2b40559b3..4e887b1177 100644
--- a/src/modules/netlib/netlibpktrecver.cpp
+++ b/src/modules/netlib/netlibpktrecver.cpp
@@ -25,32 +25,32 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
INT_PTR NetlibPacketRecverCreate(WPARAM wParam, LPARAM lParam)
{
- struct NetlibConnection *nlc=(struct NetlibConnection*)wParam;
+ struct NetlibConnection *nlc = (struct NetlibConnection*)wParam;
struct NetlibPacketRecver *nlpr;
if (GetNetlibHandleType(nlc) != NLH_CONNECTION || lParam == 0) {
SetLastError(ERROR_INVALID_PARAMETER);
return (INT_PTR)(struct NetlibPacketRecver*)NULL;
}
- nlpr=(struct NetlibPacketRecver*)mir_calloc(sizeof(struct NetlibPacketRecver));
+ nlpr = (struct NetlibPacketRecver*)mir_calloc(sizeof(struct NetlibPacketRecver));
if (nlpr == NULL) {
SetLastError(ERROR_OUTOFMEMORY);
return (INT_PTR)(struct NetlibPacketRecver*)NULL;
}
- nlpr->handleType=NLH_PACKETRECVER;
- nlpr->nlc=nlc;
- nlpr->packetRecver.cbSize=sizeof(nlpr->packetRecver);
- nlpr->packetRecver.bufferSize=lParam;
- nlpr->packetRecver.buffer=(PBYTE)mir_alloc(nlpr->packetRecver.bufferSize);
- nlpr->packetRecver.bytesUsed=0;
- nlpr->packetRecver.bytesAvailable=0;
+ nlpr->handleType = NLH_PACKETRECVER;
+ nlpr->nlc = nlc;
+ nlpr->packetRecver.cbSize = sizeof(nlpr->packetRecver);
+ nlpr->packetRecver.bufferSize = lParam;
+ nlpr->packetRecver.buffer = (PBYTE)mir_alloc(nlpr->packetRecver.bufferSize);
+ nlpr->packetRecver.bytesUsed = 0;
+ nlpr->packetRecver.bytesAvailable = 0;
return (INT_PTR)nlpr;
}
INT_PTR NetlibPacketRecverGetMore(WPARAM wParam, LPARAM lParam)
{
- struct NetlibPacketRecver *nlpr=(struct NetlibPacketRecver*)wParam;
- NETLIBPACKETRECVER *nlprParam=(NETLIBPACKETRECVER*)lParam;
+ struct NetlibPacketRecver *nlpr = (struct NetlibPacketRecver*)wParam;
+ NETLIBPACKETRECVER *nlprParam = (NETLIBPACKETRECVER*)lParam;
INT_PTR recvResult;
if (GetNetlibHandleType(nlpr) != NLH_PACKETRECVER || nlprParam == NULL || nlprParam->cbSize != sizeof(NETLIBPACKETRECVER) || nlprParam->bytesUsed>nlpr->packetRecver.bytesAvailable) {
@@ -61,10 +61,10 @@ INT_PTR NetlibPacketRecverGetMore(WPARAM wParam, LPARAM lParam)
SetLastError(ERROR_TIMEOUT);
return SOCKET_ERROR;
}
- nlpr->packetRecver.dwTimeout=nlprParam->dwTimeout;
+ nlpr->packetRecver.dwTimeout = nlprParam->dwTimeout;
if (nlprParam->bytesUsed == 0) {
if (nlpr->packetRecver.bytesAvailable == nlpr->packetRecver.bufferSize) {
- nlpr->packetRecver.bytesAvailable=0;
+ nlpr->packetRecver.bytesAvailable = 0;
NetlibLogf(nlpr->nlc->nlu, "Packet recver: packet overflowed buffer, ditching");
}
}
@@ -74,12 +74,12 @@ INT_PTR NetlibPacketRecverGetMore(WPARAM wParam, LPARAM lParam)
}
if (nlprParam->dwTimeout != INFINITE) {
if ( !si.pending(nlpr->nlc->hSsl) && WaitUntilReadable(nlpr->nlc->s, nlprParam->dwTimeout) <= 0) {
- *nlprParam=nlpr->packetRecver;
+ *nlprParam = nlpr->packetRecver;
return SOCKET_ERROR;
}
}
- recvResult=NLRecv(nlpr->nlc, (char*)nlpr->packetRecver.buffer+nlpr->packetRecver.bytesAvailable, nlpr->packetRecver.bufferSize-nlpr->packetRecver.bytesAvailable, 0);
+ recvResult = NLRecv(nlpr->nlc, (char*)nlpr->packetRecver.buffer+nlpr->packetRecver.bytesAvailable, nlpr->packetRecver.bufferSize-nlpr->packetRecver.bytesAvailable, 0);
if (recvResult>0) nlpr->packetRecver.bytesAvailable+=recvResult;
- *nlprParam=nlpr->packetRecver;
+ *nlprParam = nlpr->packetRecver;
return recvResult;
}
diff --git a/src/modules/netlib/netlibsecurity.cpp b/src/modules/netlib/netlibsecurity.cpp
index 9ff92944e3..c95b4fd7ab 100644
--- a/src/modules/netlib/netlibsecurity.cpp
+++ b/src/modules/netlib/netlibsecurity.cpp
@@ -241,12 +241,12 @@ char* CompleteGssapi(HANDLE hSecurity, unsigned char *szChallenge, unsigned chls
}
unsigned i, ressz = 0;
- for (i = 0; i < outBuffersDesc.cBuffers; i++)
+ for (i=0; i < outBuffersDesc.cBuffers; i++)
ressz += outBuffersDesc.pBuffers[i].cbBuffer;
unsigned char *response = (unsigned char*)alloca(ressz), *p = response;
- for (i = 0; i < outBuffersDesc.cBuffers; i++)
+ for (i=0; i < outBuffersDesc.cBuffers; i++)
{
memcpy(p, outBuffersDesc.pBuffers[i].pvBuffer, outBuffersDesc.pBuffers[i].cbBuffer);
p += outBuffersDesc.pBuffers[i].cbBuffer;
@@ -430,7 +430,7 @@ char* NtlmCreateResponseFromChallenge(HANDLE hSecurity, const char *szChallenge,
char *szAuth = (char*)alloca(authLen);
nlb64.cbDecoded = mir_snprintf(szAuth, authLen, "%s:%s", szLogin, szPassw);
- nlb64.pbDecoded=(PBYTE)szAuth;
+ nlb64.pbDecoded = (PBYTE)szAuth;
complete = true;
mir_free(szPassw);
diff --git a/src/modules/netlib/netlibsock.cpp b/src/modules/netlib/netlibsock.cpp
index badc1fe0ca..ac0435564e 100644
--- a/src/modules/netlib/netlibsock.cpp
+++ b/src/modules/netlib/netlibsock.cpp
@@ -106,7 +106,7 @@ static int ConnectionListToSocketList(HANDLE *hConns, fd_set *fd, int& pending)
int i;
FD_ZERO(fd);
- for (i = 0; hConns[i] && hConns[i] != INVALID_HANDLE_VALUE && i < FD_SETSIZE; i++)
+ for (i=0; hConns[i] && hConns[i] != INVALID_HANDLE_VALUE && i < FD_SETSIZE; i++)
{
nlcCheck = (NetlibConnection*)hConns[i];
if (nlcCheck->handleType != NLH_CONNECTION && nlcCheck->handleType != NLH_BOUNDPORT)
@@ -131,8 +131,8 @@ INT_PTR NetlibSelect(WPARAM, LPARAM lParam)
}
TIMEVAL tv;
- tv.tv_sec=nls->dwTimeout/1000;
- tv.tv_usec=(nls->dwTimeout%1000)*1000;
+ tv.tv_sec = nls->dwTimeout/1000;
+ tv.tv_usec = (nls->dwTimeout%1000)*1000;
int pending = 0;
fd_set readfd, writefd, exceptfd;
@@ -305,7 +305,7 @@ static NETLIBIPLIST* GetMyIpv6(unsigned flags)
NETLIBIPLIST *addr = (NETLIBIPLIST*)mir_calloc(n * 64 + 4);
addr->cbNum = n;
- unsigned i = 0;
+ unsigned i=0;
for (ai = air; ai; ai = ai->ai_next)
{
SOCKADDR_INET_M* iaddr = (SOCKADDR_INET_M*)ai->ai_addr;
@@ -336,7 +336,7 @@ static NETLIBIPLIST* GetMyIpv4(void)
NETLIBIPLIST *addr = (NETLIBIPLIST*)mir_calloc(n * 64 + 4);
addr->cbNum = n;
- for (unsigned i = 0; i < n; ++i)
+ for (unsigned i=0; i < n; ++i)
strcpy(addr->szIp[i], inet_ntoa(*(PIN_ADDR)he->h_addr_list[i]));
return addr;
diff --git a/src/modules/netlib/netlibssl.cpp b/src/modules/netlib/netlibssl.cpp
index 77c6bec8c9..a1910f3ca6 100644
--- a/src/modules/netlib/netlibssl.cpp
+++ b/src/modules/netlib/netlibssl.cpp
@@ -119,7 +119,7 @@ static bool AcquireCredentials(void)
ZeroMemory(&SchannelCred, sizeof(SchannelCred));
- SchannelCred.dwVersion = SCHANNEL_CRED_VERSION;
+ SchannelCred.dwVersion = SCHANNEL_CRED_VERSION;
SchannelCred.grbitEnabledProtocols = SP_PROT_SSL3TLS1_CLIENTS /*| 0xA00 TLS1.1 & 1.2*/;
SchannelCred.dwFlags |= SCH_CRED_NO_DEFAULT_CREDS | SCH_CRED_MANUAL_CRED_VALIDATION;
@@ -235,7 +235,7 @@ static bool VerifyCertificate(SslHandle *ssl, PCSTR pszServerName, DWORD dwCertF
ChainPara.cbSize = sizeof(ChainPara);
ChainPara.RequestedUsage.dwType = USAGE_MATCH_TYPE_OR;
- ChainPara.RequestedUsage.Usage.cUsageIdentifier = SIZEOF(rgszUsages);
+ ChainPara.RequestedUsage.Usage.cUsageIdentifier = SIZEOF(rgszUsages);
ChainPara.RequestedUsage.Usage.rgpszUsageIdentifier = rgszUsages;
if ( !fnCertGetCertificateChain(NULL, pServerCert, NULL, pServerCert->hCertStore,
@@ -245,12 +245,12 @@ static bool VerifyCertificate(SslHandle *ssl, PCSTR pszServerName, DWORD dwCertF
goto cleanup;
}
- polHttps.cbStruct = sizeof(HTTPSPolicyCallbackData);
- polHttps.dwAuthType = AUTHTYPE_SERVER;
- polHttps.fdwChecks = dwCertFlags;
- polHttps.pwszServerName = pwszServerName;
+ polHttps.cbStruct = sizeof(HTTPSPolicyCallbackData);
+ polHttps.dwAuthType = AUTHTYPE_SERVER;
+ polHttps.fdwChecks = dwCertFlags;
+ polHttps.pwszServerName = pwszServerName;
- PolicyPara.cbSize = sizeof(PolicyPara);
+ PolicyPara.cbSize = sizeof(PolicyPara);
PolicyPara.pvExtraPolicyPara = &polHttps;
PolicyStatus.cbSize = sizeof(PolicyStatus);
@@ -361,29 +361,29 @@ static SECURITY_STATUS ClientHandshakeLoop(SslHandle *ssl, BOOL fDoInitialRead)
// of this. Leftover data (if any) will be placed in buffer 1 and
// given a buffer type of SECBUFFER_EXTRA.
- InBuffers[0].pvBuffer = ssl->pbIoBuffer;
- InBuffers[0].cbBuffer = ssl->cbIoBuffer;
+ InBuffers[0].pvBuffer = ssl->pbIoBuffer;
+ InBuffers[0].cbBuffer = ssl->cbIoBuffer;
InBuffers[0].BufferType = SECBUFFER_TOKEN;
- InBuffers[1].pvBuffer = NULL;
- InBuffers[1].cbBuffer = 0;
+ InBuffers[1].pvBuffer = NULL;
+ InBuffers[1].cbBuffer = 0;
InBuffers[1].BufferType = SECBUFFER_EMPTY;
- InBuffer.cBuffers = 2;
- InBuffer.pBuffers = InBuffers;
- InBuffer.ulVersion = SECBUFFER_VERSION;
+ InBuffer.cBuffers = 2;
+ InBuffer.pBuffers = InBuffers;
+ InBuffer.ulVersion = SECBUFFER_VERSION;
// Set up the output buffers. These are initialized to NULL
// so as to make it less likely we'll attempt to free random
// garbage later.
- OutBuffers[0].pvBuffer = NULL;
- OutBuffers[0].BufferType= SECBUFFER_TOKEN;
- OutBuffers[0].cbBuffer = 0;
+ OutBuffers[0].pvBuffer = NULL;
+ OutBuffers[0].BufferType = SECBUFFER_TOKEN;
+ OutBuffers[0].cbBuffer = 0;
- OutBuffer.cBuffers = 1;
- OutBuffer.pBuffers = OutBuffers;
- OutBuffer.ulVersion = SECBUFFER_VERSION;
+ OutBuffer.cBuffers = 1;
+ OutBuffer.pBuffers = OutBuffers;
+ OutBuffer.ulVersion = SECBUFFER_VERSION;
scRet = g_pSSPI->InitializeSecurityContextA(
&hCreds,
@@ -509,9 +509,9 @@ static bool ClientConnect(SslHandle *ssl, const char *host)
// Initiate a ClientHello message and generate a token.
- OutBuffers[0].pvBuffer = NULL;
+ OutBuffers[0].pvBuffer = NULL;
OutBuffers[0].BufferType = SECBUFFER_TOKEN;
- OutBuffers[0].cbBuffer = 0;
+ OutBuffers[0].cbBuffer = 0;
OutBuffer.cBuffers = 1;
OutBuffer.pBuffers = OutBuffers;
@@ -600,12 +600,12 @@ void NetlibSslShutdown(SslHandle *ssl)
dwType = SCHANNEL_SHUTDOWN;
- OutBuffers[0].pvBuffer = &dwType;
+ OutBuffers[0].pvBuffer = &dwType;
OutBuffers[0].BufferType = SECBUFFER_TOKEN;
- OutBuffers[0].cbBuffer = sizeof(dwType);
+ OutBuffers[0].cbBuffer = sizeof(dwType);
- OutBuffer.cBuffers = 1;
- OutBuffer.pBuffers = OutBuffers;
+ OutBuffer.cBuffers = 1;
+ OutBuffer.pBuffers = OutBuffers;
OutBuffer.ulVersion = SECBUFFER_VERSION;
scRet = g_pSSPI->ApplyControlToken(&ssl->hContext, &OutBuffer);
@@ -622,12 +622,12 @@ void NetlibSslShutdown(SslHandle *ssl)
ISC_REQ_ALLOCATE_MEMORY |
ISC_REQ_STREAM;
- OutBuffers[0].pvBuffer = NULL;
+ OutBuffers[0].pvBuffer = NULL;
OutBuffers[0].BufferType = SECBUFFER_TOKEN;
- OutBuffers[0].cbBuffer = 0;
+ OutBuffers[0].cbBuffer = 0;
- OutBuffer.cBuffers = 1;
- OutBuffer.pBuffers = OutBuffers;
+ OutBuffer.cBuffers = 1;
+ OutBuffer.pBuffers = OutBuffers;
OutBuffer.ulVersion = SECBUFFER_VERSION;
scRet = g_pSSPI->InitializeSecurityContextA(
@@ -760,17 +760,17 @@ int NetlibSslRead(SslHandle *ssl, char *buf, int num, int peek)
}
// Attempt to decrypt the received data.
- Buffers[0].pvBuffer = ssl->pbIoBuffer;
- Buffers[0].cbBuffer = ssl->cbIoBuffer;
- Buffers[0].BufferType = SECBUFFER_DATA;
+ Buffers[0].pvBuffer = ssl->pbIoBuffer;
+ Buffers[0].cbBuffer = ssl->cbIoBuffer;
+ Buffers[0].BufferType = SECBUFFER_DATA;
- Buffers[1].BufferType = SECBUFFER_EMPTY;
- Buffers[2].BufferType = SECBUFFER_EMPTY;
- Buffers[3].BufferType = SECBUFFER_EMPTY;
+ Buffers[1].BufferType = SECBUFFER_EMPTY;
+ Buffers[2].BufferType = SECBUFFER_EMPTY;
+ Buffers[3].BufferType = SECBUFFER_EMPTY;
- Message.ulVersion = SECBUFFER_VERSION;
- Message.cBuffers = 4;
- Message.pBuffers = Buffers;
+ Message.ulVersion = SECBUFFER_VERSION;
+ Message.cBuffers = 4;
+ Message.pBuffers = Buffers;
if (g_pSSPI->DecryptMessage != NULL && g_pSSPI->DecryptMessage != PVOID(0x80000000))
scRet = g_pSSPI->DecryptMessage(&ssl->hContext, &Message, 0, NULL);
@@ -791,7 +791,7 @@ int NetlibSslRead(SslHandle *ssl, char *buf, int num, int peek)
}
// Locate data and (optional) extra buffers.
- pDataBuffer = NULL;
+ pDataBuffer = NULL;
pExtraBuffer = NULL;
for (i = 1; i < 4; i++)
{
@@ -900,23 +900,23 @@ int NetlibSslWrite(SslHandle *ssl, const char *buf, int num)
cbMessage = min(Sizes.cbMaximumMessage, (DWORD)num - sendOff);
CopyMemory(pbMessage, buf+sendOff, cbMessage);
- Buffers[0].pvBuffer = pbDataBuffer;
- Buffers[0].cbBuffer = Sizes.cbHeader;
- Buffers[0].BufferType = SECBUFFER_STREAM_HEADER;
+ Buffers[0].pvBuffer = pbDataBuffer;
+ Buffers[0].cbBuffer = Sizes.cbHeader;
+ Buffers[0].BufferType = SECBUFFER_STREAM_HEADER;
- Buffers[1].pvBuffer = pbMessage;
- Buffers[1].cbBuffer = cbMessage;
- Buffers[1].BufferType = SECBUFFER_DATA;
+ Buffers[1].pvBuffer = pbMessage;
+ Buffers[1].cbBuffer = cbMessage;
+ Buffers[1].BufferType = SECBUFFER_DATA;
- Buffers[2].pvBuffer = pbMessage + cbMessage;
- Buffers[2].cbBuffer = Sizes.cbTrailer;
- Buffers[2].BufferType = SECBUFFER_STREAM_TRAILER;
+ Buffers[2].pvBuffer = pbMessage + cbMessage;
+ Buffers[2].cbBuffer = Sizes.cbTrailer;
+ Buffers[2].BufferType = SECBUFFER_STREAM_TRAILER;
- Buffers[3].BufferType = SECBUFFER_EMPTY;
+ Buffers[3].BufferType = SECBUFFER_EMPTY;
- Message.ulVersion = SECBUFFER_VERSION;
- Message.cBuffers = 4;
- Message.pBuffers = Buffers;
+ Message.ulVersion = SECBUFFER_VERSION;
+ Message.cBuffers = 4;
+ Message.pBuffers = Buffers;
if (g_pSSPI->EncryptMessage != NULL)
scRet = g_pSSPI->EncryptMessage(&ssl->hContext, 0, &Message, 0);
@@ -953,12 +953,12 @@ static INT_PTR GetSslApi(WPARAM, LPARAM lParam)
if (si->cbSize != sizeof(SSL_API))
return FALSE;
- si->connect = (HSSL (__cdecl *)(SOCKET, const char *, int))NetlibSslConnect;
- si->pending = (BOOL (__cdecl *)(HSSL))NetlibSslPending;
- si->read = (int (__cdecl *)(HSSL, char *, int, int))NetlibSslRead;
- si->write = (int (__cdecl *)(HSSL, const char *, int))NetlibSslWrite;
+ si->connect = (HSSL (__cdecl *)(SOCKET, const char *, int))NetlibSslConnect;
+ si->pending = (BOOL (__cdecl *)(HSSL))NetlibSslPending;
+ si->read = (int (__cdecl *)(HSSL, char *, int, int))NetlibSslRead;
+ si->write = (int (__cdecl *)(HSSL, const char *, int))NetlibSslWrite;
si->shutdown = (void (__cdecl *)(HSSL))NetlibSslShutdown;
- si->sfree = (void (__cdecl *)(HSSL))NetlibSslFree;
+ si->sfree = (void (__cdecl *)(HSSL))NetlibSslFree;
return TRUE;
}
diff --git a/src/modules/netlib/netlibupnp.cpp b/src/modules/netlib/netlibupnp.cpp
index 8bec975111..b75953d280 100644
--- a/src/modules/netlib/netlibupnp.cpp
+++ b/src/modules/netlib/netlibupnp.cpp
@@ -23,7 +23,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "..\..\core\commonheaders.h"
#include "netlib.h"
-static const char search_request_msg[] =
+static const char search_request_msg[] =
"M-SEARCH * HTTP/1.1\r\n"
"HOST: 239.255.255.250:1900\r\n"
"MAN: \"ssdp:discover\"\r\n"
@@ -31,55 +31,55 @@ static const char search_request_msg[] =
"ST: urn:schemas-upnp-org:service:%s\r\n"
"\r\n";
-static const char xml_get_hdr[] =
+static const char xml_get_hdr[] =
"GET %s HTTP/1.1\r\n"
"HOST: %s:%u\r\n"
"ACCEPT-LANGUAGE: *\r\n\r\n";
-static const char soap_post_hdr[] =
+static const char soap_post_hdr[] =
"POST %s HTTP/1.1\r\n"
"HOST: %s:%u\r\n"
"CONTENT-LENGTH: %u\r\n"
- "CONTENT-TYPE: text/xml; charset=\"utf-8\"\r\n"
+ "CONTENT-TYPE: text/xml; charset = \"utf-8\"\r\n"
"SOAPACTION: \"%s#%s\"\r\n\r\n"
"%s";
-static const char soap_post_hdr_m[] =
+static const char soap_post_hdr_m[] =
"M-POST %s URL HTTP/1.1\r\n"
"HOST: %s:%u\r\n"
"CONTENT-LENGTH: %u\r\n"
- "CONTENT-TYPE: text/xml; charset=\"utf-8\"\r\n"
- "MAN: \"http://schemas.xmlsoap.org/soap/envelope/\"; ns=01\r\n"
+ "CONTENT-TYPE: text/xml; charset = \"utf-8\"\r\n"
+ "MAN: \"http://schemas.xmlsoap.org/soap/envelope/\"; ns = 01\r\n"
"01-SOAPACTION: \"%s#%s\"\r\n\r\n"
"%s";
-static const char search_device[] =
+static const char search_device[] =
"<serviceType>%s</serviceType>";
-static const char soap_action[] =
- "<?xml version=\"1.0\"?>\r\n"
+static const char soap_action[] =
+ "<?xml version = \"1.0\"?>\r\n"
"<s:Envelope\r\n"
- " xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\"\r\n"
- " s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\">\r\n"
+ " xmlns:s = \"http://schemas.xmlsoap.org/soap/envelope/\"\r\n"
+ " s:encodingStyle = \"http://schemas.xmlsoap.org/soap/encoding/\">\r\n"
" <s:Body>\r\n"
- " <u:%s xmlns:u=\"%s\">\r\n"
+ " <u:%s xmlns:u = \"%s\">\r\n"
"%s"
" </u:%s>\r\n"
" </s:Body>\r\n"
"</s:Envelope>\r\n";
-static const char soap_query[] =
+static const char soap_query[] =
"<s:Envelope\r\n"
- " xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\"\r\n"
- " s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\">\r\n"
+ " xmlns:s = \"http://schemas.xmlsoap.org/soap/envelope/\"\r\n"
+ " s:encodingStyle = \"http://schemas.xmlsoap.org/soap/encoding/\">\r\n"
" <s:Body>\r\n"
- " <u:QueryStateVariable xmlns:u=\"urn:schemas-upnp-org:control-1-0\">\r\n"
+ " <u:QueryStateVariable xmlns:u = \"urn:schemas-upnp-org:control-1-0\">\r\n"
" <u:varName>%s</u:varName>\r\n"
" </u:QueryStateVariable>\r\n"
" </s:Body>\r\n"
"</s:Envelope>\r\n";
-static const char add_port_mapping[] =
+static const char add_port_mapping[] =
" <NewRemoteHost></NewRemoteHost>\r\n"
" <NewExternalPort>%i</NewExternalPort>\r\n"
" <NewProtocol>%s</NewProtocol>\r\n"
@@ -89,12 +89,12 @@ static const char add_port_mapping[] =
" <NewPortMappingDescription>Miranda</NewPortMappingDescription>\r\n"
" <NewLeaseDuration>0</NewLeaseDuration>\r\n";
-static const char delete_port_mapping[] =
+static const char delete_port_mapping[] =
" <NewRemoteHost></NewRemoteHost>\r\n"
" <NewExternalPort>%i</NewExternalPort>\r\n"
" <NewProtocol>%s</NewProtocol>\r\n";
-static const char get_port_mapping[] =
+static const char get_port_mapping[] =
" <NewPortMappingIndex>%i</NewPortMappingIndex>\r\n";
static bool gatewayFound;
@@ -249,7 +249,7 @@ static int httpTransact(char* szUrl, char* szResult, int resSize, char* szAction
const char* szPostHdr = soap_post_hdr;
char* szData = (char*)mir_alloc(4096);
- char* szReq = NULL;
+ char* szReq = NULL;
parseURL(szUrl, szHost, &sPort, szPath);
@@ -678,7 +678,7 @@ static void discoverUPnP(void)
}
txtParseParam(buf, NULL, "ST:", "\n", szDev, sizeof(szDev));
- txtParseParam(buf, "max-age", "=", "\n", age, sizeof(age));
+ txtParseParam(buf, "max-age", " = ", "\n", age, sizeof(age));
expireTime = atoi(lrtrimp(age));
lrtrim(szDev);
@@ -784,7 +784,7 @@ void NetlibUPnPDeletePortMapping(WORD extport, char* proto)
mir_snprintf(szData, 4096, delete_port_mapping, extport, proto);
httpTransact(szCtlUrl, szData, 4096, "DeletePortMapping", ControlAction);
- for (i = 0; i < numports; ++i)
+ for (i=0; i < numports; ++i)
if (portList[i] == extport && --numports > 0)
memmove(&portList[i], &portList[i+1], (numports - i) * sizeof(WORD));
@@ -802,7 +802,7 @@ void NetlibUPnPCleanup(void*)
{
int incoming = 0;
mir_cslock lck(csNetlibUser);
- for (int i = 0; i < netlibUser.getCount(); ++i)
+ for (int i=0; i < netlibUser.getCount(); ++i)
if (netlibUser[i]->user.flags & NUF_INCOMING) {
incoming = 1;
break;
@@ -851,7 +851,7 @@ void NetlibUPnPCleanup(void*)
if (j >= SIZEOF(ports))
break;
- for (k=0; k<numports; ++k)
+ for (k = 0; k<numports; ++k)
if (portList[k] == mport)
break;