diff options
-rw-r--r-- | bin10/lib/mir_core.lib | bin | 32014 -> 32224 bytes | |||
-rw-r--r-- | bin10/lib/mir_core64.lib | bin | 29232 -> 29424 bytes | |||
-rw-r--r-- | bin11/lib/mir_core.lib | bin | 32014 -> 32224 bytes | |||
-rw-r--r-- | bin11/lib/mir_core64.lib | bin | 29232 -> 29424 bytes | |||
-rw-r--r-- | include/delphi/m_core.inc | 6 | ||||
-rw-r--r-- | include/delphi/m_idle.inc | 4 | ||||
-rw-r--r-- | include/delphi/m_netlib.inc | 18 | ||||
-rw-r--r-- | include/m_core.h | 5 | ||||
-rw-r--r-- | include/m_netlib.h | 2 | ||||
-rw-r--r-- | plugins/!NotAdopted/Chess4Net/MI/MirandaINC/m_netlib.inc | 4 | ||||
-rw-r--r-- | src/mir_core/http.cpp | 58 | ||||
-rw-r--r-- | src/mir_core/mir_core.def | 1 | ||||
-rw-r--r-- | src/mir_core/mir_core_10.vcxproj | 1 | ||||
-rw-r--r-- | src/mir_core/mir_core_10.vcxproj.filters | 3 | ||||
-rw-r--r-- | src/mir_core/mir_core_11.vcxproj | 1 | ||||
-rw-r--r-- | src/mir_core/mir_core_11.vcxproj.filters | 3 | ||||
-rw-r--r-- | src/mir_core/subclass.cpp | 12 | ||||
-rw-r--r-- | src/modules/netlib/netlib.cpp | 38 |
18 files changed, 102 insertions, 54 deletions
diff --git a/bin10/lib/mir_core.lib b/bin10/lib/mir_core.lib Binary files differindex dad0ff7cfc..76c63681c7 100644 --- a/bin10/lib/mir_core.lib +++ b/bin10/lib/mir_core.lib diff --git a/bin10/lib/mir_core64.lib b/bin10/lib/mir_core64.lib Binary files differindex 789e26cd25..db6ff56939 100644 --- a/bin10/lib/mir_core64.lib +++ b/bin10/lib/mir_core64.lib diff --git a/bin11/lib/mir_core.lib b/bin11/lib/mir_core.lib Binary files differindex 5c51311e9a..44aa9504ae 100644 --- a/bin11/lib/mir_core.lib +++ b/bin11/lib/mir_core.lib diff --git a/bin11/lib/mir_core64.lib b/bin11/lib/mir_core64.lib Binary files differindex 45d0d5fce5..bf5c841786 100644 --- a/bin11/lib/mir_core64.lib +++ b/bin11/lib/mir_core64.lib diff --git a/include/delphi/m_core.inc b/include/delphi/m_core.inc index 7221ec7c59..417aa4b7b5 100644 --- a/include/delphi/m_core.inc +++ b/include/delphi/m_core.inc @@ -236,6 +236,12 @@ function CallContactService(hContact:THANDLE;const name:PAnsiChar;wParam:WPARAM; function CallProtoService(const szModule:PAnsiChar;const szService:PAnsiChar;wParam:WPARAM;lParam:LPARAM):uint_ptr; cdecl;
external CoreDLL name 'CallProtoService';
+///////////////////////////////////////////////////////////////////////////////
+// http
+
+// returned result must be freed using mir_free()
+function mir_urlEncode(url:pAnsiChar); pAnsiChar; stdcall;
+ external CoreDLL name 'mir_urlEncode';
///////////////////////////////////////////////////////////////////////////////
// exceptions
diff --git a/include/delphi/m_idle.inc b/include/delphi/m_idle.inc index bda2caea84..f3646fbc40 100644 --- a/include/delphi/m_idle.inc +++ b/include/delphi/m_idle.inc @@ -48,8 +48,6 @@ const }
ME_IDLE_CHANGED:PAnsiChar = 'Miranda/Idle/Changed';
- MIRANDA_IDLE_INFO_SIZE_1 = 20;
-
type
PMIRANDA_IDLE_INFO = ^TMIRANDA_IDLE_INFO;
TMIRANDA_IDLE_INFO = record
@@ -60,7 +58,7 @@ type aaLock : int; // the status shouldn't be unset if its set
idleType : int;
idlesoundsoff: int;
- end;
+ end;
{
wParam; 0
lParam: address of MIRANDA_IDLE_INFO
diff --git a/include/delphi/m_netlib.inc b/include/delphi/m_netlib.inc index 1d6615ec7c..69df8f5793 100644 --- a/include/delphi/m_netlib.inc +++ b/include/delphi/m_netlib.inc @@ -356,7 +356,7 @@ const {
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.
+ 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
@@ -501,9 +501,7 @@ const lParam : Pointer to a null terminated string
Affects: URL-encodes a string for x-www-form-urlencoded (and other uses) -- see notes
Returns: A pointer to a null terminated string, NULL(0) on failure
- Notes : The returned string must be freed after it's no longer needed,
- to do this Miranda's process heap must be used (under the WINAPI), e.g.
- HeapFree(GetProcessHeap(), 0, the_returned_string)
+ Notes : The returned string must be freed after it's no longer needed using mir_free
Errors : ERROR_INVALID_PARAMETER, ERROR_OUTOFMEMORY
}
MS_NETLIB_URLENCODE:PAnsiChar = 'Netlib/UrlEncode';
@@ -556,12 +554,12 @@ const MS_NETLIB_STARINGTOADDRESS:PAnsiChar = 'Netlib/StringToAddress';
{
- Converts numerical representation of IP in SOCKADDR_INET into string representation with IP and port
+ Converts numerical representation of IP in SOCKADDR_INET into string representation with IP and port
IPv4 will be supplied in formats address:port or address
IPv6 will be supplied in formats [address]:port or [address]
wParam=(WPARAM)(int) 0 - lParam - (SOCKADDR_INET*); 1 - lParam - (unsigned) in host byte order
lParam=(LPARAM)(SOCKADDR_INET*) or (unsigned) numeric IP address structure
- Returns pointer to the string or NULL if not successful
+ Returns pointer to the string or NULL if not successful
}
MS_NETLIB_ADDRESSTOSTRING:PAnsiChar = 'Netlib/AddressToString';
@@ -580,7 +578,7 @@ const IPv6 will be supplied in formats [address]:port or [address]
wParam=(WPARAM)(HANDLE)hConnection
lParam=(LPARAM)(NETLIBCONNINFO*) pointer to the connection information structure to fill
- Returns 0 if successful
+ Returns 0 if successful
}
MS_NETLIB_GETCONNECTIONINFO:PAnsiChar = 'Netlib/GetConnectionInfo';
@@ -594,7 +592,7 @@ const {
Get connection Information
wParam=(WPARAM)IP filter 1 - return global only IPv6 address, 0 all IPs
- Returns (INT_PTR)(NETLIBIPLIST*) numeric IP address address array
+ Returns (INT_PTR)(NETLIBIPLIST*) numeric IP address address array
the last element of the array is all 0s, 0 if not successful
}
MS_NETLIB_GETMYIP:PAnsiChar = 'Netlib/GetMyIP';
@@ -755,7 +753,7 @@ const Shutdown connection
wParam=(WPARAM)(HANDLE)hConnection
lParam=(LPARAM)0
- Returns 0
+ Returns 0
}
MS_NETLIB_SHUTDOWN:PAnsiChar = 'Netlib/Shutdown';
@@ -827,7 +825,7 @@ const MS_NETLIB_SETPOLLINGTIMEOUT:PAnsiChar = 'Netlib/SetPollingTimeout';
{
- Makes connection SSL
+ Makes connection SSL
wParam=(WPARAM)(HANDLE)hConn
lParam=0
Returns 0 on failure 1 on success
diff --git a/include/m_core.h b/include/m_core.h index 66841e0f6a..c073cdea66 100644 --- a/include/m_core.h +++ b/include/m_core.h @@ -197,6 +197,11 @@ MIR_CORE_DLL(pfnExceptionFilter) GetExceptionFilter(void); MIR_CORE_DLL(pfnExceptionFilter) SetExceptionFilter(pfnExceptionFilter pMirandaExceptFilter);
///////////////////////////////////////////////////////////////////////////////
+// http support
+
+MIR_CORE_DLL(char*) mir_urlEncode(const char *szUrl);
+
+///////////////////////////////////////////////////////////////////////////////
// icons support
extern int hLangpack;
diff --git a/include/m_netlib.h b/include/m_netlib.h index 62b7512b69..8403adfc97 100644 --- a/include/m_netlib.h +++ b/include/m_netlib.h @@ -384,7 +384,7 @@ typedef struct { //wParam = 0
//lParam = (LPARAM)(const char *)pszString
//Returns a char* containing the new string. This must be freed with
-//HeapFree(GetProcessHeap(), 0, pszReturnString) when you're done with it.
+//mir_free() when you're done with it.
//Returns NULL on error.
//Errors: ERROR_INVALID_PARAMETER, ERROR_OUTOFMEMORY
#define MS_NETLIB_URLENCODE "Netlib/UrlEncode"
diff --git a/plugins/!NotAdopted/Chess4Net/MI/MirandaINC/m_netlib.inc b/plugins/!NotAdopted/Chess4Net/MI/MirandaINC/m_netlib.inc index 8c5f37ef9c..6ce0ca8e9e 100644 --- a/plugins/!NotAdopted/Chess4Net/MI/MirandaINC/m_netlib.inc +++ b/plugins/!NotAdopted/Chess4Net/MI/MirandaINC/m_netlib.inc @@ -458,9 +458,7 @@ const lParam : Pointer to a null terminated string
Affects: URL-encodes a string for x-www-form-urlencoded (and other uses) -- see notes
Returns: A pointer to a null terminated string, NULL(0) on failure
- Notes : The returned string must be freed after it's no longer needed,
- to do this Miranda's process heap must be used (under the WINAPI), e.g.
- HeapFree(GetProcessHeap(), 0, the_returned_string)
+ Notes : The returned string must be freed after it's no longer needed using mir_free
Errors : ERROR_INVALID_PARAMETER, ERROR_OUTOFMEMORY
}
MS_NETLIB_URLENCODE = 'Netlib/UrlEncode';
diff --git a/src/mir_core/http.cpp b/src/mir_core/http.cpp new file mode 100644 index 0000000000..aa977fee45 --- /dev/null +++ b/src/mir_core/http.cpp @@ -0,0 +1,58 @@ +/*
+Copyright (C) 2012-13 Miranda NG team (http://miranda-ng.org)
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation version 2
+of the License.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "commonheaders.h"
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
+static const char szHexDigits[] = "0123456789ABCDEF";
+
+MIR_CORE_DLL(char*) mir_urlEncode(const char *szUrl)
+{
+ if (szUrl == NULL)
+ return NULL;
+
+ const char *s;
+ int outputLen;
+ for (outputLen = 0, s = szUrl; *s; s++) {
+ if (('0' <= *s && *s <= '9') || //0-9
+ ('A' <= *s && *s <= 'Z') || //ABC...XYZ
+ ('a' <= *s && *s <= 'z') || //abc...xyz
+ *s == '-' || *s == '_' || *s == '.' || *s == ' ') outputLen++;
+ else outputLen += 3;
+ }
+
+ char *szOutput = (char*)mir_alloc(outputLen+1);
+ if (szOutput == NULL)
+ return NULL;
+
+ char *d = szOutput;
+ for (s = szUrl; *s; s++) {
+ if (('0' <= *s && *s <= '9') || //0-9
+ ('A' <= *s && *s <= 'Z') || //ABC...XYZ
+ ('a' <= *s && *s <= 'z') || //abc...xyz
+ *s == '-' || *s == '_' || *s == '.') *d++ = *s;
+ else if (*s == ' ') *d++='+';
+ else {
+ *d++ = '%';
+ *d++ = szHexDigits[*s >> 4];
+ *d++ = szHexDigits[*s & 0xF];
+ }
+ }
+ *d = '\0';
+ return szOutput;
+}
diff --git a/src/mir_core/mir_core.def b/src/mir_core/mir_core.def index 042b5bb9d9..6858f16234 100644 --- a/src/mir_core/mir_core.def +++ b/src/mir_core/mir_core.def @@ -141,3 +141,4 @@ mir_callNextSubclass @138 KillModuleSubclassing @139
mir_wstrndup @140
mir_unsubclassWindow @141
+mir_urlEncode @142
diff --git a/src/mir_core/mir_core_10.vcxproj b/src/mir_core/mir_core_10.vcxproj index a44a146761..fdb1c7da9d 100644 --- a/src/mir_core/mir_core_10.vcxproj +++ b/src/mir_core/mir_core_10.vcxproj @@ -27,6 +27,7 @@ </ItemGroup>
<ItemGroup>
<ClCompile Include="cmdline.cpp" />
+ <ClCompile Include="http.cpp" />
<ClCompile Include="icons.cpp" />
<ClCompile Include="stdafx.cpp">
<PrecompiledHeader>Create</PrecompiledHeader>
diff --git a/src/mir_core/mir_core_10.vcxproj.filters b/src/mir_core/mir_core_10.vcxproj.filters index 3c50baf5a8..1ccf05526a 100644 --- a/src/mir_core/mir_core_10.vcxproj.filters +++ b/src/mir_core/mir_core_10.vcxproj.filters @@ -61,6 +61,9 @@ <ClCompile Include="subclass.cpp">
<Filter>Source Files</Filter>
</ClCompile>
+ <ClCompile Include="http.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="commonheaders.h">
diff --git a/src/mir_core/mir_core_11.vcxproj b/src/mir_core/mir_core_11.vcxproj index 2a7728f708..84f2ad5cfa 100644 --- a/src/mir_core/mir_core_11.vcxproj +++ b/src/mir_core/mir_core_11.vcxproj @@ -27,6 +27,7 @@ </ItemGroup>
<ItemGroup>
<ClCompile Include="cmdline.cpp" />
+ <ClCompile Include="http.cpp" />
<ClCompile Include="icons.cpp" />
<ClCompile Include="stdafx.cpp">
<PrecompiledHeader>Create</PrecompiledHeader>
diff --git a/src/mir_core/mir_core_11.vcxproj.filters b/src/mir_core/mir_core_11.vcxproj.filters index 3c50baf5a8..1ccf05526a 100644 --- a/src/mir_core/mir_core_11.vcxproj.filters +++ b/src/mir_core/mir_core_11.vcxproj.filters @@ -61,6 +61,9 @@ <ClCompile Include="subclass.cpp">
<Filter>Source Files</Filter>
</ClCompile>
+ <ClCompile Include="http.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="commonheaders.h">
diff --git a/src/mir_core/subclass.cpp b/src/mir_core/subclass.cpp index a2e7530f0e..4bf17e5de2 100644 --- a/src/mir_core/subclass.cpp +++ b/src/mir_core/subclass.cpp @@ -43,7 +43,7 @@ static LRESULT CALLBACK MSubclassWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LP return p->m_hooks[p->m_iHooks-1](hwnd, uMsg, wParam, lParam);
return p->m_origWndProc(hwnd, uMsg, wParam, lParam);
- }
+ }
return DefWindowProc(hwnd, uMsg, wParam, lParam);
}
@@ -67,7 +67,7 @@ MIR_CORE_DLL(void) mir_subclassWindow(HWND hWnd, WNDPROC wndProc) p->m_hooks = (WNDPROC*)realloc(p->m_hooks, (p->m_iHooks+1)*sizeof(WNDPROC));
}
- p->m_hooks[p->m_iHooks++] = wndProc;
+ p->m_hooks[p->m_iHooks++] = wndProc;
}
MIR_CORE_DLL(void) mir_subclassWindowFull(HWND hWnd, WNDPROC wndProc, WNDPROC oldWndProc)
@@ -91,7 +91,7 @@ MIR_CORE_DLL(void) mir_subclassWindowFull(HWND hWnd, WNDPROC wndProc, WNDPROC ol p->m_hooks = (WNDPROC*)realloc(p->m_hooks, (p->m_iHooks+1)*sizeof(WNDPROC));
}
- p->m_hooks[p->m_iHooks++] = wndProc;
+ p->m_hooks[p->m_iHooks++] = wndProc;
}
/////////////////////////////////////////////////////////////////////////////////////////
@@ -141,14 +141,14 @@ MIR_CORE_DLL(LRESULT) mir_callNextSubclass(HWND hWnd, WNDPROC wndProc, UINT uMsg if (p->m_hooks[i] != wndProc)
continue;
- // next hook exists, call it
+ // next hook exists, call it
if (i != 0)
return p->m_hooks[i-1](hWnd, uMsg, wParam, lParam);
// last hook called, ping the default window procedure
if (uMsg != WM_DESTROY)
return p->m_origWndProc(hWnd, uMsg, wParam, lParam);
-
+
WNDPROC saveProc = p->m_origWndProc;
arSubclass.remove(p);
delete p;
@@ -156,7 +156,7 @@ MIR_CORE_DLL(LRESULT) mir_callNextSubclass(HWND hWnd, WNDPROC wndProc, UINT uMsg SetWindowLongPtr(hWnd, GWLP_WNDPROC, (LONG_PTR)saveProc);
return saveProc(hWnd, uMsg, wParam, lParam);
}
-
+
// invalid / closed hook
return 0;
}
diff --git a/src/modules/netlib/netlib.cpp b/src/modules/netlib/netlib.cpp index 4245a0e5d6..5758824627 100644 --- a/src/modules/netlib/netlib.cpp +++ b/src/modules/netlib/netlib.cpp @@ -409,43 +409,19 @@ INT_PTR NetlibShutdown(WPARAM wParam, LPARAM) return 0;
}
-static const char szHexDigits[] = "0123456789ABCDEF";
INT_PTR NetlibHttpUrlEncode(WPARAM, LPARAM lParam)
{
- unsigned char *szOutput, *szInput = (unsigned char*)lParam;
- unsigned char *pszIn, *pszOut;
- int outputLen;
-
- if (szInput == NULL) {
+ if (lParam == NULL) {
SetLastError(ERROR_INVALID_PARAMETER);
- return (INT_PTR)(char*)NULL;
- }
- for (outputLen = 0, pszIn = szInput;*pszIn;pszIn++) {
- if ((48 <= *pszIn && *pszIn <= 57) || //0-9
- (65 <= *pszIn && *pszIn <= 90) || //ABC...XYZ
- (97 <= *pszIn && *pszIn <= 122) || //abc...xyz
- *pszIn == '-' || *pszIn == '_' || *pszIn == '.' || *pszIn == ' ') outputLen++;
- else outputLen+=3;
+ return NULL;
}
- szOutput = (unsigned char*)HeapAlloc(GetProcessHeap(), 0, outputLen+1);
- if (szOutput == NULL) {
+
+ char *p = mir_urlEncode((LPCSTR)lParam);
+ if (p == NULL) {
SetLastError(ERROR_OUTOFMEMORY);
- return (INT_PTR)(unsigned char*)NULL;
- }
- for (pszOut = szOutput, pszIn = szInput;*pszIn;pszIn++) {
- if ((48 <= *pszIn && *pszIn <= 57) ||
- (65 <= *pszIn && *pszIn <= 90) ||
- (97 <= *pszIn && *pszIn <= 122) ||
- *pszIn == '-' || *pszIn == '_' || *pszIn == '.') *pszOut++=*pszIn;
- else if (*pszIn == ' ') *pszOut++='+';
- else {
- *pszOut++='%';
- *pszOut++=szHexDigits[*pszIn>>4];
- *pszOut++=szHexDigits[*pszIn&0xF];
- }
+ return NULL;
}
- *pszOut = '\0';
- return (INT_PTR)szOutput;
+ return (INT_PTR)p;
}
static const char base64chars[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|