summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2017-01-11 19:51:30 +0300
committerGeorge Hazan <ghazan@miranda.im>2017-01-11 19:51:30 +0300
commitbb03623fd3ba7b9cc456da2c9504bad87b80ace0 (patch)
treea48d6ead0275d8b8e34815e20c22c64dcb30538a /include
parente004a33b7853108b49f77ced20a460b3c8b78c35 (diff)
- Netlib_Send & Netlib_Recv helpers became real functions, MS_NETLIB_SEND & MS_NETLIB_RECV died;
- fix for dumping chunked http replies into a network log
Diffstat (limited to 'include')
-rw-r--r--include/delphi/m_helpers.inc43
-rw-r--r--include/delphi/m_netlib.inc51
-rw-r--r--include/m_netlib.h47
3 files changed, 21 insertions, 120 deletions
diff --git a/include/delphi/m_helpers.inc b/include/delphi/m_helpers.inc
index 3e9d70b32f..0c98ecd947 100644
--- a/include/delphi/m_helpers.inc
+++ b/include/delphi/m_helpers.inc
@@ -16,11 +16,6 @@ function CreateVersionStringPlugin(pluginInfo:PPluginInfoEx;buf:PAnsiChar):PAnsi
function PLUGIN_MAKE_VERSION(a,b,c,d: Cardinal): int;
function PLUGIN_CMP_VERSION(verA: LongInt; verB: LongInt): int;
-function Netlib_CloseHandle(Handle: THANDLE): int;
-function Netlib_GetBase64DecodedBufferSize(const cchEncoded: int): int;
-function Netlib_GetBase64EncodedBufferSize(const cbDecoded: int): int;
-function Netlib_Send(hConn: THANDLE; const buf: PAnsiChar; len: int; flags: int): int_ptr;
-function Netlib_Recv(hConn: THANDLE; const buf: PAnsiChar; len: int; flags: int): int_ptr;
procedure Netlib_Log(hNetLib: THANDLE; const sz: PAnsiChar);
function mir_hashstr (const key:PAnsiChar):uint; {inline;}
@@ -178,44 +173,6 @@ begin
Inc(Result, (verA and $FF000000) - (verB and $FF000000));
end;
-function Netlib_CloseHandle(Handle: THANDLE): int;
- {$IFDEF AllowInline}inline;{$ENDIF}
-begin
- Result := CallService(MS_NETLIB_CLOSEHANDLE, Handle, 0);
-end;
-
-function Netlib_GetBase64DecodedBufferSize(const cchEncoded: int): int;
- {$IFDEF AllowInline}inline;{$ENDIF}
-begin
- Result := (cchEncoded shr 2) * 3;
-end;
-
-function Netlib_GetBase64EncodedBufferSize(const cbDecoded: int): int;
- {$IFDEF AllowInline}inline;{$ENDIF}
-begin
- Result := (cbDecoded * 4+11) div 12*4+1;
-end;
-
-function Netlib_Send(hConn: THANDLE; const buf: PAnsiChar; len: int; flags: int): int_ptr;
-var
- nlb: TNETLIBBUFFER;
-begin
- nlb.buf := buf;
- nlb.len := len;
- nlb.flags := flags;
- Result := CallService(MS_NETLIB_SEND, wParam(hConn), lParam(@nlb));
-end;
-
-function Netlib_Recv(hConn: THANDLE; const buf: PAnsiChar; len: int; flags: int): int_ptr;
-var
- nlb: TNETLIBBUFFER;
-begin
- nlb.buf := buf;
- nlb.len := len;
- nlb.flags := flags;
- Result := CallService(MS_NETLIB_RECV, wParam(hConn), lParam(@nlb));
-end;
-
procedure Netlib_Log(hNetLib: THANDLE; const sz: PAnsiChar);
{$IFDEF AllowInline}inline;{$ENDIF}
begin
diff --git a/include/delphi/m_netlib.inc b/include/delphi/m_netlib.inc
index edbf277804..3a9512cb49 100644
--- a/include/delphi/m_netlib.inc
+++ b/include/delphi/m_netlib.inc
@@ -313,27 +313,6 @@ const
}
MS_NETLIB_REGISTERUSER:PAnsiChar = 'Netlib/RegisterUser';
-{
- Assign a Netlib user handle a set of dynamic HTTP headers to be used with all
-
- HTTP connections that enable the HTTP-use-sticky headers flag.
- The headers persist until cleared with lParam=NULL.
-
- All memory should be allocated by the caller using malloc() from MS_SYSTEM_GET_MMI
- Once it has passed to Netlib, Netlib is the owner of it, the caller should not refer to the memory
- In any way after this point.
-
- wParam=(WPARAM)hNetLibUser
- lParam=(LPARAM)(AnsiChar*)szHeaders
-
- NOTE: The szHeaders parameter should be a NULL terminated string following the HTTP header syntax.
- This string will be injected verbatim, thus the user should be aware of setting strings that are not
- headers. This service is NOT THREAD SAFE, only a single thread is expected to set the headers and a single
- thread reading the pointer internally, stopping race conditions and mutual exclusion don't happen.
-
- Version 0.3.2a+ (2003/10/27)
-}
- MS_NETLIB_SETSTICKYHEADERS:PAnsiChar = 'Netlib/SetStickyHeaders';
{
wParam : HANDLE
@@ -348,20 +327,6 @@ const
Errors : ERROR_INVALID_PARAMETER
}
MS_NETLIB_GETUSERSETTINGS:PAnsiChar = 'Netlib/GetUserSettings';
-
- {
- wParam : HANDLE
- lParam : Pointer to a initalised NETLIBUSERSETTINGS structure
- Affect : Changes the configurable settings for a Netlib user -- see notes
- Returns: [non zero] on success, NULL(0) on failure
- Notes : This service is only really useful for people that specify NUF_NOOPTIONS
- when registering and want to create their own options.
- Settings will be stored even if the option to enable it, is it not enabled,
- e.g. useProxyAuth is 0, szProxyAuthPassword will still be saved
- Errors : ERROR_INVALID_PARAMETER
- }
- MS_NETLIB_SETUSERSETTINGS:PAnsiChar = 'Netlib/SetUserSettings';
-
{
wParam : HANDLE / SOCKET
lParam : 0
@@ -371,7 +336,8 @@ const
If a SOCKET type is passed instead of netlib handle type, it is closed
Errors : ERROR_INVALID_PARAMETER
}
- MS_NETLIB_CLOSEHANDLE:PAnsiChar = 'Netlib/CloseHandle';
+
+function Netlib_CloseHandle(pHandle:THANDLE) : int; stdcall; external AppDll;
{
wParam : HANDLE
@@ -390,6 +356,8 @@ const
Errors : ERROR_INVALID_PARAMETER, any returned by socket(), bind(), listen()
getsockname()
}
+
+const
MS_NETLIB_BINDPORT:PAnsiChar = 'Netlib/BindPort';
{
@@ -602,8 +570,6 @@ const
MS_NETLIB_HTTPTRANSACTION:PAnsiChar = 'Netlib/HttpTransaction';
{
- wParam : HANDLE
- lParam : Pointer to an initialised TNETLIBBUFFER structure
Affect : Send data over an open connection see notes
Returns: The number of bytes sent on success, SOCKET_ERROR on failure
Notes : see Netlib_Send() helper function
@@ -613,11 +579,10 @@ const
(HTTP proxy): ERROR_GEN_FAILURE (http result code wasn't 2xx)
MS_NETLIB_SENDHTTPREQUEST, MS_NETLIB_RECVHTTPHEADERS
}
- MS_NETLIB_SEND:PAnsiChar = 'Netlib/Send';
+
+function Netlib_Send(hConn:THANDLE; pBuf:Pointer; len,flags:int) : int; stdcall; external AppDll;
{
- wParam : HANDLE
- lParam : Pointer to an initialised TNETLIBBUFFER structure
Affect : Receive data over a connection, see notes
Returns: The number of bytes read on success, SOCKET_ERROR on failure
Notes :
@@ -646,7 +611,8 @@ const
connect(), MS_NETLIB_SENDHTTPREQUEST
}
- MS_NETLIB_RECV:PAnsiChar = 'Netlib/Recv';
+
+function Netlib_Recv(hConn:THANDLE; pBuf:Pointer; len,flags:int) : int; stdcall; external AppDll;
{
wParam : 0
@@ -659,6 +625,7 @@ const
or INVALID_HANDLE_VALUE.
Errors : ERROR_INVALID_HANDLE, ERROR_INVALID_DATA, anything from select()
}
+const
MS_NETLIB_SELECT :PAnsiChar = 'Netlib/Select';
MS_NETLIB_SELECTEX:PAnsiChar = 'Netlib/SelectEx'; // added in v0.3.3
diff --git a/include/m_netlib.h b/include/m_netlib.h
index 1daf530be5..51b18adc48 100644
--- a/include/m_netlib.h
+++ b/include/m_netlib.h
@@ -61,7 +61,7 @@ struct NETLIBOPENCONNECTION;
typedef int (*NETLIBHTTPGATEWAYINITPROC)(HANDLE hConn, NETLIBOPENCONNECTION *nloc, NETLIBHTTPREQUEST *nlhr);
typedef int (*NETLIBHTTPGATEWAYBEGINPROC)(HANDLE hConn, NETLIBOPENCONNECTION *nloc);
-typedef int (*NETLIBHTTPGATEWAYWRAPSENDPROC)(HANDLE hConn, PBYTE buf, int len, int flags, MIRANDASERVICE pfnNetlibSend);
+typedef int (*NETLIBHTTPGATEWAYWRAPSENDPROC)(HANDLE hConn, PBYTE buf, int len, int flags);
typedef PBYTE (*NETLIBHTTPGATEWAYUNWRAPRECVPROC)(NETLIBHTTPREQUEST *nlhr, PBYTE buf, int len, int *outBufLen, void *(*NetlibRealloc)(void*, size_t));
struct NETLIBUSER
@@ -223,18 +223,13 @@ struct NETLIBUSERSETTINGS
#define MS_NETLIB_SETUSERSETTINGS "Netlib/SetUserSettings"
// Closes a netlib handle
-// wParam = (WPARAM)(HANDLE)hNetlibHandle
-// lParam = 0
// Returns nonzero on success, 0 on failure (!! this is different to most of the rest of Miranda, but consistent with netlib)
// This function should be called on all handles returned by netlib functions
// once you are done with them. If it's called on a socket-type handle, the
// socket will be closed.
// Errors: ERROR_INVALID_PARAMETER
-#define MS_NETLIB_CLOSEHANDLE "Netlib/CloseHandle"
-__forceinline INT_PTR Netlib_CloseHandle(HANDLE h)
-{ return CallService(MS_NETLIB_CLOSEHANDLE, (WPARAM)h, 0);
-}
+EXTERN_C MIR_APP_DLL(int) Netlib_CloseHandle(HANDLE h);
/////////////////////////////////////////////////////////////////////////////////////////
// Open a port and wait for connections on it
@@ -599,8 +594,7 @@ public:
/////////////////////////////////////////////////////////////////////////////////////////
// Send data over a connection
-// wParam = (WPARAM)(HANDLE)hConnection
-// lParam = (LPARAM)(NETLIBBUFFER*)&nlb
+//
// Returns the number of bytes sent on success, SOCKET_ERROR on failure
// Errors: ERROR_INVALID_PARAMETER
// anything from send(), nlu.pfnHttpGatewayWrapSend()
@@ -610,31 +604,18 @@ public:
// flags:
#define MSG_NOHTTPGATEWAYWRAP 0x010000 // don't wrap the outgoing packet using nlu.pfnHttpGatewayWrapSend
-#define MSG_NODUMP 0x020000 // don't dump this packet to the log
+#define MSG_NODUMP 0x020000 // don't dump this packet to the log
#define MSG_DUMPPROXY 0x040000 // this is proxy communiciation. For dump filtering only.
-#define MSG_DUMPASTEXT 0x080000 // this is textual data, don't dump as hex
+#define MSG_DUMPASTEXT 0x080000 // this is textual data, don't dump as hex
#define MSG_RAW 0x100000 // send as raw data, bypass any HTTP proxy stuff
#define MSG_DUMPSSL 0x200000 // this is SSL traffic. For dump filtering only.
+#define MSG_NOTITLE 0x400000 // skip date, time & protocol from dump
-struct NETLIBBUFFER
-{
- char *buf;
- int len;
- int flags;
-};
-
-#define MS_NETLIB_SEND "Netlib/Send"
-
-__inline INT_PTR Netlib_Send(HANDLE hConn, const char *buf, int len, int flags)
-{
- NETLIBBUFFER nlb = {(char*)buf, len, flags};
- return CallService(MS_NETLIB_SEND, (WPARAM)hConn, (LPARAM)&nlb);
-}
+EXTERN_C MIR_APP_DLL(int) Netlib_Send(HANDLE hConn, const char *buf, int len, int flags = 0);
/////////////////////////////////////////////////////////////////////////////////////////
// Receive data over a connection
-// wParam = (WPARAM)(HANDLE)hConnection
-// lParam = (LPARAM)(NETLIBBUFFER*)&nlb
+//
// Returns the number of bytes read on success, SOCKET_ERROR on failure,
// 0 if the connection has been closed
// Flags supported: MSG_PEEK, MSG_NODUMP, MSG_DUMPPROXY, MSG_NOHTTPGATEWAYWRAP,
@@ -654,13 +635,7 @@ __inline INT_PTR Netlib_Send(HANDLE hConn, const char *buf, int len, int flags)
// nlu.pfnHttpGatewayUnwrapRecv, socket(), connect(),
// MS_NETLIB_SENDHTTPREQUEST
-#define MS_NETLIB_RECV "Netlib/Recv"
-
-__inline INT_PTR Netlib_Recv(HANDLE hConn, char *buf, int len, int flags)
-{
- NETLIBBUFFER nlb = {buf, len, flags};
- return CallService(MS_NETLIB_RECV, (WPARAM)hConn, (LPARAM)&nlb);
-}
+EXTERN_C MIR_APP_DLL(int) Netlib_Recv(HANDLE hConn, char *buf, int len, int flags = 0);
/////////////////////////////////////////////////////////////////////////////////////////
// Determine the status of one or more connections
@@ -924,7 +899,9 @@ static __inline char* Netlib_NtlmCreateResponse2(HANDLE hProvider, char* szChall
struct NETLIBNOTIFY
{
- NETLIBBUFFER* nlb; // pointer to the request buffer
+ const char *buf;
+ int len;
+ int flags;
int result; // amount of bytes really sent/received
};