| 1 | /*
 | 
|---|
| 2 |  * Project Odin Software License can be found in LICENSE.TXT
 | 
|---|
| 3 |  *
 | 
|---|
| 4 |  * Win32 compatibility string functions for OS/2
 | 
|---|
| 5 |  *
 | 
|---|
| 6 |  * Copyright 1999 Patrick Haller
 | 
|---|
| 7 |  */
 | 
|---|
| 8 | 
 | 
|---|
| 9 | #include <odin.h>
 | 
|---|
| 10 | 
 | 
|---|
| 11 | #include <wine\unicode.h>
 | 
|---|
| 12 | //SvL: strcase -> case insensitive!
 | 
|---|
| 13 | #define strncasecmp     lstrncmpiA
 | 
|---|
| 14 | #define strcasecmp      lstrcmpiA
 | 
|---|
| 15 | #define strncmpiW       lstrncmpiW
 | 
|---|
| 16 | #define _strlwr(a)      strlwr(a)
 | 
|---|
| 17 | 
 | 
|---|
| 18 | 
 | 
|---|
| 19 | /*****************************************************************************
 | 
|---|
| 20 |  * Prototypes                                                                *
 | 
|---|
| 21 |  *****************************************************************************/
 | 
|---|
| 22 | 
 | 
|---|
| 23 | int    WIN32API lstrlenA       (LPCSTR arg1);
 | 
|---|
| 24 | int    WIN32API lstrlenW       (LPCWSTR arg1);
 | 
|---|
| 25 | LPSTR  WIN32API lstrcatA       (LPSTR arg1, LPCSTR arg2);
 | 
|---|
| 26 | LPWSTR WIN32API lstrcatW       (LPWSTR arg1, LPCWSTR arg2);
 | 
|---|
| 27 | int    WIN32API lstrcmpA       (LPCSTR arg1, LPCSTR  arg2);
 | 
|---|
| 28 | int    WIN32API lstrcmpW       (LPCWSTR arg1, LPCWSTR arg2);
 | 
|---|
| 29 | int    WIN32API lstrncmpA      (LPCSTR arg1, LPCSTR  arg2, int i);
 | 
|---|
| 30 | int    WIN32API lstrncmpW      (LPCWSTR arg1, LPCWSTR arg2, int i);
 | 
|---|
| 31 | int    WIN32API lstrncmpiA     (LPCSTR arg1, LPCSTR  arg2, int i);
 | 
|---|
| 32 | int    WIN32API lstrncmpiW     (LPCWSTR arg1, LPCWSTR arg2, int i);
 | 
|---|
| 33 | #define lstrcmpniW lstrncmpiW
 | 
|---|
| 34 | LPSTR  WIN32API lstrcpyA       (LPSTR arg1, LPCSTR  arg2);
 | 
|---|
| 35 | LPWSTR WIN32API lstrcpyW       (LPWSTR dest, LPCWSTR src);
 | 
|---|
| 36 | LPSTR  WIN32API lstrcpynA      (LPSTR arg1, LPCSTR  arg2, int arg3);
 | 
|---|
| 37 | LPWSTR WIN32API lstrcpynW      (LPWSTR dest, LPCWSTR src, int arg3);
 | 
|---|
| 38 | int    WIN32API lstrcmpiA      (LPCSTR arg1, LPCSTR  arg2);
 | 
|---|
| 39 | int    WIN32API lstrcmpiW      (LPCWSTR arg1, LPCWSTR arg2);
 | 
|---|
| 40 | int    WIN32API lstrcpynAtoW   (LPWSTR unicode, LPCSTR ascii, int asciilen);
 | 
|---|
| 41 | int    WIN32API lstrcpynWtoA   (LPSTR ascii, LPCWSTR unicode, int unilen);
 | 
|---|
| 42 | LPSTR  WIN32API lstrcpyWtoA    (LPSTR ascii, LPCWSTR unicode);
 | 
|---|
| 43 | LPWSTR WIN32API lstrcpyAtoW    (LPWSTR unicode, LPCSTR ascii);
 | 
|---|
| 44 | 
 | 
|---|
| 45 | LPVOID WIN32API HEAP_xalloc    ( HANDLE heap, DWORD flags, DWORD size );
 | 
|---|
| 46 | LPVOID WIN32API HEAP_xrealloc  ( HANDLE heap, DWORD flags, LPVOID lpMem, DWORD size );
 | 
|---|
| 47 | LPVOID WIN32API HEAP_malloc    ( DWORD size );
 | 
|---|
| 48 | LPVOID WIN32API HEAP_realloc   ( LPVOID lpMem, DWORD size );
 | 
|---|
| 49 | DWORD  WIN32API HEAP_size      ( LPVOID lpMem );
 | 
|---|
| 50 | BOOL   WIN32API HEAP_free      ( LPVOID lpMem );
 | 
|---|
| 51 | 
 | 
|---|
| 52 | LPSTR  WIN32API HEAP_strdupA   ( HANDLE heap, DWORD flags, LPCSTR str );
 | 
|---|
| 53 | LPWSTR WIN32API HEAP_strdupW   ( HANDLE heap, DWORD flags, LPCWSTR str );
 | 
|---|
| 54 | LPWSTR WIN32API HEAP_strdupAtoW( HANDLE heap, DWORD flags, LPCSTR str );
 | 
|---|
| 55 | LPSTR  WIN32API HEAP_strdupWtoA( HANDLE heap, DWORD flags, LPCWSTR str );
 | 
|---|
| 56 | 
 | 
|---|
| 57 | INT WIN32API WideCharToLocal(LPSTR pLocal, LPWSTR pWide, INT dwChars);
 | 
|---|
| 58 | INT WIN32API LocalToWideChar(LPWSTR pWide, LPSTR pLocal, INT dwChars);
 | 
|---|
| 59 | 
 | 
|---|
| 60 | 
 | 
|---|
| 61 | /*****************************************************************************
 | 
|---|
| 62 |  * Special accelerator macros (avoid heap trashing)                          *
 | 
|---|
| 63 |  *****************************************************************************/
 | 
|---|
| 64 | 
 | 
|---|
| 65 | #ifdef __WIN32OS2__
 | 
|---|
| 66 | 
 | 
|---|
| 67 | #ifndef CP_ACP
 | 
|---|
| 68 | // from include/win/winnls.h
 | 
|---|
| 69 | #define CP_ACP                                  0
 | 
|---|
| 70 | #endif
 | 
|---|
| 71 | 
 | 
|---|
| 72 | #define STACK_strdupAtoW(strA,strW)                                      \
 | 
|---|
| 73 |   if (!strA) strW = NULL;                                                \
 | 
|---|
| 74 |   else                                                                   \
 | 
|---|
| 75 |   {                                                                      \
 | 
|---|
| 76 |     int len = MultiByteToWideChar( CP_ACP, 0, strA, -1, NULL, 0);        \
 | 
|---|
| 77 |     strW = (LPWSTR)_alloca( len*sizeof(WCHAR) );                         \
 | 
|---|
| 78 |     MultiByteToWideChar(CP_ACP, 0, strA, -1, strW, len);                 \
 | 
|---|
| 79 |   }
 | 
|---|
| 80 | 
 | 
|---|
| 81 | #define STACK_strdupWtoA(strW,strA)                                      \
 | 
|---|
| 82 |   if (!strW) strA = NULL;                                                \
 | 
|---|
| 83 |   else                                                                   \
 | 
|---|
| 84 |   {                                                                      \
 | 
|---|
| 85 |       int len = WideCharToMultiByte( CP_ACP, 0, strW, -1, NULL, 0, 0, NULL);\
 | 
|---|
| 86 |       strA = (LPSTR)_alloca(len);                                        \
 | 
|---|
| 87 |       WideCharToMultiByte(CP_ACP, 0, strW, -1, strA, len, 0, NULL );     \
 | 
|---|
| 88 |   }
 | 
|---|
| 89 | 
 | 
|---|
| 90 | #define STACK_strdupA(strDest, strSrc)                                   \
 | 
|---|
| 91 |   {                                                                      \
 | 
|---|
| 92 |     int iLength = lstrlenA(strSrc) + 1;                                  \
 | 
|---|
| 93 |     strDest = (LPSTR)_alloca( iLength );                                 \
 | 
|---|
| 94 |     memcpy( strDest, strSrc, iLength);                                   \
 | 
|---|
| 95 |   }
 | 
|---|
| 96 | 
 | 
|---|
| 97 | #define STACK_strdupW(strDest, strSrc)                                   \
 | 
|---|
| 98 |   {                                                                      \
 | 
|---|
| 99 |     int iLength = lstrlenW(strSrc) + 1;                                  \
 | 
|---|
| 100 |     strDest = (LPWSTR)_alloca( iLength * sizeof(WCHAR) );                \
 | 
|---|
| 101 |     memcpy( strDest, strSrc, iLength * sizeof(WCHAR) );                  \
 | 
|---|
| 102 |   }
 | 
|---|
| 103 | 
 | 
|---|
| 104 | 
 | 
|---|
| 105 | #endif
 | 
|---|
| 106 | 
 | 
|---|