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__))
60#elif defined(_MSC_VER)
61#define BSTR_PRINTF(format, argument)
63 __pragma(warning(suppress:4100))
65#define BSTR_PRINTF(format, argument)
84#define BSTR_BS_BUFF_LENGTH_GET (0)
95#define cstr2bstr bfromcstr
676#define bstrchr(b, c) \
677 bstrchrp((b), (c), 0)
685#define bstrrchr(b, c) \
686 bstrrchrp((b), (c), blength(b) - 1)
913 unsigned char splitChar,
915 int(*cb)(
void *parm,
int ofs,
int len),
942 int(*cb)(
void *parm,
int ofs,
int len),
969 int(*cb)(
void *parm,
int ofs,
int len),
void *parm);
1148#define bvformata(ret, b, fmt, lastarg) \
1150 bstring bstrtmp_b =(b); \
1151 const char *bstrtmp_fmt = (fmt); \
1152 int bstrtmp_r = BSTR_ERR, bstrtmp_sz = 16; \
1154 va_list bstrtmp_arglist; \
1155 va_start(bstrtmp_arglist, lastarg); \
1156 bstrtmp_r = bvcformata(bstrtmp_b, bstrtmp_sz, bstrtmp_fmt, \
1158 va_end(bstrtmp_arglist); \
1159 if(bstrtmp_r >= 0) { \
1161 bstrtmp_r = BSTR_OK; \
1163 } else if(-bstrtmp_r <= bstrtmp_sz) { \
1165 bstrtmp_r = BSTR_ERR; \
1169 bstrtmp_sz = -bstrtmp_r; \
1176typedef size_t (*
bNread)(
void *buff,
size_t elsize,
size_t nelem,
void *parm);
1215#if defined(HAVE_BGETS)
1216bgetstream(
bNgetc getcPtr,
void *parm,
char terminator);
1218bgets(
bNgetc getcPtr,
void *parm,
char terminator);
1475#define blengthe(b, e) \
1476 (((b) == (void *)0 || (b)->slen < 0) \
1493#define bdataofse(b, o, e) \
1494 (((b) == (void *)0 || (b)->data == (void *)0) \
1496 : ((char *)(b)->data) + (o))
1503#define bdataofs(b, o) \
1504 (bdataofse((b),(o),(void *)0))
1511#define bdatae(b, e) \
1512 (bdataofse(b, 0, e))
1528#define bchare(b, p, e) \
1529 ((((unsigned)(p)) < (unsigned)blength(b)) \
1530 ? ((b)->data[(p)]) \
1539#define bchar(b, p) \
1540 bchare((b), (p), '\0')
1546#define bsStaticMlen(q, m) { (m), (int)sizeof(q) - 1, (unsigned char *)("" q "") }
1548#if defined (_MSC_VER)
1563#define bsStatic(q) bsStaticMlen(q, -32)
1569#define bsStatic(q) bsStaticMlen(q, -__LINE__)
1592#define bsStaticBlkParms(q) \
1593 ((void *)("" q "")), ((int)sizeof(q) -1)
1597#define bcatStatic(b, s) ((bcatblk)((b), bsStaticBlkParms(s)))
1598#define bfromStatic(s) ((blk2bstr)(bsStaticBlkParms(s)))
1599#define bassignStatic(b, s) ((bassignblk)((b), bsStaticBlkParms(s)))
1600#define binsertStatic(b, p, s, f) ((binsertblk)((b), (p), bsStaticBlkParms(s), (f)))
1601#define bjoinStatic(b, s) ((bjoinblk)((b), bsStaticBlkParms(s)))
1602#define biseqStatic(b, s) ((biseqblk)((b), bsStaticBlkParms(s)))
1603#define bisstemeqStatic(b, s) ((bisstemeqblk)((b), bsStaticBlkParms(s)))
1604#define biseqcaselessStatic(b, s) ((biseqcaselessblk)((b), bsStaticBlkParms(s)))
1605#define bisstemeqcaselessStatic(b, s) ((bisstemeqcaselessblk)((b), bsStaticBlkParms(s)))
1611#define cstr2tbstr btfromcstr
1626#define btfromcstr(t, s) \
1628 (t).data = (unsigned char *)(s); \
1629 (t).slen = ((t).data) \
1630 ? ((int)(strlen)((char *)(t).data)) \
1637#define blk2tbstr(t, s, l) \
1639 (t).data = (unsigned char *)(s); \
1658#define btfromblk(t, s, l) blk2tbstr(t, s, l)
1675#define bmid2tbstr(t, b, p, l) \
1677 const bstring bstrtmp_s =(b); \
1678 if (bstrtmp_s && bstrtmp_s->data && bstrtmp_s->slen >= 0) { \
1679 int bstrtmp_left = (p); \
1680 int bstrtmp_len = (l); \
1681 if (bstrtmp_left < 0) { \
1682 bstrtmp_len += bstrtmp_left; \
1685 if (bstrtmp_len > bstrtmp_s->slen - bstrtmp_left) { \
1686 bstrtmp_len = bstrtmp_s->slen - bstrtmp_left; \
1688 if(bstrtmp_len <= 0) { \
1689 (t).data =(unsigned char *)""; \
1692 (t).data = bstrtmp_s->data + bstrtmp_left; \
1693 (t).slen = bstrtmp_len; \
1696 (t).data = (unsigned char *)""; \
1699 (t).mlen = -__LINE__; \
1716#define btfromblkltrimws(t, s, l) \
1718 int bstrtmp_idx = 0, bstrtmp_len =(l); \
1719 unsigned char *bstrtmp_s = (s); \
1720 if (bstrtmp_s && bstrtmp_len >= 0) { \
1721 for (; bstrtmp_idx < bstrtmp_len; bstrtmp_idx++) { \
1722 if (!isspace(bstrtmp_s[bstrtmp_idx])) { \
1727 (t).data = bstrtmp_s + bstrtmp_idx; \
1728 (t).slen = bstrtmp_len - bstrtmp_idx; \
1729 (t).mlen = -__LINE__; \
1746#define btfromblkrtrimws(t, s, l) \
1748 int bstrtmp_len = (l) - 1; \
1749 unsigned char *bstrtmp_s = (s); \
1750 if (bstrtmp_s && bstrtmp_len >= 0) { \
1751 for (; bstrtmp_len >= 0; bstrtmp_len--) { \
1752 if (!isspace(bstrtmp_s[bstrtmp_len])) { \
1757 (t).data = bstrtmp_s; \
1758 (t).slen = bstrtmp_len + 1; \
1759 (t).mlen = -__LINE__; \
1776#define btfromblktrimws(t, s, l) \
1778 int bstrtmp_idx = 0, bstrtmp_len = (l) - 1; \
1779 unsigned char *bstrtmp_s = (s); \
1780 if (bstrtmp_s && bstrtmp_len >= 0) { \
1781 for (; bstrtmp_idx <= bstrtmp_len; bstrtmp_idx++) { \
1782 if(!isspace(bstrtmp_s[bstrtmp_idx])) { \
1786 for (; bstrtmp_len >= bstrtmp_idx; bstrtmp_len--) { \
1787 if (!isspace(bstrtmp_s[bstrtmp_len])) { \
1792 (t).data = bstrtmp_s + bstrtmp_idx; \
1793 (t).slen = bstrtmp_len + 1 - bstrtmp_idx; \
1794 (t).mlen = -__LINE__; \
1807#define bwriteprotect(t) \
1809 if ((t).mlen >= 0) { \
1826#define bwriteallow(t) \
1828 if ((t).mlen == -1) { \
1829 (t).mlen = (t).slen + ((t).slen == 0); \
1836#define biswriteprotected(t) \
int bgetsa(bstring b, bNgetc getcPtr, void *parm, char terminator)
Definition bstrlib.c:1973
int bassigncstr(bstring a, const char *str)
Definition bstrlib.c:521
int biseq(const bstring b0, const bstring b1)
Definition bstrlib.c:843
int bspeek(bstring r, const struct bStream *s)
Definition bstrlib.c:2353
struct bStream * bsopen(bNread readPtr, void *parm)
Definition bstrlib.c:2027
int bsbufflength(struct bStream *s, int sz)
Definition bstrlib.c:2045
int breplace(bstring b1, int pos, int len, const bstring b2, unsigned char fill)
Definition bstrlib.c:1587
void * bsclose(struct bStream *s)
Definition bstrlib.c:2068
int bsplitcb(const bstring str, unsigned char splitChar, int pos, int(*cb)(void *parm, int ofs, int len), void *parm)
Definition bstrlib.c:2669
int bsplitstrcb(const bstring str, const bstring splitStr, int pos, int(*cb)(void *parm, int ofs, int len), void *parm)
Definition bstrlib.c:2729
int bninchr(const bstring b0, int pos, const bstring b1)
Definition bstrlib.c:1438
int bisstemeqcaselessblk(const bstring b0, const void *blk, int len)
Definition bstrlib.c:732
int bisstemeqblk(const bstring b0, const void *blk, int len)
Definition bstrlib.c:860
struct bstrList * bstrListCreate(void)
Definition bstrlib.c:2569
int biseqblk(const bstring b, const void *blk, int len)
Definition bstrlib.c:827
int bsread(bstring r, struct bStream *s, int n)
Definition bstrlib.c:2331
int bassignformat(bstring b, const char *fmt,...)
Definition bstrlib.c:2952
bstring bfromcstr(const char *str)
Definition bstrlib.c:188
char * bstr2cstr(const bstring b, char z)
Definition bstrlib.c:305
int bsetstr(bstring b0, int pos, const bstring b1, unsigned char fill)
Definition bstrlib.c:1471
int bassignmidstr(bstring a, const bstring b, int left, int len)
Definition bstrlib.c:490
int bstrncmp(const bstring b0, const bstring b1, int n)
Definition bstrlib.c:944
int bsreadlns(bstring r, struct bStream *s, const bstring term)
Definition bstrlib.c:2312
int bsreadlna(bstring r, struct bStream *s, char terminator)
Definition bstrlib.c:2087
int bfindreplacecaseless(bstring b, const bstring find, const bstring repl, int pos)
Definition bstrlib.c:1836
int bssplitstrcb(struct bStream *s, const bstring splitStr, int(*cb)(void *parm, int ofs, const bstring entry), void *parm)
Definition bstrlib.c:2511
int bstrchrp(const bstring b, int c, int pos)
Definition bstrlib.c:1288
bstring bmidstr(const bstring b, int left, int len)
Definition bstrlib.c:979
int binstrcaseless(const bstring b1, int pos, const bstring b2)
Definition bstrlib.c:1186
struct bstrList * bsplit(const bstring str, unsigned char splitChar)
Definition bstrlib.c:2802
int binstrr(const bstring b1, int pos, const bstring b2)
Definition bstrlib.c:1135
struct bstrList * bsplitstr(const bstring str, const bstring splitStr)
Definition bstrlib.c:2829
int binchr(const bstring b0, int pos, const bstring b1)
Definition bstrlib.c:1386
int bconcat(bstring b0, const bstring b1)
Definition bstrlib.c:332
bstring blk2bstr(const void *blk, int len)
Definition bstrlib.c:272
int btoupper(bstring b)
Definition bstrlib.c:590
int bstrrchrp(const bstring b, int c, int pos)
Definition bstrlib.c:1303
int bcatblk(bstring b, const void *s, int len)
Definition bstrlib.c:410
int biseqcaselessblk(const bstring b, const void *blk, int len)
Definition bstrlib.c:698
bstring bjoinblk(const struct bstrList *bl, const void *blk, int len)
Definition bstrlib.c:2362
int balloc(bstring b, int olen)
Definition bstrlib.c:97
int btrimws(bstring b)
Definition bstrlib.c:800
int bformata(bstring b, const char *fmt,...)
Definition bstrlib.c:2897
int bltrimws(bstring b)
Definition bstrlib.c:756
int bpattern(bstring b, int len)
Definition bstrlib.c:1881
int bstrnicmp(const bstring b0, const bstring b1, int n)
Definition bstrlib.c:656
int biseqcaseless(const bstring b0, const bstring b1)
Definition bstrlib.c:723
int btrunc(bstring b, int n)
Definition bstrlib.c:566
int bninchrr(const bstring b0, int pos, const bstring b1)
Definition bstrlib.c:1453
int bseof(const struct bStream *s)
Definition bstrlib.c:2059
int btolower(bstring b)
Definition bstrlib.c:605
int binsert(bstring b1, int pos, const bstring b2, unsigned char fill)
Definition bstrlib.c:1578
int biseqcstr(const bstring b, const char *s)
Definition bstrlib.c:880
int bstrcmp(const bstring b0, const bstring b1)
Definition bstrlib.c:911
int bcatcstr(bstring b, const char *s)
Definition bstrlib.c:386
int bassign(bstring a, const bstring b)
Definition bstrlib.c:467
int ballocmin(bstring b, int len)
Definition bstrlib.c:159
int bassigngets(bstring b, bNgetc getcPtr, void *parm, char terminator)
Definition bstrlib.c:1943
int bvcformata(bstring b, int count, const char *fmt, va_list arg)
Definition bstrlib.c:3058
int brtrimws(bstring b)
Definition bstrlib.c:775
int bfindreplace(bstring b, const bstring find, const bstring repl, int pos)
Definition bstrlib.c:1830
int bassignblk(bstring a, const void *s, int len)
Definition bstrlib.c:548
bstring bfromcstrrangealloc(int minl, int maxl, const char *str)
Definition bstrlib.c:217
int binsertch(bstring b, int pos, int len, unsigned char fill)
Definition bstrlib.c:1842
int bcstrfree(char *s)
Definition bstrlib.c:325
int bstricmp(const bstring b0, const bstring b1)
Definition bstrlib.c:620
int bconchar(bstring b, char c)
Definition bstrlib.c:369
bstring bfromcstralloc(int mlen, const char *str)
Definition bstrlib.c:266
int binstrrcaseless(const bstring b1, int pos, const bstring b2)
Definition bstrlib.c:1236
int biseqcstrcaseless(const bstring b, const char *s)
Definition bstrlib.c:895
int bdelete(bstring b, int pos, int len)
Definition bstrlib.c:998
int bdestroy(bstring b)
Definition bstrlib.c:1024
int bsunread(struct bStream *s, const bstring b)
Definition bstrlib.c:2344
int binsertblk(bstring b, int pos, const void *blk, int len, unsigned char fill)
Definition bstrlib.c:1524
bstring bjoin(const struct bstrList *bl, const bstring sep)
Definition bstrlib.c:2436
bstring bstrcpy(const bstring b)
Definition bstrlib.c:432
int binstr(const bstring b1, int pos, const bstring b2)
Definition bstrlib.c:1045
int bssplitscb(struct bStream *s, const bstring splitStr, int(*cb)(void *parm, int ofs, const bstring entry), void *parm)
Definition bstrlib.c:2450
bstring bgets(bNgetc getcPtr, void *parm, char terminator)
Definition bstrlib.c:2006
int bstrListDestroy(struct bstrList *sl)
Definition bstrlib.c:2586
struct bstrList * bsplits(const bstring str, const bstring splitStr)
Definition bstrlib.c:2855
int bstrListAllocMin(struct bstrList *sl, int msz)
Definition bstrlib.c:2640
bstring bread(bNread readPtr, void *parm)
Definition bstrlib.c:1932
int breada(bstring b, bNread readPtr, void *parm)
Definition bstrlib.c:1904
int bsreadln(bstring r, struct bStream *s, char terminator)
Definition bstrlib.c:2299
int bsreadlnsa(bstring r, struct bStream *s, const bstring term)
Definition bstrlib.c:2155
int bstrListAlloc(struct bstrList *sl, int msz)
Definition bstrlib.c:2607
int binchrr(const bstring b0, int pos, const bstring b1)
Definition bstrlib.c:1417
int bsreada(bstring r, struct bStream *s, int n)
Definition bstrlib.c:2231
bstring bformat(const char *fmt,...)
Definition bstrlib.c:3007
int bsplitscb(const bstring str, const bstring splitStr, int pos, int(*cb)(void *parm, int ofs, int len), void *parm)
Definition bstrlib.c:2693
#define BSTR_PUBLIC
Definition bstrlib.h:51
struct tagbstring * bstring
Definition bstrlib.h:86
int(*) bNgetc(void *parm)
Definition bstrlib.h:1174
size_t(*) bNread(void *buff, size_t elsize, size_t nelem, void *parm)
Definition bstrlib.h:1176
Definition bstrlib.c:2018
void * parm
Definition bstrlib.c:2020
int qty
Definition bstrlib.h:779
int mlen
Definition bstrlib.h:779
bstring * entry
Definition bstrlib.h:780
int mlen
Definition bstrlib.h:89
unsigned char * data
Definition bstrlib.h:91
int slen
Definition bstrlib.h:90