added concrete implementations of putc(), getc(), getchar() and gets()
[tangerine.git] / workbench / devs / afs / extstrings.c
blobd7b53b6843b7dbe6c7240b280affb72a7110340c
1 /*
2 Copyright © 1995-2006, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include "extstrings.h"
8 UBYTE capitalch(UBYTE ch, UBYTE flags) {
10 if ((flags==0) || (flags==1))
11 return (UBYTE)((ch>='a') && (ch<='z') ? ch-('a'-'A') : ch);
12 else // DOS\(>=2)
13 return (UBYTE)(((ch>=224) && (ch<=254) && (ch!=247)) ||
14 ((ch>='a') && (ch<='z')) ? ch-('a'-'A') : ch);
17 // str2 is a BCPL string
18 LONG noCaseStrCmp(char *str1, char *str2, UBYTE flags, int maxlen) {
19 UBYTE length, i=0;
21 length=str2++[0];
22 do {
23 if (((*str1==0) || (length==maxlen)) && (i==length))
24 return 1;
25 i++;
26 } while (capitalch(*str1++,flags)==capitalch(*str2++,flags));
27 return 0;
30 LONG StrCmp(STRPTR str1, STRPTR str2) {
33 if ((*str1==0) && (*str2==0))
34 return 1;
35 } while ((*str1++==*str2++));
36 return 0;
39 void StrCpyToBstr(char *src, char *dst, int maxlen) {
40 UWORD len=0;
42 while (*src && (len<maxlen))
44 dst[len+1]=*src++;
45 len++;
47 dst[0]=len;