4 * Copyright 1993 Yngvi Sigurjonsson (yngvi@hafro.is)
17 #define ToUpper(c) toupper(c)
18 #define ToLower(c) tolower(c)
21 static const BYTE Oem2Ansi
[256] =
22 "\000\001\002\003\004\005\006\007\010\011\012\013\014\015\016\244"
23 "\020\021\022\023\266\247\026\027\030\031\032\033\034\035\036\037"
24 "\040\041\042\043\044\045\046\047\050\051\052\053\054\055\056\057"
25 "\060\061\062\063\064\065\066\067\070\071\072\073\074\075\076\077"
26 "\100\101\102\103\104\105\106\107\110\111\112\113\114\115\116\117"
27 "\120\121\122\123\124\125\126\127\130\131\132\133\134\135\136\137"
28 "\140\141\142\143\144\145\146\147\150\151\152\153\154\155\156\157"
29 "\160\161\162\163\164\165\166\167\170\171\172\173\174\175\176\177"
30 "\307\374\351\342\344\340\345\347\352\353\350\357\356\354\304\305"
31 "\311\346\306\364\366\362\373\371\377\326\334\242\243\245\120\203"
32 "\341\355\363\372\361\321\252\272\277\137\254\275\274\241\253\273"
33 "\137\137\137\246\246\246\246\053\053\246\246\053\053\053\053\053"
34 "\053\055\055\053\055\053\246\246\053\053\055\055\246\055\053\055"
35 "\055\055\055\053\053\053\053\053\053\053\053\137\137\246\137\137"
36 "\137\337\137\266\137\137\265\137\137\137\137\137\137\137\137\137"
37 "\137\261\137\137\137\137\367\137\260\225\267\137\156\262\137\137";
39 static const BYTE Ansi2Oem
[256] =
40 "\000\001\002\003\004\005\006\007\010\011\012\013\014\015\016\017"
41 "\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037"
42 "\040\041\042\043\044\045\046\047\050\051\052\053\054\055\056\057"
43 "\060\061\062\063\064\065\066\067\070\071\072\073\074\075\076\077"
44 "\100\101\102\103\104\105\106\107\110\111\112\113\114\115\116\117"
45 "\120\121\122\123\124\125\126\127\130\131\132\133\134\135\136\137"
46 "\140\141\142\143\144\145\146\147\150\151\152\153\154\155\156\157"
47 "\160\161\162\163\164\165\166\167\170\171\172\173\174\175\176\177"
48 "\200\201\054\237\054\137\375\374\210\045\123\074\117\215\216\217"
49 "\220\140\047\042\042\371\055\137\230\231\163\076\157\235\236\131"
50 "\040\255\233\234\017\235\335\025\042\143\246\256\252\055\162\137"
51 "\370\361\375\063\047\346\024\372\054\061\247\257\254\253\137\250"
52 "\101\101\101\101\216\217\222\200\105\220\105\105\111\111\111\111"
53 "\104\245\117\117\117\117\231\170\117\125\125\125\232\131\137\341"
54 "\205\240\203\141\204\206\221\207\212\202\210\211\215\241\214\213"
55 "\144\244\225\242\223\157\224\366\157\227\243\226\201\171\137\230";
57 /* Funny to divide them between user and kernel. */
60 SEGPTR
lstrcat( SEGPTR target
, SEGPTR source
)
62 strcat( (char *)PTR_SEG_TO_LIN(target
), (char *)PTR_SEG_TO_LIN(source
) );
67 INT
lstrcmp(LPCSTR str1
,LPCSTR str2
)
69 return strcmp( str1
, str2
);
73 INT
lstrcmpi( LPCSTR str1
, LPCSTR str2
)
79 if ((res
= toupper(*str1
) - toupper(*str2
)) != 0) return res
;
83 return toupper(*str1
) - toupper(*str2
);
86 /* Not a Windows API*/
87 INT
lstrncmpi( LPCSTR str1
, LPCSTR str2
, int n
)
92 while ((--n
> 0) && *str1
)
94 if ((res
= toupper(*str1
) - toupper(*str2
)) != 0) return res
;
98 return toupper(*str1
) - toupper(*str2
);
102 SEGPTR
lstrcpy( SEGPTR target
, SEGPTR source
)
104 strcpy( (char *)PTR_SEG_TO_LIN(target
), (char *)PTR_SEG_TO_LIN(source
) );
108 /* KERNEL.353 32-bit version*/
109 char *lstrcpyn( char *dst
, const char *src
, int n
)
112 while(n
-- > 1 && *src
)
118 /* KERNEL.353 16-bit version*/
119 SEGPTR
WIN16_lstrcpyn( SEGPTR target
, SEGPTR source
, WORD n
)
121 lstrcpyn((char *)PTR_SEG_TO_LIN(target
), (char *)PTR_SEG_TO_LIN(source
),n
);
126 INT
lstrlen(LPCSTR str
)
131 /* IsCharAlpha USER 433 */
132 BOOL
IsCharAlpha(char ch
)
134 return isalpha(ch
); /* This is probably not right for NLS */
137 /* IsCharAlphanumeric USER 434 */
138 BOOL
IsCharAlphanumeric(char ch
)
140 return (ch
< '0') ? 0 : (ch
<= '9');
143 /* IsCharUpper USER 435 */
144 BOOL
IsCharUpper(char ch
)
149 /* IsCharLower USER 436 */
150 BOOL
IsCharLower(char ch
)
155 /***********************************************************************
156 * AnsiUpper (USER.431)
160 SEGPTR
WIN16_AnsiUpper( SEGPTR strOrChar
)
162 /* I am not sure if the locale stuff works with toupper, but then again
163 I am not sure if the Linux libc locale stuffs works at all */
165 /* uppercase only one char if strOrChar < 0x10000 */
166 if (HIWORD(strOrChar
))
168 char *s
= PTR_SEG_TO_LIN(strOrChar
);
175 else return (SEGPTR
)ToUpper( (int)strOrChar
);
179 LPSTR
AnsiUpper(LPSTR strOrChar
)
182 /* I am not sure if the locale stuff works with toupper, but then again
183 I am not sure if the Linux libc locale stuffs works at all */
193 /***********************************************************************
194 * AnsiUpperBuff (USER.437)
196 UINT
AnsiUpperBuff(LPSTR str
,UINT len
)
199 len
=(len
==0)?65536:len
;
202 str
[i
]=toupper(str
[i
]);
206 /***********************************************************************
207 * AnsiLower (USER.432)
211 SEGPTR
WIN16_AnsiLower(SEGPTR strOrChar
)
213 /* I am not sure if the locale stuff works with toupper, but then again
214 I am not sure if the Linux libc locale stuffs works at all */
216 /* lowercase only one char if strOrChar < 0x10000 */
217 if (HIWORD(strOrChar
))
219 char *s
= PTR_SEG_TO_LIN( strOrChar
);
226 else return (SEGPTR
)ToLower( (int)strOrChar
);
230 LPSTR
AnsiLower(LPSTR strOrChar
)
233 /* I am not sure if the locale stuff works with toupper, but then again
234 I am not sure if the Linux libc locale stuffs works at all */
244 /***********************************************************************
245 * AnsiLowerBuff (USER.438)
247 UINT
AnsiLowerBuff(LPSTR str
,UINT len
)
250 len
=(len
==0)?65536:len
;
254 str
[i
]=tolower(str
[i
]);
260 /* AnsiNext USER.472 */
261 SEGPTR
AnsiNext(SEGPTR current
)
263 return (*(char *)PTR_SEG_TO_LIN(current
)) ? current
+ 1 : current
;
266 /* AnsiPrev USER.473 */
267 SEGPTR
AnsiPrev( SEGPTR start
, SEGPTR current
)
269 return (current
==start
)?start
:current
-1;
273 /* AnsiToOem Keyboard.5 */
274 INT
AnsiToOem(LPSTR lpAnsiStr
, LPSTR lpOemStr
)
276 dprintf_keyboard(stddeb
, "AnsiToOem: %s\n", lpAnsiStr
);
278 *lpOemStr
++=Ansi2Oem
[(unsigned char)(*lpAnsiStr
++)];
284 /* OemToAnsi Keyboard.6 */
285 BOOL
OemToAnsi(LPSTR lpOemStr
, LPSTR lpAnsiStr
)
287 dprintf_keyboard(stddeb
, "OemToAnsi: %s\n", lpOemStr
);
289 *lpAnsiStr
++=Oem2Ansi
[(unsigned char)(*lpOemStr
++)];
295 /* AnsiToOemBuff Keyboard.134 */
296 void AnsiToOemBuff(LPSTR lpAnsiStr
, LPSTR lpOemStr
, INT nLength
)
299 for(i
=0;i
<nLength
;i
++)
300 lpOemStr
[i
]=Ansi2Oem
[(unsigned char)(lpAnsiStr
[i
])];
303 /* OemToAnsi Keyboard.135 */
304 void OemToAnsiBuff(LPSTR lpOemStr
, LPSTR lpAnsiStr
, INT nLength
)
307 for(i
=0;i
<nLength
;i
++)
308 lpAnsiStr
[i
]=Oem2Ansi
[(unsigned char)(lpOemStr
[i
])];