diff options
Diffstat (limited to 'src/mir_core/utils.cpp')
-rw-r--r-- | src/mir_core/utils.cpp | 34 |
1 files changed, 34 insertions, 0 deletions
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;
+}
|