| [469] | 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 |  | 
|---|
| [2341] | 9 | #include <odin.h> | 
|---|
| [469] | 10 |  | 
|---|
| [5456] | 11 | #include <wine\unicode.h> | 
|---|
| [4415] | 12 | //SvL: strcase -> case insensitive! | 
|---|
| [10163] | 13 | #define strncasecmp lstrncmpiA | 
|---|
|  | 14 | #define strcasecmp  lstrcmpiA | 
|---|
| [4079] | 15 | #define strncmpiW       lstrncmpiW | 
|---|
| [10163] | 16 | #define _strlwr(a)  strlwr(a) | 
|---|
| [4079] | 17 |  | 
|---|
| [7333] | 18 |  | 
|---|
| [469] | 19 | /***************************************************************************** | 
|---|
|  | 20 | * Prototypes                                                                * | 
|---|
|  | 21 | *****************************************************************************/ | 
|---|
| [9673] | 22 | #ifdef __cplusplus | 
|---|
|  | 23 | extern "C" { | 
|---|
|  | 24 | #endif | 
|---|
| [469] | 25 |  | 
|---|
| [10192] | 26 | extern BOOL fIsDBCSEnv; | 
|---|
|  | 27 |  | 
|---|
|  | 28 | #define IsDBCSEnv()     fIsDBCSEnv | 
|---|
|  | 29 |  | 
|---|
| [469] | 30 | int    WIN32API lstrlenA       (LPCSTR arg1); | 
|---|
|  | 31 | int    WIN32API lstrlenW       (LPCWSTR arg1); | 
|---|
|  | 32 | LPSTR  WIN32API lstrcatA       (LPSTR arg1, LPCSTR arg2); | 
|---|
|  | 33 | LPWSTR WIN32API lstrcatW       (LPWSTR arg1, LPCWSTR arg2); | 
|---|
|  | 34 | int    WIN32API lstrcmpA       (LPCSTR arg1, LPCSTR  arg2); | 
|---|
|  | 35 | int    WIN32API lstrcmpW       (LPCWSTR arg1, LPCWSTR arg2); | 
|---|
| [567] | 36 | int    WIN32API lstrncmpA      (LPCSTR arg1, LPCSTR  arg2, int i); | 
|---|
|  | 37 | int    WIN32API lstrncmpW      (LPCWSTR arg1, LPCWSTR arg2, int i); | 
|---|
| [970] | 38 | int    WIN32API lstrncmpiA     (LPCSTR arg1, LPCSTR  arg2, int i); | 
|---|
| [1130] | 39 | int    WIN32API lstrncmpiW     (LPCWSTR arg1, LPCWSTR arg2, int i); | 
|---|
|  | 40 | #define lstrcmpniW lstrncmpiW | 
|---|
| [469] | 41 | LPSTR  WIN32API lstrcpyA       (LPSTR arg1, LPCSTR  arg2); | 
|---|
|  | 42 | LPWSTR WIN32API lstrcpyW       (LPWSTR dest, LPCWSTR src); | 
|---|
|  | 43 | LPSTR  WIN32API lstrcpynA      (LPSTR arg1, LPCSTR  arg2, int arg3); | 
|---|
|  | 44 | LPWSTR WIN32API lstrcpynW      (LPWSTR dest, LPCWSTR src, int arg3); | 
|---|
|  | 45 | int    WIN32API lstrcmpiA      (LPCSTR arg1, LPCSTR  arg2); | 
|---|
|  | 46 | int    WIN32API lstrcmpiW      (LPCWSTR arg1, LPCWSTR arg2); | 
|---|
| [10163] | 47 | int    WIN32API lstrcpynAtoW   (LPWSTR unicode, LPCSTR ascii, int unilen); | 
|---|
|  | 48 | int    WIN32API lstrcpynWtoA   (LPSTR ascii, LPCWSTR unicode, int asciilen); | 
|---|
| [1974] | 49 | LPSTR  WIN32API lstrcpyWtoA    (LPSTR ascii, LPCWSTR unicode); | 
|---|
|  | 50 | LPWSTR WIN32API lstrcpyAtoW    (LPWSTR unicode, LPCSTR ascii); | 
|---|
| [10163] | 51 | int    WIN32API lstrlenWtoA    ( LPCWSTR ustring, int ulen ); | 
|---|
|  | 52 | int    WIN32API lstrlenAtoW    ( LPCSTR astring, int alen ); | 
|---|
| [10192] | 53 | int    WIN32API lstrtrunc      ( LPSTR astring, int max ); | 
|---|
| [469] | 54 |  | 
|---|
|  | 55 | LPVOID WIN32API HEAP_xalloc    ( HANDLE heap, DWORD flags, DWORD size ); | 
|---|
|  | 56 | LPVOID WIN32API HEAP_xrealloc  ( HANDLE heap, DWORD flags, LPVOID lpMem, DWORD size ); | 
|---|
|  | 57 | LPVOID WIN32API HEAP_malloc    ( DWORD size ); | 
|---|
|  | 58 | LPVOID WIN32API HEAP_realloc   ( LPVOID lpMem, DWORD size ); | 
|---|
| [4363] | 59 | DWORD  WIN32API HEAP_size      ( LPVOID lpMem ); | 
|---|
| [7513] | 60 | BOOL   WIN32API HEAP_free      ( LPVOID lpMem ); | 
|---|
| [469] | 61 |  | 
|---|
|  | 62 | LPSTR  WIN32API HEAP_strdupA   ( HANDLE heap, DWORD flags, LPCSTR str ); | 
|---|
|  | 63 | LPWSTR WIN32API HEAP_strdupW   ( HANDLE heap, DWORD flags, LPCWSTR str ); | 
|---|
|  | 64 | LPWSTR WIN32API HEAP_strdupAtoW( HANDLE heap, DWORD flags, LPCSTR str ); | 
|---|
|  | 65 | LPSTR  WIN32API HEAP_strdupWtoA( HANDLE heap, DWORD flags, LPCWSTR str ); | 
|---|
|  | 66 |  | 
|---|
| [794] | 67 | INT WIN32API WideCharToLocal(LPSTR pLocal, LPWSTR pWide, INT dwChars); | 
|---|
|  | 68 | INT WIN32API LocalToWideChar(LPWSTR pWide, LPSTR pLocal, INT dwChars); | 
|---|
|  | 69 |  | 
|---|
| [9673] | 70 | #ifdef __cplusplus | 
|---|
|  | 71 | } | 
|---|
|  | 72 | #endif | 
|---|
| [7333] | 73 |  | 
|---|
|  | 74 | /***************************************************************************** | 
|---|
|  | 75 | * Special accelerator macros (avoid heap trashing)                          * | 
|---|
|  | 76 | *****************************************************************************/ | 
|---|
|  | 77 |  | 
|---|
|  | 78 | #ifdef __WIN32OS2__ | 
|---|
|  | 79 |  | 
|---|
|  | 80 | #ifndef CP_ACP | 
|---|
|  | 81 | // from include/win/winnls.h | 
|---|
|  | 82 | #define CP_ACP                                  0 | 
|---|
|  | 83 | #endif | 
|---|
|  | 84 |  | 
|---|
|  | 85 | #define STACK_strdupAtoW(strA,strW)                                      \ | 
|---|
|  | 86 | if (!strA) strW = NULL;                                                \ | 
|---|
|  | 87 | else                                                                   \ | 
|---|
|  | 88 | {                                                                      \ | 
|---|
|  | 89 | int len = MultiByteToWideChar( CP_ACP, 0, strA, -1, NULL, 0);        \ | 
|---|
|  | 90 | strW = (LPWSTR)_alloca( len*sizeof(WCHAR) );                         \ | 
|---|
|  | 91 | MultiByteToWideChar(CP_ACP, 0, strA, -1, strW, len);                 \ | 
|---|
|  | 92 | } | 
|---|
|  | 93 |  | 
|---|
|  | 94 | #define STACK_strdupWtoA(strW,strA)                                      \ | 
|---|
|  | 95 | if (!strW) strA = NULL;                                                \ | 
|---|
|  | 96 | else                                                                   \ | 
|---|
|  | 97 | {                                                                      \ | 
|---|
|  | 98 | int len = WideCharToMultiByte( CP_ACP, 0, strW, -1, NULL, 0, 0, NULL);\ | 
|---|
|  | 99 | strA = (LPSTR)_alloca(len);                                        \ | 
|---|
|  | 100 | WideCharToMultiByte(CP_ACP, 0, strW, -1, strA, len, 0, NULL );     \ | 
|---|
|  | 101 | } | 
|---|
|  | 102 |  | 
|---|
|  | 103 | #define STACK_strdupA(strDest, strSrc)                                   \ | 
|---|
|  | 104 | {                                                                      \ | 
|---|
|  | 105 | int iLength = lstrlenA(strSrc) + 1;                                  \ | 
|---|
|  | 106 | strDest = (LPSTR)_alloca( iLength );                                 \ | 
|---|
| [7417] | 107 | memcpy( strDest, strSrc, iLength);                                   \ | 
|---|
| [7333] | 108 | } | 
|---|
|  | 109 |  | 
|---|
|  | 110 | #define STACK_strdupW(strDest, strSrc)                                   \ | 
|---|
|  | 111 | {                                                                      \ | 
|---|
|  | 112 | int iLength = lstrlenW(strSrc) + 1;                                  \ | 
|---|
|  | 113 | strDest = (LPWSTR)_alloca( iLength * sizeof(WCHAR) );                \ | 
|---|
| [7417] | 114 | memcpy( strDest, strSrc, iLength * sizeof(WCHAR) );                  \ | 
|---|
| [7333] | 115 | } | 
|---|
|  | 116 |  | 
|---|
|  | 117 |  | 
|---|
|  | 118 | #endif | 
|---|
|  | 119 |  | 
|---|