1 static char Copyright
[] = "Copyright Yngvi Sigurjonsson (yngvi@hafro.is), 1993";
11 #include "prototypes.h"
15 #define ToUpper(c) toupper(c)
16 #define ToLower(c) tolower(c)
18 /* Funny to divide them between user and kernel. */
21 LPSTR
lstrcat(LPSTR target
,LPCSTR source
)
24 fprintf(stderr
,"lstrcat(%s,%s)\n",target
,source
);
26 return strcat(target
,source
);
30 INT
lstrcmp(LPCSTR str1
,LPCSTR str2
)
32 return strcmp(str1
,str2
);
36 INT
lstrcmpi(LPCSTR str1
,LPCSTR str2
)
40 while((toupper(str1
[i
])==toupper(str2
[i
]))&&(str1
[i
]!=0))
42 return toupper(str1
[i
])-toupper(str2
[i
]);
46 LPSTR
lstrcpy(LPSTR target
,LPCSTR source
)
48 return strcpy(target
,source
);
52 LPSTR
lstrcpyn(LPSTR target
,LPCSTR source
,int n
)
54 return strncpy(target
,source
,n
);
58 INT
lstrlen(LPCSTR str
)
63 /* IsCharAlpha USER 433 */
64 BOOL
IsCharAlpha(char ch
)
66 return isalpha(ch
); /* This is probably not right for NLS */
69 /* IsCharAlphanumeric USER 434 */
70 BOOL
IsCharAlphanumeric(char ch
)
72 return (ch
<'0')?0:(ch
<'9');
75 /* IsCharUpper USER 435 */
76 BOOL
IsCharUpper(char ch
)
81 /* IsCharLower USER 436 */
82 BOOL
IsCharLower(char ch
)
87 /* AnsiUpper USER.431 */
88 LPSTR
AnsiUpper(LPSTR strOrChar
)
91 /* I am not sure if the locale stuff works with toupper, but then again
92 I am not sure if the Linux libc locale stuffs works at all */
94 /* uppercase only one char if strOrChar < 0x10000 */
95 if(HIWORD((DWORD
)strOrChar
)) {
103 if (IsCharLower((int)strOrChar
))
104 return (LPSTR
) ToUpper((int)strOrChar
);
106 return (LPSTR
) strOrChar
;
109 /* AnsiUpperBuff USER.437 */
110 UINT
AnsiUpperBuff(LPSTR str
,UINT len
)
113 len
=(len
==0)?65536:len
;
116 str
[i
]=toupper(str
[i
]);
120 /* AnsiLower USER.432 */
121 LPSTR
AnsiLower(LPSTR strOrChar
)
124 /* I am not sure if the locale stuff works with toupper, but then again
125 I am not sure if the Linux libc locale stuffs works at all */
127 /* lowercase only one char if strOrChar < 0x10000 */
128 if(HIWORD((DWORD
)strOrChar
)) {
136 if (IsCharUpper((int)strOrChar
))
137 return (LPSTR
) ToLower((int)strOrChar
);
139 return (LPSTR
) strOrChar
;
142 /* AnsiLowerBuff USER.438 */
143 UINT
AnsiLowerBuff(LPSTR str
,UINT len
)
146 len
=(len
==0)?65536:len
;
150 str
[i
]=tolower(str
[i
]);
155 /* AnsiNext USER.472 */
156 LPSTR
AnsiNext(LPSTR current
)
158 return (*current
)?current
+1:current
;
161 /* AnsiPrev USER.473 */
162 char FAR
* AnsiPrev(/*const*/ char FAR
* start
,char FAR
* current
)
164 return (current
==start
)?start
:current
-1;
167 static char Oem2Ansi
[256];
168 static char Ansi2Oem
[256];
170 void InitOemAnsiTranslations(void)
172 static int inited
=0; /* should called called in some init function*/
175 if(transfile
=open("oem2ansi.trl",O_RDONLY
)){
176 read(transfile
,Oem2Ansi
,256);
179 else { /* sets up passive translations if it does not find the file */
180 for(i
=0;i
<256;i
++) /* Needs some fixing */
183 if(transfile
=open("ansi2oem.trl",O_RDONLY
)){
184 read(transfile
,Ansi2Oem
,256);
187 else { /* sets up passive translations if it does not find the file */
188 for(i
=0;i
<256;i
++) /* Needs some fixing */
194 /* AnsiToOem Keyboard.5 */
195 INT
AnsiToOem(LPSTR lpAnsiStr
, LPSTR lpOemStr
) /* why is this int ??? */
197 InitOemAnsiTranslations(); /* should called called in some init function*/
199 *lpOemStr
++=Ansi2Oem
[*lpAnsiStr
++];
204 /* OemToAnsi Keyboard.6 */
205 BOOL
OemToAnsi(LPSTR lpOemStr
, LPSTR lpAnsiStr
) /* why is this BOOL ???? */
207 InitOemAnsiTranslations(); /* should called called in some init function*/
209 *lpAnsiStr
++=Oem2Ansi
[*lpOemStr
++];
214 /* AnsiToOemBuff Keyboard.134 */
215 void AnsiToOemBuff(LPSTR lpAnsiStr
, LPSTR lpOemStr
, INT nLength
)
218 InitOemAnsiTranslations(); /* should called called in some init function*/
219 for(i
=0;i
<nLength
;i
++)
220 lpOemStr
[i
]=Ansi2Oem
[lpAnsiStr
[i
]];
223 /* OemToAnsi Keyboard.135 */
224 void OemToAnsiBuff(LPSTR lpOemStr
, LPSTR lpAnsiStr
, INT nLength
)
227 InitOemAnsiTranslations(); /* should called called in some init function*/
228 for(i
=0;i
<nLength
;i
++)
229 lpAnsiStr
[i
]=Oem2Ansi
[lpOemStr
[i
]];