2 * (c) Oleg Puchinin 2006
3 * graycardinalster@gmail.com
7 #include <gclib/gclib.h>
12 __export
int Dsplit (char * STR
, char *ch
, DList
* to_list
)
14 DList
* ret
= to_list
;
20 if (!STR
|| !ch
|| !ret
)
24 while((S
= strstr (ptr
, ch
)) && S
) {
25 ret
->add_tail (Dstrndup (ptr
, S
- ptr
));
32 ret
->add_tail (strdup (ptr
));
39 __export
int Dsplit (char * buf
, size_t buflen
, char *str
, EList
* to_list
)
47 if (!buf
|| !str
|| !to_list
)
50 last
= &buf
[buflen
-1];
51 str_len
= strlen (str
);
52 while((S
= Dmid_memmem (ptr
, last
, str
, str_len
)) && S
) {
53 *to_list
<< Dstrndup (ptr
, S
- ptr
);
60 *to_list
<< Dstrndup (ptr
, last
-ptr
+1);