summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bin10/lib/mir_core.libbin49958 -> 50334 bytes
-rw-r--r--bin10/lib/mir_core64.libbin45476 -> 45804 bytes
-rw-r--r--bin11/lib/mir_core.libbin49958 -> 50334 bytes
-rw-r--r--bin11/lib/mir_core64.libbin45476 -> 45804 bytes
-rw-r--r--include/delphi/m_core.inc6
-rw-r--r--include/m_core.h25
-rw-r--r--src/mir_core/mir_core.def2
-rw-r--r--src/mir_core/utils.cpp34
8 files changed, 58 insertions, 9 deletions
diff --git a/bin10/lib/mir_core.lib b/bin10/lib/mir_core.lib
index db16ef5188..e801d4686d 100644
--- a/bin10/lib/mir_core.lib
+++ b/bin10/lib/mir_core.lib
Binary files differ
diff --git a/bin10/lib/mir_core64.lib b/bin10/lib/mir_core64.lib
index d936d51975..9523446aba 100644
--- a/bin10/lib/mir_core64.lib
+++ b/bin10/lib/mir_core64.lib
Binary files differ
diff --git a/bin11/lib/mir_core.lib b/bin11/lib/mir_core.lib
index 553bbe2092..fc21ec1695 100644
--- a/bin11/lib/mir_core.lib
+++ b/bin11/lib/mir_core.lib
Binary files differ
diff --git a/bin11/lib/mir_core64.lib b/bin11/lib/mir_core64.lib
index be95d42b45..883fa9b5a5 100644
--- a/bin11/lib/mir_core64.lib
+++ b/bin11/lib/mir_core64.lib
Binary files differ
diff --git a/include/delphi/m_core.inc b/include/delphi/m_core.inc
index a8ecb0227d..9b36825a91 100644
--- a/include/delphi/m_core.inc
+++ b/include/delphi/m_core.inc
@@ -633,6 +633,12 @@ function replaceStr(var dest:pAnsiChar; const src:pAnsiChar):pAnsiChar; stdcall;
external CoreDLL name 'replaceStr';
function replaceStrW(var dest:pWideChar; const src:pWideChar):pWideChar; stdcall;
external CoreDLL name 'replaceStrW';
+
+function bin2hex(data:pointer; dataLen:uint_ptr; pDest:pAnsiChar):pAnsiChar; stdcall;
+ external CoreDLL name 'bin2hex';
+function bin2hexW(data:pointer; dataLen:uint_ptr; pDest:pWideChar):pWideChar; stdcall;
+ external CoreDLL name 'bin2hexW';
+
///////////////////////////////////////////////////////////////////////////////
// text conversion functions
diff --git a/include/m_core.h b/include/m_core.h
index 7d80dc6931..73937eb366 100644
--- a/include/m_core.h
+++ b/include/m_core.h
@@ -692,6 +692,9 @@ MIR_CORE_DLL(int) wildcmpw(const WCHAR *name, const WCHAR *mask);
MIR_CORE_DLL(int) wildcmpi(const char *name, const char *mask);
MIR_CORE_DLL(int) wildcmpiw(const WCHAR *name, const WCHAR *mask);
+MIR_CORE_DLL(char*) bin2hex(const void *pData, size_t len, char *dest);
+MIR_CORE_DLL(WCHAR*) bin2hexW(const void *pData, size_t len, WCHAR *dest);
+
__forceinline char* lrtrim(char *str) { return ltrim(rtrim(str)); };
__forceinline char* lrtrimp(char *str) { return ltrimp(rtrim(str)); };
@@ -719,19 +722,21 @@ __forceinline char* lrtrimp(char *str) { return ltrimp(rtrim(str)); };
#define mir_tstrdup mir_wstrdup
#define mir_tstrndup mir_wstrndup
- #define replaceStrT replaceStrW
- #define rtrimt rtrimw
- #define ltrimt ltrimw
+ #define replaceStrT replaceStrW
+ #define bin2hexT bin2hexW
+
+ #define rtrimt rtrimw
+ #define ltrimt ltrimw
#define ltrimpt ltrimpw
- #define wildcmpt wildcmpw
+ #define wildcmpt wildcmpw
#define wildcmpit wildcmpiw
- #define mir_sntprintf mir_snwprintf
+ #define mir_sntprintf mir_snwprintf
#define mir_vsntprintf mir_vsnwprintf
- #define mir_writeLogT mir_writeLogW
+ #define mir_writeLogT mir_writeLogW
#define mir_writeLogVT mir_writeLogVW
#else
#define mir_t2a(s) mir_strdup(s)
@@ -746,7 +751,9 @@ __forceinline char* lrtrimp(char *str) { return ltrimp(rtrim(str)); };
#define mir_tstrdup mir_strdup
#define mir_tstrndup mir_strndup
- #define replaceStrT replaceStr
+
+ #define replaceStrT replaceStr
+ #define bin2hexT bin2hex
#define rtrimt rtrim
#define ltrimt ltrim
@@ -755,10 +762,10 @@ __forceinline char* lrtrimp(char *str) { return ltrimp(rtrim(str)); };
#define wildcmpt wildcmp
#define wildcmpit wildcmpi
- #define mir_sntprintf mir_snprintf
+ #define mir_sntprintf mir_snprintf
#define mir_vsntprintf mir_vsnprintf
- #define mir_writeLogT mir_writeLogA
+ #define mir_writeLogT mir_writeLogA
#define mir_writeLogVT mir_writeLogVA
#endif
diff --git a/src/mir_core/mir_core.def b/src/mir_core/mir_core.def
index c820c2dd59..037afb2aaf 100644
--- a/src/mir_core/mir_core.def
+++ b/src/mir_core/mir_core.def
@@ -227,3 +227,5 @@ mir_writeLogA @224
mir_writeLogW @225
mir_writeLogVA @226
mir_writeLogVW @227
+bin2hex @228
+bin2hexW @229
diff --git a/src/mir_core/utils.cpp b/src/mir_core/utils.cpp
index 52eef31fc2..d357b4538f 100644
--- a/src/mir_core/utils.cpp
+++ b/src/mir_core/utils.cpp
@@ -139,6 +139,8 @@ MIR_CORE_DLL(WCHAR*) ltrimpw(WCHAR *str)
}
}
+/////////////////////////////////////////////////////////////////////////////////////////
+
MIR_CORE_DLL(int) wildcmp(const char *name, const char *mask)
{
const char *last='\0';
@@ -212,3 +214,35 @@ MIR_CORE_DLL(int) wildcmpiw(const WCHAR *name, const WCHAR *mask)
if (*mask != '?' && _qtoupper(*mask) != _qtoupper(*name)) name -= (size_t)(mask - last) - 1, mask = last;
}
}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
+static char szHexTable[] = "0123456789abcdef";
+
+MIR_CORE_DLL(char*) bin2hex(const void *pData, size_t len, char *dest)
+{
+ const BYTE *p = (const BYTE*)pData;
+ char *d = dest;
+
+ for (size_t i=0; i < len; i++, p++) {
+ *d++ = szHexTable[*p >> 4];
+ *d++ = szHexTable[*p & 0x0F];
+ }
+ *d = 0;
+
+ return dest;
+}
+
+MIR_CORE_DLL(WCHAR*) bin2hexW(const void *pData, size_t len, WCHAR *dest)
+{
+ const BYTE *p = (const BYTE*)pData;
+ WCHAR *d = dest;
+
+ for (size_t i=0; i < len; i++, p++) {
+ *d++ = szHexTable[*p >> 4];
+ *d++ = szHexTable[*p & 0x0F];
+ }
+ *d = 0;
+
+ return dest;
+}