47 __attribute__ ((visibility ("default")))
49 __attribute__ ((visibility ("hidden")))
55#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 4)
56#define BSTR_PRINTF(format, argument) \
57 __attribute__ ((__format__ (__printf__, format, argument)))
59 __attribute__ ((__unused__))
61#define BSTR_PRINTF(format, argument)
80#define BSTR_BS_BUFF_LENGTH_GET (0)
91#define cstr2bstr bfromcstr
355binsert(bstring s1,
int pos,
const bstring s2,
unsigned char fill);
367binsertch(bstring s1,
int pos,
int len,
unsigned char fill);
377breplace(bstring b1,
int pos,
int len,
const bstring b2,
unsigned char fill);
400bsetstr(bstring b0,
int pos,
const bstring b1,
unsigned char fill);
472biseq(
const bstring b0,
const bstring b1);
554bstrncmp(
const bstring b0,
const bstring b1,
int n);
565binstr(
const bstring s1,
int pos,
const bstring s2);
578binstrr(
const bstring s1,
int pos,
const bstring s2);
628#define bstrchr(b, c) \
629 bstrchrp((b), (c), 0)
637#define bstrrchr(b, c) \
638 bstrrchrp((b), (c), blength(b) - 1)
648binchr(
const bstring b0,
int pos,
const bstring b1);
658binchrr(
const bstring b0,
int pos,
const bstring b1);
668bninchr(
const bstring b0,
int pos,
const bstring b1);
678bninchrr(
const bstring b0,
int pos,
const bstring b1);
702bfindreplace(bstring b,
const bstring find,
const bstring repl,
int pos);
794bsplit(
const bstring str,
unsigned char splitChar);
804bsplits(
const bstring str,
const bstring splitStr);
855 unsigned char splitChar,
857 int(*cb)(
void *parm,
int ofs,
int len),
882 const bstring splitStr,
884 int(*cb)(
void *parm,
int ofs,
int len),
909 const bstring splitStr,
911 int(*cb)(
void *parm,
int ofs,
int len),
void *parm);
1063bvcformata(bstring b,
int count,
const char *fmt, va_list arglist);
1090#define bvformata(ret, b, fmt, lastarg) \
1092 bstring bstrtmp_b =(b); \
1093 const char *bstrtmp_fmt = (fmt); \
1094 int bstrtmp_r = BSTR_ERR, bstrtmp_sz = 16; \
1096 va_list bstrtmp_arglist; \
1097 va_start(bstrtmp_arglist, lastarg); \
1098 bstrtmp_r = bvcformata(bstrtmp_b, bstrtmp_sz, bstrtmp_fmt, \
1100 va_end(bstrtmp_arglist); \
1101 if(bstrtmp_r >= 0) { \
1103 bstrtmp_r = BSTR_OK; \
1105 } else if(-bstrtmp_r <= bstrtmp_sz) { \
1107 bstrtmp_r = BSTR_ERR; \
1111 bstrtmp_sz = -bstrtmp_r; \
1116typedef int (*bNgetc)(
void *parm);
1118typedef size_t (*bNread)(
void *buff,
size_t elsize,
size_t nelem,
void *parm);
1157#if defined(HAVE_BGETS)
1158bgetstream(bNgetc getcPtr,
void *parm,
char terminator);
1160bgets(bNgetc getcPtr,
void *parm,
char terminator);
1188bgetsa(bstring b, bNgetc getcPtr,
void *parm,
char terminator);
1208breada(bstring b, bNread readPtr,
void *parm);
1217BSTR_PUBLIC
struct bStream *
1251bsreadln(bstring b,
struct bStream *s,
char terminator);
1356 const bstring splitStr,
1357 int(*cb)(
void *parm,
int ofs,
const bstring entry),
1386 const bstring splitStr,
1387 int(*cb)(
void *parm,
int ofs,
const bstring entry),
1417#define blengthe(b, e) \
1418 (((b) == (void *)0 || (b)->slen < 0) \
1435#define bdataofse(b, o, e) \
1436 (((b) == (void *)0 || (b)->data == (void *)0) \
1438 : ((char *)(b)->data) + (o))
1445#define bdataofs(b, o) \
1446 (bdataofse((b),(o),(void *)0))
1453#define bdatae(b, e) \
1454 (bdataofse(b, 0, e))
1470#define bchare(b, p, e) \
1471 ((((unsigned)(p)) < (unsigned)blength(b)) \
1472 ? ((b)->data[(p)]) \
1481#define bchar(b, p) \
1482 bchare((b), (p), '\0')
1488#define bsStaticMlen(q, m) { (m), (int)sizeof(q) - 1, (unsigned char *)("" q "") }
1490#if defined (_MSC_VER)
1505#define bsStatic(q) bsStaticMlen(q, -32)
1511#define bsStatic(q) bsStaticMlen(q, -__LINE__)
1534#define bsStaticBlkParms(q) \
1535 ((void *)("" q "")), ((int)sizeof(q) -1)
1541#define cstr2tbstr btfromcstr
1556#define btfromcstr(t, s) \
1558 (t).data = (unsigned char *)(s); \
1559 (t).slen = ((t).data) \
1560 ? ((int)(strlen)((char *)(t).data)) \
1567#define blk2tbstr(t, s, l) \
1569 (t).data = (unsigned char *)(s); \
1588#define btfromblk(t, s, l) blk2tbstr(t, s, l)
1605#define bmid2tbstr(t, b, p, l) \
1607 const bstring bstrtmp_s =(b); \
1608 if (bstrtmp_s && bstrtmp_s->data && bstrtmp_s->slen >= 0) { \
1609 int bstrtmp_left = (p); \
1610 int bstrtmp_len = (l); \
1611 if (bstrtmp_left < 0) { \
1612 bstrtmp_len += bstrtmp_left; \
1615 if (bstrtmp_len > bstrtmp_s->slen - bstrtmp_left) { \
1616 bstrtmp_len = bstrtmp_s->slen - bstrtmp_left; \
1618 if(bstrtmp_len <= 0) { \
1619 (t).data =(unsigned char *)""; \
1622 (t).data = bstrtmp_s->data + bstrtmp_left; \
1623 (t).slen = bstrtmp_len; \
1626 (t).data = (unsigned char *)""; \
1629 (t).mlen = -__LINE__; \
1646#define btfromblkltrimws(t, s, l) \
1648 int bstrtmp_idx = 0, bstrtmp_len =(l); \
1649 unsigned char *bstrtmp_s = (s); \
1650 if (bstrtmp_s && bstrtmp_len >= 0) { \
1651 for (; bstrtmp_idx < bstrtmp_len; bstrtmp_idx++) { \
1652 if (!isspace(bstrtmp_s[bstrtmp_idx])) { \
1657 (t).data = bstrtmp_s + bstrtmp_idx; \
1658 (t).slen = bstrtmp_len - bstrtmp_idx; \
1659 (t).mlen = -__LINE__; \
1676#define btfromblkrtrimws(t, s, l) \
1678 int bstrtmp_len = (l) - 1; \
1679 unsigned char *bstrtmp_s = (s); \
1680 if (bstrtmp_s && bstrtmp_len >= 0) { \
1681 for (; bstrtmp_len >= 0; bstrtmp_len--) { \
1682 if (!isspace(bstrtmp_s[bstrtmp_len])) { \
1687 (t).data = bstrtmp_s; \
1688 (t).slen = bstrtmp_len + 1; \
1689 (t).mlen = -__LINE__; \
1706#define btfromblktrimws(t, s, l) \
1708 int bstrtmp_idx = 0, bstrtmp_len = (l) - 1; \
1709 unsigned char *bstrtmp_s = (s); \
1710 if (bstrtmp_s && bstrtmp_len >= 0) { \
1711 for (; bstrtmp_idx <= bstrtmp_len; bstrtmp_idx++) { \
1712 if(!isspace(bstrtmp_s[bstrtmp_idx])) { \
1716 for (; bstrtmp_len >= bstrtmp_idx; bstrtmp_len--) { \
1717 if (!isspace(bstrtmp_s[bstrtmp_len])) { \
1722 (t).data = bstrtmp_s + bstrtmp_idx; \
1723 (t).slen = bstrtmp_len + 1 - bstrtmp_idx; \
1724 (t).mlen = -__LINE__; \
1737#define bwriteprotect(t) \
1739 if ((t).mlen >= 0) { \
1756#define bwriteallow(t) \
1758 if ((t).mlen == -1) { \
1759 (t).mlen = (t).slen + ((t).slen == 0); \
1766#define biswriteprotected(t) \
BSTR_PUBLIC int bassign(bstring a, const bstring b)
BSTR_PUBLIC int bisstemeqblk(const bstring b0, const void *blk, int len)
BSTR_PUBLIC int bpattern(bstring b, int len)
BSTR_PUBLIC int binstrrcaseless(const bstring s1, int pos, const bstring s2)
BSTR_PUBLIC int bspeek(bstring r, const struct bStream *s)
BSTR_PUBLIC int breplace(bstring b1, int pos, int len, const bstring b2, unsigned char fill)
BSTR_PUBLIC int bsunread(struct bStream *s, const bstring b)
BSTR_PUBLIC bstring bfromcstr(const char *str)
BSTR_PUBLIC int bstrcmp(const bstring b0, const bstring b1)
BSTR_PUBLIC int bstrnicmp(const bstring b0, const bstring b1, int n)
BSTR_PUBLIC int ballocmin(bstring b, int len)
BSTR_PUBLIC int bstrchrp(const bstring b, int c, int pos)
BSTR_PUBLIC bstring bread(bNread readPtr, void *parm)
BSTR_PUBLIC int binstrr(const bstring s1, int pos, const bstring s2)
BSTR_PUBLIC int bstrListAlloc(struct bstrList *sl, int msz)
BSTR_PUBLIC int bconcat(bstring b0, const bstring b1)
BSTR_PUBLIC int bsreada(bstring b, struct bStream *s, int n)
BSTR_PUBLIC int bsreadlns(bstring r, struct bStream *s, const bstring term)
BSTR_PUBLIC int bcstrfree(char *s)
BSTR_PUBLIC int bdelete(bstring s1, int pos, int len)
BSTR_PUBLIC int btolower(bstring b)
BSTR_PUBLIC void * bsclose(struct bStream *s)
BSTR_PUBLIC int bsreadln(bstring b, struct bStream *s, char terminator)
BSTR_PUBLIC bstring bmidstr(const bstring b, int left, int len)
BSTR_PUBLIC struct bstrList * bsplit(const bstring str, unsigned char splitChar)
BSTR_PUBLIC int bdestroy(bstring b)
BSTR_PUBLIC bstring bfromcstralloc(int mlen, const char *str)
BSTR_PUBLIC int bformata(bstring b, const char *fmt,...)
BSTR_PUBLIC int binstrcaseless(const bstring s1, int pos, const bstring s2)
BSTR_PUBLIC int bninchrr(const bstring b0, int pos, const bstring b1)
BSTR_PUBLIC int btoupper(bstring b)
BSTR_PUBLIC int biseqcstr(const bstring b, const char *s)
BSTR_PUBLIC int bvcformata(bstring b, int count, const char *fmt, va_list arglist)
BSTR_PUBLIC int brtrimws(bstring b)
BSTR_PUBLIC int binchrr(const bstring b0, int pos, const bstring b1)
BSTR_PUBLIC struct bstrList * bsplits(const bstring str, const bstring splitStr)
BSTR_PUBLIC int bconchar(bstring b0, char c)
BSTR_PUBLIC int bssplitscb(struct bStream *s, const bstring splitStr, int(*cb)(void *parm, int ofs, const bstring entry), void *parm)
BSTR_PUBLIC int bassignformat(bstring b, const char *fmt,...)
BSTR_PUBLIC bstring blk2bstr(const void *blk, int len)
BSTR_PUBLIC int bcatblk(bstring b, const void *s, int len)
BSTR_PUBLIC int bassigncstr(bstring a, const char *str)
BSTR_PUBLIC char * bstr2cstr(const bstring s, char z)
BSTR_PUBLIC int bsreadlnsa(bstring r, struct bStream *s, const bstring term)
BSTR_PUBLIC int bstrrchrp(const bstring b, int c, int pos)
BSTR_PUBLIC int bassigngets(bstring b, bNgetc getcPtr, void *parm, char terminator)
BSTR_PUBLIC struct bstrList * bsplitstr(const bstring str, const bstring splitStr)
BSTR_PUBLIC struct bstrList * bstrListCreate(void)
BSTR_PUBLIC int bsplitstrcb(const bstring str, const bstring splitStr, int pos, int(*cb)(void *parm, int ofs, int len), void *parm)
BSTR_PUBLIC int bstricmp(const bstring b0, const bstring b1)
BSTR_PUBLIC int bgetsa(bstring b, bNgetc getcPtr, void *parm, char terminator)
BSTR_PUBLIC bstring bstrcpy(const bstring b1)
BSTR_PUBLIC int btrunc(bstring b, int n)
BSTR_PUBLIC int bfindreplace(bstring b, const bstring find, const bstring repl, int pos)
BSTR_PUBLIC int bseof(const struct bStream *s)
BSTR_PUBLIC int biseq(const bstring b0, const bstring b1)
BSTR_PUBLIC bstring bgets(bNgetc getcPtr, void *parm, char terminator)
BSTR_PUBLIC int bsetstr(bstring b0, int pos, const bstring b1, unsigned char fill)
BSTR_PUBLIC int bsplitscb(const bstring str, const bstring splitStr, int pos, int(*cb)(void *parm, int ofs, int len), void *parm)
BSTR_PUBLIC int bcatcstr(bstring b, const char *s)
BSTR_PUBLIC int bassignmidstr(bstring a, const bstring b, int left, int len)
BSTR_PUBLIC int biseqcstrcaseless(const bstring b, const char *s)
BSTR_PUBLIC struct bStream * bsopen(bNread readPtr, void *parm)
BSTR_PUBLIC int bfindreplacecaseless(bstring b, const bstring find, const bstring repl, int pos)
BSTR_PUBLIC int binsertch(bstring s1, int pos, int len, unsigned char fill)
BSTR_PUBLIC int bsplitcb(const bstring str, unsigned char splitChar, int pos, int(*cb)(void *parm, int ofs, int len), void *parm)
BSTR_PUBLIC int bltrimws(bstring b)
BSTR_PUBLIC int breada(bstring b, bNread readPtr, void *parm)
BSTR_PUBLIC int bstrListAllocMin(struct bstrList *sl, int msz)
BSTR_PUBLIC int bstrListDestroy(struct bstrList *sl)
BSTR_PUBLIC int btrimws(bstring b)
BSTR_PUBLIC int biseqcaseless(const bstring b0, const bstring b1)
BSTR_PUBLIC bstring bjoin(const struct bstrList *bl, const bstring sep)
BSTR_PUBLIC int bsbufflength(struct bStream *s, int sz)
BSTR_PUBLIC int bisstemeqcaselessblk(const bstring b0, const void *blk, int len)
BSTR_PUBLIC int binchr(const bstring b0, int pos, const bstring b1)
BSTR_PUBLIC int bassignblk(bstring a, const void *s, int len)
BSTR_PUBLIC int bsreadlna(bstring b, struct bStream *s, char terminator)
BSTR_PUBLIC int bninchr(const bstring b0, int pos, const bstring b1)
BSTR_PUBLIC int bssplitstrcb(struct bStream *s, const bstring splitStr, int(*cb)(void *parm, int ofs, const bstring entry), void *parm)
BSTR_PUBLIC int bstrncmp(const bstring b0, const bstring b1, int n)
BSTR_PUBLIC bstring bformat(const char *fmt,...)
BSTR_PUBLIC int binsert(bstring s1, int pos, const bstring s2, unsigned char fill)
BSTR_PUBLIC int balloc(bstring s, int len)
BSTR_PUBLIC int binstr(const bstring s1, int pos, const bstring s2)
BSTR_PUBLIC int bsread(bstring b, struct bStream *s, int n)