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
)
22 fprintf(stderr
,"lstrcat(%s,%s)\n",target
,source
);
24 return strcat(target
,source
);
28 INT
lstrcmp(LPCSTR str1
,LPCSTR str2
)
30 return strcmp(str1
,str2
);
34 INT
lstrcmpi(LPCSTR str1
,LPCSTR str2
)
38 while((toupper(str1
[i
])==toupper(str2
[i
]))&&(str1
[i
]!=0))
40 return toupper(str1
[i
])-toupper(str2
[i
]);
44 LPSTR
lstrcpy(LPSTR target
,LPCSTR source
)
46 return strcpy(target
,source
);
50 LPSTR
lstrcpyn(LPSTR target
,LPCSTR source
,int n
)
52 return strncpy(target
,source
,n
);
56 INT
lstrlen(LPCSTR str
)
62 /* AnsiUpper USER.431 */
63 char FAR
* AnsiUpper(char FAR
* strOrChar
)
65 /* I am not sure if the locale stuff works with toupper, but then again
66 I am not sure if the Linux libc locale stuffs works at all */
67 /* if((int)strOrChar<256)
68 return (char FAR*) toupper((int)strOrChar);
71 for(i=0;(i<65536) && strOrChar[i];i++)
72 strOrChar[i]=toupper(strOrChar[i]);
76 for (i
= 0; (i
< 65536 && strOrChar
[i
]);i
++)
77 strOrChar
[i
] = (strOrChar
[i
] >= 'a' && strOrChar
[i
] <= 'z') ?
78 strOrChar
[i
] - ('a' - 'A') : strOrChar
[i
];
82 /* AnsiLower USER.432 */
83 char FAR
* AnsiLower(char FAR
* strOrChar
)
85 /* I am not sure if the locale stuff works with tolower, but then again
86 I am not sure if the Linux libc locale stuffs works at all */
87 /* if((int)strOrChar<256)
88 return (char FAR*)tolower((int)strOrChar);
91 for(i=0;(i<65536)&&strOrChar[i];i++)
92 strOrChar[i]=tolower(strOrChar[i]);
96 for (i
= 0; (i
< 65536 && strOrChar
[i
]);i
++)
97 strOrChar
[i
] = (strOrChar
[i
] >= 'A' && strOrChar
[i
] <= 'Z') ?
98 strOrChar
[i
] + ('a' - 'A') : strOrChar
[i
];
101 /* AnsiUpperBuff USER.437 */
102 UINT
AnsiUpperBuff(LPSTR str
,UINT len
)
105 len
=(len
==0)?65536:len
;
108 str
[i
]=toupper(str
[i
]);
112 /* AnsiLowerBuff USER.438 */
113 UINT
AnsiLowerBuff(LPSTR str
,UINT len
)
116 len
=(len
==0)?65536:len
;
120 str
[i
]=tolower(str
[i
]);
125 /* AnsiNext USER.472 */
126 LPSTR
AnsiNext(LPSTR current
)
128 return (*current
)?current
+1:current
;
131 /* AnsiPrev USER.473 */
132 char FAR
* AnsiPrev(/*const*/ char FAR
* start
,char FAR
* current
)
134 return (current
==start
)?start
:current
-1;
137 /* IsCharAlpha USER 433 */
138 BOOL
IsCharAlpha(char ch
)
140 return isalpha(ch
); /* This is probably not right for NLS */
142 /* IsCharAlphanumeric USER 434 */
143 BOOL
IsCharAlphanumeric(char ch
)
145 return (ch
<'0')?0:(ch
<'9');
148 /* IsCharUpper USER 435 */
149 BOOL
IsCharUpper(char ch
)
154 /* IsCharUpper USER 436 */
155 BOOL
IsCharLower(char ch
)
160 static char Oem2Ansi
[256];
161 static char Ansi2Oem
[256];
163 void InitOemAnsiTranslations(void)
165 static int inited
=0; /* should called called in some init function*/
168 if(transfile
=open("oem2ansi.trl",O_RDONLY
)){
169 read(transfile
,Oem2Ansi
,256);
172 else { /* sets up passive translations if it does not find the file */
173 for(i
=0;i
<256;i
++) /* Needs some fixing */
176 if(transfile
=open("ansi2oem.trl",O_RDONLY
)){
177 read(transfile
,Ansi2Oem
,256);
180 else { /* sets up passive translations if it does not find the file */
181 for(i
=0;i
<256;i
++) /* Needs some fixing */
187 /* AnsiToOem Keyboard.5 */
188 INT
AnsiToOem(LPSTR lpAnsiStr
, LPSTR lpOemStr
) /* why is this int ??? */
190 InitOemAnsiTranslations(); /* should called called in some init function*/
192 *lpOemStr
++=Ansi2Oem
[*lpAnsiStr
++];
197 /* OemToAnsi Keyboard.6 */
198 BOOL
OemToAnsi(LPSTR lpOemStr
, LPSTR lpAnsiStr
) /* why is this BOOL ???? */
200 InitOemAnsiTranslations(); /* should called called in some init function*/
202 *lpAnsiStr
++=Oem2Ansi
[*lpOemStr
++];
207 /* AnsiToOemBuff Keyboard.134 */
208 void AnsiToOemBuff(LPSTR lpAnsiStr
, LPSTR lpOemStr
, INT nLength
)
211 InitOemAnsiTranslations(); /* should called called in some init function*/
212 for(i
=0;i
<nLength
;i
++)
213 lpOemStr
[i
]=Ansi2Oem
[lpAnsiStr
[i
]];
216 /* OemToAnsi Keyboard.135 */
217 void OemToAnsiBuff(LPSTR lpOemStr
, LPSTR lpAnsiStr
, INT nLength
)
220 InitOemAnsiTranslations(); /* should called called in some init function*/
221 for(i
=0;i
<nLength
;i
++)
222 lpAnsiStr
[i
]=Oem2Ansi
[lpOemStr
[i
]];