2
Copyright (C) 2005- The University of Notre Dame
3
This software is distributed under the GNU General Public License.
4
See the file COPYING for details.
13
/** @file buffer.h String Buffer Operations.
14
You can use the buffer in the same way you would print to a file. Use the
15
buffer to do formatted printing. When you are done retrieve the final
16
string using buffer_tostring.
19
/** buffer_t is an opaque object representing a buffer. */
20
typedef struct buffer_t buffer_t;
22
/** Create a new buffer.
23
@return A new empty buffer object. Returns NULL when out of memory.
25
buffer_t *buffer_create (void);
28
@param b The buffer to free.
30
void buffer_delete (buffer_t *b);
32
/** Print the formatted output to the buffer. The format string follows the
33
same semantics as the UNIX vprintf function. buffer_vprintf does not call
34
the variable argument macros va_(start|end) on ap.
35
@param b The buffer to fill.
36
@param format The format string.
37
@param ap The variable argument list for the format string.
38
@return Negative value on error.
40
int buffer_vprintf (buffer_t *b, const char *format, va_list ap);
42
/** Print the formatted output to the buffer. The format string follows the
43
same semantics as the UNIX vprintf function.
44
@param b The buffer to fill.
45
@param format The format string.
46
@param ... The variable arguments for the format string.
47
@return Negative value on error.
49
int buffer_printf (buffer_t *b, const char *format, ...);
51
/** Returns the buffer as a string. The string is no longer valid after
52
deleting the buffer. A final ASCII NUL character is guaranteed to terminate
55
@param size The size of the string is placed in this variable.
56
@return The buffer as a string with a NUL terminator.
58
const char *buffer_tostring (buffer_t *b, size_t *size);