]> mj.ucw.cz Git - moe.git/blob - ucw/bbuf.h
Merge commit '700824d3e9bce9219819e4e5096ab94da301d44b' from branch bernard/master
[moe.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 #define GBUF_TYPE       byte
14 #define GBUF_PREFIX(x)  bb_##x
15 #include "ucw/gbuf.h"
16
17 /**
18  * printf() into a growing buffer with `va_list` arguments.
19  * Generates a `'\0'`-terminated string at the beginning of the buffer
20  * and returns pointer to it.
21  *
22  * See @bb_printf().
23  **/
24 char *bb_vprintf(bb_t *bb, const char *fmt, va_list args);
25 /**
26  * printf() into a growing buffer.
27  * Generates a `'\0'`-terminated string at the beginning of the buffer
28  * and returns pointer to it.
29  *
30  * See @bb_vprintf().
31  **/
32 char *bb_printf(bb_t *bb, const char *fmt, ...);
33 /**
34  * Like @bb_vprintf(), but it does not start at the beginning of the
35  * buffer, but @ofs bytes further.
36  *
37  * Returns pointer to the new string (eg. @ofs bytes after the
38  * beginning of buffer).
39  **/
40 char *bb_vprintf_at(bb_t *bb, uns ofs, const char *fmt, va_list args);
41 /**
42  * Like @bb_vprintf_at(), but it takes individual arguments.
43  **/
44 char *bb_printf_at(bb_t *bb, uns ofs, const char *fmt, ...);
45
46 #endif