diff options
Diffstat (limited to 'src/mir_core/utils.cpp')
-rw-r--r-- | src/mir_core/utils.cpp | 136 |
1 files changed, 127 insertions, 9 deletions
diff --git a/src/mir_core/utils.cpp b/src/mir_core/utils.cpp index 69ad5de18e..28d48f7f33 100644 --- a/src/mir_core/utils.cpp +++ b/src/mir_core/utils.cpp @@ -24,7 +24,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "commonheaders.h"
-MIR_CORE_DLL(char*) replaceStr( char* &dest, const char *src)
+MIR_CORE_DLL(char*) replaceStr(char* &dest, const char *src)
{
if (dest != NULL)
mir_free(dest);
@@ -32,7 +32,7 @@ MIR_CORE_DLL(char*) replaceStr( char* &dest, const char *src) return dest = (src != NULL) ? mir_strdup(src) : NULL;
}
-MIR_CORE_DLL(WCHAR*) replaceStrW( WCHAR* &dest, const WCHAR *src)
+MIR_CORE_DLL(WCHAR*) replaceStrW(WCHAR* &dest, const WCHAR *src)
{
if (dest != NULL)
mir_free(dest);
@@ -175,7 +175,7 @@ MIR_CORE_DLL(int) wildcmpw(const WCHAR *name, const WCHAR *mask) }
if (*mask != '*') return FALSE;
for (;; mask++, name++) {
- while(*mask == '*') {
+ while (*mask == '*') {
last = mask++;
if (*mask == '\0') return ((BOOL)!*mask); /* true */
}
@@ -198,12 +198,12 @@ MIR_CORE_DLL(int) wildcmpi(const char *name, const char *mask) }
if (*mask != '*') return FALSE;
for (;; mask++, name++) {
- while(*mask == '*') {
+ while (*mask == '*') {
last = mask++;
if (*mask == '\0') return ((BOOL)!*mask); /* true */
}
if (*name == '\0') return ((BOOL)!*mask); /* *mask == EOS */
- if (*mask != '?' && _qtoupper(*mask) != _qtoupper(*name)) name -= (size_t)(mask - last) - 1, mask = last;
+ if (*mask != '?' && _qtoupper(*mask) != _qtoupper(*name)) name -= (size_t)(mask - last) - 1, mask = last;
}
}
@@ -219,12 +219,12 @@ MIR_CORE_DLL(int) wildcmpiw(const WCHAR *name, const WCHAR *mask) }
if (*mask != '*') return FALSE;
for (;; mask++, name++) {
- while(*mask == '*') {
+ while (*mask == '*') {
last = mask++;
if (*mask == '\0') return ((BOOL)!*mask); /* true */
}
if (*name == '\0') return ((BOOL)!*mask); /* *mask == EOS */
- if (*mask != '?' && _qtoupper(*mask) != _qtoupper(*name)) name -= (size_t)(mask - last) - 1, mask = last;
+ if (*mask != '?' && _qtoupper(*mask) != _qtoupper(*name)) name -= (size_t)(mask - last) - 1, mask = last;
}
}
@@ -237,7 +237,7 @@ 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++) {
+ for (size_t i = 0; i < len; i++, p++) {
*d++ = szHexTable[*p >> 4];
*d++ = szHexTable[*p & 0x0F];
}
@@ -251,7 +251,7 @@ 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++) {
+ for (size_t i = 0; i < len; i++, p++) {
*d++ = szHexTable[*p >> 4];
*d++ = szHexTable[*p & 0x0F];
}
@@ -259,3 +259,121 @@ MIR_CORE_DLL(WCHAR*) bin2hexW(const void *pData, size_t len, WCHAR *dest) return dest;
}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
+#pragma intrinsic(strlen, strcpy, strcat, wcslen, wcscpy, wcscat)
+
+MIR_CORE_DLL(size_t) mir_strlen(const char *p)
+{
+ return (p) ? strlen(p) : 0;
+}
+
+MIR_CORE_DLL(size_t) mir_wstrlen(const wchar_t *p)
+{
+ return (p) ? wcslen(p) : 0;
+}
+
+MIR_CORE_DLL(char*) mir_strcpy(char *dest, const char *src)
+{
+ if (dest == NULL)
+ return NULL;
+
+ if (src == NULL) {
+ *dest = 0;
+ return dest;
+ }
+
+ return strcpy(dest, src);
+}
+
+MIR_CORE_DLL(wchar_t*) mir_wstrcpy(wchar_t *dest, const wchar_t *src)
+{
+ if (dest == NULL)
+ return NULL;
+
+ if (src == NULL) {
+ *dest = 0;
+ return dest;
+ }
+
+ return wcscpy(dest, src);
+}
+
+MIR_CORE_DLL(char*) mir_strncpy(char *dest, const char *src, size_t len)
+{
+ if (dest == NULL)
+ return NULL;
+
+ if (src == NULL) {
+ *dest = 0;
+ return dest;
+ }
+
+ return strncpy(dest, src, len);
+}
+
+MIR_CORE_DLL(wchar_t*) mir_wstrncpy(wchar_t *dest, const wchar_t *src, size_t len)
+{
+ if (dest == NULL)
+ return NULL;
+
+ if (src == NULL) {
+ *dest = 0;
+ return dest;
+ }
+
+ return wcsncpy(dest, src, len);
+}
+
+MIR_CORE_DLL(char*) mir_strcat(char *dest, const char *src)
+{
+ if (dest == NULL)
+ return NULL;
+
+ if (src == NULL) {
+ *dest = 0;
+ return dest;
+ }
+
+ return strcat(dest, src);
+}
+
+MIR_CORE_DLL(wchar_t*) mir_wstrcat(wchar_t *dest, const wchar_t *src)
+{
+ if (dest == NULL)
+ return NULL;
+
+ if (src == NULL) {
+ *dest = 0;
+ return dest;
+ }
+
+ return wcscat(dest, src);
+}
+
+MIR_CORE_DLL(char*) mir_strncat(char *dest, const char *src, size_t len)
+{
+ if (dest == NULL)
+ return NULL;
+
+ if (src == NULL) {
+ *dest = 0;
+ return dest;
+ }
+
+ return strncat(dest, src, len);
+}
+
+MIR_CORE_DLL(wchar_t*) mir_wstrncat(wchar_t *dest, const wchar_t *src, size_t len)
+{
+ if (dest == NULL)
+ return NULL;
+
+ if (src == NULL) {
+ *dest = 0;
+ return dest;
+ }
+
+ return wcsncat(dest, src, len);
+}
|