netatalk  4.6.0
Free and Open Source Apple Filing Protocol (AFP) Server
Loading...
Searching...
No Matches
bstrlib.h
Go to the documentation of this file.
1/* Copyright 2002-2015 Paul Hsieh
2 * This file is part of Bstrlib.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are met:
6 *
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 *
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 *
14 * 3. Neither the name of bstrlib nor the names of its contributors may be
15 * used to endorse or promote products derived from this software
16 * without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
22 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26 * CONTRACT, STRICT LIABILITY, OR TORT(INCLUDING NEGLIGENCE OR OTHERWISE)
27 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28 * POSSIBILITY OF SUCH DAMAGE.
29 *
30 * Alternatively, the contents of this file may be used under the terms of
31 * GNU General Public License Version 2 (the "GPL").
32 */
33
41
42#ifndef BSTRLIB_H
43#define BSTRLIB_H
44
45#if __GNUC__ >= 4
46#define BSTR_PUBLIC \
47 __attribute__ ((visibility ("default")))
48#define BSTR_PRIVATE \
49 __attribute__ ((visibility ("hidden")))
50#else
51#define BSTR_PUBLIC
52#define BSTR_PRIVATE
53#endif
54
55#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 4)
56#define BSTR_PRINTF(format, argument) \
57 __attribute__ ((__format__ (__printf__, format, argument)))
58#define BSTR_UNUSED \
59 __attribute__ ((__unused__))
60#elif defined(_MSC_VER)
61#define BSTR_PRINTF(format, argument)
62#define BSTR_UNUSED \
63 __pragma(warning(suppress:4100))
64#else
65#define BSTR_PRINTF(format, argument)
66#define BSTR_UNUSED
67#endif
68
69#ifdef __cplusplus
70extern "C" {
71#endif
72
73#ifdef HAVE_CONFIG_H
74#include <config.h>
75#endif
76
77#include <stdarg.h>
78#include <string.h>
79#include <limits.h>
80#include <ctype.h>
81
82#define BSTR_ERR (-1)
83#define BSTR_OK (0)
84#define BSTR_BS_BUFF_LENGTH_GET (0)
85
86typedef struct tagbstring *bstring;
87
88struct tagbstring {
89 int mlen;
90 int slen;
91 unsigned char *data;
92};
93
94/* Copy functions */
95#define cstr2bstr bfromcstr
96
113bfromcstr(const char *str);
114
135bfromcstralloc(int mlen, const char *str);
136
144bfromcstrrangealloc(int minl, int maxl, const char *str);
145
158blk2bstr(const void *blk, int len);
159
168BSTR_PUBLIC char *
169bstr2cstr(const bstring s, char z);
170
181BSTR_PUBLIC int
182bcstrfree(char *s);
183
191bstrcpy(const bstring b1);
192
199BSTR_PUBLIC int
200bassign(bstring a, const bstring b);
201
210BSTR_PUBLIC int
211bassignmidstr(bstring a, const bstring b, int left, int len);
212
219BSTR_PUBLIC int
220bassigncstr(bstring a, const char *str);
221
230BSTR_PUBLIC int
231bassignblk(bstring a, const void *s, int len);
232
233/* Destroy function */
234
247BSTR_PUBLIC int
249
250/* Space allocation hinting functions */
251
282BSTR_PUBLIC int
283balloc(bstring s, int len);
284
309BSTR_PUBLIC int
310ballocmin(bstring b, int len);
311
312/* Substring extraction */
313
322bmidstr(const bstring b, int left, int len);
323
324/*Various standard manipulations */
325
332BSTR_PUBLIC int
333bconcat(bstring b0, const bstring b1);
334
341BSTR_PUBLIC int
342bconchar(bstring b0, char c);
343
350BSTR_PUBLIC int
351bcatcstr(bstring b, const char *s);
352
359BSTR_PUBLIC int
360bcatblk(bstring b, const void *s, int len);
361
370BSTR_PUBLIC int
371binsert(bstring s1, int pos, const bstring s2, unsigned char fill);
372
381BSTR_PUBLIC int
382binsertblk(bstring b, int pos, const void *blk, int len,
383 unsigned char fill);
384
394BSTR_PUBLIC int
395binsertch(bstring s1, int pos, int len, unsigned char fill);
396
404BSTR_PUBLIC int
405breplace(bstring b1, int pos, int len, const bstring b2, unsigned char fill);
406
416BSTR_PUBLIC int
417bdelete(bstring s1, int pos, int len);
418
427BSTR_PUBLIC int
428bsetstr(bstring b0, int pos, const bstring b1, unsigned char fill);
429
436BSTR_PUBLIC int
437btrunc(bstring b, int n);
438
439/*Scan/search functions */
440
450BSTR_PUBLIC int
451bstricmp(const bstring b0, const bstring b1);
452
463BSTR_PUBLIC int
464bstrnicmp(const bstring b0, const bstring b1, int n);
465
474BSTR_PUBLIC int
475biseqcaseless(const bstring b0, const bstring b1);
476
486BSTR_PUBLIC int
487biseqcaselessblk(const bstring b, const void *blk, int len);
488
497BSTR_PUBLIC int
498bisstemeqcaselessblk(const bstring b0, const void *blk, int len);
499
511BSTR_PUBLIC int
512biseq(const bstring b0, const bstring b1);
513
522BSTR_PUBLIC int
523biseqblk(const bstring b, const void *blk, int len);
524
533BSTR_PUBLIC int
534bisstemeqblk(const bstring b0, const void *blk, int len);
535
547BSTR_PUBLIC int
548biseqcstr(const bstring b, const char *s);
549
562BSTR_PUBLIC int
563biseqcstrcaseless(const bstring b, const char *s);
564
587BSTR_PUBLIC int
588bstrcmp(const bstring b0, const bstring b1);
589
604BSTR_PUBLIC int
605bstrncmp(const bstring b0, const bstring b1, int n);
606
615BSTR_PUBLIC int
616binstr(const bstring s1, int pos, const bstring s2);
617
628BSTR_PUBLIC int
629binstrr(const bstring s1, int pos, const bstring s2);
630
639BSTR_PUBLIC int
640binstrcaseless(const bstring s1, int pos, const bstring s2);
641
652BSTR_PUBLIC int
653binstrrcaseless(const bstring s1, int pos, const bstring s2);
654
661BSTR_PUBLIC int
662bstrchrp(const bstring b, int c, int pos);
663
670BSTR_PUBLIC int
671bstrrchrp(const bstring b, int c, int pos);
672
679#define bstrchr(b, c) \
680 bstrchrp((b), (c), 0)
681
688#define bstrrchr(b, c) \
689 bstrrchrp((b), (c), blength(b) - 1)
690
698BSTR_PUBLIC int
699binchr(const bstring b0, int pos, const bstring b1);
700
708BSTR_PUBLIC int
709binchrr(const bstring b0, int pos, const bstring b1);
710
718BSTR_PUBLIC int
719bninchr(const bstring b0, int pos, const bstring b1);
720
728BSTR_PUBLIC int
729bninchrr(const bstring b0, int pos, const bstring b1);
730
752BSTR_PUBLIC int
753bfindreplace(bstring b, const bstring find, const bstring repl, int pos);
754
776BSTR_PUBLIC int
777bfindreplacecaseless(bstring b, const bstring find, const bstring repl,
778 int pos);
779
780/* List of string container functions */
781struct bstrList {
782 int qty, mlen;
784};
785
808BSTR_PUBLIC struct bstrList *
809bstrListCreate(void);
810
816BSTR_PUBLIC int
817bstrListDestroy(struct bstrList *sl);
818
823BSTR_PUBLIC int
824bstrListAlloc(struct bstrList *sl, int msz);
825
830BSTR_PUBLIC int
831bstrListAllocMin(struct bstrList *sl, int msz);
832
833/* String split and join functions */
834
844BSTR_PUBLIC struct bstrList *
845bsplit(const bstring str, unsigned char splitChar);
846
854BSTR_PUBLIC struct bstrList *
855bsplits(const bstring str, const bstring splitStr);
856
864BSTR_PUBLIC struct bstrList *
865bsplitstr(const bstring str, const bstring splitStr);
866
882bjoin(const struct bstrList *bl, const bstring sep);
883
892bjoinblk(const struct bstrList *bl, const void *blk, int len);
893
914BSTR_PUBLIC int
915bsplitcb(const bstring str,
916 unsigned char splitChar,
917 int pos,
918 int(*cb)(void *parm, int ofs, int len),
919 void *parm);
920
941BSTR_PUBLIC int
942bsplitscb(const bstring str,
943 const bstring splitStr,
944 int pos,
945 int(*cb)(void *parm, int ofs, int len),
946 void *parm);
947
968BSTR_PUBLIC int
969bsplitstrcb(const bstring str,
970 const bstring splitStr,
971 int pos,
972 int(*cb)(void *parm, int ofs, int len), void *parm);
973
974/* Miscellaneous functions */
975
983BSTR_PUBLIC int
984bpattern(bstring b, int len);
985
992BSTR_PUBLIC int
994
1001BSTR_PUBLIC int
1002btolower(bstring b);
1003
1010BSTR_PUBLIC int
1011bltrimws(bstring b);
1012
1019BSTR_PUBLIC int
1020brtrimws(bstring b);
1021
1028BSTR_PUBLIC int
1029btrimws(bstring b);
1030
1031/* *printf format functions */
1052bformat(const char *fmt, ...);
1053
1073BSTR_PUBLIC int
1074bformata(bstring b, const char *fmt, ...);
1075
1095BSTR_PUBLIC int
1096bassignformat(bstring b, const char *fmt, ...);
1097
1123BSTR_PUBLIC int
1124bvcformata(bstring b, int count, const char *fmt, va_list arglist);
1125
1151#define bvformata(ret, b, fmt, lastarg) \
1152do { \
1153 bstring bstrtmp_b =(b); \
1154 const char *bstrtmp_fmt = (fmt); \
1155 int bstrtmp_r = BSTR_ERR, bstrtmp_sz = 16; \
1156 for (;;) { \
1157 va_list bstrtmp_arglist; \
1158 va_start(bstrtmp_arglist, lastarg); \
1159 bstrtmp_r = bvcformata(bstrtmp_b, bstrtmp_sz, bstrtmp_fmt, \
1160 bstrtmp_arglist); \
1161 va_end(bstrtmp_arglist); \
1162 if(bstrtmp_r >= 0) { \
1163 /* Everything went ok */ \
1164 bstrtmp_r = BSTR_OK; \
1165 break; \
1166 } else if(-bstrtmp_r <= bstrtmp_sz) { \
1167 /* A real error? */ \
1168 bstrtmp_r = BSTR_ERR; \
1169 break; \
1170 } \
1171 /* Doubled or target size */ \
1172 bstrtmp_sz = -bstrtmp_r; \
1173 } \
1174 ret = bstrtmp_r; \
1175} while (0);
1176
1177typedef int (*bNgetc)(void *parm);
1178
1179typedef size_t (*bNread)(void *buff, size_t elsize, size_t nelem, void *parm);
1180
1181/* Input functions */
1182
1218#if defined(HAVE_BGETS)
1219bgetstream(bNgetc getcPtr, void *parm, char terminator);
1220#else
1221bgets(bNgetc getcPtr, void *parm, char terminator);
1222#endif
1223
1238bread(bNread readPtr, void *parm);
1239
1248BSTR_PUBLIC int
1249bgetsa(bstring b, bNgetc getcPtr, void *parm, char terminator);
1250
1259BSTR_PUBLIC int
1260bassigngets(bstring b, bNgetc getcPtr, void *parm, char terminator);
1261
1268BSTR_PUBLIC int
1269breada(bstring b, bNread readPtr, void *parm);
1270
1271/* Stream functions */
1272
1278BSTR_PUBLIC struct bStream *
1279bsopen(bNread readPtr, void *parm);
1280
1287BSTR_PUBLIC void *
1288bsclose(struct bStream *s);
1289
1297BSTR_PUBLIC int
1298bsbufflength(struct bStream *s, int sz);
1299
1311BSTR_PUBLIC int
1312bsreadln(bstring b, struct bStream *s, char terminator);
1313
1322BSTR_PUBLIC int
1323bsreadlns(bstring r, struct bStream *s, const bstring term);
1324
1333BSTR_PUBLIC int
1334bsread(bstring b, struct bStream *s, int n);
1335
1347BSTR_PUBLIC int
1348bsreadlna(bstring b, struct bStream *s, char terminator);
1349
1360BSTR_PUBLIC int
1361bsreadlnsa(bstring r, struct bStream *s, const bstring term);
1362
1371BSTR_PUBLIC int
1372bsreada(bstring b, struct bStream *s, int n);
1373
1380BSTR_PUBLIC int
1381bsunread(struct bStream *s, const bstring b);
1382
1388BSTR_PUBLIC int
1389bspeek(bstring r, const struct bStream *s);
1390
1415BSTR_PUBLIC int
1416bssplitscb(struct bStream *s,
1417 const bstring splitStr,
1418 int(*cb)(void *parm, int ofs, const bstring entry),
1419 void *parm);
1420
1445BSTR_PUBLIC int
1446bssplitstrcb(struct bStream *s,
1447 const bstring splitStr,
1448 int(*cb)(void *parm, int ofs, const bstring entry),
1449 void *parm);
1450
1468BSTR_PUBLIC int
1469bseof(const struct bStream *s);
1470
1471/* Accessor macros */
1472
1478#define blengthe(b, e) \
1479 (((b) == (void *)0 || (b)->slen < 0) \
1480 ? (int)(e) \
1481 : ((b)->slen))
1482
1488#define blength(b) \
1489 (blengthe((b), 0))
1490
1496#define bdataofse(b, o, e) \
1497 (((b) == (void *)0 || (b)->data == (void *)0) \
1498 ? (char *)(e) \
1499 : ((char *)(b)->data) + (o))
1500
1506#define bdataofs(b, o) \
1507 (bdataofse((b),(o),(void *)0))
1508
1514#define bdatae(b, e) \
1515 (bdataofse(b, 0, e))
1516
1522#define bdata(b) \
1523 (bdataofs(b, 0))
1524
1531#define bchare(b, p, e) \
1532 ((((unsigned)(p)) < (unsigned)blength(b)) \
1533 ? ((b)->data[(p)]) \
1534 : (e))
1535
1542#define bchar(b, p) \
1543 bchare((b), (p), '\0')
1544
1545/* Static constant string initialization macro */
1546
1549#define bsStaticMlen(q, m) { (m), (int)sizeof(q) - 1, (unsigned char *)("" q "") }
1550
1551#if defined (_MSC_VER)
1552/* There are many versions of MSVC which emit __LINE__ as a non-constant. */
1566#define bsStatic(q) bsStaticMlen(q, -32)
1567#endif /* defined (_MSC_VER) */
1568
1569#ifndef bsStatic
1572#define bsStatic(q) bsStaticMlen(q, -__LINE__)
1573#endif /* bsStatic */
1574
1575/* Static constant block parameter pair */
1576
1595#define bsStaticBlkParms(q) \
1596 ((void *)("" q "")), ((int)sizeof(q) -1)
1597
1598/* Static convenience macros for blk functions with string literals */
1599
1600#define bcatStatic(b, s) ((bcatblk)((b), bsStaticBlkParms(s)))
1601#define bfromStatic(s) ((blk2bstr)(bsStaticBlkParms(s)))
1602#define bassignStatic(b, s) ((bassignblk)((b), bsStaticBlkParms(s)))
1603#define binsertStatic(b, p, s, f) ((binsertblk)((b), (p), bsStaticBlkParms(s), (f)))
1604#define bjoinStatic(b, s) ((bjoinblk)((b), bsStaticBlkParms(s)))
1605#define biseqStatic(b, s) ((biseqblk)((b), bsStaticBlkParms(s)))
1606#define bisstemeqStatic(b, s) ((bisstemeqblk)((b), bsStaticBlkParms(s)))
1607#define biseqcaselessStatic(b, s) ((biseqcaselessblk)((b), bsStaticBlkParms(s)))
1608#define bisstemeqcaselessStatic(b, s) ((bisstemeqcaselessblk)((b), bsStaticBlkParms(s)))
1609
1610/* Reference building macros */
1611
1614#define cstr2tbstr btfromcstr
1615
1629#define btfromcstr(t, s) \
1630do { \
1631 (t).data = (unsigned char *)(s); \
1632 (t).slen = ((t).data) \
1633 ? ((int)(strlen)((char *)(t).data)) \
1634 : 0; \
1635 (t).mlen = -1; \
1636} while (0)
1637
1640#define blk2tbstr(t, s, l) \
1641do { \
1642 (t).data = (unsigned char *)(s); \
1643 (t).slen = l; \
1644 (t).mlen = -1; \
1645} while (0)
1646
1661#define btfromblk(t, s, l) blk2tbstr(t, s, l)
1662
1678#define bmid2tbstr(t, b, p, l) \
1679do { \
1680 const bstring bstrtmp_s =(b); \
1681 if (bstrtmp_s && bstrtmp_s->data && bstrtmp_s->slen >= 0) { \
1682 int bstrtmp_left = (p); \
1683 int bstrtmp_len = (l); \
1684 if (bstrtmp_left < 0) { \
1685 bstrtmp_len += bstrtmp_left; \
1686 bstrtmp_left = 0; \
1687 } \
1688 if (bstrtmp_len > bstrtmp_s->slen - bstrtmp_left) { \
1689 bstrtmp_len = bstrtmp_s->slen - bstrtmp_left; \
1690 } \
1691 if(bstrtmp_len <= 0) { \
1692 (t).data =(unsigned char *)""; \
1693 (t).slen = 0; \
1694 } else { \
1695 (t).data = bstrtmp_s->data + bstrtmp_left; \
1696 (t).slen = bstrtmp_len; \
1697 } \
1698 } else { \
1699 (t).data = (unsigned char *)""; \
1700 (t).slen = 0; \
1701 } \
1702 (t).mlen = -__LINE__; \
1703} while (0)
1704
1719#define btfromblkltrimws(t, s, l) \
1720do { \
1721 int bstrtmp_idx = 0, bstrtmp_len =(l); \
1722 unsigned char *bstrtmp_s = (s); \
1723 if (bstrtmp_s && bstrtmp_len >= 0) { \
1724 for (; bstrtmp_idx < bstrtmp_len; bstrtmp_idx++) { \
1725 if (!isspace(bstrtmp_s[bstrtmp_idx])) { \
1726 break; \
1727 } \
1728 } \
1729 } \
1730 (t).data = bstrtmp_s + bstrtmp_idx; \
1731 (t).slen = bstrtmp_len - bstrtmp_idx; \
1732 (t).mlen = -__LINE__; \
1733} while (0)
1734
1749#define btfromblkrtrimws(t, s, l) \
1750do { \
1751 int bstrtmp_len = (l) - 1; \
1752 unsigned char *bstrtmp_s = (s); \
1753 if (bstrtmp_s && bstrtmp_len >= 0) { \
1754 for (; bstrtmp_len >= 0; bstrtmp_len--) { \
1755 if (!isspace(bstrtmp_s[bstrtmp_len])) { \
1756 break; \
1757 } \
1758 } \
1759 } \
1760 (t).data = bstrtmp_s; \
1761 (t).slen = bstrtmp_len + 1; \
1762 (t).mlen = -__LINE__; \
1763} while (0)
1764
1779#define btfromblktrimws(t, s, l) \
1780do { \
1781 int bstrtmp_idx = 0, bstrtmp_len = (l) - 1; \
1782 unsigned char *bstrtmp_s = (s); \
1783 if (bstrtmp_s && bstrtmp_len >= 0) { \
1784 for (; bstrtmp_idx <= bstrtmp_len; bstrtmp_idx++) { \
1785 if(!isspace(bstrtmp_s[bstrtmp_idx])) { \
1786 break; \
1787 } \
1788 } \
1789 for (; bstrtmp_len >= bstrtmp_idx; bstrtmp_len--) { \
1790 if (!isspace(bstrtmp_s[bstrtmp_len])) { \
1791 break; \
1792 } \
1793 } \
1794 } \
1795 (t).data = bstrtmp_s + bstrtmp_idx; \
1796 (t).slen = bstrtmp_len + 1 - bstrtmp_idx; \
1797 (t).mlen = -__LINE__; \
1798} while (0)
1799
1800/* Write protection macros */
1801
1810#define bwriteprotect(t) \
1811do { \
1812 if ((t).mlen >= 0) { \
1813 (t).mlen = -1; \
1814 } \
1815} while (0)
1816
1829#define bwriteallow(t) \
1830do { \
1831 if ((t).mlen == -1) { \
1832 (t).mlen = (t).slen + ((t).slen == 0); \
1833 } \
1834} while (0)
1835
1839#define biswriteprotected(t) \
1840 ((t).mlen <= 0)
1841
1842#ifdef __cplusplus
1843}
1844#endif
1845
1846#endif /* BSTRLIB_H */
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:1177
size_t(*) bNread(void *buff, size_t elsize, size_t nelem, void *parm)
Definition bstrlib.h:1179
Definition bstrlib.c:2018
void * parm
Definition bstrlib.c:2020
Definition bstrlib.h:781
int qty
Definition bstrlib.h:782
int mlen
Definition bstrlib.h:782
bstring * entry
Definition bstrlib.h:783
Definition ad_open.c:96
Definition bstrlib.h:88
int mlen
Definition bstrlib.h:89
unsigned char * data
Definition bstrlib.h:91
int slen
Definition bstrlib.h:90