Added a test for MUIA_Listview_SelectChange.
[AROS.git] / arch / m68k-all / dos / bstr_helper.c
blobac49ede3ce900694ab6339f1402dce3fd17e9429
1 /*
2 Copyright © 1995-2011, The AROS Development Team. All rights reserved.
4 Desc: BSTR helpers
5 Lang: English
6 */
8 #include <proto/exec.h>
9 #include <dos/dosextens.h>
11 #define DEBUG 0
12 #include <aros/debug.h>
14 BSTR C2BSTR(CONST_STRPTR src)
16 STRPTR dst;
18 dst = AllocVec(strlen(src) + 2, MEMF_ANY);
19 if (!dst)
20 return 0;
21 dst[0] = strlen(src);
22 strcpy(dst + 1, src);
23 return MKBADDR(dst);
25 char *BSTR2C(BSTR srcs)
27 UBYTE *src = BADDR(srcs);
28 char *dst;
30 dst = AllocVec(src[0] + 1, MEMF_ANY);
31 if (!dst)
32 return NULL;
33 memcpy (dst, src + 1, src[0]);
34 dst[src[0]] = 0;
35 return dst;
38 BOOL CMPBSTR(BSTR s1, BSTR s2)
40 UBYTE *ss1 = BADDR(s1);
41 UBYTE *ss2 = BADDR(s2);
42 return memcmp(ss1, ss2, ss1[0] + 1);
44 BOOL CMPCBSTR(CONST_STRPTR s1, BSTR s2)
46 UBYTE *ss2 = BADDR(s2);
47 LONG len = strlen(s1);
48 if (len != ss2[0])
49 return TRUE;
50 return memcmp(s1, ss2 + 1, len);
53 BOOL CMPICBSTR(CONST_STRPTR s1, BSTR s2)
55 int length = strlen(s1);
57 if (length != AROS_BSTR_strlen(s2))
58 return TRUE;
60 return strnicmp(s1, AROS_BSTR_ADDR(s2), length);
63 BOOL CMPNICBSTR(CONST_STRPTR s1, BSTR s2, UBYTE length)
65 if (AROS_BSTR_strlen(s2) < length || strlen(s1) < length)
66 return TRUE;
67 return strnicmp(s1, AROS_BSTR_ADDR(s2), length);
70 void BSTR2CINLINE(char *s)
72 UBYTE len = s[0];
73 memmove(s, s + 1, len);
74 s[len] = 0;
77 void fixfib(struct FileInfoBlock *fib)
79 BSTR2CINLINE(fib->fib_FileName);
80 BSTR2CINLINE(fib->fib_Comment);