|
Electroneum
|

Go to the source code of this file.
Classes | |
| struct | sldns_buffer |
Macros | |
| #define | INLINE static inline |
Typedefs | |
| typedef struct sldns_buffer | sldns_buffer |
This file contains the definition of sldns_buffer, and functions to manipulate those.
Definition in file sbuffer.h.
| typedef struct sldns_buffer sldns_buffer |
| INLINE uint8_t* sldns_buffer_at | ( | const sldns_buffer * | buffer, |
| size_t | at | ||
| ) |
| INLINE int sldns_buffer_available | ( | sldns_buffer * | buffer, |
| size_t | count | ||
| ) |
checks if the buffer has count bytes available at the current position
| [in] | buffer | the buffer |
| [in] | count | how much is available |
Definition at line 445 of file sbuffer.h.

| INLINE int sldns_buffer_available_at | ( | sldns_buffer * | buffer, |
| size_t | at, | ||
| size_t | count | ||
| ) |
checks if the buffer has at least COUNT more bytes available. Before reading or writing the caller needs to ensure enough space is available!
| [in] | buffer | the buffer |
| [in] | at | indicated position |
| [in] | count | how much is available |
Definition at line 433 of file sbuffer.h.


| INLINE uint8_t* sldns_buffer_begin | ( | const sldns_buffer * | buffer | ) |
returns a pointer to the beginning of the buffer (the data at position 0).
| [in] | buffer | the buffer |
Definition at line 368 of file sbuffer.h.

| INLINE size_t sldns_buffer_capacity | ( | sldns_buffer * | buffer | ) |
| INLINE void sldns_buffer_clear | ( | sldns_buffer * | buffer | ) |
clears the buffer and make it ready for writing. The buffer's limit is set to the capacity and the position is set to 0.
| [in] | buffer | the buffer to clear |
Definition at line 213 of file sbuffer.h.

| void sldns_buffer_copy | ( | sldns_buffer * | result, |
| sldns_buffer * | from | ||
| ) |
Copy contents of the from buffer to the result buffer and then flips the result buffer. Data will be silently truncated if the result buffer is too small.
| [out] | *result | resulting buffer which is copied to. |
| [in] | *from | what to copy to result. |
| INLINE uint8_t* sldns_buffer_current | ( | sldns_buffer * | buffer | ) |
returns a pointer to the data at the buffer's current position.
| [in] | buffer | the buffer |
Definition at line 391 of file sbuffer.h.

| INLINE uint8_t* sldns_buffer_end | ( | sldns_buffer * | buffer | ) |
returns a pointer to the end of the buffer (the data at the buffer's limit).
| [in] | buffer | the buffer |
Definition at line 380 of file sbuffer.h.

| void* sldns_buffer_export | ( | sldns_buffer * | buffer | ) |
Makes the buffer fixed and returns a pointer to the data. The caller is responsible for free'ing the result.
| [in] | *buffer | the buffer to be exported |
| INLINE void sldns_buffer_flip | ( | sldns_buffer * | buffer | ) |
makes the buffer ready for reading the data that has been written to the buffer. The buffer's limit is set to the current position and the position is set to 0.
| [in] | buffer | the buffer to flip |
Definition at line 231 of file sbuffer.h.

| int void sldns_buffer_free | ( | sldns_buffer * | buffer | ) |
frees the buffer.
| [in] | *buffer | the buffer to be freed |
| void sldns_buffer_init_frm_data | ( | sldns_buffer * | buffer, |
| void * | data, | ||
| size_t | size | ||
| ) |
Setup a buffer with the data pointed to. No data copied, no memory allocs. The buffer is fixed.
| [in] | buffer | pointer to the buffer to put the data in |
| [in] | data | the data to encapsulate in the buffer |
| [in] | size | the size of the data |
| void sldns_buffer_init_vfixed_frm_data | ( | sldns_buffer * | buffer, |
| void * | data, | ||
| size_t | size | ||
| ) |
Setup a buffer with the data pointed to. No data copied, no memory allocs. The buffer is "virtually" fixed. Writes beyond size (the capacity) will only update position, but no data will be written beyond capacity. This allows to determine how big the buffer should have been to contain all the written data, by looking at the position with sldns_buffer_position(), similarly to the return value of POSIX's snprintf.
| [in] | buffer | pointer to the buffer to put the data in |
| [in] | data | the data to encapsulate in the buffer |
| [in] | size | the size of the data |
| INLINE void sldns_buffer_invariant | ( | sldns_buffer * | buffer | ) |
| INLINE size_t sldns_buffer_limit | ( | sldns_buffer * | buffer | ) |
returns the maximum size of the buffer
| [in] | buffer |
| sldns_buffer* sldns_buffer_new | ( | size_t | capacity | ) |
creates a new buffer with the specified capacity.
| [in] | capacity | the size (in bytes) to allocate for the buffer |
| void sldns_buffer_new_frm_data | ( | sldns_buffer * | buffer, |
| void * | data, | ||
| size_t | size | ||
| ) |
creates a buffer with the specified data. The data IS copied and MEMORY allocations are done. The buffer is not fixed and can be resized using buffer_reserve().
| [in] | buffer | pointer to the buffer to put the data in |
| [in] | data | the data to encapsulate in the buffer |
| [in] | size | the size of the data |
| INLINE size_t sldns_buffer_position | ( | sldns_buffer * | buffer | ) |
| int sldns_buffer_printf | ( | sldns_buffer * | buffer, |
| const char * | format, | ||
| ... | |||
| ) |
prints to the buffer, increasing the capacity if required using buffer_reserve(). The buffer's position is set to the terminating '\0' Returns the number of characters written (not including the terminating '\0') or -1 on failure.
| INLINE void sldns_buffer_read | ( | sldns_buffer * | buffer, |
| void * | data, | ||
| size_t | count | ||
| ) |
copies count bytes of data at the current position to the given data-array
| [in] | buffer | the buffer |
| [out] | data | buffer to copy to |
| [in] | count | the length of the data to copy |
Definition at line 657 of file sbuffer.h.

| INLINE void sldns_buffer_read_at | ( | sldns_buffer * | buffer, |
| size_t | at, | ||
| void * | data, | ||
| size_t | count | ||
| ) |
copies count bytes of data at the given position to the given data-array
| [in] | buffer | the buffer |
| [in] | at | the position in the buffer to start |
| [out] | data | buffer to copy to |
| [in] | count | the length of the data to copy |
Definition at line 644 of file sbuffer.h.


| INLINE uint16_t sldns_buffer_read_u16 | ( | sldns_buffer * | buffer | ) |
returns the 2-byte integer value at the current position in the buffer
| [in] | buffer | the buffer |
Definition at line 708 of file sbuffer.h.

| INLINE uint16_t sldns_buffer_read_u16_at | ( | sldns_buffer * | buffer, |
| size_t | at | ||
| ) |
returns the 2-byte integer value at the given position in the buffer
| [in] | buffer | the buffer |
| [in] | at | position in the buffer |
Definition at line 696 of file sbuffer.h.


| INLINE uint32_t sldns_buffer_read_u32 | ( | sldns_buffer * | buffer | ) |
returns the 4-byte integer value at the current position in the buffer
| [in] | buffer | the buffer |
Definition at line 734 of file sbuffer.h.

| INLINE uint32_t sldns_buffer_read_u32_at | ( | sldns_buffer * | buffer, |
| size_t | at | ||
| ) |
returns the 4-byte integer value at the given position in the buffer
| [in] | buffer | the buffer |
| [in] | at | position in the buffer |
Definition at line 722 of file sbuffer.h.


| INLINE uint8_t sldns_buffer_read_u8 | ( | sldns_buffer * | buffer | ) |
returns the byte value at the current position in the buffer
| [in] | buffer | the buffer |
Definition at line 682 of file sbuffer.h.

| INLINE uint8_t sldns_buffer_read_u8_at | ( | sldns_buffer * | buffer, |
| size_t | at | ||
| ) |
returns the byte value at the given position in the buffer
| [in] | buffer | the buffer |
| [in] | at | the position in the buffer |
Definition at line 670 of file sbuffer.h.


| INLINE size_t sldns_buffer_remaining | ( | sldns_buffer * | buffer | ) |
returns the number of bytes remaining between the buffer's position and limit.
| [in] | buffer | the buffer |
Definition at line 418 of file sbuffer.h.

| INLINE size_t sldns_buffer_remaining_at | ( | sldns_buffer * | buffer, |
| size_t | at | ||
| ) |
returns the number of bytes remaining between the indicated position and the limit.
| [in] | buffer | the buffer |
| [in] | at | indicated position |
Definition at line 404 of file sbuffer.h.


| int sldns_buffer_reserve | ( | sldns_buffer * | buffer, |
| size_t | amount | ||
| ) |
ensures BUFFER can contain at least AMOUNT more bytes. The buffer's capacity is increased if necessary using buffer_set_capacity().
The buffer's limit is always set to the (possibly increased) capacity.
| [in] | buffer | the buffer |
| [in] | amount | amount to use |
| INLINE void sldns_buffer_rewind | ( | sldns_buffer * | buffer | ) |
make the buffer ready for re-reading the data. The buffer's position is reset to 0.
| [in] | buffer | the buffer to rewind |
Definition at line 244 of file sbuffer.h.

| INLINE void sldns_buffer_set_at | ( | sldns_buffer * | buffer, |
| size_t | at, | ||
| int | c, | ||
| size_t | count | ||
| ) |
set the given byte to the buffer at the specified position
| [in] | buffer | the buffer |
| [in] | at | the position (in number of bytes) to write the data at |
| [in] | c | the byte to set to the buffer |
| [in] | count | the number of bytes of bytes to write |
Definition at line 481 of file sbuffer.h.

| int sldns_buffer_set_capacity | ( | sldns_buffer * | buffer, |
| size_t | capacity | ||
| ) |
changes the buffer's capacity. The data is reallocated so any pointers to the data may become invalid. The buffer's limit is set to the buffer's new capacity.
| [in] | buffer | the buffer |
| [in] | capacity | the capacity to use |
| INLINE void sldns_buffer_set_limit | ( | sldns_buffer * | buffer, |
| size_t | limit | ||
| ) |
| INLINE void sldns_buffer_set_position | ( | sldns_buffer * | buffer, |
| size_t | mark | ||
| ) |
| INLINE void sldns_buffer_skip | ( | sldns_buffer * | buffer, |
| ssize_t | count | ||
| ) |
| INLINE int sldns_buffer_status | ( | sldns_buffer * | buffer | ) |
| INLINE int sldns_buffer_status_ok | ( | sldns_buffer * | buffer | ) |
| INLINE void sldns_buffer_write | ( | sldns_buffer * | buffer, |
| const void * | data, | ||
| size_t | count | ||
| ) |
writes count bytes of data to the current position of the buffer
| [in] | buffer | the buffer |
| [in] | data | the data to write |
| [in] | count | the length of the data to write |
Definition at line 503 of file sbuffer.h.


| INLINE void sldns_buffer_write_at | ( | sldns_buffer * | buffer, |
| size_t | at, | ||
| const void * | data, | ||
| size_t | count | ||
| ) |
writes the given data to the buffer at the specified position
| [in] | buffer | the buffer |
| [in] | at | the position (in number of bytes) to write the data at |
| [in] | data | pointer to the data to write to the buffer |
| [in] | count | the number of bytes of data to write |
Definition at line 458 of file sbuffer.h.


| INLINE void sldns_buffer_write_string | ( | sldns_buffer * | buffer, |
| const char * | str | ||
| ) |
copies the given (null-delimited) string to the current position at the buffer
| [in] | buffer | the buffer |
| [in] | str | the string to write |
Definition at line 527 of file sbuffer.h.

| INLINE void sldns_buffer_write_string_at | ( | sldns_buffer * | buffer, |
| size_t | at, | ||
| const char * | str | ||
| ) |
copies the given (null-delimited) string to the specified position at the buffer
| [in] | buffer | the buffer |
| [in] | at | the position in the buffer |
| [in] | str | the string to write |
Definition at line 516 of file sbuffer.h.

| INLINE void sldns_buffer_write_u16 | ( | sldns_buffer * | buffer, |
| uint16_t | data | ||
| ) |
writes the given 2 byte integer at the current position in the buffer
| [in] | buffer | the buffer |
| [in] | data | the 16 bits to write |
Definition at line 578 of file sbuffer.h.

| INLINE void sldns_buffer_write_u16_at | ( | sldns_buffer * | buffer, |
| size_t | at, | ||
| uint16_t | data | ||
| ) |
writes the given 2 byte integer at the given position in the buffer
| [in] | buffer | the buffer |
| [in] | at | the position in the buffer |
| [in] | data | the 16 bits to write |
Definition at line 565 of file sbuffer.h.


| INLINE void sldns_buffer_write_u32 | ( | sldns_buffer * | buffer, |
| uint32_t | data | ||
| ) |
writes the given 4 byte integer at the current position in the buffer
| [in] | buffer | the buffer |
| [in] | data | the 32 bits to write |
Definition at line 618 of file sbuffer.h.

| INLINE void sldns_buffer_write_u32_at | ( | sldns_buffer * | buffer, |
| size_t | at, | ||
| uint32_t | data | ||
| ) |
writes the given 4 byte integer at the given position in the buffer
| [in] | buffer | the buffer |
| [in] | at | the position in the buffer |
| [in] | data | the 32 bits to write |
Definition at line 591 of file sbuffer.h.


| INLINE void sldns_buffer_write_u48 | ( | sldns_buffer * | buffer, |
| uint64_t | data | ||
| ) |
writes the given 6 byte integer at the current position in the buffer
| [in] | buffer | the buffer |
| [in] | data | the 48 bits to write |
Definition at line 630 of file sbuffer.h.

| INLINE void sldns_buffer_write_u48_at | ( | sldns_buffer * | buffer, |
| size_t | at, | ||
| uint64_t | data | ||
| ) |
writes the given 6 byte integer at the given position in the buffer
| [in] | buffer | the buffer |
| [in] | at | the position in the buffer |
| [in] | data | the (lower) 48 bits to write |
Definition at line 605 of file sbuffer.h.


| INLINE void sldns_buffer_write_u8 | ( | sldns_buffer * | buffer, |
| uint8_t | data | ||
| ) |
writes the given byte of data at the current position in the buffer
| [in] | buffer | the buffer |
| [in] | data | the 8 bits to write |
Definition at line 552 of file sbuffer.h.

| INLINE void sldns_buffer_write_u8_at | ( | sldns_buffer * | buffer, |
| size_t | at, | ||
| uint8_t | data | ||
| ) |
writes the given byte of data at the given position in the buffer
| [in] | buffer | the buffer |
| [in] | at | the position in the buffer |
| [in] | data | the 8 bits to write |
Definition at line 539 of file sbuffer.h.

