The FreeRADIUS server $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
|
A generic data buffer structure for encoding and decoding. More...
#include <freeradius-devel/util/dbuff.h>
#include <freeradius-devel/util/syserror.h>
Go to the source code of this file.
Macros | |
#define | CHECK_DBUFF_INIT(_sbuff) do { if (!(_sbuff)->extend && (unlikely(!(_sbuff)->buff) || unlikely(!(_sbuff)->start) || unlikely(!(_sbuff)->end) || unlikely(!(_sbuff)->p))) return 0; } while (0) |
#define | FR_DBUFF_MOVE_DEF(_out_type, _in_type) |
Internal macro for defining dbuff move functions. | |
Functions | |
size_t | _fr_dbuff_extend_fd (fr_dbuff_t *dbuff, size_t extension) |
Refresh the buffer with more data from the file. | |
int | fr_dbuff_reset_talloc (fr_dbuff_t *dbuff) |
Reset a talloced buffer to its initial length, clearing any data stored. | |
size_t | fr_dbuff_shift (fr_dbuff_t *dbuff, size_t shift) |
Shift the contents of the dbuff, returning the number of bytes we managed to shift. | |
int | fr_dbuff_trim_talloc (fr_dbuff_t *dbuff, size_t len) |
Trim a talloced dbuff to the minimum length required to represent the contained string. | |
void | fr_dbuff_update (fr_dbuff_t *dbuff, uint8_t *new_buff, size_t new_len) |
Update all markers and pointers in the set of dbuffs to point to new_buff. | |
static size_t | min (size_t x, size_t y) |
A generic data buffer structure for encoding and decoding.
Because doing manual length checks is error prone and a waste of everyone's time.
Definition in file dbuff.c.
#define FR_DBUFF_MOVE_DEF | ( | _out_type, | |
_in_type | |||
) |
Internal macro for defining dbuff move functions.
size_t _fr_dbuff_extend_fd | ( | fr_dbuff_t * | dbuff, |
size_t | extension | ||
) |
int fr_dbuff_reset_talloc | ( | fr_dbuff_t * | dbuff | ) |
size_t fr_dbuff_shift | ( | fr_dbuff_t * | dbuff, |
size_t | shift | ||
) |
Shift the contents of the dbuff, returning the number of bytes we managed to shift.
[in] | dbuff | to shift. |
[in] | shift | the number of bytes to shift (not necessarily the amount actually shifted, because one can't move pointers outside the buffer) |
Definition at line 116 of file dbuff.c.
int fr_dbuff_trim_talloc | ( | fr_dbuff_t * | dbuff, |
size_t | len | ||
) |
Trim a talloced dbuff to the minimum length required to represent the contained string.
[in] | dbuff | to trim. |
[in] | len | Length to trim to. Passing SIZE_MAX will result in the buffer being trimmed to the length of the content. |
Definition at line 297 of file dbuff.c.
void fr_dbuff_update | ( | fr_dbuff_t * | dbuff, |
uint8_t * | new_buff, | ||
size_t | new_len | ||
) |
Update all markers and pointers in the set of dbuffs to point to new_buff.
This function should be used if the underlying buffer is realloced.
[in] | dbuff | to update. |
[in] | new_buff | to assign to to sbuff. |
[in] | new_len | Length of the new buffer. |
Definition at line 79 of file dbuff.c.