Turnstone Operating System
|
buffer implementation More...
Classes | |
struct | buffer_t |
Macros | |
#define | BUFFER_PRINTF_BUFFER_SIZE 2048 |
Typedefs | |
typedef struct buffer_t | buffer_t |
opaque buffer_t struct | |
Functions | |
MODULE ("turnstone.lib.buffer") | |
buffer_t * | buffer_get_tmp_buffer_for_printf (void) |
returns a temporary buffer for printf, before gui is initialized, this is a static buffer, after gui is initialized, this is a buffer allocated with malloc More... | |
void | buffer_reset_tmp_buffer_for_printf (void) |
resets temporary buffer for printf | |
buffer_t * | buffer_new_with_capacity (memory_heap_t *heap, uint64_t capacity) |
buffer_new_with_capacity creates a new buffer with capacity More... | |
memory_heap_t * | buffer_get_heap (buffer_t *buffer) |
buffer_get_heap returns heap of buffer More... | |
buffer_t * | buffer_encapsulate (uint8_t *data, uint64_t length) |
returns a buffer encapsulating a byte array, byte array is not copied More... | |
boolean_t | buffer_set_readonly (buffer_t *buffer, boolean_t ro) |
sets readonly flag of buffer More... | |
uint64_t | buffer_get_length (buffer_t *buffer) |
returns length of buffer More... | |
uint64_t | buffer_get_mark_position (buffer_t *buffer) |
boolean_t | buffer_set_mark_position (buffer_t *buffer, uint64_t position) |
boolean_t | buffer_reset (buffer_t *buffer) |
resets buffer, sets length and position to 0 and all bytes to 0, capacity stays same More... | |
uint64_t | buffer_get_capacity (buffer_t *buffer) |
returns capacity of buffer More... | |
uint64_t | buffer_get_position (buffer_t *buffer) |
returns position of buffer More... | |
static boolean_t | buffer_resize_if_need (buffer_t *buffer, uint64_t length) |
buffer_t * | buffer_append_byte (buffer_t *buffer, uint8_t data) |
buffer_append_byte appends a byte to buffer More... | |
buffer_t * | buffer_append_bytes (buffer_t *buffer, uint8_t *data, uint64_t length) |
appends bytes to buffer More... | |
buffer_t * | buffer_append_buffer (buffer_t *buffer, buffer_t *appenden) |
appends buffer to buffer More... | |
uint8_t * | buffer_get_bytes (buffer_t *buffer, uint64_t length) |
returns a byte array from buffer with length, byte array is copied, position is advanced with length More... | |
uint8_t * | buffer_get_all_bytes (buffer_t *buffer, uint64_t *length) |
returns a byte array containing all bytes from buffer, byte array is copied, position is not advanced More... | |
uint8_t * | buffer_get_all_bytes_and_reset (buffer_t *buffer, uint64_t *length) |
returns a byte array containing all bytes from buffer, byte array is copied, position is not advanced, buffer is resetted More... | |
uint8_t * | buffer_get_all_bytes_and_destroy (buffer_t *buffer, uint64_t *length) |
returns a byte array containing all bytes from buffer, byte array is copied, position is not advanced, buffer is destroyed More... | |
uint8_t | buffer_get_byte (buffer_t *buffer) |
returns a byte array from buffer with length, byte array is copied, position is advanced 1 More... | |
uint8_t | buffer_peek_byte (buffer_t *buffer) |
returns a byte from buffer at current position, position is not changed More... | |
uint8_t | buffer_peek_byte_at_position (buffer_t *buffer, uint64_t position) |
returns a byte from buffer at position, position is not changed More... | |
uint64_t | buffer_peek_ints_at_position (buffer_t *buffer, uint64_t position, uint8_t bc) |
returns an int from buffer at position, position is not changed More... | |
uint64_t | buffer_peek_ints (buffer_t *buffer, uint8_t bc) |
returns an int from buffer at current position, position is not changed More... | |
uint64_t | buffer_remaining (buffer_t *buffer) |
returns how many bytes are remaining in buffer (length - position) More... | |
boolean_t | buffer_seek (buffer_t *buffer, int64_t position, buffer_seek_direction_t direction) |
changes position of buffer More... | |
int8_t | buffer_destroy (buffer_t *buffer) |
destroys buffer More... | |
boolean_t | buffer_write_slice_into (buffer_t *buffer, uint64_t pos, uint64_t len, uint8_t *dest) |
copies bytes from buffer to dest (should be at least length long), position is not changed More... | |
uint8_t * | buffer_get_view_at_position (buffer_t *buffer, uint64_t position, uint64_t length) |
returns a byte array from buffer with length, byte array is not copied, position is not changed More... | |
int64_t | buffer_printf (buffer_t *buffer, const char_t *fmt,...) |
prints to buffer, returns number of bytes written More... | |
int64_t | buffer_vprintf (buffer_t *buffer, const char_t *fmt, va_list args) |
prints to buffer, returns number of bytes written More... | |
char_t * | buffer_read_line_ext (buffer_t *buffer, char_t line_continuation_char, char_t delimiter_char, uint64_t *length) |
reads a line from buffer, line is null terminated, position is advanced More... | |
Variables | |
uint8_t | buffer_tmp_buffer_area_for_printf [BUFFER_PRINTF_BUFFER_SIZE] |
buffer_t | buffer_tmp_buffer_for_printf |
buffer implementation
This work is licensed under TURNSTONE OS Public License. Please read and understand latest version of Licence.
appends buffer to buffer
[in] | buffer | buffer to append |
[in] | appenden | buffer to append |
buffer_append_byte appends a byte to buffer
[in] | buffer | buffer to append |
[in] | data | byte to append |
appends bytes to buffer
[in] | buffer | buffer to append |
[in] | data | bytes to append |
[in] | length | length of bytes |
destroys buffer
[in] | buffer | buffer to destroy |
returns a buffer encapsulating a byte array, byte array is not copied
[in] | data | byte array to encapsulate |
[in] | length | length of byte array |
returns a byte array containing all bytes from buffer, byte array is copied, position is not advanced
[in] | buffer | buffer to get bytes |
[out] | length | length of bytes returned |
returns a byte array containing all bytes from buffer, byte array is copied, position is not advanced, buffer is destroyed
[in] | buffer | buffer to get bytes |
[out] | length | length of bytes returned |
returns a byte array containing all bytes from buffer, byte array is copied, position is not advanced, buffer is resetted
[in] | buffer | buffer to get bytes |
[out] | length | length of bytes returned |
returns a byte array from buffer with length, byte array is copied, position is advanced 1
[in] | buffer | buffer to get bytes |
returns a byte array from buffer with length, byte array is copied, position is advanced with length
[in] | buffer | buffer to get bytes |
[in] | length | length of bytes |
returns capacity of buffer
[in] | buffer | buffer to get capacity |
memory_heap_t * buffer_get_heap | ( | buffer_t * | buffer | ) |
buffer_get_heap returns heap of buffer
[in] | buffer | buffer to get heap |
returns length of buffer
[in] | buffer | buffer to get length |
returns position of buffer
[in] | buffer | buffer to get position |
buffer_t * buffer_get_tmp_buffer_for_printf | ( | void | ) |
returns a temporary buffer for printf, before gui is initialized, this is a static buffer, after gui is initialized, this is a buffer allocated with malloc
returns a byte array from buffer with length, byte array is not copied, position is not changed
[in] | buffer | buffer to get bytes |
[in] | position | position to get bytes |
[in] | length | length of bytes |
buffer_t * buffer_new_with_capacity | ( | memory_heap_t * | heap, |
uint64_t | capacity | ||
) |
buffer_new_with_capacity creates a new buffer with capacity
heap | heap to allocate buffer |
capacity | capacity of buffer |
returns a byte from buffer at current position, position is not changed
[in] | buffer | buffer to peek |
returns a byte from buffer at position, position is not changed
[in] | buffer | buffer to peek |
[in] | position | position to peek |
returns an int from buffer at current position, position is not changed
[in] | buffer | buffer to peek |
[in] | bc | byte count of int |
returns an int from buffer at position, position is not changed
[in] | buffer | buffer to peek |
[in] | position | position to peek |
[in] | bc | byte count of int |
prints to buffer, returns number of bytes written
[in] | buffer | buffer to print to |
[in] | format | format string |
[in] | ... | arguments |
char_t * buffer_read_line_ext | ( | buffer_t * | buffer, |
char_t | line_continuation_char, | ||
char_t | delimiter_char, | ||
uint64_t * | length | ||
) |
reads a line from buffer, line is null terminated, position is advanced
[in] | buffer | buffer to read line |
[in] | line_continuation_char | line continuation char |
[in] | delimiter_char | delimiter char |
[out] | length | length of line optional parameter |
returns how many bytes are remaining in buffer (length - position)
[in] | buffer | buffer to get remaining bytes |
boolean_t buffer_reset | ( | buffer_t * | buffer | ) |
resets buffer, sets length and position to 0 and all bytes to 0, capacity stays same
[in] | buffer | buffer to reset |
boolean_t buffer_seek | ( | buffer_t * | buffer, |
int64_t | position, | ||
buffer_seek_direction_t | direction | ||
) |
changes position of buffer
[in] | buffer | buffer to change position |
[in] | position | position to change |
[in] | direction | direction to change |
boolean_t buffer_set_readonly | ( | buffer_t * | buffer, |
boolean_t | ro | ||
) |
sets readonly flag of buffer
[in] | buffer | buffer to set readonly |
[in] | ro | readonly flag |
prints to buffer, returns number of bytes written
[in] | buffer | buffer to print to |
[in] | format | format string |
[in] | args | va_list of arguments |
copies bytes from buffer to dest (should be at least length long), position is not changed
[in] | buffer | buffer to copy |
[in] | pos | position to copy |
[in] | len | length to copy |
[out] | dest | destination to copy to, dest should be at least len long |
buffer_t buffer_tmp_buffer_for_printf |