1 static char Copyright
[] = "Copyright Yngvi Sigurjonsson (yngvi@hafro.is), 1993";
11 #include "prototypes.h"
16 /* Funny to divide them between user and kernel. */
19 LPSTR
lstrcat(LPSTR target
,LPCSTR source
)
21 fprintf(stderr
,"lstrcat(%s,%s)\n",target
,source
);
22 return strcat(target
,source
);
26 int lstrcmp(LPCSTR str1
,LPCSTR str2
)
28 return strcmp(str1
,str2
);
32 int lstrcmpi(LPCSTR str1
,LPCSTR str2
)
36 while((toupper(str1
[i
])==toupper(str2
[i
]))&&(str1
[i
]!=0))
38 return toupper(str1
[i
])-toupper(str2
[i
]);
42 LPSTR
lstrcpy(LPSTR target
,LPCSTR source
)
44 return strcpy(target
,source
);
48 LPSTR
lstrcpyn(LPSTR target
,LPCSTR source
,int n
)
50 return strncpy(target
,source
,n
);
54 int lstrlen(LPCSTR str
)
59 /* AnsiUpper USER.431 */
60 char FAR
* AnsiUpper(char FAR
* strOrChar
)
62 /* I am not sure if the locale stuff works with toupper, but then again
63 I am not sure if the Linux libc locale stuffs works at all */
64 if((int)strOrChar
<256)
65 return (char FAR
*) toupper((int)strOrChar
);
68 for(i
=0;(i
<65536)&&strOrChar
[i
];i
++)
69 strOrChar
[i
]=toupper(strOrChar
[i
]);
74 /* AnsiLower USER.432 */
75 char FAR
* AnsiLower(char FAR
* strOrChar
)
77 /* I am not sure if the locale stuff works with tolower, but then again
78 I am not sure if the Linux libc locale stuffs works at all */
79 if((int)strOrChar
<256)
80 return (char FAR
*)tolower((int)strOrChar
);
83 for(i
=0;(i
<65536)&&strOrChar
[i
];i
++)
84 strOrChar
[i
]=tolower(strOrChar
[i
]);
89 /* AnsiUpperBuff USER.437 */
90 UINT
AnsiUpperBuff(LPSTR str
,UINT len
)
93 len
=(len
==0)?65536:len
;
96 str
[i
]=toupper(str
[i
]);
100 /* AnsiLowerBuff USER.438 */
101 UINT
AnsiLowerBuff(LPSTR str
,UINT len
)
104 len
=(len
==0)?65536:len
;
108 str
[i
]=tolower(str
[i
]);
113 /* AnsiNext USER.472 */
114 LPSTR
AnsiNext(LPSTR current
)
116 return (*current
)?current
+1:current
;
119 /* AnsiPrev USER.473 */
120 char FAR
* AnsiPrev(/*const*/ char FAR
* start
,char FAR
* current
)
122 return (current
==start
)?start
:current
-1;
125 /* IsCharAlpha USER 433 */
126 BOOL
IsCharAlpha(char ch
)
128 return isalpha(ch
); /* This is probably not right for NLS */
130 /* IsCharAlphanumeric USER 434 */
131 BOOL
IsCharAlphanumeric(char ch
)
133 return (ch
<'0')?0:(ch
<'9');
136 /* IsCharUpper USER 435 */
137 BOOL
IsCharUpper(char ch
)
142 /* IsCharUpper USER 436 */
143 BOOL
IsCharLower(char ch
)
148 static char Oem2Ansi
[256];
149 static char Ansi2Oem
[256];
151 void InitOemAnsiTranslations()
153 static int inited
=0; /* should called called in some init function*/
156 if(transfile
=open("oem2ansi.trl",O_RDONLY
)){
157 read(transfile
,Oem2Ansi
,256);
160 else { /* sets up passive translations if it does not find the file */
161 for(i
=0;i
<256;i
++) /* Needs some fixing */
164 if(transfile
=open("ansi2oem.trl",O_RDONLY
)){
165 read(transfile
,Ansi2Oem
,256);
168 else { /* sets up passive translations if it does not find the file */
169 for(i
=0;i
<256;i
++) /* Needs some fixing */
175 /* AnsiToOem Keyboard.5 */
176 int AnsiToOem(LPSTR lpAnsiStr
, LPSTR lpOemStr
) /* why is this int ??? */
178 InitOemAnsiTranslations(); /* should called called in some init function*/
180 *lpOemStr
++=Ansi2Oem
[*lpAnsiStr
++];
185 /* OemToAnsi Keyboard.6 */
186 BOOL
OemToAnsi(LPSTR lpOemStr
, LPSTR lpAnsiStr
) /* why is this BOOL ???? */
188 InitOemAnsiTranslations(); /* should called called in some init function*/
190 *lpAnsiStr
++=Oem2Ansi
[*lpOemStr
++];
195 /* AnsiToOemBuff Keyboard.134 */
196 void AnsiToOemBuff(LPSTR lpAnsiStr
, LPSTR lpOemStr
, int nLength
)
199 InitOemAnsiTranslations(); /* should called called in some init function*/
200 for(i
=0;i
<nLength
;i
++)
201 lpOemStr
[i
]=Ansi2Oem
[lpAnsiStr
[i
]];
204 /* OemToAnsi Keyboard.135 */
205 void OemToAnsiBuff(LPSTR lpOemStr
, LPSTR lpAnsiStr
, int nLength
)
208 InitOemAnsiTranslations(); /* should called called in some init function*/
209 for(i
=0;i
<nLength
;i
++)
210 lpAnsiStr
[i
]=Oem2Ansi
[lpOemStr
[i
]];