diff options
author | George Hazan <george.hazan@gmail.com> | 2015-06-20 20:26:33 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2015-06-20 20:26:33 +0000 |
commit | 71d7a52d2346ea8c52cf1517c33849e4c7f0e377 (patch) | |
tree | 6d05e848b9c81241d8e03dc001d97763629a48af /src/mir_app | |
parent | 66cd901f0ff3e4ff029a2d7cf2af93745a2d6dfb (diff) |
minor code cleaning
git-svn-id: http://svn.miranda-ng.org/main/trunk@14293 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'src/mir_app')
-rw-r--r-- | src/mir_app/src/netlibhttp.cpp | 24 | ||||
-rw-r--r-- | src/mir_app/src/netlibhttpproxy.cpp | 34 | ||||
-rw-r--r-- | src/mir_app/src/netlibsock.cpp | 2 |
3 files changed, 31 insertions, 29 deletions
diff --git a/src/mir_app/src/netlibhttp.cpp b/src/mir_app/src/netlibhttp.cpp index c43d6cc13c..f06438c306 100644 --- a/src/mir_app/src/netlibhttp.cpp +++ b/src/mir_app/src/netlibhttp.cpp @@ -52,7 +52,7 @@ struct ProxyAuth mir_free(szServer);
mir_free(szMethod);
}
- static int Compare(const ProxyAuth* p1, const ProxyAuth* p2)
+ static int Compare(const ProxyAuth *p1, const ProxyAuth *p2)
{ return mir_strcmpi(p1->szServer, p2->szServer); }
};
@@ -78,7 +78,7 @@ struct ProxyAuthList : OBJLIST<ProxyAuth> const char* find(const char *szServer)
{
- ProxyAuth * rec = szServer ? OBJLIST<ProxyAuth>::find((ProxyAuth*)&szServer) : NULL;
+ ProxyAuth *rec = szServer ? OBJLIST<ProxyAuth>::find((ProxyAuth*)&szServer) : NULL;
return rec ? rec->szMethod : NULL;
}
};
@@ -166,7 +166,7 @@ static char* NetlibHttpFindAuthHeader(NETLIBHTTPREQUEST *nlhrReply, const char * return NULL;
}
-void NetlibConnFromUrl(const char* szUrl, bool secur, NETLIBOPENCONNECTION &nloc)
+void NetlibConnFromUrl(const char *szUrl, bool secur, NETLIBOPENCONNECTION &nloc)
{
secur = secur || _strnicmp(szUrl, "https", 5) == 0;
const char* phost = strstr(szUrl, "://");
@@ -189,7 +189,7 @@ void NetlibConnFromUrl(const char* szUrl, bool secur, NETLIBOPENCONNECTION &nloc nloc.flags = (secur ? NLOCF_SSL : 0);
}
-static NetlibConnection* NetlibHttpProcessUrl(NETLIBHTTPREQUEST *nlhr, NetlibUser *nlu, NetlibConnection* nlc, const char* szUrl = NULL)
+static NetlibConnection* NetlibHttpProcessUrl(NETLIBHTTPREQUEST *nlhr, NetlibUser *nlu, NetlibConnection *nlc, const char *szUrl = NULL)
{
NETLIBOPENCONNECTION nloc;
@@ -199,7 +199,10 @@ static NetlibConnection* NetlibHttpProcessUrl(NETLIBHTTPREQUEST *nlhr, NetlibUse NetlibConnFromUrl(szUrl, false, nloc);
nloc.flags |= NLOCF_HTTP;
- if (nloc.flags & NLOCF_SSL) nlhr->flags |= NLHRF_SSL; else nlhr->flags &= ~NLHRF_SSL;
+ if (nloc.flags & NLOCF_SSL)
+ nlhr->flags |= NLHRF_SSL;
+ else
+ nlhr->flags &= ~NLHRF_SSL;
if (nlc != NULL) {
bool httpProxy = !(nloc.flags & NLOCF_SSL) && nlc->proxyType == PROXYTYPE_HTTP;
@@ -248,10 +251,9 @@ struct HttpSecurityContext return m_hNtlmSecurity && m_szProvider && _stricmp(m_szProvider, "Basic");
}
- char* Execute(NetlibConnection *nlc, char* szHost, const char* szProvider,
- const char* szChallenge, unsigned& complete)
+ char* Execute(NetlibConnection *nlc, char *szHost, const char *szProvider, const char *szChallenge, unsigned &complete)
{
- char* szAuthHdr = NULL;
+ char *szAuthHdr = NULL;
bool justCreated = false;
NetlibUser *nlu = nlc->nlu;
@@ -866,7 +868,7 @@ INT_PTR NetlibHttpTransaction(WPARAM wParam, LPARAM lParam) if (nlhr->nlc != NULL && GetNetlibHandleType(nlhr->nlc) != NLH_CONNECTION)
nlhr->nlc = NULL;
- NetlibConnection* nlc = NetlibHttpProcessUrl(nlhr, nlu, (NetlibConnection*)nlhr->nlc);
+ NetlibConnection *nlc = NetlibHttpProcessUrl(nlhr, nlu, (NetlibConnection*)nlhr->nlc);
if (nlc == NULL)
return 0;
@@ -1003,7 +1005,7 @@ char* gzip_decode(char *gzip_data, int *len_ptr, int window) return output_data;
}
-static int NetlibHttpRecvChunkHeader(NetlibConnection* nlc, bool first, DWORD flags)
+static int NetlibHttpRecvChunkHeader(NetlibConnection *nlc, bool first, DWORD flags)
{
char data[64], *peol1;
@@ -1034,7 +1036,7 @@ static int NetlibHttpRecvChunkHeader(NetlibConnection* nlc, bool first, DWORD fl }
}
-NETLIBHTTPREQUEST* NetlibHttpRecv(NetlibConnection* nlc, DWORD hflags, DWORD dflags, bool isConnect)
+NETLIBHTTPREQUEST* NetlibHttpRecv(NetlibConnection *nlc, DWORD hflags, DWORD dflags, bool isConnect)
{
int dataLen = -1, i, chunkhdr = 0;
bool chunked = false;
diff --git a/src/mir_app/src/netlibhttpproxy.cpp b/src/mir_app/src/netlibhttpproxy.cpp index 62e7784c64..d8f5266836 100644 --- a/src/mir_app/src/netlibhttpproxy.cpp +++ b/src/mir_app/src/netlibhttpproxy.cpp @@ -64,12 +64,11 @@ void HttpGatewayRemovePacket(NetlibConnection *nlc, int pck) static bool NetlibHttpGatewaySend(NetlibConnection *nlc, RequestType reqType, const char *buf, int len)
{
- NETLIBHTTPREQUEST nlhrSend = { 0 };
char szUrl[512];
+ NETLIBHTTPREQUEST nlhrSend = { 0 };
nlhrSend.cbSize = sizeof(nlhrSend);
nlhrSend.nlc = nlc;
-
nlhrSend.pData = (char*)buf;
nlhrSend.dataLength = len;
@@ -260,9 +259,12 @@ int NetlibHttpGatewayRecv(NetlibConnection *nlc, char *buf, int len, int flags) {
bool peek = (flags & MSG_PEEK) != 0;
- if (nlc->dataBufferLen != 0 && (!peek || nlc->dataBufferLen >= len)) {
+ if (nlc->dataBufferLen != 0 && (!peek || nlc->dataBufferLen >= len))
return HttpGatewayReadSetResult(nlc, buf, len, peek);
- }
+
+ NetlibUser *nlu = nlc->nlu;
+ if (GetNetlibHandleType(nlu) != NLH_USER)
+ return SOCKET_ERROR;
for (int retryCount = 0; retryCount < NETLIBHTTP_RETRYCOUNT;) {
if (nlc->nlhpi.szHttpGetUrl == NULL && retryCount == 0) {
@@ -278,10 +280,9 @@ int NetlibHttpGatewayRecv(NetlibConnection *nlc, char *buf, int len, int flags) }
nlc->lastPost = GetTickCount();
- if (nlc->pHttpProxyPacketQueue == NULL && nlc->nlu->user.pfnHttpGatewayWrapSend != NULL) {
- if (nlc->nlu->user.pfnHttpGatewayWrapSend(nlc, (PBYTE)"", 0, MSG_NOHTTPGATEWAYWRAP, NetlibSend) == SOCKET_ERROR)
+ if (nlc->pHttpProxyPacketQueue == NULL && nlu->user.pfnHttpGatewayWrapSend != NULL)
+ if (nlu->user.pfnHttpGatewayWrapSend(nlc, (PBYTE)"", 0, MSG_NOHTTPGATEWAYWRAP, NetlibSend) == SOCKET_ERROR)
return SOCKET_ERROR;
- }
}
int numPackets = 0;
@@ -304,23 +305,22 @@ int NetlibHttpGatewayRecv(NetlibConnection *nlc, char *buf, int len, int flags) }
}
NETLIBHTTPREQUEST *nlhrReply = NetlibHttpRecv(nlc, flags | MSG_RAW | MSG_DUMPPROXY, MSG_RAW | MSG_DUMPPROXY);
- if (nlhrReply == NULL) return SOCKET_ERROR;
+ if (nlhrReply == NULL)
+ return SOCKET_ERROR;
- if (nlc->nlu->user.pfnHttpGatewayUnwrapRecv && !(flags & MSG_NOHTTPGATEWAYWRAP)) {
- nlhrReply->pData = (char*)nlc->nlu->user.pfnHttpGatewayUnwrapRecv(nlhrReply,
- (PBYTE)nlhrReply->pData, nlhrReply->dataLength, &nlhrReply->dataLength, mir_realloc);
- }
+ if (nlu->user.pfnHttpGatewayUnwrapRecv && !(flags & MSG_NOHTTPGATEWAYWRAP))
+ nlhrReply->pData = (char*)nlu->user.pfnHttpGatewayUnwrapRecv(nlhrReply, (PBYTE)nlhrReply->pData, nlhrReply->dataLength, &nlhrReply->dataLength, mir_realloc);
if (nlhrReply->resultCode >= 300) {
int resultCode = nlhrReply->resultCode;
NetlibHttpFreeRequestStruct(0, (LPARAM)nlhrReply);
if (nlc->nlhpi.szHttpGetUrl && resultCode != 404) {
- NetlibLogf(nlc->nlu, "Error received from proxy, retrying");
+ NetlibLogf(nlu, "Error received from proxy, retrying");
continue;
}
else {
- NetlibLogf(nlc->nlu, "Error received from proxy, retry attempts exceeded (%u)", retryCount);
+ NetlibLogf(nlu, "Error received from proxy, retry attempts exceeded (%u)", retryCount);
SetLastError(ERROR_GEN_FAILURE);
return SOCKET_ERROR;
}
@@ -431,7 +431,8 @@ INT_PTR NetlibHttpGatewaySetInfo(WPARAM wParam, LPARAM lParam) nlc->nlhpi.combinePackets = 1;
memcpy(&nlc->nlhpi, nlhpi, min(nlhpi->cbSize, sizeof(*nlhpi)));
- if (nlc->nlhpi.combinePackets == 0) nlc->nlhpi.combinePackets = 1;
+ if (nlc->nlhpi.combinePackets == 0)
+ nlc->nlhpi.combinePackets = 1;
nlc->nlhpi.szHttpGetUrl = mir_strdup(nlc->nlhpi.szHttpGetUrl);
nlc->nlhpi.szHttpPostUrl = mir_strdup(nlc->nlhpi.szHttpPostUrl);
@@ -443,8 +444,7 @@ INT_PTR NetlibHttpSetSticky(WPARAM wParam, LPARAM lParam) {
NetlibUser * nu = (NetlibUser*)wParam;
if (GetNetlibHandleType(nu) != NLH_USER) return ERROR_INVALID_PARAMETER;
- mir_free(nu->szStickyHeaders);
- nu->szStickyHeaders = mir_strdup((char*)lParam); // pointer is ours
+ replaceStr(nu->szStickyHeaders, (char*)lParam); // pointer is ours
return 0;
}
diff --git a/src/mir_app/src/netlibsock.cpp b/src/mir_app/src/netlibsock.cpp index 88c089d73f..0cbec573fc 100644 --- a/src/mir_app/src/netlibsock.cpp +++ b/src/mir_app/src/netlibsock.cpp @@ -226,7 +226,7 @@ char* NetlibAddressToString(SOCKADDR_INET_M* addr) return NULL;
}
-void NetlibGetConnectionInfo(NetlibConnection* nlc, NETLIBCONNINFO *connInfo)
+void NetlibGetConnectionInfo(NetlibConnection *nlc, NETLIBCONNINFO *connInfo)
{
if (!nlc || !connInfo || connInfo->cbSize < sizeof(NETLIBCONNINFO)) return;
|