summaryrefslogtreecommitdiff
path: root/src/mir_app
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2017-01-14 01:22:55 +0300
committerGeorge Hazan <ghazan@miranda.im>2017-01-14 01:22:55 +0300
commitd3cb19278d60ac6f7963379254546cdca36a90e2 (patch)
treef2fa018b343d5460419c1b323f5f3ce04a393d00 /src/mir_app
parentd5a6c0666a8d8d2055a3f4402f67f91e8548ec3a (diff)
separate handle types for HNETLIBCONN & HNETLIBBIND
Diffstat (limited to 'src/mir_app')
-rw-r--r--src/mir_app/src/netlib.cpp9
-rw-r--r--src/mir_app/src/netlibbind.cpp4
-rw-r--r--src/mir_app/src/netlibhttp.cpp5
-rw-r--r--src/mir_app/src/netlibopenconn.cpp4
-rw-r--r--src/mir_app/src/netlibsock.cpp14
5 files changed, 15 insertions, 21 deletions
diff --git a/src/mir_app/src/netlib.cpp b/src/mir_app/src/netlib.cpp
index a0051c2dc5..4405f265e5 100644
--- a/src/mir_app/src/netlib.cpp
+++ b/src/mir_app/src/netlib.cpp
@@ -354,14 +354,14 @@ MIR_APP_DLL(HNETLIBUSER) Netlib_GetConnNlu(HANDLE hConn)
/////////////////////////////////////////////////////////////////////////////////////////
-MIR_APP_DLL(void) Netlib_Shutdown(HANDLE h)
+MIR_APP_DLL(void) Netlib_Shutdown(HNETLIBCONN h)
{
if (h) {
WaitForSingleObject(hConnectionHeaderMutex, INFINITE);
switch (GetNetlibHandleType(h)) {
case NLH_CONNECTION:
{
- NetlibConnection *nlc = (NetlibConnection*)h;
+ NetlibConnection *nlc = h;
if (!nlc->termRequested) {
if (nlc->hSsl) sslApi.shutdown(nlc->hSsl);
if (nlc->s != INVALID_SOCKET) shutdown(nlc->s, 2);
@@ -372,7 +372,7 @@ MIR_APP_DLL(void) Netlib_Shutdown(HANDLE h)
break;
case NLH_BOUNDPORT:
- struct NetlibBoundPort *nlb = (NetlibBoundPort*)h;
+ NetlibBoundPort *nlb = (NetlibBoundPort*)h;
if (nlb->s != INVALID_SOCKET)
shutdown(nlb->s, 2);
break;
@@ -403,10 +403,9 @@ void UnloadNetlibModule(void)
int LoadNetlibModule(void)
{
- WSADATA wsadata;
-
bModuleInitialized = TRUE;
+ WSADATA wsadata;
WSAStartup(MAKEWORD(2, 2), &wsadata);
HookEvent(ME_OPT_INITIALISE, NetlibOptInitialise);
diff --git a/src/mir_app/src/netlibbind.cpp b/src/mir_app/src/netlibbind.cpp
index b5dcc6b6c3..fff3f092d2 100644
--- a/src/mir_app/src/netlibbind.cpp
+++ b/src/mir_app/src/netlibbind.cpp
@@ -174,15 +174,13 @@ static void NetlibBindAcceptThread(void* param)
Netlib_Logf(nlbp->nlu, "NetlibBindAcceptThread: (%p) thread for port %u closed", nlbp->s, nlbp->wPort);
}
-MIR_APP_DLL(HANDLE) Netlib_BindPort(HNETLIBUSER nlu, NETLIBBIND *nlb)
+MIR_APP_DLL(HNETLIBBIND) Netlib_BindPort(HNETLIBUSER nlu, NETLIBBIND *nlb)
{
if (GetNetlibHandleType(nlu) != NLH_USER || !(nlu->user.flags & NUF_INCOMING) ||
nlb == NULL || nlb->pfnNewConnection == NULL) {
SetLastError(ERROR_INVALID_PARAMETER);
return 0;
}
- if (nlb->cbSize != sizeof(NETLIBBIND))
- return 0;
NetlibBoundPort *nlbp = (NetlibBoundPort*)mir_calloc(sizeof(NetlibBoundPort));
nlbp->handleType = NLH_BOUNDPORT;
diff --git a/src/mir_app/src/netlibhttp.cpp b/src/mir_app/src/netlibhttp.cpp
index 5209ca6468..a680d26f67 100644
--- a/src/mir_app/src/netlibhttp.cpp
+++ b/src/mir_app/src/netlibhttp.cpp
@@ -367,9 +367,8 @@ static int SendHttpRequestAndData(NetlibConnection *nlc, CMStringA &httpRequest,
return bytesSent;
}
-MIR_APP_DLL(int) Netlib_SendHttpRequest(HANDLE hConnection, NETLIBHTTPREQUEST *nlhr)
+MIR_APP_DLL(int) Netlib_SendHttpRequest(HNETLIBCONN nlc, NETLIBHTTPREQUEST *nlhr)
{
- NetlibConnection *nlc = (NetlibConnection*)hConnection;
NETLIBHTTPREQUEST *nlhrReply = NULL;
HttpSecurityContext httpSecurity;
@@ -717,7 +716,7 @@ MIR_APP_DLL(bool) Netlib_FreeHttpRequest(NETLIBHTTPREQUEST *nlhr)
#define NHRV_BUF_SIZE 8192
-MIR_APP_DLL(NETLIBHTTPREQUEST*) Netlib_RecvHttpHeaders(HANDLE hConnection, int flags)
+MIR_APP_DLL(NETLIBHTTPREQUEST*) Netlib_RecvHttpHeaders(HNETLIBCONN hConnection, int flags)
{
NetlibConnection *nlc = (NetlibConnection*)hConnection;
if (!NetlibEnterNestedCS(nlc, NLNCS_RECV))
diff --git a/src/mir_app/src/netlibopenconn.cpp b/src/mir_app/src/netlibopenconn.cpp
index 9d504b66ad..dba769dd27 100644
--- a/src/mir_app/src/netlibopenconn.cpp
+++ b/src/mir_app/src/netlibopenconn.cpp
@@ -816,7 +816,7 @@ bool NetlibReconnect(NetlibConnection *nlc)
return true;
}
-MIR_APP_DLL(HANDLE) Netlib_OpenConnection(NetlibUser *nlu, const NETLIBOPENCONNECTION *nloc)
+MIR_APP_DLL(HNETLIBCONN) Netlib_OpenConnection(NetlibUser *nlu, const NETLIBOPENCONNECTION *nloc)
{
if (nloc == NULL || nloc->cbSize != sizeof(NETLIBOPENCONNECTION) || nloc->szHost == NULL || nloc->wPort == 0) {
@@ -851,7 +851,7 @@ MIR_APP_DLL(HANDLE) Netlib_OpenConnection(NetlibUser *nlu, const NETLIBOPENCONNE
return nlc;
}
-MIR_APP_DLL(int) Netlib_StartSsl(HANDLE hConnection, const char *szHost)
+MIR_APP_DLL(int) Netlib_StartSsl(HNETLIBCONN hConnection, const char *szHost)
{
NetlibConnection *nlc = (NetlibConnection*)hConnection;
if (nlc == NULL)
diff --git a/src/mir_app/src/netlibsock.cpp b/src/mir_app/src/netlibsock.cpp
index a920f7cd93..57cb023b4b 100644
--- a/src/mir_app/src/netlibsock.cpp
+++ b/src/mir_app/src/netlibsock.cpp
@@ -29,9 +29,8 @@ extern HANDLE hConnectionHeaderMutex, hSendEvent, hRecvEvent;
/////////////////////////////////////////////////////////////////////////////////////////
-MIR_APP_DLL(int) Netlib_Send(HANDLE hConn, const char *buf, int len, int flags)
+MIR_APP_DLL(int) Netlib_Send(HNETLIBCONN nlc, const char *buf, int len, int flags)
{
- NetlibConnection *nlc = (NetlibConnection*)hConn;
if (!NetlibEnterNestedCS(nlc, NLNCS_SEND))
return SOCKET_ERROR;
@@ -39,7 +38,7 @@ MIR_APP_DLL(int) Netlib_Send(HANDLE hConn, const char *buf, int len, int flags)
if (nlc->usingHttpGateway && !(flags & MSG_RAW)) {
if (!(flags & MSG_NOHTTPGATEWAYWRAP) && nlc->nlu->user.pfnHttpGatewayWrapSend) {
NetlibDumpData(nlc, (PBYTE)buf, len, 1, flags);
- result = nlc->nlu->user.pfnHttpGatewayWrapSend((HANDLE)nlc, (PBYTE)buf, len, flags | MSG_NOHTTPGATEWAYWRAP);
+ result = nlc->nlu->user.pfnHttpGatewayWrapSend(nlc, (PBYTE)buf, len, flags | MSG_NOHTTPGATEWAYWRAP);
}
else result = NetlibHttpGatewayPost(nlc, buf, len, flags);
}
@@ -60,9 +59,8 @@ MIR_APP_DLL(int) Netlib_Send(HANDLE hConn, const char *buf, int len, int flags)
/////////////////////////////////////////////////////////////////////////////////////////
-MIR_APP_DLL(int) Netlib_Recv(HANDLE hConn, char *buf, int len, int flags)
+MIR_APP_DLL(int) Netlib_Recv(HNETLIBCONN nlc, char *buf, int len, int flags)
{
- NetlibConnection *nlc = (NetlibConnection*)hConn;
if (!NetlibEnterNestedCS(nlc, NLNCS_RECV))
return SOCKET_ERROR;
@@ -95,11 +93,11 @@ MIR_APP_DLL(int) Netlib_Recv(HANDLE hConn, char *buf, int len, int flags)
/////////////////////////////////////////////////////////////////////////////////////////
-static int ConnectionListToSocketList(const HANDLE *hConns, fd_set *fd, int& pending)
+static int ConnectionListToSocketList(const HNETLIBCONN *hConns, fd_set *fd, int& pending)
{
FD_ZERO(fd);
for (int i = 0; hConns[i] && hConns[i] != INVALID_HANDLE_VALUE && i < FD_SETSIZE; i++) {
- NetlibConnection *nlcCheck = (NetlibConnection*)hConns[i];
+ NetlibConnection *nlcCheck = hConns[i];
if (nlcCheck->handleType != NLH_CONNECTION && nlcCheck->handleType != NLH_BOUNDPORT) {
SetLastError(ERROR_INVALID_DATA);
return 0;
@@ -224,7 +222,7 @@ MIR_APP_DLL(char*) Netlib_AddressToString(sockaddr_in *addr)
/////////////////////////////////////////////////////////////////////////////////////////
-MIR_APP_DLL(int) Netlib_GetConnectionInfo(HANDLE hConnection, NETLIBCONNINFO *connInfo)
+MIR_APP_DLL(int) Netlib_GetConnectionInfo(HNETLIBCONN hConnection, NETLIBCONNINFO *connInfo)
{
NetlibConnection *nlc = (NetlibConnection*)hConnection;
if (!nlc || !connInfo)