summaryrefslogtreecommitdiff
path: root/src/modules/netlib
diff options
context:
space:
mode:
Diffstat (limited to 'src/modules/netlib')
-rw-r--r--src/modules/netlib/netlib.cpp60
-rw-r--r--src/modules/netlib/netlibbind.cpp4
-rw-r--r--src/modules/netlib/netlibhttp.cpp2
-rw-r--r--src/modules/netlib/netlibhttpproxy.cpp4
-rw-r--r--src/modules/netlib/netliblog.cpp20
-rw-r--r--src/modules/netlib/netlibopenconn.cpp18
-rw-r--r--src/modules/netlib/netlibopts.cpp60
-rw-r--r--src/modules/netlib/netlibpktrecver.cpp12
-rw-r--r--src/modules/netlib/netlibupnp.cpp4
9 files changed, 92 insertions, 92 deletions
diff --git a/src/modules/netlib/netlib.cpp b/src/modules/netlib/netlib.cpp
index ed084b523d..80e005ad7a 100644
--- a/src/modules/netlib/netlib.cpp
+++ b/src/modules/netlib/netlib.cpp
@@ -69,13 +69,13 @@ int NetlibEnterNestedCS(struct NetlibConnection *nlc,int which)
DWORD dwCurrentThreadId=GetCurrentThreadId();
WaitForSingleObject(hConnectionHeaderMutex,INFINITE);
- if (nlc==NULL || nlc->handleType!=NLH_CONNECTION) {
+ if (nlc == NULL || nlc->handleType != NLH_CONNECTION) {
ReleaseMutex(hConnectionHeaderMutex);
SetLastError(ERROR_INVALID_PARAMETER);
return 0;
}
nlncs = (which == NLNCS_SEND) ? &nlc->ncsSend : &nlc->ncsRecv;
- if (nlncs->lockCount && nlncs->dwOwningThreadId==dwCurrentThreadId) {
+ if (nlncs->lockCount && nlncs->dwOwningThreadId == dwCurrentThreadId) {
nlncs->lockCount++;
ReleaseMutex(hConnectionHeaderMutex);
return 1;
@@ -86,14 +86,14 @@ int NetlibEnterNestedCS(struct NetlibConnection *nlc,int which)
WaitForSingleObject(nlncs->hMutex,INFINITE);
nlncs->dwOwningThreadId=dwCurrentThreadId;
nlncs->lockCount=1;
- if (InterlockedDecrement(&nlc->dontCloseNow)==0)
+ if (InterlockedDecrement(&nlc->dontCloseNow) == 0)
SetEvent(nlc->hOkToCloseEvent);
return 1;
}
void NetlibLeaveNestedCS(struct NetlibNestedCriticalSection *nlncs)
{
- if (--nlncs->lockCount==0) {
+ if (--nlncs->lockCount == 0) {
nlncs->dwOwningThreadId=0;
ReleaseMutex(nlncs->hMutex);
}
@@ -105,8 +105,8 @@ static INT_PTR GetNetlibUserSettingInt(const char *szUserModule,const char *szSe
if (DBGetContactSetting(NULL,szUserModule,szSetting,&dbv)
&& DBGetContactSetting(NULL,"Netlib",szSetting,&dbv))
return defValue;
- if (dbv.type==DBVT_BYTE) return dbv.bVal;
- if (dbv.type==DBVT_WORD) return dbv.wVal;
+ if (dbv.type == DBVT_BYTE) return dbv.bVal;
+ if (dbv.type == DBVT_WORD) return dbv.wVal;
return dbv.dVal;
}
@@ -122,7 +122,7 @@ static char *GetNetlibUserSettingString(const char *szUserModule,const char *szS
if (decode) CallService(MS_DB_CRYPT_DECODESTRING, strlen(dbv.pszVal) + 1, (LPARAM)dbv.pszVal);
szRet=mir_strdup(dbv.pszVal);
DBFreeVariant(&dbv);
- if (szRet==NULL) SetLastError(ERROR_OUTOFMEMORY);
+ if (szRet == NULL) SetLastError(ERROR_OUTOFMEMORY);
return szRet;
}
}
@@ -132,9 +132,9 @@ static INT_PTR NetlibRegisterUser(WPARAM,LPARAM lParam)
NETLIBUSER *nlu=(NETLIBUSER*)lParam;
struct NetlibUser *thisUser;
- if (nlu==NULL || nlu->cbSize!=sizeof(NETLIBUSER) || nlu->szSettingsModule==NULL
- || (!(nlu->flags&NUF_NOOPTIONS) && nlu->szDescriptiveName==NULL)
- || (nlu->flags&NUF_HTTPGATEWAY && (nlu->pfnHttpGatewayInit==NULL))) {
+ if (nlu == NULL || nlu->cbSize != sizeof(NETLIBUSER) || nlu->szSettingsModule == NULL
+ || (!(nlu->flags&NUF_NOOPTIONS) && nlu->szDescriptiveName == NULL)
+ || (nlu->flags&NUF_HTTPGATEWAY && (nlu->pfnHttpGatewayInit == NULL))) {
SetLastError(ERROR_INVALID_PARAMETER);
return 0;
}
@@ -156,9 +156,9 @@ 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
- || (nlu->szDescriptiveName && thisUser->user.ptszDescriptiveName ==NULL)
- || (nlu->szHttpGatewayUserAgent && (thisUser->user.szHttpGatewayUserAgent=mir_strdup(nlu->szHttpGatewayUserAgent))==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))
{
mir_free(thisUser);
SetLastError(ERROR_OUTOFMEMORY);
@@ -172,9 +172,9 @@ static INT_PTR NetlibRegisterUser(WPARAM,LPARAM lParam)
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)
+ 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;
}
@@ -204,7 +204,7 @@ static INT_PTR NetlibGetUserSettings(WPARAM wParam,LPARAM lParam)
NETLIBUSERSETTINGS *nlus=(NETLIBUSERSETTINGS*)lParam;
struct NetlibUser *nlu=(struct NetlibUser*)wParam;
- if (GetNetlibHandleType(nlu)!=NLH_USER || nlus==NULL || nlus->cbSize!=sizeof(NETLIBUSERSETTINGS)) {
+ if (GetNetlibHandleType(nlu) != NLH_USER || nlus == NULL || nlus->cbSize != sizeof(NETLIBUSERSETTINGS)) {
SetLastError(ERROR_INVALID_PARAMETER);
return 0;
}
@@ -217,7 +217,7 @@ static INT_PTR NetlibSetUserSettings(WPARAM wParam,LPARAM lParam)
NETLIBUSERSETTINGS *nlus=(NETLIBUSERSETTINGS*)lParam;
struct NetlibUser *nlu=(struct NetlibUser*)wParam;
- if (GetNetlibHandleType(nlu)!=NLH_USER || nlus==NULL || nlus->cbSize!=sizeof(NETLIBUSERSETTINGS)) {
+ if (GetNetlibHandleType(nlu) != NLH_USER || nlus == NULL || nlus->cbSize != sizeof(NETLIBUSERSETTINGS)) {
SetLastError(ERROR_INVALID_PARAMETER);
return 0;
}
@@ -415,7 +415,7 @@ INT_PTR NetlibHttpUrlEncode(WPARAM,LPARAM lParam)
unsigned char *pszIn,*pszOut;
int outputLen;
- if (szInput==NULL) {
+ if (szInput == NULL) {
SetLastError(ERROR_INVALID_PARAMETER);
return (INT_PTR)(char*)NULL;
}
@@ -427,7 +427,7 @@ INT_PTR NetlibHttpUrlEncode(WPARAM,LPARAM lParam)
else outputLen+=3;
}
szOutput=(unsigned char*)HeapAlloc(GetProcessHeap(),0,outputLen+1);
- if (szOutput==NULL) {
+ if (szOutput == NULL) {
SetLastError(ERROR_OUTOFMEMORY);
return (INT_PTR)(unsigned char*)NULL;
}
@@ -436,7 +436,7 @@ INT_PTR NetlibHttpUrlEncode(WPARAM,LPARAM lParam)
(65 <= *pszIn && *pszIn <= 90) ||
(97 <= *pszIn && *pszIn <= 122) ||
*pszIn == '-' || *pszIn == '_' || *pszIn == '.') *pszOut++=*pszIn;
- else if (*pszIn==' ') *pszOut++='+';
+ else if (*pszIn == ' ') *pszOut++='+';
else {
*pszOut++='%';
*pszOut++=szHexDigits[*pszIn>>4];
@@ -455,7 +455,7 @@ INT_PTR NetlibBase64Encode(WPARAM, LPARAM lParam)
char *pszOut;
PBYTE pbIn;
- if (nlb64==NULL || nlb64->pszEncoded==NULL || nlb64->pbDecoded==NULL) {
+ if (nlb64 == NULL || nlb64->pszEncoded == NULL || nlb64->pbDecoded == NULL) {
SetLastError(ERROR_INVALID_PARAMETER);
return 0;
}
@@ -466,7 +466,7 @@ INT_PTR NetlibBase64Encode(WPARAM, LPARAM lParam)
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) {
+ if (nlb64->cbDecoded-iIn == 1) {
pszOut[1]=base64chars[(pbIn[0]&3)<<4];
pszOut[2]='=';
pszOut[3]='=';
@@ -474,7 +474,7 @@ INT_PTR NetlibBase64Encode(WPARAM, LPARAM lParam)
break;
}
pszOut[1]=base64chars[((pbIn[0]&3)<<4)|(pbIn[1]>>4)];
- if (nlb64->cbDecoded-iIn==2) {
+ if (nlb64->cbDecoded-iIn == 2) {
pszOut[2]=base64chars[(pbIn[1]&0xF)<<2];
pszOut[3]='=';
pszOut+=4;
@@ -492,9 +492,9 @@ 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=='+') return 62;
- if (c=='/') return 63;
- if (c=='=') return 64;
+ if (c == '+') return 62;
+ if (c == '/') return 63;
+ if (c == '=') return 64;
return 255;
}
@@ -506,7 +506,7 @@ INT_PTR NetlibBase64Decode(WPARAM, LPARAM lParam)
BYTE b1,b2,b3,b4;
int iIn;
- if (nlb64==NULL || nlb64->pszEncoded==NULL || nlb64->pbDecoded==NULL) {
+ if (nlb64 == NULL || nlb64->pszEncoded == NULL || nlb64->pbDecoded == NULL) {
SetLastError(ERROR_INVALID_PARAMETER);
return 0;
}
@@ -524,14 +524,14 @@ INT_PTR NetlibBase64Decode(WPARAM, LPARAM lParam)
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) {
+ 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);
- if (b3==64) {nlb64->cbDecoded-=2; break;}
+ if (b3 == 64) {nlb64->cbDecoded-=2; break;}
pbOut[1]=(b2<<4)|(b3>>2);
- if (b4==64) {nlb64->cbDecoded--; break;}
+ if (b4 == 64) {nlb64->cbDecoded--; break;}
pbOut[2]=b4|(b3<<6);
}
return 1;
diff --git a/src/modules/netlib/netlibbind.cpp b/src/modules/netlib/netlibbind.cpp
index 3f28551434..5e8d76d464 100644
--- a/src/modules/netlib/netlibbind.cpp
+++ b/src/modules/netlib/netlibbind.cpp
@@ -221,7 +221,7 @@ INT_PTR NetlibBindPort(WPARAM wParam, LPARAM lParam)
sin6.sin6_family = AF_INET6;
/* if the netlib user wanted a free port given in the range, then
- they better have given wPort==0, let's hope so */
+ 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))
@@ -234,7 +234,7 @@ INT_PTR NetlibBindPort(WPARAM wParam, LPARAM lParam)
}
else
{
- /* if ->wPort==0 then they'll get any free port, otherwise they'll
+ /* if ->wPort == 0 then they'll get any free port, otherwise they'll
be asking for whatever was in nlb->wPort*/
if (nlb->wPort != 0)
{
diff --git a/src/modules/netlib/netlibhttp.cpp b/src/modules/netlib/netlibhttp.cpp
index d0be2f35b2..fb027366bc 100644
--- a/src/modules/netlib/netlibhttp.cpp
+++ b/src/modules/netlib/netlibhttp.cpp
@@ -400,7 +400,7 @@ static int HttpPeekFirstResponseLine(NetlibConnection *nlc, DWORD dwTimeoutTime,
static int SendHttpRequestAndData(struct NetlibConnection *nlc,struct ResizableCharBuffer *httpRequest,NETLIBHTTPREQUEST *nlhr,int sendContentLengthHeader)
{
- bool sendData = (nlhr->requestType==REQUEST_POST || nlhr->requestType==REQUEST_PUT);
+ bool sendData = (nlhr->requestType == REQUEST_POST || nlhr->requestType == REQUEST_PUT);
if (sendContentLengthHeader && sendData)
AppendToCharBuffer(httpRequest,"Content-Length: %d\r\n\r\n", nlhr->dataLength);
diff --git a/src/modules/netlib/netlibhttpproxy.cpp b/src/modules/netlib/netlibhttpproxy.cpp
index fa6c2368b5..a760aee43d 100644
--- a/src/modules/netlib/netlibhttpproxy.cpp
+++ b/src/modules/netlib/netlibhttpproxy.cpp
@@ -505,7 +505,7 @@ INT_PTR NetlibHttpGatewaySetInfo(WPARAM wParam,LPARAM lParam)
INT_PTR NetlibHttpSetSticky(WPARAM wParam, LPARAM lParam)
{
struct NetlibUser * nu = (struct NetlibUser*)wParam;
- if (GetNetlibHandleType(nu)!=NLH_USER) return ERROR_INVALID_PARAMETER;
+ if (GetNetlibHandleType(nu) != NLH_USER) return ERROR_INVALID_PARAMETER;
mir_free(nu->szStickyHeaders);
nu->szStickyHeaders = mir_strdup((char*)lParam); // pointer is ours
return 0;
@@ -515,7 +515,7 @@ INT_PTR NetlibHttpSetPollingTimeout(WPARAM wParam, LPARAM lParam)
{
int oldTimeout;
struct NetlibConnection *nlc=(struct NetlibConnection*)wParam;
- if (GetNetlibHandleType(nlc)!=NLH_CONNECTION) return -1;
+ if (GetNetlibHandleType(nlc) != NLH_CONNECTION) return -1;
oldTimeout = nlc->pollingTimeout;
nlc->pollingTimeout = lParam;
return oldTimeout;
diff --git a/src/modules/netlib/netliblog.cpp b/src/modules/netlib/netliblog.cpp
index d974406047..92496eaa5c 100644
--- a/src/modules/netlib/netliblog.cpp
+++ b/src/modules/netlib/netliblog.cpp
@@ -137,8 +137,8 @@ static INT_PTR CALLBACK LogOptionsDlgProc(HWND hwndDlg,UINT message,WPARAM wPara
break;
*/
case IDC_FILENAME:
- if (HIWORD(wParam)!=EN_CHANGE) break;
- if ((HWND)lParam==GetFocus())
+ if (HIWORD(wParam) != EN_CHANGE) break;
+ if ((HWND)lParam == GetFocus())
CheckDlgButton(hwndDlg,IDC_TOFILE,BST_CHECKED);
{
@@ -161,7 +161,7 @@ static INT_PTR CALLBACK LogOptionsDlgProc(HWND hwndDlg,UINT message,WPARAM wPara
ofn.lStructSize=OPENFILENAME_SIZE_VERSION_400;
ofn.hwndOwner=hwndDlg;
ofn.Flags=OFN_HIDEREADONLY | OFN_DONTADDTORECENT;
- if (LOWORD(wParam)==IDC_FILENAMEBROWSE) {
+ if (LOWORD(wParam) == IDC_FILENAMEBROWSE) {
ofn.lpstrTitle=TranslateT("Select where log file will be created");
} else {
ofn.Flags|=OFN_PATHMUSTEXIST|OFN_FILEMUSTEXIST;
@@ -177,12 +177,12 @@ static INT_PTR CALLBACK LogOptionsDlgProc(HWND hwndDlg,UINT message,WPARAM wPara
ofn.lpstrFile=str;
ofn.nMaxFile=SIZEOF(str)-2;
ofn.nMaxFileTitle=MAX_PATH;
- if (LOWORD(wParam)==IDC_FILENAMEBROWSE) {
+ if (LOWORD(wParam) == IDC_FILENAMEBROWSE) {
if (!GetSaveFileName(&ofn)) return 1;
} else {
if (!GetOpenFileName(&ofn)) return 1;
}
- if (LOWORD(wParam)==IDC_RUNATSTARTBROWSE && _tcschr(str,' ')!=NULL) {
+ if (LOWORD(wParam) == IDC_RUNATSTARTBROWSE && _tcschr(str,' ') != NULL) {
MoveMemory(str+1,str,SIZEOF(str)-2);
str[0]='"';
lstrcat(str,_T("\""));
@@ -241,10 +241,10 @@ static INT_PTR CALLBACK LogOptionsDlgProc(HWND hwndDlg,UINT message,WPARAM wPara
tvi.mask=TVIF_HANDLE|TVIF_PARAM|TVIF_STATE|TVIF_TEXT;
tvi.hItem=TreeView_GetRoot(hwndFilter);
- while(tvi.hItem)
+ while (tvi.hItem)
{
TreeView_GetItem(hwndFilter,&tvi);
- checked = ((tvi.state&TVIS_STATEIMAGEMASK)>>12==2);
+ checked = ((tvi.state&TVIS_STATEIMAGEMASK)>>12 == 2);
if (tvi.lParam == -1) {
logOptions.toLog = checked;
@@ -298,7 +298,7 @@ static INT_PTR CALLBACK LogOptionsDlgProc(HWND hwndDlg,UINT message,WPARAM wPara
void NetlibLogShowOptions(void)
{
- if (logOptions.hwndOpts==NULL)
+ if (logOptions.hwndOpts == NULL)
logOptions.hwndOpts=CreateDialog(hMirandaInst,MAKEINTRESOURCE(IDD_NETLIBLOGOPTS),NULL,LogOptionsDlgProc);
SetForegroundWindow(logOptions.hwndOpts);
}
@@ -490,7 +490,7 @@ void NetlibDumpData(struct NetlibConnection *nlc,PBYTE buf,int len,int sent,int
int i;
for (i = 0; i<len; i++)
{
- if ((buf[i]<' ' && buf[i]!='\t' && buf[i]!='\r' && buf[i]!='\n') || buf[i]>=0x80)
+ if ((buf[i]<' ' && buf[i] != '\t' && buf[i] != '\r' && buf[i] != '\n') || buf[i]>=0x80)
{
isText = 0;
break;
@@ -533,7 +533,7 @@ void NetlibDumpData(struct NetlibConnection *nlc,PBYTE buf,int len,int sent,int
pszBuf += wsprintfA(pszBuf, "%08X: ", line);
// Dump data as hex
for (col = 0; col < colsInLine; col++)
- pszBuf += wsprintfA(pszBuf, "%02X%c", buf[line + col], ((col&3)==3 && col != 15)?'-':' ');
+ pszBuf += wsprintfA(pszBuf, "%02X%c", buf[line + col], ((col&3) == 3 && col != 15)?'-':' ');
// Fill out last line with blanks
for ( ; col<16; col++)
{
diff --git a/src/modules/netlib/netlibopenconn.cpp b/src/modules/netlib/netlibopenconn.cpp
index 086269c021..0be23f2da1 100644
--- a/src/modules/netlib/netlibopenconn.cpp
+++ b/src/modules/netlib/netlibopenconn.cpp
@@ -168,7 +168,7 @@ static int NetlibInitSocks5Connection(struct NetlibConnection *nlc,struct Netlib
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) {
+ if (NLSend(nlc,(char*)buf,3,MSG_DUMPPROXY) == SOCKET_ERROR) {
NetlibLogf(nlu,"%s %d: %s() failed (%u)",__FILE__,__LINE__,"NLSend",GetLastError());
return 0;
}
@@ -178,13 +178,13 @@ static int NetlibInitSocks5Connection(struct NetlibConnection *nlc,struct Netlib
NetlibLogf(nlu,"%s %d: %s() failed (%u)",__FILE__,__LINE__,"RecvUntilTimeout",GetLastError());
return 0;
}
- if ((buf[1]!=0 && buf[1]!=2)) {
+ if ((buf[1] != 0 && buf[1] != 2)) {
SetLastError(ERROR_INVALID_ID_AUTHORITY);
NetlibLogf(nlu,"%s %d: %s() failed (%u)",__FILE__,__LINE__,"NLRecv",GetLastError());
return 0;
}
- if (buf[1]==2) { //rfc1929
+ if (buf[1] == 2) { //rfc1929
int nUserLen,nPassLen;
PBYTE pAuthBuf;
@@ -196,7 +196,7 @@ static int NetlibInitSocks5Connection(struct NetlibConnection *nlc,struct Netlib
memcpy(pAuthBuf+2,nlu->settings.szProxyAuthUser,nUserLen);
pAuthBuf[2+nUserLen]=nPassLen;
memcpy(pAuthBuf+3+nUserLen,nlu->settings.szProxyAuthPassword,nPassLen);
- if (NLSend(nlc,(char*)pAuthBuf,3+nUserLen+nPassLen,MSG_DUMPPROXY)==SOCKET_ERROR) {
+ if (NLSend(nlc,(char*)pAuthBuf,3+nUserLen+nPassLen,MSG_DUMPPROXY) == SOCKET_ERROR) {
NetlibLogf(nlu,"%s %d: %s() failed (%u)",__FILE__,__LINE__,"NLSend",GetLastError());
mir_free(pAuthBuf);
return 0;
@@ -237,7 +237,7 @@ static int NetlibInitSocks5Connection(struct NetlibConnection *nlc,struct Netlib
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
+ if (hostIP == INADDR_NONE) { //DNS lookup through proxy
pInit[3]=3;
pInit[4]=nHostLen-1;
memcpy(pInit+5,nloc->szHost,nHostLen-1);
@@ -247,7 +247,7 @@ static int NetlibInitSocks5Connection(struct NetlibConnection *nlc,struct Netlib
*(PDWORD)(pInit+4)=hostIP;
}
*(PWORD)(pInit+4+nHostLen)=htons(nloc->wPort);
- if (NLSend(nlc,(char*)pInit,6+nHostLen,MSG_DUMPPROXY)==SOCKET_ERROR) {
+ 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);
return 0;
@@ -260,7 +260,7 @@ static int NetlibInitSocks5Connection(struct NetlibConnection *nlc,struct Netlib
return 0;
}
- if ( buf[0]!=5 || buf[1] ) {
+ if ( buf[0] != 5 || buf[1] ) {
const char* err = "Unknown response";
if ( buf[0] != 5 )
SetLastError(ERROR_BAD_FORMAT);
@@ -348,7 +348,7 @@ static bool NetlibInitHttpsConnection(struct NetlibConnection *nlc, struct Netli
}
NetlibHttpSetLastErrorUsingHttpResult(nlhrReply->resultCode);
- NetlibLogf(nlu,"%s %d: %s request failed (%u %s)",__FILE__,__LINE__,nlu->settings.proxyType==PROXYTYPE_HTTP?"HTTP":"HTTPS",nlhrReply->resultCode,nlhrReply->szResultDescr);
+ NetlibLogf(nlu,"%s %d: %s request failed (%u %s)",__FILE__,__LINE__,nlu->settings.proxyType == PROXYTYPE_HTTP?"HTTP":"HTTPS",nlhrReply->resultCode,nlhrReply->szResultDescr);
NetlibHttpFreeRequestStruct(0, (LPARAM)nlhrReply);
return 0;
}
@@ -361,7 +361,7 @@ static void FreePartiallyInitedConnection(struct NetlibConnection *nlc)
{
DWORD dwOriginalLastError=GetLastError();
- if (nlc->s!=INVALID_SOCKET) closesocket(nlc->s);
+ if (nlc->s != INVALID_SOCKET) closesocket(nlc->s);
mir_free(nlc->nlhpi.szHttpPostUrl);
mir_free(nlc->nlhpi.szHttpGetUrl);
mir_free((char*)nlc->nloc.szHost);
diff --git a/src/modules/netlib/netlibopts.cpp b/src/modules/netlib/netlibopts.cpp
index 0988f5d552..48d4f4c291 100644
--- a/src/modules/netlib/netlibopts.cpp
+++ b/src/modules/netlib/netlibopts.cpp
@@ -86,7 +86,7 @@ static void EnableMultipleControls(HWND hwndDlg,const UINT *controls,int cContro
static void AddProxyTypeItem(HWND hwndDlg,int type,int selectType)
{
int i;
- i = SendDlgItemMessage(hwndDlg,IDC_PROXYTYPE,CB_ADDSTRING,0,(LPARAM)(type==0?TranslateTS(szProxyTypes[type]):szProxyTypes[type]));
+ i = SendDlgItemMessage(hwndDlg,IDC_PROXYTYPE,CB_ADDSTRING,0,(LPARAM)(type == 0?TranslateTS(szProxyTypes[type]):szProxyTypes[type]));
SendDlgItemMessage(hwndDlg, IDC_PROXYTYPE, CB_SETITEMDATA, i, type);
if (type == selectType) SendDlgItemMessage(hwndDlg, IDC_PROXYTYPE, CB_SETCURSEL, i, 0);
}
@@ -103,23 +103,23 @@ static void CopySettingsStruct(NETLIBUSERSETTINGS *dest,NETLIBUSERSETTINGS *sour
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 {
@@ -142,8 +142,8 @@ static void CombineSettingsStructs(NETLIBUSERSETTINGS *dest,DWORD *destFlags,NET
}
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 {
@@ -153,7 +153,7 @@ static void CombineSettingsStructs(NETLIBUSERSETTINGS *dest,DWORD *destFlags,NET
if (dest->szIncomingPorts) dest->szIncomingPorts=mir_strdup(dest->szIncomingPorts);
}
}
- if ((*destFlags&NUF_NOHTTPSOPTION)!=(sourceFlags&NUF_NOHTTPSOPTION))
+ if ((*destFlags&NUF_NOHTTPSOPTION) != (sourceFlags&NUF_NOHTTPSOPTION))
*destFlags=(*destFlags|sourceFlags)&~NUF_NOHTTPSOPTION;
else *destFlags|=sourceFlags;
}
@@ -162,7 +162,7 @@ static void ChangeSettingIntByCheckbox(HWND hwndDlg,UINT ctrlId,int iUser,int me
{
int newValue,i;
- newValue=IsDlgButtonChecked(hwndDlg,ctrlId)!=BST_CHECKED;
+ newValue=IsDlgButtonChecked(hwndDlg,ctrlId) != BST_CHECKED;
CheckDlgButton(hwndDlg,ctrlId,newValue?BST_CHECKED:BST_UNCHECKED);
if (iUser == -1)
{
@@ -252,13 +252,13 @@ void NetlibSaveUserSettingsStruct(const char *szSettingsModule,NETLIBUSERSETTING
if (thisUser->user.flags & NUF_NOOPTIONS) 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);
LeaveCriticalSection(&csNetlibUser);
@@ -368,7 +368,7 @@ static INT_PTR CALLBACK DlgProcNetlibOpts(HWND hwndDlg, UINT msg, WPARAM wParam,
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;
@@ -399,8 +399,8 @@ static INT_PTR CALLBACK DlgProcNetlibOpts(HWND hwndDlg, UINT msg, WPARAM wParam,
EnableWindow(GetDlgItem(hwndDlg,IDC_PROXYPORT), enableServer);
}
else EnableMultipleControls(hwndDlg,useProxyControls,SIZEOF(useProxyControls),FALSE);
- EnableMultipleControls(hwndDlg,specifyPortsControls,SIZEOF(specifyPortsControls),IsDlgButtonChecked(hwndDlg,IDC_SPECIFYPORTS)!=BST_UNCHECKED);
- EnableMultipleControls(hwndDlg,specifyOPortsControls,SIZEOF(specifyOPortsControls),IsDlgButtonChecked(hwndDlg,IDC_SPECIFYPORTSO)!=BST_UNCHECKED);
+ EnableMultipleControls(hwndDlg,specifyPortsControls,SIZEOF(specifyPortsControls),IsDlgButtonChecked(hwndDlg,IDC_SPECIFYPORTS) != BST_UNCHECKED);
+ EnableMultipleControls(hwndDlg,specifyOPortsControls,SIZEOF(specifyOPortsControls),IsDlgButtonChecked(hwndDlg,IDC_SPECIFYPORTSO) != BST_UNCHECKED);
break;
}
case WM_COMMAND:
@@ -408,7 +408,7 @@ static INT_PTR CALLBACK DlgProcNetlibOpts(HWND hwndDlg, UINT msg, WPARAM wParam,
switch(LOWORD(wParam))
{
case IDC_NETLIBUSERS:
- if (HIWORD(wParam)==CBN_SELCHANGE) SendMessage(hwndDlg,M_REFRESHALL,0,0);
+ if (HIWORD(wParam) == CBN_SELCHANGE) SendMessage(hwndDlg,M_REFRESHALL,0,0);
return 0;
case IDC_LOGOPTIONS:
@@ -462,11 +462,11 @@ static INT_PTR CALLBACK DlgProcNetlibOpts(HWND hwndDlg, UINT msg, WPARAM wParam,
ChangeSettingIntByCheckbox(hwndDlg,LOWORD(wParam),iUser,offsetof(NETLIBUSERSETTINGS,validateSSL));
break;
case IDC_PROXYHOST:
- if (HIWORD(wParam)!=EN_CHANGE || (HWND)lParam!=GetFocus()) return 0;
+ if (HIWORD(wParam) != EN_CHANGE || (HWND)lParam != GetFocus()) return 0;
ChangeSettingStringByEdit(hwndDlg,LOWORD(wParam),iUser,offsetof(NETLIBUSERSETTINGS,szProxyServer));
break;
case IDC_PROXYPORT:
- if (HIWORD(wParam)!=EN_CHANGE || (HWND)lParam!=GetFocus()) return 0;
+ if (HIWORD(wParam) != EN_CHANGE || (HWND)lParam != GetFocus()) return 0;
{ int newValue,i;
newValue=GetDlgItemInt(hwndDlg,LOWORD(wParam),NULL,FALSE);
if (iUser == -1)
@@ -479,19 +479,19 @@ static INT_PTR CALLBACK DlgProcNetlibOpts(HWND hwndDlg, UINT msg, WPARAM wParam,
}
break;
case IDC_PROXYUSER:
- if (HIWORD(wParam)!=EN_CHANGE || (HWND)lParam!=GetFocus()) return 0;
+ if (HIWORD(wParam) != EN_CHANGE || (HWND)lParam != GetFocus()) return 0;
ChangeSettingStringByEdit(hwndDlg,LOWORD(wParam),iUser,offsetof(NETLIBUSERSETTINGS,szProxyAuthUser));
break;
case IDC_PROXYPASS:
- if (HIWORD(wParam)!=EN_CHANGE || (HWND)lParam!=GetFocus()) return 0;
+ if (HIWORD(wParam) != EN_CHANGE || (HWND)lParam != GetFocus()) return 0;
ChangeSettingStringByEdit(hwndDlg,LOWORD(wParam),iUser,offsetof(NETLIBUSERSETTINGS,szProxyAuthPassword));
break;
case IDC_PORTSRANGE:
- if (HIWORD(wParam)!=EN_CHANGE || (HWND)lParam!=GetFocus()) return 0;
+ if (HIWORD(wParam) != EN_CHANGE || (HWND)lParam != GetFocus()) return 0;
ChangeSettingStringByEdit(hwndDlg,LOWORD(wParam),iUser,offsetof(NETLIBUSERSETTINGS,szIncomingPorts));
break;
case IDC_PORTSRANGEO:
- if (HIWORD(wParam)!=EN_CHANGE || (HWND)lParam!=GetFocus()) return 0;
+ if (HIWORD(wParam) != EN_CHANGE || (HWND)lParam != GetFocus()) return 0;
ChangeSettingStringByEdit(hwndDlg,LOWORD(wParam),iUser,offsetof(NETLIBUSERSETTINGS,szOutgoingPorts));
break;
}
diff --git a/src/modules/netlib/netlibpktrecver.cpp b/src/modules/netlib/netlibpktrecver.cpp
index 91fc4ddbe9..401e545792 100644
--- a/src/modules/netlib/netlibpktrecver.cpp
+++ b/src/modules/netlib/netlibpktrecver.cpp
@@ -28,12 +28,12 @@ INT_PTR NetlibPacketRecverCreate(WPARAM wParam,LPARAM lParam)
struct NetlibConnection *nlc=(struct NetlibConnection*)wParam;
struct NetlibPacketRecver *nlpr;
- if (GetNetlibHandleType(nlc)!=NLH_CONNECTION || lParam==0) {
+ 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));
- if (nlpr==NULL) {
+ if (nlpr == NULL) {
SetLastError(ERROR_OUTOFMEMORY);
return (INT_PTR)(struct NetlibPacketRecver*)NULL;
}
@@ -53,7 +53,7 @@ INT_PTR NetlibPacketRecverGetMore(WPARAM wParam,LPARAM lParam)
NETLIBPACKETRECVER *nlprParam=(NETLIBPACKETRECVER*)lParam;
INT_PTR recvResult;
- if (GetNetlibHandleType(nlpr)!=NLH_PACKETRECVER || nlprParam==NULL || nlprParam->cbSize!=sizeof(NETLIBPACKETRECVER) || nlprParam->bytesUsed>nlpr->packetRecver.bytesAvailable) {
+ if (GetNetlibHandleType(nlpr) != NLH_PACKETRECVER || nlprParam == NULL || nlprParam->cbSize != sizeof(NETLIBPACKETRECVER) || nlprParam->bytesUsed>nlpr->packetRecver.bytesAvailable) {
SetLastError(ERROR_INVALID_PARAMETER);
return SOCKET_ERROR;
}
@@ -62,8 +62,8 @@ INT_PTR NetlibPacketRecverGetMore(WPARAM wParam,LPARAM lParam)
return SOCKET_ERROR;
}
nlpr->packetRecver.dwTimeout=nlprParam->dwTimeout;
- if (nlprParam->bytesUsed==0) {
- if (nlpr->packetRecver.bytesAvailable==nlpr->packetRecver.bufferSize) {
+ if (nlprParam->bytesUsed == 0) {
+ if (nlpr->packetRecver.bytesAvailable == nlpr->packetRecver.bufferSize) {
nlpr->packetRecver.bytesAvailable=0;
NetlibLogf(nlpr->nlc->nlu,"Packet recver: packet overflowed buffer, ditching");
}
@@ -72,7 +72,7 @@ INT_PTR NetlibPacketRecverGetMore(WPARAM wParam,LPARAM lParam)
MoveMemory(nlpr->packetRecver.buffer,nlpr->packetRecver.buffer+nlprParam->bytesUsed,nlpr->packetRecver.bytesAvailable-nlprParam->bytesUsed);
nlpr->packetRecver.bytesAvailable-=nlprParam->bytesUsed;
}
- if (nlprParam->dwTimeout!=INFINITE) {
+ if (nlprParam->dwTimeout != INFINITE) {
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/netlibupnp.cpp b/src/modules/netlib/netlibupnp.cpp
index 639cade4de..655bb781eb 100644
--- a/src/modules/netlib/netlibupnp.cpp
+++ b/src/modules/netlib/netlibupnp.cpp
@@ -622,7 +622,7 @@ static void discoverUPnP(void)
if (he)
{
- while(he->h_addr_list[nip]) ++nip;
+ while (he->h_addr_list[nip]) ++nip;
ips = ( unsigned* )mir_alloc(nip * sizeof(unsigned));
@@ -795,7 +795,7 @@ void NetlibUPnPDeletePortMapping(WORD extport, char* proto)
void NetlibUPnPCleanup(void*)
{
- if (DBGetContactSettingByte(NULL,"Netlib","NLEnableUPnP",1)==0)
+ if (DBGetContactSettingByte(NULL,"Netlib","NLEnableUPnP",1) == 0)
// upnp is disabled globally, no need for a cleanup
return;