Lines Matching refs:buffer
25 /* Buffer handling routines, designed to avoid overflows/using invalid data */
29 #include "buffer.h"
31 /* Prevent integer overflows when incrementing buffer position/length.
40 /* Create (malloc) a new buffer of size */
41 buffer* buf_new(unsigned int size) {
43 buffer* buf;
49 buf = (buffer*)m_malloc(sizeof(buffer));
65 /* free the buffer's data and the buffer itself */
66 void buf_free(buffer* buf) {
72 /* overwrite the contents of the buffer to clear it */
73 void buf_burn(buffer* buf) {
79 /* resize a buffer, pos and len will be repositioned if required when
81 void buf_resize(buffer *buf, unsigned int newsize) {
95 /* The new buffer is sized the same as the length of the source buffer. */
96 buffer* buf_newcopy(buffer* buf) {
98 buffer* ret;
106 /* Set the length of the buffer */
107 void buf_setlen(buffer* buf, unsigned int len) {
114 /* Increment the length of the buffer */
115 void buf_incrlen(buffer* buf, unsigned int incr) {
121 /* Set the position of the buffer */
122 void buf_setpos(buffer* buf, unsigned int pos) {
130 /* increment the postion by incr, increasing the buffer length if required */
131 void buf_incrwritepos(buffer* buf, unsigned int incr) {
143 void buf_incrpos(buffer* buf, int incr) {
152 /* Get a byte from the buffer and increment the pos */
153 unsigned char buf_getbyte(buffer* buf) {
163 /* Get a bool from the buffer and increment the pos */
164 unsigned char buf_getbool(buffer* buf) {
174 void buf_putbyte(buffer* buf, unsigned char val) {
183 /* returns an in-place pointer to the buffer, checking that
185 unsigned char* buf_getptr(buffer* buf, unsigned int len) {
195 unsigned char* buf_getwriteptr(buffer* buf, unsigned int len) {
206 unsigned char* buf_getstring(buffer* buf, unsigned int *retlen) {
226 /* Just increment the buffer position the same as if we'd used buf_getstring,
228 void buf_eatstring(buffer *buf) {
233 /* Get an uint32 from the buffer and increment the pos */
234 unsigned int buf_getint(buffer* buf) {
242 /* put a 32bit uint into the buffer, incr bufferlen & pos if required */
243 void buf_putint(buffer* buf, int unsigned val) {
250 /* put a SSH style string into the buffer, increasing buffer len if required */
251 void buf_putstring(buffer* buf, const unsigned char* str, unsigned int len) {
258 /* put the set of len bytes into the buffer, incrementing the pos, increasing
260 void buf_putbytes(buffer *buf, const unsigned char *bytes, unsigned int len) {
268 void buf_putmpint(buffer* buf, mp_int * mp) {
310 /* Retrieve an mp_int from the buffer.
313 int buf_getmpint(buffer* buf, mp_int* mp) {