netatalk: bstrlib.h Source File

netatalk 4.5.1
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
86 typedef struct tagbstring *bstring;
87
88 struct tagbstring {
89 int mlen;
90 int slen;
91 unsigned char *data;
92};
93
94/* Copy functions */
95#define cstr2bstr bfromcstr
96
112 BSTR_PUBLIC bstring
113 bfromcstr(const char *str);
114
134 BSTR_PUBLIC bstring
135 bfromcstralloc(int mlen, const char *str);
136
143 BSTR_PUBLIC bstring
144 bfromcstrrangealloc(int minl, int maxl, const char *str);
145
154 BSTR_PUBLIC bstring
155 blk2bstr(const void *blk, int len);
156
165 BSTR_PUBLIC char *
166 bstr2cstr(const bstring s, char z);
167
178 BSTR_PUBLIC int
179 bcstrfree(char *s);
180
187 BSTR_PUBLIC bstring
188 bstrcpy(const bstring b1);
189
196 BSTR_PUBLIC int
197 bassign(bstring a, const bstring b);
198
207 BSTR_PUBLIC int
208 bassignmidstr(bstring a, const bstring b, int left, int len);
209
216 BSTR_PUBLIC int
217 bassigncstr(bstring a, const char *str);
218
227 BSTR_PUBLIC int
228 bassignblk(bstring a, const void *s, int len);
229
230/* Destroy function */
231
244 BSTR_PUBLIC int
245 bdestroy(bstring b);
246
247/* Space allocation hinting functions */
248
279 BSTR_PUBLIC int
280 balloc(bstring s, int len);
281
306 BSTR_PUBLIC int
307 ballocmin(bstring b, int len);
308
309/* Substring extraction */
310
318 BSTR_PUBLIC bstring
319 bmidstr(const bstring b, int left, int len);
320
321/*Various standard manipulations */
322
329 BSTR_PUBLIC int
330 bconcat(bstring b0, const bstring b1);
331
338 BSTR_PUBLIC int
339 bconchar(bstring b0, char c);
340
347 BSTR_PUBLIC int
348 bcatcstr(bstring b, const char *s);
349
356 BSTR_PUBLIC int
357 bcatblk(bstring b, const void *s, int len);
358
367 BSTR_PUBLIC int
368 binsert(bstring s1, int pos, const bstring s2, unsigned char fill);
369
378 BSTR_PUBLIC int
379 binsertblk(bstring b, int pos, const void *blk, int len,
380 unsigned char fill);
381
391 BSTR_PUBLIC int
392 binsertch(bstring s1, int pos, int len, unsigned char fill);
393
401 BSTR_PUBLIC int
402 breplace(bstring b1, int pos, int len, const bstring b2, unsigned char fill);
403
413 BSTR_PUBLIC int
414 bdelete(bstring s1, int pos, int len);
415
424 BSTR_PUBLIC int
425 bsetstr(bstring b0, int pos, const bstring b1, unsigned char fill);
426
433 BSTR_PUBLIC int
434 btrunc(bstring b, int n);
435
436/*Scan/search functions */
437
447 BSTR_PUBLIC int
448 bstricmp(const bstring b0, const bstring b1);
449
460 BSTR_PUBLIC int
461 bstrnicmp(const bstring b0, const bstring b1, int n);
462
471 BSTR_PUBLIC int
472 biseqcaseless(const bstring b0, const bstring b1);
473
483 BSTR_PUBLIC int
484 biseqcaselessblk(const bstring b, const void *blk, int len);
485
494 BSTR_PUBLIC int
495 bisstemeqcaselessblk(const bstring b0, const void *blk, int len);
496
508 BSTR_PUBLIC int
509 biseq(const bstring b0, const bstring b1);
510
519 BSTR_PUBLIC int
520 biseqblk(const bstring b, const void *blk, int len);
521
530 BSTR_PUBLIC int
531 bisstemeqblk(const bstring b0, const void *blk, int len);
532
544 BSTR_PUBLIC int
545 biseqcstr(const bstring b, const char *s);
546
559 BSTR_PUBLIC int
560 biseqcstrcaseless(const bstring b, const char *s);
561
584 BSTR_PUBLIC int
585 bstrcmp(const bstring b0, const bstring b1);
586
601 BSTR_PUBLIC int
602 bstrncmp(const bstring b0, const bstring b1, int n);
603
612 BSTR_PUBLIC int
613 binstr(const bstring s1, int pos, const bstring s2);
614
625 BSTR_PUBLIC int
626 binstrr(const bstring s1, int pos, const bstring s2);
627
636 BSTR_PUBLIC int
637 binstrcaseless(const bstring s1, int pos, const bstring s2);
638
649 BSTR_PUBLIC int
650 binstrrcaseless(const bstring s1, int pos, const bstring s2);
651
658 BSTR_PUBLIC int
659 bstrchrp(const bstring b, int c, int pos);
660
667 BSTR_PUBLIC int
668 bstrrchrp(const bstring b, int c, int pos);
669
676#define bstrchr(b, c) \
677 bstrchrp((b), (c), 0)
678
685#define bstrrchr(b, c) \
686 bstrrchrp((b), (c), blength(b) - 1)
687
695 BSTR_PUBLIC int
696 binchr(const bstring b0, int pos, const bstring b1);
697
705 BSTR_PUBLIC int
706 binchrr(const bstring b0, int pos, const bstring b1);
707
715 BSTR_PUBLIC int
716 bninchr(const bstring b0, int pos, const bstring b1);
717
725 BSTR_PUBLIC int
726 bninchrr(const bstring b0, int pos, const bstring b1);
727
749 BSTR_PUBLIC int
750 bfindreplace(bstring b, const bstring find, const bstring repl, int pos);
751
773 BSTR_PUBLIC int
774 bfindreplacecaseless(bstring b, const bstring find, const bstring repl,
775 int pos);
776
777/* List of string container functions */
778 struct bstrList {
779 int qty, mlen;
780 bstring *entry;
781};
782
805 BSTR_PUBLIC struct bstrList *
806 bstrListCreate(void);
807
813 BSTR_PUBLIC int
814 bstrListDestroy(struct bstrList *sl);
815
820 BSTR_PUBLIC int
821 bstrListAlloc(struct bstrList *sl, int msz);
822
827 BSTR_PUBLIC int
828 bstrListAllocMin(struct bstrList *sl, int msz);
829
830/* String split and join functions */
831
841 BSTR_PUBLIC struct bstrList *
842 bsplit(const bstring str, unsigned char splitChar);
843
851 BSTR_PUBLIC struct bstrList *
852 bsplits(const bstring str, const bstring splitStr);
853
861 BSTR_PUBLIC struct bstrList *
862 bsplitstr(const bstring str, const bstring splitStr);
863
878 BSTR_PUBLIC bstring
879 bjoin(const struct bstrList *bl, const bstring sep);
880
888 BSTR_PUBLIC bstring
889 bjoinblk(const struct bstrList *bl, const void *blk, int len);
890
911 BSTR_PUBLIC int
912 bsplitcb(const bstring str,
913 unsigned char splitChar,
914 int pos,
915 int(*cb)(void *parm, int ofs, int len),
916 void *parm);
917
938 BSTR_PUBLIC int
939 bsplitscb(const bstring str,
940 const bstring splitStr,
941 int pos,
942 int(*cb)(void *parm, int ofs, int len),
943 void *parm);
944
965 BSTR_PUBLIC int
966 bsplitstrcb(const bstring str,
967 const bstring splitStr,
968 int pos,
969 int(*cb)(void *parm, int ofs, int len), void *parm);
970
971/* Miscellaneous functions */
972
980 BSTR_PUBLIC int
981 bpattern(bstring b, int len);
982
989 BSTR_PUBLIC int
990 btoupper(bstring b);
991
998 BSTR_PUBLIC int
999 btolower(bstring b);
1000
1007 BSTR_PUBLIC int
1008 bltrimws(bstring b);
1009
1016 BSTR_PUBLIC int
1017 brtrimws(bstring b);
1018
1025 BSTR_PUBLIC int
1026 btrimws(bstring b);
1027
1028/* *printf format functions */
1048 BSTR_PUBLIC bstring
1049 bformat(const char *fmt, ...);
1050
1070 BSTR_PUBLIC int
1071 bformata(bstring b, const char *fmt, ...);
1072
1092 BSTR_PUBLIC int
1093 bassignformat(bstring b, const char *fmt, ...);
1094
1120 BSTR_PUBLIC int
1121 bvcformata(bstring b, int count, const char *fmt, va_list arglist);
1122
1148#define bvformata(ret, b, fmt, lastarg) \
1149do { \
1150 bstring bstrtmp_b =(b); \
1151 const char *bstrtmp_fmt = (fmt); \
1152 int bstrtmp_r = BSTR_ERR, bstrtmp_sz = 16; \
1153 for (;;) { \
1154 va_list bstrtmp_arglist; \
1155 va_start(bstrtmp_arglist, lastarg); \
1156 bstrtmp_r = bvcformata(bstrtmp_b, bstrtmp_sz, bstrtmp_fmt, \
1157 bstrtmp_arglist); \
1158 va_end(bstrtmp_arglist); \
1159 if(bstrtmp_r >= 0) { \
1160 /* Everything went ok */ \
1161 bstrtmp_r = BSTR_OK; \
1162 break; \
1163 } else if(-bstrtmp_r <= bstrtmp_sz) { \
1164 /* A real error? */ \
1165 bstrtmp_r = BSTR_ERR; \
1166 break; \
1167 } \
1168 /* Doubled or target size */ \
1169 bstrtmp_sz = -bstrtmp_r; \
1170 } \
1171 ret = bstrtmp_r; \
1172} while (0);
1173
1174 typedef int (*bNgetc)(void *parm);
1175
1176 typedef size_t (*bNread)(void *buff, size_t elsize, size_t nelem, void *parm);
1177
1178/* Input functions */
1179
1214 BSTR_PUBLIC bstring
1215#if defined(HAVE_BGETS)
1216bgetstream(bNgetc getcPtr, void *parm, char terminator);
1217#else
1218 bgets(bNgetc getcPtr, void *parm, char terminator);
1219#endif
1220
1234 BSTR_PUBLIC bstring
1235 bread(bNread readPtr, void *parm);
1236
1245 BSTR_PUBLIC int
1246 bgetsa(bstring b, bNgetc getcPtr, void *parm, char terminator);
1247
1256 BSTR_PUBLIC int
1257 bassigngets(bstring b, bNgetc getcPtr, void *parm, char terminator);
1258
1265 BSTR_PUBLIC int
1266 breada(bstring b, bNread readPtr, void *parm);
1267
1268/* Stream functions */
1269
1275 BSTR_PUBLIC struct bStream *
1276 bsopen(bNread readPtr, void *parm);
1277
1284 BSTR_PUBLIC void *
1285 bsclose(struct bStream *s);
1286
1294 BSTR_PUBLIC int
1295 bsbufflength(struct bStream *s, int sz);
1296
1308 BSTR_PUBLIC int
1309 bsreadln(bstring b, struct bStream *s, char terminator);
1310
1319 BSTR_PUBLIC int
1320 bsreadlns(bstring r, struct bStream *s, const bstring term);
1321
1330 BSTR_PUBLIC int
1331 bsread(bstring b, struct bStream *s, int n);
1332
1344 BSTR_PUBLIC int
1345 bsreadlna(bstring b, struct bStream *s, char terminator);
1346
1357 BSTR_PUBLIC int
1358 bsreadlnsa(bstring r, struct bStream *s, const bstring term);
1359
1368 BSTR_PUBLIC int
1369 bsreada(bstring b, struct bStream *s, int n);
1370
1377 BSTR_PUBLIC int
1378 bsunread(struct bStream *s, const bstring b);
1379
1385 BSTR_PUBLIC int
1386 bspeek(bstring r, const struct bStream *s);
1387
1412 BSTR_PUBLIC int
1413 bssplitscb(struct bStream *s,
1414 const bstring splitStr,
1415 int(*cb)(void *parm, int ofs, const bstring entry),
1416 void *parm);
1417
1442 BSTR_PUBLIC int
1443 bssplitstrcb(struct bStream *s,
1444 const bstring splitStr,
1445 int(*cb)(void *parm, int ofs, const bstring entry),
1446 void *parm);
1447
1465 BSTR_PUBLIC int
1466 bseof(const struct bStream *s);
1467
1468/* Accessor macros */
1469
1475#define blengthe(b, e) \
1476 (((b) == (void *)0 || (b)->slen < 0) \
1477 ? (int)(e) \
1478 : ((b)->slen))
1479
1485#define blength(b) \
1486 (blengthe((b), 0))
1487
1493#define bdataofse(b, o, e) \
1494 (((b) == (void *)0 || (b)->data == (void *)0) \
1495 ? (char *)(e) \
1496 : ((char *)(b)->data) + (o))
1497
1503#define bdataofs(b, o) \
1504 (bdataofse((b),(o),(void *)0))
1505
1511#define bdatae(b, e) \
1512 (bdataofse(b, 0, e))
1513
1519#define bdata(b) \
1520 (bdataofs(b, 0))
1521
1528#define bchare(b, p, e) \
1529 ((((unsigned)(p)) < (unsigned)blength(b)) \
1530 ? ((b)->data[(p)]) \
1531 : (e))
1532
1539#define bchar(b, p) \
1540 bchare((b), (p), '\0')
1541
1542/* Static constant string initialization macro */
1543
1546#define bsStaticMlen(q, m) { (m), (int)sizeof(q) - 1, (unsigned char *)("" q "") }
1547
1548#if defined (_MSC_VER)
1549/* There are many versions of MSVC which emit __LINE__ as a non-constant. */
1563#define bsStatic(q) bsStaticMlen(q, -32)
1564#endif /* defined (_MSC_VER) */
1565
1566#ifndef bsStatic
1569#define bsStatic(q) bsStaticMlen(q, -__LINE__)
1570#endif /* bsStatic */
1571
1572/* Static constant block parameter pair */
1573
1592#define bsStaticBlkParms(q) \
1593 ((void *)("" q "")), ((int)sizeof(q) -1)
1594
1595/* Static convenience macros for blk functions with string literals */
1596
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)))
1606
1607/* Reference building macros */
1608
1611#define cstr2tbstr btfromcstr
1612
1626#define btfromcstr(t, s) \
1627do { \
1628 (t).data = (unsigned char *)(s); \
1629 (t).slen = ((t).data) \
1630 ? ((int)(strlen)((char *)(t).data)) \
1631 : 0; \
1632 (t).mlen = -1; \
1633} while (0)
1634
1637#define blk2tbstr(t, s, l) \
1638do { \
1639 (t).data = (unsigned char *)(s); \
1640 (t).slen = l; \
1641 (t).mlen = -1; \
1642} while (0)
1643
1658#define btfromblk(t, s, l) blk2tbstr(t, s, l)
1659
1675#define bmid2tbstr(t, b, p, l) \
1676do { \
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; \
1683 bstrtmp_left = 0; \
1684 } \
1685 if (bstrtmp_len > bstrtmp_s->slen - bstrtmp_left) { \
1686 bstrtmp_len = bstrtmp_s->slen - bstrtmp_left; \
1687 } \
1688 if(bstrtmp_len <= 0) { \
1689 (t).data =(unsigned char *)""; \
1690 (t).slen = 0; \
1691 } else { \
1692 (t).data = bstrtmp_s->data + bstrtmp_left; \
1693 (t).slen = bstrtmp_len; \
1694 } \
1695 } else { \
1696 (t).data = (unsigned char *)""; \
1697 (t).slen = 0; \
1698 } \
1699 (t).mlen = -__LINE__; \
1700} while (0)
1701
1716#define btfromblkltrimws(t, s, l) \
1717do { \
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])) { \
1723 break; \
1724 } \
1725 } \
1726 } \
1727 (t).data = bstrtmp_s + bstrtmp_idx; \
1728 (t).slen = bstrtmp_len - bstrtmp_idx; \
1729 (t).mlen = -__LINE__; \
1730} while (0)
1731
1746#define btfromblkrtrimws(t, s, l) \
1747do { \
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])) { \
1753 break; \
1754 } \
1755 } \
1756 } \
1757 (t).data = bstrtmp_s; \
1758 (t).slen = bstrtmp_len + 1; \
1759 (t).mlen = -__LINE__; \
1760} while (0)
1761
1776#define btfromblktrimws(t, s, l) \
1777do { \
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])) { \
1783 break; \
1784 } \
1785 } \
1786 for (; bstrtmp_len >= bstrtmp_idx; bstrtmp_len--) { \
1787 if (!isspace(bstrtmp_s[bstrtmp_len])) { \
1788 break; \
1789 } \
1790 } \
1791 } \
1792 (t).data = bstrtmp_s + bstrtmp_idx; \
1793 (t).slen = bstrtmp_len + 1 - bstrtmp_idx; \
1794 (t).mlen = -__LINE__; \
1795} while (0)
1796
1797/* Write protection macros */
1798
1807#define bwriteprotect(t) \
1808do { \
1809 if ((t).mlen >= 0) { \
1810 (t).mlen = -1; \
1811 } \
1812} while (0)
1813
1826#define bwriteallow(t) \
1827do { \
1828 if ((t).mlen == -1) { \
1829 (t).mlen = (t).slen + ((t).slen == 0); \
1830 } \
1831} while (0)
1832
1836#define biswriteprotected(t) \
1837 ((t).mlen <= 0)
1838
1839#ifdef __cplusplus
1840}
1841#endif
1842
1843#endif /* BSTRLIB_H */
bassign
BSTR_PUBLIC int bassign(bstring a, const bstring b)
Definition bstrlib.c:467
bisstemeqblk
BSTR_PUBLIC int bisstemeqblk(const bstring b0, const void *blk, int len)
Definition bstrlib.c:860
bpattern
BSTR_PUBLIC int bpattern(bstring b, int len)
Definition bstrlib.c:1881
bNread
size_t(* bNread)(void *buff, size_t elsize, size_t nelem, void *parm)
Definition bstrlib.h:1176
binstrrcaseless
BSTR_PUBLIC int binstrrcaseless(const bstring s1, int pos, const bstring s2)
Definition bstrlib.c:1236
bspeek
BSTR_PUBLIC int bspeek(bstring r, const struct bStream *s)
Definition bstrlib.c:2353
breplace
BSTR_PUBLIC int breplace(bstring b1, int pos, int len, const bstring b2, unsigned char fill)
Definition bstrlib.c:1587
bsunread
BSTR_PUBLIC int bsunread(struct bStream *s, const bstring b)
Definition bstrlib.c:2344
binsertblk
BSTR_PUBLIC int binsertblk(bstring b, int pos, const void *blk, int len, unsigned char fill)
Definition bstrlib.c:1524
bjoinblk
BSTR_PUBLIC bstring bjoinblk(const struct bstrList *bl, const void *blk, int len)
Definition bstrlib.c:2362
bfromcstr
BSTR_PUBLIC bstring bfromcstr(const char *str)
Definition bstrlib.c:188
BSTR_PUBLIC
#define BSTR_PUBLIC
Definition bstrlib.h:51
bstrcmp
BSTR_PUBLIC int bstrcmp(const bstring b0, const bstring b1)
Definition bstrlib.c:911
bstrnicmp
BSTR_PUBLIC int bstrnicmp(const bstring b0, const bstring b1, int n)
Definition bstrlib.c:656
ballocmin
BSTR_PUBLIC int ballocmin(bstring b, int len)
Definition bstrlib.c:159
bstrchrp
BSTR_PUBLIC int bstrchrp(const bstring b, int c, int pos)
Definition bstrlib.c:1288
bread
BSTR_PUBLIC bstring bread(bNread readPtr, void *parm)
Definition bstrlib.c:1932
binstrr
BSTR_PUBLIC int binstrr(const bstring s1, int pos, const bstring s2)
Definition bstrlib.c:1135
bstrListAlloc
BSTR_PUBLIC int bstrListAlloc(struct bstrList *sl, int msz)
Definition bstrlib.c:2607
bconcat
BSTR_PUBLIC int bconcat(bstring b0, const bstring b1)
Definition bstrlib.c:332
bsreada
BSTR_PUBLIC int bsreada(bstring b, struct bStream *s, int n)
Definition bstrlib.c:2231
bsreadlns
BSTR_PUBLIC int bsreadlns(bstring r, struct bStream *s, const bstring term)
Definition bstrlib.c:2312
bcstrfree
BSTR_PUBLIC int bcstrfree(char *s)
Definition bstrlib.c:325
bdelete
BSTR_PUBLIC int bdelete(bstring s1, int pos, int len)
Definition bstrlib.c:998
btolower
BSTR_PUBLIC int btolower(bstring b)
Definition bstrlib.c:605
bsclose
BSTR_PUBLIC void * bsclose(struct bStream *s)
Definition bstrlib.c:2068
bsreadln
BSTR_PUBLIC int bsreadln(bstring b, struct bStream *s, char terminator)
Definition bstrlib.c:2299
bmidstr
BSTR_PUBLIC bstring bmidstr(const bstring b, int left, int len)
Definition bstrlib.c:979
bsplit
BSTR_PUBLIC struct bstrList * bsplit(const bstring str, unsigned char splitChar)
Definition bstrlib.c:2802
bdestroy
BSTR_PUBLIC int bdestroy(bstring b)
Definition bstrlib.c:1024
bfromcstralloc
BSTR_PUBLIC bstring bfromcstralloc(int mlen, const char *str)
Definition bstrlib.c:266
bformata
BSTR_PUBLIC int bformata(bstring b, const char *fmt,...)
Definition bstrlib.c:2897
biseqblk
BSTR_PUBLIC int biseqblk(const bstring b, const void *blk, int len)
Definition bstrlib.c:827
binstrcaseless
BSTR_PUBLIC int binstrcaseless(const bstring s1, int pos, const bstring s2)
Definition bstrlib.c:1186
bninchrr
BSTR_PUBLIC int bninchrr(const bstring b0, int pos, const bstring b1)
Definition bstrlib.c:1453
btoupper
BSTR_PUBLIC int btoupper(bstring b)
Definition bstrlib.c:590
biseqcstr
BSTR_PUBLIC int biseqcstr(const bstring b, const char *s)
Definition bstrlib.c:880
bvcformata
BSTR_PUBLIC int bvcformata(bstring b, int count, const char *fmt, va_list arglist)
Definition bstrlib.c:3058
brtrimws
BSTR_PUBLIC int brtrimws(bstring b)
Definition bstrlib.c:775
binchrr
BSTR_PUBLIC int binchrr(const bstring b0, int pos, const bstring b1)
Definition bstrlib.c:1417
bsplits
BSTR_PUBLIC struct bstrList * bsplits(const bstring str, const bstring splitStr)
Definition bstrlib.c:2855
bconchar
BSTR_PUBLIC int bconchar(bstring b0, char c)
Definition bstrlib.c:369
bssplitscb
BSTR_PUBLIC int bssplitscb(struct bStream *s, const bstring splitStr, int(*cb)(void *parm, int ofs, const bstring entry), void *parm)
Definition bstrlib.c:2450
bassignformat
BSTR_PUBLIC int bassignformat(bstring b, const char *fmt,...)
Definition bstrlib.c:2952
blk2bstr
BSTR_PUBLIC bstring blk2bstr(const void *blk, int len)
Definition bstrlib.c:272
bcatblk
BSTR_PUBLIC int bcatblk(bstring b, const void *s, int len)
Definition bstrlib.c:410
bassigncstr
BSTR_PUBLIC int bassigncstr(bstring a, const char *str)
Definition bstrlib.c:521
bstr2cstr
BSTR_PUBLIC char * bstr2cstr(const bstring s, char z)
Definition bstrlib.c:305
bsreadlnsa
BSTR_PUBLIC int bsreadlnsa(bstring r, struct bStream *s, const bstring term)
Definition bstrlib.c:2155
bstring
struct tagbstring * bstring
Definition bstrlib.h:86
bstrrchrp
BSTR_PUBLIC int bstrrchrp(const bstring b, int c, int pos)
Definition bstrlib.c:1303
bassigngets
BSTR_PUBLIC int bassigngets(bstring b, bNgetc getcPtr, void *parm, char terminator)
Definition bstrlib.c:1943
bsplitstr
BSTR_PUBLIC struct bstrList * bsplitstr(const bstring str, const bstring splitStr)
Definition bstrlib.c:2829
bstrListCreate
BSTR_PUBLIC struct bstrList * bstrListCreate(void)
Definition bstrlib.c:2569
bsplitstrcb
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:2729
bstricmp
BSTR_PUBLIC int bstricmp(const bstring b0, const bstring b1)
Definition bstrlib.c:620
bgetsa
BSTR_PUBLIC int bgetsa(bstring b, bNgetc getcPtr, void *parm, char terminator)
Definition bstrlib.c:1973
bstrcpy
BSTR_PUBLIC bstring bstrcpy(const bstring b1)
Definition bstrlib.c:432
btrunc
BSTR_PUBLIC int btrunc(bstring b, int n)
Definition bstrlib.c:566
bfindreplace
BSTR_PUBLIC int bfindreplace(bstring b, const bstring find, const bstring repl, int pos)
Definition bstrlib.c:1830
bseof
BSTR_PUBLIC int bseof(const struct bStream *s)
Definition bstrlib.c:2059
biseq
BSTR_PUBLIC int biseq(const bstring b0, const bstring b1)
Definition bstrlib.c:843
bgets
BSTR_PUBLIC bstring bgets(bNgetc getcPtr, void *parm, char terminator)
Definition bstrlib.c:2006
bsetstr
BSTR_PUBLIC int bsetstr(bstring b0, int pos, const bstring b1, unsigned char fill)
Definition bstrlib.c:1471
bsplitscb
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:2693
bcatcstr
BSTR_PUBLIC int bcatcstr(bstring b, const char *s)
Definition bstrlib.c:386
bassignmidstr
BSTR_PUBLIC int bassignmidstr(bstring a, const bstring b, int left, int len)
Definition bstrlib.c:490
biseqcaselessblk
BSTR_PUBLIC int biseqcaselessblk(const bstring b, const void *blk, int len)
Definition bstrlib.c:698
biseqcstrcaseless
BSTR_PUBLIC int biseqcstrcaseless(const bstring b, const char *s)
Definition bstrlib.c:895
bsopen
BSTR_PUBLIC struct bStream * bsopen(bNread readPtr, void *parm)
Definition bstrlib.c:2027
bfindreplacecaseless
BSTR_PUBLIC int bfindreplacecaseless(bstring b, const bstring find, const bstring repl, int pos)
Definition bstrlib.c:1836
binsertch
BSTR_PUBLIC int binsertch(bstring s1, int pos, int len, unsigned char fill)
Definition bstrlib.c:1842
bsplitcb
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:2669
bltrimws
BSTR_PUBLIC int bltrimws(bstring b)
Definition bstrlib.c:756
breada
BSTR_PUBLIC int breada(bstring b, bNread readPtr, void *parm)
Definition bstrlib.c:1904
bstrListAllocMin
BSTR_PUBLIC int bstrListAllocMin(struct bstrList *sl, int msz)
Definition bstrlib.c:2640
bstrListDestroy
BSTR_PUBLIC int bstrListDestroy(struct bstrList *sl)
Definition bstrlib.c:2586
btrimws
BSTR_PUBLIC int btrimws(bstring b)
Definition bstrlib.c:800
biseqcaseless
BSTR_PUBLIC int biseqcaseless(const bstring b0, const bstring b1)
Definition bstrlib.c:723
bjoin
BSTR_PUBLIC bstring bjoin(const struct bstrList *bl, const bstring sep)
Definition bstrlib.c:2436
bsbufflength
BSTR_PUBLIC int bsbufflength(struct bStream *s, int sz)
Definition bstrlib.c:2045
bisstemeqcaselessblk
BSTR_PUBLIC int bisstemeqcaselessblk(const bstring b0, const void *blk, int len)
Definition bstrlib.c:732
binchr
BSTR_PUBLIC int binchr(const bstring b0, int pos, const bstring b1)
Definition bstrlib.c:1386
bNgetc
int(* bNgetc)(void *parm)
Definition bstrlib.h:1174
bassignblk
BSTR_PUBLIC int bassignblk(bstring a, const void *s, int len)
Definition bstrlib.c:548
bsreadlna
BSTR_PUBLIC int bsreadlna(bstring b, struct bStream *s, char terminator)
Definition bstrlib.c:2087
bninchr
BSTR_PUBLIC int bninchr(const bstring b0, int pos, const bstring b1)
Definition bstrlib.c:1438
bssplitstrcb
BSTR_PUBLIC int bssplitstrcb(struct bStream *s, const bstring splitStr, int(*cb)(void *parm, int ofs, const bstring entry), void *parm)
Definition bstrlib.c:2511
bstrncmp
BSTR_PUBLIC int bstrncmp(const bstring b0, const bstring b1, int n)
Definition bstrlib.c:944
bformat
BSTR_PUBLIC bstring bformat(const char *fmt,...)
Definition bstrlib.c:3007
bfromcstrrangealloc
BSTR_PUBLIC bstring bfromcstrrangealloc(int minl, int maxl, const char *str)
Definition bstrlib.c:217
binsert
BSTR_PUBLIC int binsert(bstring s1, int pos, const bstring s2, unsigned char fill)
Definition bstrlib.c:1578
balloc
BSTR_PUBLIC int balloc(bstring s, int len)
Definition bstrlib.c:97
binstr
BSTR_PUBLIC int binstr(const bstring s1, int pos, const bstring s2)
Definition bstrlib.c:1045
bsread
BSTR_PUBLIC int bsread(bstring b, struct bStream *s, int n)
Definition bstrlib.c:2331
config.h
b1
q_t * b1
Definition dircache.c:246
c
size_t c
Definition dircache.c:257
b2
q_t * b2
Definition dircache.c:247
count
int count
Definition server_ipc.c:89
bStream
Definition bstrlib.c:2018
bStream::parm
void * parm
Definition bstrlib.c:2020
bstrList
Definition bstrlib.h:778
bstrList::qty
int qty
Definition bstrlib.h:779
bstrList::mlen
int mlen
Definition bstrlib.h:779
bstrList::entry
bstring * entry
Definition bstrlib.h:780
entry
Definition ad_open.c:95
tagbstring
Definition bstrlib.h:88
tagbstring::mlen
int mlen
Definition bstrlib.h:89
tagbstring::data
unsigned char * data
Definition bstrlib.h:91
tagbstring::slen
int slen
Definition bstrlib.h:90