2 * Copyright (C) 2010 Martin Willi
3 * Copyright (C) 2010 revosec AG
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; either version 2 of the License, or (at your
8 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17 * @defgroup bio_writer bio_writer
24 typedef struct bio_writer_t bio_writer_t
;
29 * Buffered output generator.
34 * Append a 8-bit integer to the buffer.
36 * @param value value to append
38 void (*write_uint8
)(bio_writer_t
*this, u_int8_t value
);
41 * Append a 16-bit integer to the buffer.
43 * @param value value to append
45 void (*write_uint16
)(bio_writer_t
*this, u_int16_t value
);
48 * Append a 24-bit integer to the buffer.
50 * @param value value to append
52 void (*write_uint24
)(bio_writer_t
*this, u_int32_t value
);
55 * Append a 32-bit integer to the buffer.
57 * @param value value to append
59 void (*write_uint32
)(bio_writer_t
*this, u_int32_t value
);
62 * Append a chunk of data without a length header.
64 * @param value value to append
66 void (*write_data
)(bio_writer_t
*this, chunk_t value
);
69 * Append a chunk of data with a 8-bit length header.
71 * @param value value to append
73 void (*write_data8
)(bio_writer_t
*this, chunk_t value
);
76 * Append a chunk of data with a 16-bit length header.
78 * @param value value to append
80 void (*write_data16
)(bio_writer_t
*this, chunk_t value
);
83 * Append a chunk of data with a 24-bit length header.
85 * @param value value to append
87 void (*write_data24
)(bio_writer_t
*this, chunk_t value
);
90 * Append a chunk of data with a 32-bit length header.
92 * @param value value to append
94 void (*write_data32
)(bio_writer_t
*this, chunk_t value
);
97 * Prepend a 8-bit length header to existing data.
99 void (*wrap8
)(bio_writer_t
*this);
102 * Prepend a 16-bit length header to existing data.
104 void (*wrap16
)(bio_writer_t
*this);
107 * Prepend a 24-bit length header to existing data.
109 void (*wrap24
)(bio_writer_t
*this);
112 * Prepend a 32-bit length header to existing data.
114 void (*wrap32
)(bio_writer_t
*this);
117 * Get the encoded data buffer.
119 * @return chunk to internal buffer
121 chunk_t (*get_buf
)(bio_writer_t
*this);
124 * Destroy a bio_writer_t.
126 void (*destroy
)(bio_writer_t
*this);
130 * Create a bio_writer instance.
132 * @param bufsize initially allocated buffer size
134 bio_writer_t
*bio_writer_create(u_int32_t bufsize
);
136 #endif /** BIO_WRITER_H_ @}*/