~ubuntu-branches/ubuntu/vivid/cctools/vivid

« back to all changes in this revision

Viewing changes to dttools/src/buffer.h

  • Committer: Bazaar Package Importer
  • Author(s): Michael Hanke
  • Date: 2011-05-07 09:05:00 UTC
  • Revision ID: james.westby@ubuntu.com-20110507090500-lqpmdtwndor6e7os
Tags: upstream-3.3.2
ImportĀ upstreamĀ versionĀ 3.3.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
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.
 
5
*/
 
6
 
 
7
#ifndef BUFFER_H
 
8
#define BUFFER_H
 
9
 
 
10
#include <stdlib.h>
 
11
#include <stdarg.h>
 
12
 
 
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.
 
17
*/
 
18
 
 
19
/** buffer_t is an opaque object representing a buffer. */
 
20
typedef struct buffer_t buffer_t;
 
21
 
 
22
/** Create a new buffer.
 
23
    @return A new empty buffer object. Returns NULL when out of memory.
 
24
  */
 
25
buffer_t *buffer_create (void);
 
26
 
 
27
/** Delete a buffer.
 
28
    @param b The buffer to free.
 
29
  */
 
30
void buffer_delete (buffer_t *b);
 
31
 
 
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.
 
39
  */
 
40
int buffer_vprintf (buffer_t *b, const char *format, va_list ap);
 
41
 
 
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.
 
48
  */
 
49
int buffer_printf (buffer_t *b, const char *format, ...);
 
50
 
 
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
 
53
    the string.
 
54
    @param b The buffer.
 
55
    @param size The size of the string is placed in this variable.
 
56
    @return The buffer as a string with a NUL terminator.
 
57
  */
 
58
const char *buffer_tostring (buffer_t *b, size_t *size);
 
59
 
 
60
#endif /* BUFFER_H */