4 * Copyright 1993 Yngvi Sigurjonsson
5 * Copyright 1996 Alexandre Julliard
13 static const BYTE STRING_Oem2Ansi
[256] =
14 "\000\001\002\003\004\005\006\007\010\011\012\013\014\015\016\244"
15 "\020\021\022\023\266\247\026\027\030\031\032\033\034\035\036\037"
16 "\040\041\042\043\044\045\046\047\050\051\052\053\054\055\056\057"
17 "\060\061\062\063\064\065\066\067\070\071\072\073\074\075\076\077"
18 "\100\101\102\103\104\105\106\107\110\111\112\113\114\115\116\117"
19 "\120\121\122\123\124\125\126\127\130\131\132\133\134\135\136\137"
20 "\140\141\142\143\144\145\146\147\150\151\152\153\154\155\156\157"
21 "\160\161\162\163\164\165\166\167\170\171\172\173\174\175\176\177"
22 "\307\374\351\342\344\340\345\347\352\353\350\357\356\354\304\305"
23 "\311\346\306\364\366\362\373\371\377\326\334\242\243\245\120\203"
24 "\341\355\363\372\361\321\252\272\277\137\254\275\274\241\253\273"
25 "\137\137\137\246\246\246\246\053\053\246\246\053\053\053\053\053"
26 "\053\055\055\053\055\053\246\246\053\053\055\055\246\055\053\055"
27 "\055\055\055\053\053\053\053\053\053\053\053\137\137\246\137\137"
28 "\137\337\137\266\137\137\265\137\137\137\137\137\137\137\137\137"
29 "\137\261\137\137\137\137\367\137\260\225\267\137\156\262\137\137";
31 static const BYTE STRING_Ansi2Oem
[256] =
32 "\000\001\002\003\004\005\006\007\010\011\012\013\014\015\016\017"
33 "\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037"
34 "\040\041\042\043\044\045\046\047\050\051\052\053\054\055\056\057"
35 "\060\061\062\063\064\065\066\067\070\071\072\073\074\075\076\077"
36 "\100\101\102\103\104\105\106\107\110\111\112\113\114\115\116\117"
37 "\120\121\122\123\124\125\126\127\130\131\132\133\134\135\136\137"
38 "\140\141\142\143\144\145\146\147\150\151\152\153\154\155\156\157"
39 "\160\161\162\163\164\165\166\167\170\171\172\173\174\175\176\177"
40 "\200\201\054\237\054\137\375\374\210\045\123\074\117\215\216\217"
41 "\220\140\047\042\042\371\055\137\230\231\163\076\157\235\236\131"
42 "\040\255\233\234\017\235\335\025\042\143\246\256\252\055\162\137"
43 "\370\361\375\063\047\346\024\372\054\061\247\257\254\253\137\250"
44 "\101\101\101\101\216\217\222\200\105\220\105\105\111\111\111\111"
45 "\104\245\117\117\117\117\231\170\117\125\125\125\232\131\137\341"
46 "\205\240\203\141\204\206\221\207\212\202\210\211\215\241\214\213"
47 "\144\244\225\242\223\157\224\366\157\227\243\226\201\171\137\230";
49 #define OEM_TO_ANSI(ch) (STRING_Oem2Ansi[(unsigned char)(ch)])
50 #define ANSI_TO_OEM(ch) (STRING_Ansi2Oem[(unsigned char)(ch)])
53 /***********************************************************************
54 * hmemcpy (KERNEL.348)
56 void hmemcpy( LPVOID dst
, LPCVOID src
, LONG count
)
58 memcpy( dst
, src
, count
);
62 /***********************************************************************
63 * lstrcat16 (KERNEL.89)
65 SEGPTR
lstrcat16( SEGPTR dst
, SEGPTR src
)
67 lstrcat32A( (LPSTR
)PTR_SEG_TO_LIN(dst
), (LPCSTR
)PTR_SEG_TO_LIN(src
) );
72 /***********************************************************************
73 * lstrcat32A (KERNEL32.599)
75 LPSTR
lstrcat32A( LPSTR dst
, LPCSTR src
)
82 /***********************************************************************
83 * lstrcat32W (KERNEL32.600)
85 LPWSTR
lstrcat32W( LPWSTR dst
, LPCWSTR src
)
87 register LPWSTR p
= dst
;
89 while ((*p
++ = *src
++));
94 /***********************************************************************
95 * lstrcatn16 (KERNEL.352)
97 SEGPTR
lstrcatn16( SEGPTR dst
, SEGPTR src
, INT16 n
)
99 lstrcatn32A( (LPSTR
)PTR_SEG_TO_LIN(dst
), (LPCSTR
)PTR_SEG_TO_LIN(src
), n
);
104 /***********************************************************************
105 * lstrcatn32A (Not a Windows API)
107 LPSTR
lstrcatn32A( LPSTR dst
, LPCSTR src
, INT32 n
)
109 register LPSTR p
= dst
;
111 if ((n
-= (INT32
)(p
- dst
)) <= 0) return dst
;
112 lstrcpyn32A( p
, src
, n
);
117 /***********************************************************************
118 * lstrcatn32W (Not a Windows API)
120 LPWSTR
lstrcatn32W( LPWSTR dst
, LPCWSTR src
, INT32 n
)
122 register LPWSTR p
= dst
;
124 if ((n
-= (INT32
)(p
- dst
)) <= 0) return dst
;
125 lstrcpyn32W( p
, src
, n
);
130 /***********************************************************************
131 * lstrcmp16 (USER.430)
133 INT16
lstrcmp16( LPCSTR str1
, LPCSTR str2
)
135 return (INT16
)lstrcmp32A( str1
, str2
);
139 /***********************************************************************
140 * lstrcmp32A (KERNEL.602)
142 INT32
lstrcmp32A( LPCSTR str1
, LPCSTR str2
)
144 return (INT32
)strcmp( str1
, str2
);
148 /***********************************************************************
149 * lstrcmp32W (KERNEL.603)
151 INT32
lstrcmp32W( LPCWSTR str1
, LPCWSTR str2
)
153 while (*str1
&& (*str1
== *str2
)) { str1
++; str2
++; }
154 return (INT32
)(*str1
- *str2
);
158 /***********************************************************************
159 * lstrcmpi16 (USER.471)
161 INT16
lstrcmpi16( LPCSTR str1
, LPCSTR str2
)
163 return (INT16
)lstrcmpi32A( str1
, str2
);
167 /***********************************************************************
168 * lstrcmpi32A (KERNEL32.605)
170 INT32
lstrcmpi32A( LPCSTR str1
, LPCSTR str2
)
176 if ((res
= toupper(*str1
) - toupper(*str2
)) != 0) return res
;
180 return toupper(*str1
) - toupper(*str2
);
184 /***********************************************************************
185 * lstrcmpi32W (KERNEL32.606)
187 INT32
lstrcmpi32W( LPCWSTR str1
, LPCWSTR str2
)
194 if ((res
= toupper(*str1
) - toupper(*str2
)) != 0) return res
;
198 return toupper(*str1
) - toupper(*str2
);
202 /***********************************************************************
203 * lstrcpy16 (KERNEL.88)
205 SEGPTR
lstrcpy16( SEGPTR dst
, SEGPTR src
)
207 lstrcpy32A( (LPSTR
)PTR_SEG_TO_LIN(dst
), (LPCSTR
)PTR_SEG_TO_LIN(src
) );
212 /***********************************************************************
213 * lstrcpy32A (KERNEL32.608)
215 LPSTR
lstrcpy32A( LPSTR dst
, LPCSTR src
)
217 if (!src
|| !dst
) return NULL
;
223 /***********************************************************************
224 * lstrcpy32W (KERNEL32.609)
226 LPWSTR
lstrcpy32W( LPWSTR dst
, LPCWSTR src
)
228 register LPWSTR p
= dst
;
229 while ((*p
++ = *src
++));
234 /***********************************************************************
235 * lstrcpyn16 (KERNEL.353)
237 SEGPTR
lstrcpyn16( SEGPTR dst
, SEGPTR src
, INT16 n
)
239 lstrcpyn32A( (LPSTR
)PTR_SEG_TO_LIN(dst
), (LPCSTR
)PTR_SEG_TO_LIN(src
), n
);
244 /***********************************************************************
245 * lstrcpyn32A (KERNEL32.611)
247 LPSTR
lstrcpyn32A( LPSTR dst
, LPCSTR src
, INT32 n
)
250 while ((n
-- > 1) && *src
) *p
++ = *src
++;
256 /***********************************************************************
257 * lstrcpyn32W (KERNEL32.612)
259 LPWSTR
lstrcpyn32W( LPWSTR dst
, LPCWSTR src
, INT32 n
)
262 while ((n
-- > 1) && *src
) *p
++ = *src
++;
268 /***********************************************************************
269 * lstrlen16 (KERNEL.90)
271 INT16
lstrlen16( LPCSTR str
)
273 return (INT16
)lstrlen32A( str
);
277 /***********************************************************************
278 * lstrlen32A (KERNEL32.614)
280 INT32
lstrlen32A( LPCSTR str
)
282 /* looks weird, but win3.1 KERNEL got a GeneralProtection handler
283 * in lstrlen() ... we check only for NULL pointer reference.
287 return (INT32
)strlen(str
);
291 /***********************************************************************
292 * lstrlen32W (KERNEL32.615)
294 INT32
lstrlen32W( LPCWSTR str
)
298 while (*str
++) len
++;
303 /***********************************************************************
304 * lstrncmp32A (Not a Windows API)
306 INT32
lstrncmp32A( LPCSTR str1
, LPCSTR str2
, INT32 n
)
308 return (INT32
)strncmp( str1
, str2
, n
);
312 /***********************************************************************
313 * lstrncmp32W (Not a Windows API)
315 INT32
lstrncmp32W( LPCWSTR str1
, LPCWSTR str2
, INT32 n
)
318 while ((--n
> 0) && *str1
&& (*str1
== *str2
)) { str1
++; str2
++; }
319 return (INT32
)(*str1
- *str2
);
323 /***********************************************************************
324 * lstrncmpi32A (Not a Windows API)
326 INT32
lstrncmpi32A( LPCSTR str1
, LPCSTR str2
, INT32 n
)
331 while ((--n
> 0) && *str1
)
332 if ( (res
= toupper(*str1
++) - toupper(*str2
++)) ) return res
;
334 return toupper(*str1
) - toupper(*str2
);
338 /***********************************************************************
339 * lstrncmpi32W (Not a Windows API)
341 INT32
lstrncmpi32W( LPCWSTR str1
, LPCWSTR str2
, INT32 n
)
346 while ((--n
> 0) && *str1
)
349 if ((res
= toupper(*str1
) - toupper(*str2
)) != 0) return res
;
353 return toupper(*str1
) - toupper(*str2
);
357 /***********************************************************************
358 * lstrcpyAtoW (Not a Windows API)
360 LPWSTR
lstrcpyAtoW( LPWSTR dst
, LPCSTR src
)
362 register LPWSTR p
= dst
;
363 while ((*p
++ = (WCHAR
)(unsigned char)*src
++));
368 /***********************************************************************
369 * lstrcpyWtoA (Not a Windows API)
371 LPSTR
lstrcpyWtoA( LPSTR dst
, LPCWSTR src
)
373 register LPSTR p
= dst
;
374 while ((*p
++ = (CHAR
)*src
++));
379 /***********************************************************************
380 * lstrcpynAtoW (Not a Windows API)
382 LPWSTR
lstrcpynAtoW( LPWSTR dst
, LPCSTR src
, INT32 n
)
385 while ((n
-- > 1) && *src
) *p
++ = (WCHAR
)(unsigned char)*src
++;
391 /***********************************************************************
392 * lstrcpynWtoA (Not a Windows API)
394 LPSTR
lstrcpynWtoA( LPSTR dst
, LPCWSTR src
, INT32 n
)
397 while ((n
-- > 1) && *src
) *p
++ = (CHAR
)*src
++;
403 /***********************************************************************
404 * RtlFillMemory (KERNEL32.441)
406 VOID
RtlFillMemory( LPVOID ptr
, UINT32 len
, UINT32 fill
)
408 memset( ptr
, fill
, len
);
412 /***********************************************************************
413 * RtlMoveMemory (KERNEL32.442)
415 VOID
RtlMoveMemory( LPVOID dst
, LPCVOID src
, UINT32 len
)
417 memmove( dst
, src
, len
);
421 /***********************************************************************
422 * RtlZeroMemory (KERNEL32.444)
424 VOID
RtlZeroMemory( LPVOID ptr
, UINT32 len
)
426 memset( ptr
, 0, len
);
430 /***********************************************************************
431 * AnsiToOem16 (KEYBOARD.5)
433 INT16
AnsiToOem16( LPCSTR s
, LPSTR d
)
435 CharToOem32A( s
, d
);
440 /***********************************************************************
441 * OemToAnsi16 (KEYBOARD.6)
443 INT16
OemToAnsi16( LPCSTR s
, LPSTR d
)
445 OemToChar32A( s
, d
);
450 /***********************************************************************
451 * AnsiToOemBuff16 (KEYBOARD.134)
453 void AnsiToOemBuff16( LPCSTR s
, LPSTR d
, UINT16 len
)
455 CharToOemBuff32A( s
, d
, len
? len
: 65536 );
459 /***********************************************************************
460 * OemToAnsiBuff16 (KEYBOARD.135)
462 void OemToAnsiBuff16( LPCSTR s
, LPSTR d
, UINT16 len
)
464 OemToCharBuff32A( s
, d
, len
? len
: 65536 );
468 /***********************************************************************
469 * CharToOem32A (USER32.36)
471 BOOL32
CharToOem32A( LPCSTR s
, LPSTR d
)
473 if (!s
|| !d
) return TRUE
;
474 while ((*d
++ = ANSI_TO_OEM(*s
++)));
479 /***********************************************************************
480 * CharToOemBuff32A (USER32.37)
482 BOOL32
CharToOemBuff32A( LPCSTR s
, LPSTR d
, DWORD len
)
484 while (len
--) *d
++ = ANSI_TO_OEM(*s
++);
489 /***********************************************************************
490 * CharToOemBuff32W (USER32.38)
492 BOOL32
CharToOemBuff32W( LPCWSTR s
, LPSTR d
, DWORD len
)
494 while (len
--) *d
++ = ANSI_TO_OEM(*s
++);
499 /***********************************************************************
500 * CharToOem32W (USER32.39)
502 BOOL32
CharToOem32W( LPCWSTR s
, LPSTR d
)
504 while ((*d
++ = ANSI_TO_OEM(*s
++)));
509 /***********************************************************************
510 * OemToChar32A (USER32.401)
512 BOOL32
OemToChar32A( LPCSTR s
, LPSTR d
)
514 while ((*d
++ = OEM_TO_ANSI(*s
++)));
519 /***********************************************************************
520 * OemToCharBuff32A (USER32.402)
522 BOOL32
OemToCharBuff32A( LPCSTR s
, LPSTR d
, DWORD len
)
524 while (len
--) *d
++ = OEM_TO_ANSI(*s
++);
529 /***********************************************************************
530 * OemToCharBuff32W (USER32.403)
532 BOOL32
OemToCharBuff32W( LPCSTR s
, LPWSTR d
, DWORD len
)
534 while (len
--) *d
++ = (WCHAR
)OEM_TO_ANSI(*s
++);
539 /***********************************************************************
540 * OemToChar32W (USER32.404)
542 BOOL32
OemToChar32W( LPCSTR s
, LPWSTR d
)
544 while ((*d
++ = (WCHAR
)OEM_TO_ANSI(*s
++)));