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
628#define bstrchr(b, c) \
629 bstrchrp((b), (c), 0)
637#define bstrrchr(b, c) \
638 bstrrchrp((b), (c), blength(b) - 1)
855 unsigned char splitChar,
857 int(*cb)(
void *parm,
int ofs,
int len),
884 int(*cb)(
void *parm,
int ofs,
int len),
911 int(*cb)(
void *parm,
int ofs,
int len),
void *parm);
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; \
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);
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)
Definition bstrlib.c:444
BSTR_PUBLIC int bisstemeqblk(const bstring b0, const void *blk, int len)
Definition bstrlib.c:812
BSTR_PUBLIC int bpattern(bstring b, int len)
Definition bstrlib.c:1827
size_t(* bNread)(void *buff, size_t elsize, size_t nelem, void *parm)
Definition bstrlib.h:1118
BSTR_PUBLIC int binstrrcaseless(const bstring s1, int pos, const bstring s2)
Definition bstrlib.c:1189
BSTR_PUBLIC int bspeek(bstring r, const struct bStream *s)
Definition bstrlib.c:2299
BSTR_PUBLIC int breplace(bstring b1, int pos, int len, const bstring b2, unsigned char fill)
Definition bstrlib.c:1533
BSTR_PUBLIC int bsunread(struct bStream *s, const bstring b)
Definition bstrlib.c:2290
BSTR_PUBLIC bstring bfromcstr(const char *str)
Definition bstrlib.c:188
#define BSTR_PUBLIC
Definition bstrlib.h:51
BSTR_PUBLIC int bstrcmp(const bstring b0, const bstring b1)
Definition bstrlib.c:864
BSTR_PUBLIC int bstrnicmp(const bstring b0, const bstring b1, int n)
Definition bstrlib.c:633
BSTR_PUBLIC int ballocmin(bstring b, int len)
Definition bstrlib.c:159
BSTR_PUBLIC int bstrchrp(const bstring b, int c, int pos)
Definition bstrlib.c:1241
BSTR_PUBLIC bstring bread(bNread readPtr, void *parm)
Definition bstrlib.c:1878
BSTR_PUBLIC int binstrr(const bstring s1, int pos, const bstring s2)
Definition bstrlib.c:1088
BSTR_PUBLIC int bstrListAlloc(struct bstrList *sl, int msz)
Definition bstrlib.c:2515
BSTR_PUBLIC int bconcat(bstring b0, const bstring b1)
Definition bstrlib.c:309
BSTR_PUBLIC int bsreada(bstring b, struct bStream *s, int n)
Definition bstrlib.c:2177
BSTR_PUBLIC int bsreadlns(bstring r, struct bStream *s, const bstring term)
Definition bstrlib.c:2258
BSTR_PUBLIC int bcstrfree(char *s)
Definition bstrlib.c:302
BSTR_PUBLIC int bdelete(bstring s1, int pos, int len)
Definition bstrlib.c:951
BSTR_PUBLIC int btolower(bstring b)
Definition bstrlib.c:582
BSTR_PUBLIC void * bsclose(struct bStream *s)
Definition bstrlib.c:2014
BSTR_PUBLIC int bsreadln(bstring b, struct bStream *s, char terminator)
Definition bstrlib.c:2245
BSTR_PUBLIC bstring bmidstr(const bstring b, int left, int len)
Definition bstrlib.c:932
BSTR_PUBLIC struct bstrList * bsplit(const bstring str, unsigned char splitChar)
Definition bstrlib.c:2710
BSTR_PUBLIC int bdestroy(bstring b)
Definition bstrlib.c:977
BSTR_PUBLIC bstring bfromcstralloc(int mlen, const char *str)
Definition bstrlib.c:217
BSTR_PUBLIC int bformata(bstring b, const char *fmt,...)
Definition bstrlib.c:2805
BSTR_PUBLIC int binstrcaseless(const bstring s1, int pos, const bstring s2)
Definition bstrlib.c:1139
BSTR_PUBLIC int bninchrr(const bstring b0, int pos, const bstring b1)
Definition bstrlib.c:1406
BSTR_PUBLIC int btoupper(bstring b)
Definition bstrlib.c:567
BSTR_PUBLIC int biseqcstr(const bstring b, const char *s)
Definition bstrlib.c:833
BSTR_PUBLIC int bvcformata(bstring b, int count, const char *fmt, va_list arglist)
Definition bstrlib.c:2966
BSTR_PUBLIC int brtrimws(bstring b)
Definition bstrlib.c:743
BSTR_PUBLIC int binchrr(const bstring b0, int pos, const bstring b1)
Definition bstrlib.c:1370
BSTR_PUBLIC struct bstrList * bsplits(const bstring str, const bstring splitStr)
Definition bstrlib.c:2763
BSTR_PUBLIC int bconchar(bstring b0, char c)
Definition bstrlib.c:346
BSTR_PUBLIC int bssplitscb(struct bStream *s, const bstring splitStr, int(*cb)(void *parm, int ofs, const bstring entry), void *parm)
Definition bstrlib.c:2358
BSTR_PUBLIC int bassignformat(bstring b, const char *fmt,...)
Definition bstrlib.c:2860
BSTR_PUBLIC bstring blk2bstr(const void *blk, int len)
Definition bstrlib.c:249
BSTR_PUBLIC int bcatblk(bstring b, const void *s, int len)
Definition bstrlib.c:387
BSTR_PUBLIC int bassigncstr(bstring a, const char *str)
Definition bstrlib.c:498
BSTR_PUBLIC char * bstr2cstr(const bstring s, char z)
Definition bstrlib.c:282
BSTR_PUBLIC int bsreadlnsa(bstring r, struct bStream *s, const bstring term)
Definition bstrlib.c:2101
struct tagbstring * bstring
Definition bstrlib.h:82
BSTR_PUBLIC int bstrrchrp(const bstring b, int c, int pos)
Definition bstrlib.c:1256
BSTR_PUBLIC int bassigngets(bstring b, bNgetc getcPtr, void *parm, char terminator)
Definition bstrlib.c:1889
BSTR_PUBLIC struct bstrList * bsplitstr(const bstring str, const bstring splitStr)
Definition bstrlib.c:2737
BSTR_PUBLIC struct bstrList * bstrListCreate(void)
Definition bstrlib.c:2477
BSTR_PUBLIC int bsplitstrcb(const bstring str, const bstring splitStr, int pos, int(*cb)(void *parm, int ofs, int len), void *parm)
Definition bstrlib.c:2637
BSTR_PUBLIC int bstricmp(const bstring b0, const bstring b1)
Definition bstrlib.c:597
BSTR_PUBLIC int bgetsa(bstring b, bNgetc getcPtr, void *parm, char terminator)
Definition bstrlib.c:1919
BSTR_PUBLIC bstring bstrcpy(const bstring b1)
Definition bstrlib.c:409
BSTR_PUBLIC int btrunc(bstring b, int n)
Definition bstrlib.c:543
BSTR_PUBLIC int bfindreplace(bstring b, const bstring find, const bstring repl, int pos)
Definition bstrlib.c:1776
BSTR_PUBLIC int bseof(const struct bStream *s)
Definition bstrlib.c:2005
BSTR_PUBLIC int biseq(const bstring b0, const bstring b1)
Definition bstrlib.c:795
BSTR_PUBLIC bstring bgets(bNgetc getcPtr, void *parm, char terminator)
Definition bstrlib.c:1952
BSTR_PUBLIC int bsetstr(bstring b0, int pos, const bstring b1, unsigned char fill)
Definition bstrlib.c:1424
BSTR_PUBLIC int bsplitscb(const bstring str, const bstring splitStr, int pos, int(*cb)(void *parm, int ofs, int len), void *parm)
Definition bstrlib.c:2601
BSTR_PUBLIC int bcatcstr(bstring b, const char *s)
Definition bstrlib.c:363
BSTR_PUBLIC int bassignmidstr(bstring a, const bstring b, int left, int len)
Definition bstrlib.c:467
BSTR_PUBLIC int biseqcstrcaseless(const bstring b, const char *s)
Definition bstrlib.c:848
BSTR_PUBLIC struct bStream * bsopen(bNread readPtr, void *parm)
Definition bstrlib.c:1973
BSTR_PUBLIC int bfindreplacecaseless(bstring b, const bstring find, const bstring repl, int pos)
Definition bstrlib.c:1782
BSTR_PUBLIC int binsertch(bstring s1, int pos, int len, unsigned char fill)
Definition bstrlib.c:1788
BSTR_PUBLIC int bsplitcb(const bstring str, unsigned char splitChar, int pos, int(*cb)(void *parm, int ofs, int len), void *parm)
Definition bstrlib.c:2577
BSTR_PUBLIC int bltrimws(bstring b)
Definition bstrlib.c:724
BSTR_PUBLIC int breada(bstring b, bNread readPtr, void *parm)
Definition bstrlib.c:1850
BSTR_PUBLIC int bstrListAllocMin(struct bstrList *sl, int msz)
Definition bstrlib.c:2548
BSTR_PUBLIC int bstrListDestroy(struct bstrList *sl)
Definition bstrlib.c:2494
BSTR_PUBLIC int btrimws(bstring b)
Definition bstrlib.c:768
BSTR_PUBLIC int biseqcaseless(const bstring b0, const bstring b1)
Definition bstrlib.c:675
BSTR_PUBLIC bstring bjoin(const struct bstrList *bl, const bstring sep)
Definition bstrlib.c:2308
BSTR_PUBLIC int bsbufflength(struct bStream *s, int sz)
Definition bstrlib.c:1991
BSTR_PUBLIC int bisstemeqcaselessblk(const bstring b0, const void *blk, int len)
Definition bstrlib.c:700
BSTR_PUBLIC int binchr(const bstring b0, int pos, const bstring b1)
Definition bstrlib.c:1339
int(* bNgetc)(void *parm)
Definition bstrlib.h:1116
BSTR_PUBLIC int bassignblk(bstring a, const void *s, int len)
Definition bstrlib.c:525
BSTR_PUBLIC int bsreadlna(bstring b, struct bStream *s, char terminator)
Definition bstrlib.c:2033
BSTR_PUBLIC int bninchr(const bstring b0, int pos, const bstring b1)
Definition bstrlib.c:1391
BSTR_PUBLIC int bssplitstrcb(struct bStream *s, const bstring splitStr, int(*cb)(void *parm, int ofs, const bstring entry), void *parm)
Definition bstrlib.c:2419
BSTR_PUBLIC int bstrncmp(const bstring b0, const bstring b1, int n)
Definition bstrlib.c:897
BSTR_PUBLIC bstring bformat(const char *fmt,...)
Definition bstrlib.c:2915
BSTR_PUBLIC int binsert(bstring s1, int pos, const bstring s2, unsigned char fill)
Definition bstrlib.c:1477
BSTR_PUBLIC int balloc(bstring s, int len)
Definition bstrlib.c:97
BSTR_PUBLIC int binstr(const bstring s1, int pos, const bstring s2)
Definition bstrlib.c:998
BSTR_PUBLIC int bsread(bstring b, struct bStream *s, int n)
Definition bstrlib.c:2277
Definition bstrlib.c:1964
void * parm
Definition bstrlib.c:1966
int qty
Definition bstrlib.h:731
int mlen
Definition bstrlib.h:731
bstring * entry
Definition bstrlib.h:732
int mlen
Definition bstrlib.h:85
unsigned char * data
Definition bstrlib.h:87
int slen
Definition bstrlib.h:86