summaryrefslogtreecommitdiff
path: root/src/modules/netlib/netlib.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/modules/netlib/netlib.cpp')
-rw-r--r--src/modules/netlib/netlib.cpp60
1 files changed, 30 insertions, 30 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;