]> mj.ucw.cz Git - libucw.git/blob - ucw/bbuf.h
xtypes: bool now supports yes/no strings
[libucw.git] / ucw / bbuf.h
1 /*
2  *      UCW Library -- A simple growing buffer for byte-sized items.
3  *
4  *      (c) 2004 Martin Mares <mj@ucw.cz>
5  *
6  *      This software may be freely distributed and used according to the terms
7  *      of the GNU Lesser General Public License.
8  */
9
10 #ifndef _UCW_BBUF_H
11 #define _UCW_BBUF_H
12
13 #ifdef CONFIG_UCW_CLEAN_ABI
14 #define bb_printf ucw_bb_printf
15 #define bb_printf_at ucw_bb_printf_at
16 #define bb_vprintf ucw_bb_vprintf
17 #define bb_vprintf_at ucw_bb_vprintf_at
18 #endif
19
20 #define GBUF_TYPE       byte
21 #define GBUF_PREFIX(x)  bb_##x
22 #include <ucw/gbuf.h>
23
24 /**
25  * printf() into a growing buffer with `va_list` arguments.
26  * Generates a `'\0'`-terminated string at the beginning of the buffer
27  * and returns pointer to it.
28  *
29  * See @bb_printf().
30  **/
31 char *bb_vprintf(bb_t *bb, const char *fmt, va_list args);
32
33 /**
34  * printf() into a growing buffer.
35  * Generates a `'\0'`-terminated string at the beginning of the buffer
36  * and returns pointer to it.
37  *
38  * See @bb_vprintf().
39  **/
40 char *bb_printf(bb_t *bb, const char *fmt, ...);
41
42 /**
43  * Like @bb_vprintf(), but it does not start at the beginning of the
44  * buffer, but @ofs bytes further.
45  *
46  * Returns pointer to the new string (eg. @ofs bytes after the
47  * beginning of buffer).
48  **/
49 char *bb_vprintf_at(bb_t *bb, size_t ofs, const char *fmt, va_list args);
50
51 /**
52  * Like @bb_vprintf_at(), but it takes individual arguments.
53  **/
54 char *bb_printf_at(bb_t *bb, size_t ofs, const char *fmt, ...);
55
56 #endif