- Timestamp:
- Jun 9, 1999, 10:16:53 PM (26 years ago)
- Location:
- trunk/src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/NTDLL/rtlstr.cpp
r56 r83 2 2 * Project Odin Software License can be found in LICENSE.TXT 3 3 * Win32 NT Runtime / NTDLL for OS/2 4 *5 * Copyright 1998 original WINE Author6 * Copyright 1998, 1999 Patrick Haller (phaller@gmx.net)7 *8 4 * Rtl string functions 9 5 * 10 6 * Copyright 1996-1998 Marcus Meissner 7 * Copyright 1998, 1999 Patrick Haller (phaller@gmx.net) 11 8 */ 12 9 … … 16 13 #include <string.h> 17 14 #include <ctype.h> 15 16 #include <os2win.h> 17 #include <unicode.h> 18 18 19 19 #include "ntdll.h" … … 61 61 return STATUS_BUFFER_OVERFLOW; 62 62 63 lstrcpynAtoW(uni->Buffer,ansi->Buffer,unilen/2); 63 AsciiToUnicodeN(ansi->Buffer, 64 uni->Buffer, 65 unilen/2); 64 66 65 67 return STATUS_SUCCESS; … … 99 101 return STATUS_BUFFER_OVERFLOW; 100 102 101 lstrcpynAtoW(uni->Buffer,102 ansi->Buffer,103 AsciiToUnicodeN(ansi->Buffer, 104 uni->Buffer, 103 105 unilen/2); 104 106 return STATUS_SUCCESS; … … 135 137 (len+1)*sizeof(WCHAR)); 136 138 137 lstrcpynAtoW(x,138 oemstr,139 len+1);139 AsciiToUnicodeN(oemstr, 140 x, 141 len+1); 140 142 141 143 memcpy(unistr, … … 178 180 (len+1)*sizeof(WCHAR)); 179 181 180 lstrcpynAtoW(x,181 oemstr,182 len+1);182 AsciiToUnicodeN(oemstr, 183 x, 184 len+1); 183 185 184 186 memcpy(unistr, … … 214 216 215 217 /************************************************************************** 216 * RtlInitOemString 218 * RtlInitOemString 217 219 */ 218 220 VOID WINAPI RtlInitOemString(POEM_STRING target, … … 348 350 len+1); 349 351 350 lstrcpynWtoA(x,351 unistr,352 len+1);352 UnicodeToAsciiN(unistr, 353 x, 354 len+1); 353 355 354 356 memcpy(oemstr, … … 384 386 385 387 oem->Length = uni->Length/2; 386 lstrcpynWtoA(oem->Buffer,387 uni->Buffer,388 uni->Length/2+1);388 UnicodeToAsciiN(uni->Buffer, 389 oem->Buffer, 390 oem->MaximumLength); 389 391 return 0; 390 392 } … … 411 413 412 414 oem->Length = uni->Length/2; 413 lstrcpynWtoA(oem->Buffer,414 uni->Buffer,415 uni->Length/2+1);415 UnicodeToAsciiN(uni->Buffer, 416 oem->Buffer, 417 oem->MaximumLength); 416 418 417 419 return 0; -
trunk/src/kernel32/unicode.cpp
r81 r83 1 1 /* 2 *3 2 * Project Odin Software License can be found in LICENSE.TXT 4 *5 */6 /*7 3 * Unicode functions 8 *9 4 * Copyright 1998 Joel Troster 10 * 5 * Copyright 1999 Patrick haller 11 6 */ 12 7 #include <os2win.h> … … 136 131 } 137 132 else 138 {139 for(i = 0; i < unilen; i++) {140 141 } 142 astring[unilen] = 0;143 } 133 /* idiots unicode conversion :) */ 134 for(i = 0; i < unilen; i++) 135 astring[i] = (char)ustring[i]; 136 137 astring[unilen] = 0; // @@@PH: 1999/06/09 fix - always terminate string 138 144 139 return(unilen); 145 140 } … … 217 212 218 213 unicode[asciilen] = 0; 214 //SvL: Messes up the heap 215 // unicode[len+1] = 0; /* @@@PH 98/06/07 */ 219 216 } 220 217 //****************************************************************************** -
trunk/src/user32/RESSTRING.C
r46 r83 23 23 #include "unicode.h" 24 24 25 static char *UnicodeToAsciiN(WCHAR *wstring, char *astring, int maxlen);26 27 25 /******************************************************************************/ 28 //Strings stored as original: WORD len 26 //Strings stored as original: WORD len 29 27 // UNICODE string (not null terminated) 30 28 /******************************************************************************/ 31 int OS2LoadStringAscii(HINSTANCE hinst, UINT wID, LPSTR lpBuffer, int cchBuffer) 29 int OS2LoadStringAscii(HINSTANCE hinst, 30 UINT wID, 31 LPSTR lpBuffer, 32 int cchBuffer) 32 33 { 33 APIRET rc;34 WCHAR *szbuf;35 char modname[128];36 HMODULE hmodule;34 APIRET rc; 35 WCHAR *szbuf; 36 char modname[128]; 37 HMODULE hmodule; 37 38 38 if(hinst != 0 && hinst != -1) { 39 if(Win32QueryModuleName(hinst, modname, sizeof(modname)) == 0) { 40 #ifdef DEBUG 41 WriteLog("Can't determine handle of dll %X\n", hinst); 42 #endif 43 return(0); 44 } 45 rc = DosQueryModuleHandle(modname, &hmodule); 46 if(rc) { 47 #ifdef DEBUG 48 WriteLog("Can't determine handle of dll %s\n", modname); 49 #endif 50 return(0); 51 } 39 if(hinst != 0 && hinst != -1) 40 { 41 if(Win32QueryModuleName(hinst, 42 modname, 43 sizeof(modname)) == 0) 44 { 45 dprintf(("USER32: OS2LoadStringAscii: Can't determine handle of dll %08xh\n", 46 hinst)); 47 return(0); 48 } 49 50 rc = DosQueryModuleHandle(modname, 51 &hmodule); 52 if(rc) 53 { 54 dprintf(("USER32: OS2LoadStringAscii: Can't determine handle of dll %s\n", 55 modname)); 56 57 return(0); 58 } 52 59 } 53 else hmodule = 0; 60 else 61 hmodule = 0; 54 62 55 rc = DosGetResource(hmodule, RT_RCDATA, wID, (PPVOID)&szbuf); 56 if(rc) { 57 #ifdef DEBUG 58 WriteLog("OS2LoadString failed with rc %d\n", rc); 59 #endif 60 if(lpBuffer) *lpBuffer = 0; 61 return(0); //TODO: SetLastError! 63 rc = DosGetResource(hmodule, 64 RT_RCDATA, 65 wID, 66 (PPVOID)&szbuf); 67 if(rc) 68 { 69 dprintf(("USER32: OS2LoadStringAscii failed with rc %08xh\n", 70 rc)); 71 72 if(lpBuffer) 73 *lpBuffer = 0; 74 75 return(0); //TODO: SetLastError! 62 76 } 63 UnicodeToAsciiN(szbuf+1, lpBuffer, min((*szbuf), cchBuffer-1)); 64 #ifdef DEBUG 65 WriteLog("OS2LoadString retrieved string '%s' (size %d)\n", lpBuffer, (int)*szbuf); 66 #endif 77 78 UnicodeToAsciiN(szbuf+1, 79 lpBuffer, 80 min((*szbuf), cchBuffer-1)); 81 82 dprintf(("USER32: OS2LoadStringA retrieved string '%s' (size %d)\n", 83 lpBuffer, 84 (int)*szbuf)); 85 67 86 DosFreeResource(szbuf); 68 return(strlen(lpBuffer)); 87 return(strlen(lpBuffer)); //not including null terminator! 69 88 } 70 89 //****************************************************************************** 71 90 //****************************************************************************** 72 int OS2LoadStringUnicode(HINSTANCE hinst, UINT wID, WCHAR *lpBuffer, int cchBuffer) 91 int OS2LoadStringUnicode(HINSTANCE hinst, 92 UINT wID, 93 WCHAR *lpBuffer, 94 int cchBuffer) 73 95 { 74 APIRET rc; 75 WCHAR *szbuf; 76 char modname[128]; 77 HMODULE hmodule; 96 APIRET rc; 97 WCHAR *szbuf; 98 char modname[128]; 99 HMODULE hmodule; 100 78 101 #ifdef DEBUG 79 102 char *astring; 80 103 #endif 81 104 82 if(hinst != 0 && hinst != -1) { 83 if(Win32QueryModuleName(hinst, modname, sizeof(modname)) == 0) { 84 #ifdef DEBUG 85 WriteLog("Can't determine handle of dll %X\n", hinst); 86 #endif 87 return(0); 88 } 89 rc = DosQueryModuleHandle(modname, &hmodule); 90 if(rc) { 91 #ifdef DEBUG 92 WriteLog("Can't determine handle of dll %s\n", modname); 93 #endif 94 return(0); 95 } 105 if(hinst != 0 && hinst != -1) 106 { 107 if(Win32QueryModuleName(hinst, 108 modname, 109 sizeof(modname)) == 0) 110 { 111 dprintf(("USER32: OS2LoadStringUnicode: Can't determine handle of dll %08xh\n", 112 hinst)); 113 return(0); 114 } 115 116 rc = DosQueryModuleHandle(modname, 117 &hmodule); 118 if(rc) 119 { 120 dprintf(("USER32: OS2LoadStringUnicode: Can't determine handle of dll %s\n", 121 modname)); 122 123 return(0); 124 } 96 125 } 97 else hmodule = 0; 126 else 127 hmodule = 0; 98 128 99 rc = DosGetResource(hmodule, RT_RCDATA, wID, (PPVOID)&szbuf); 100 if(rc) { 101 #ifdef DEBUG 102 WriteLog("OS2LoadString failed with rc %d\n", rc); 103 #endif 104 if(lpBuffer) *lpBuffer = 0; 105 return(0); //TODO: SetLastError! 129 rc = DosGetResource(hmodule, 130 RT_RCDATA, 131 wID, 132 (PPVOID)&szbuf); 133 if(rc) 134 { 135 dprintf(("USER32: OS2LoadStringUnicode failed with rc %08xh\n", 136 rc)); 137 138 if(lpBuffer) 139 *lpBuffer = 0; 140 141 return(0); //TODO: SetLastError! 106 142 } 107 memcpy(lpBuffer, szbuf+1, min((*szbuf), cchBuffer-1)*sizeof(WCHAR)); 143 144 145 memcpy(lpBuffer, 146 szbuf+1, 147 min((*szbuf), cchBuffer-1) * sizeof(WCHAR)); 148 108 149 lpBuffer[min((*szbuf), cchBuffer-1)] = 0; 109 150 110 151 #ifdef DEBUG 111 152 astring = UnicodeToAsciiString(lpBuffer); 112 WriteLog("OS2LoadStringW retrieved string '%s' of size %d\n", astring, (int)*szbuf); 153 WriteLog("USER32: OS2LoadStringUnicode retrieved string '%s' of size %d\n", 154 astring, 155 (int)*szbuf); 113 156 FreeAsciiString(astring); 114 157 #endif 158 115 159 DosFreeResource(szbuf); 116 return(UniStrlen(lpBuffer)); 160 return(UniStrlen(lpBuffer)); //not including null terminator! 117 161 } 118 //******************************************************************************119 //******************************************************************************120 static char *UnicodeToAsciiN(WCHAR *wstring, char *astring, int maxlen)121 {122 int i;123 162 124 for(i=0;i<maxlen;i++) {125 astring[i] = (UCHAR)wstring[i];126 }127 astring[maxlen] = 0;128 return(astring);129 }130 /******************************************************************************/131 /******************************************************************************/132
Note:
See TracChangeset
for help on using the changeset viewer.