Turnstone Operating System
|
buffer interface More...
Macros | |
#define | ___BUFFER_H 0 |
#define | buffer_new() buffer_new_with_capacity(NULL, 128) |
buffer_new creates a new buffer with default heap More... | |
#define | buffer_create_with_heap(h, c) buffer_new_with_capacity(h, c) |
#define | buffer_write_all_into(b, d) buffer_write_slice_into(b, 0, buffer_get_length(b), d) |
#define | BUFFER_IO_INPUT 0 |
#define | BUFFER_IO_OUTPUT 1 |
#define | BUFFER_IO_ERROR 2 |
#define | buffer_read_line(b) buffer_read_line_ext(b, '\\', '\n', NULL) |
Typedefs | |
typedef struct buffer_t | buffer_t |
opaque buffer_t struct | |
typedef enum buffer_seek_direction_t | buffer_seek_direction_t |
buffer_seek_direction_t is a enum that buffer seek direction | |
Enumerations | |
enum | buffer_seek_direction_t { BUFFER_SEEK_DIRECTION_START , BUFFER_SEEK_DIRECTION_CURRENT , BUFFER_SEEK_DIRECTION_END } |
buffer_seek_direction_t is a enum that buffer seek direction More... | |
Functions | |
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_append_byte (buffer_t *buffer, uint8_t data) |
buffer_append_byte appends a byte to buffer More... | |
uint64_t | buffer_get_length (buffer_t *buffer) |
returns length of buffer More... | |
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... | |
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_byte (buffer_t *buffer) |
returns a byte array from buffer with length, byte array is copied, position is advanced 1 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... | |
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... | |
buffer_t * | buffer_encapsulate (uint8_t *data, uint64_t length) |
returns a buffer encapsulating a byte array, byte array is not copied More... | |
uint64_t | buffer_remaining (buffer_t *buffer) |
returns how many bytes are remaining in buffer (length - position) 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... | |
uint8_t | buffer_peek_byte (buffer_t *buffer) |
returns a byte from buffer at current 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... | |
boolean_t | buffer_set_readonly (buffer_t *buffer, boolean_t ro) |
sets readonly flag of 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... | |
buffer_t * | buffer_get_io_buffer (uint64_t buffer_io_id) |
returns a buffer for io buffer id, first three buffers are stdin, stdout, stderr More... | |
int64_t | buffer_printf (buffer_t *buffer, const char *format,...) |
prints to buffer, returns number of bytes written More... | |
int64_t | buffer_vprintf (buffer_t *buffer, const char *format, va_list args) |
prints to buffer, returns number of bytes written More... | |
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 | |
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... | |
uint64_t | buffer_get_mark_position (buffer_t *buffer) |
boolean_t | buffer_set_mark_position (buffer_t *buffer, uint64_t position) |
buffer interface
This work is licensed under TURNSTONE OS Public License. Please read and understand latest version of Licence.
#define ___BUFFER_H 0 |
macro for avoiding multiple inclusion
#define BUFFER_IO_ERROR 2 |
default io buffer id for stderr
#define BUFFER_IO_INPUT 0 |
default io buffer id for stdin
#define BUFFER_IO_OUTPUT 1 |
default io buffer id for stdout
buffer_t * buffer_new | ( | void | ) | buffer_new_with_capacity(NULL, 128) |
buffer_new creates a new buffer with default heap
#define buffer_read_line | ( | b | ) | buffer_read_line_ext(b, '\\', '\n', NULL) |
macro to read a line from buffer, line is null terminated, position is advanced
#define buffer_write_all_into | ( | b, | |
d | |||
) | buffer_write_slice_into(b, 0, buffer_get_length(b), d) |
macro to write all bytes from buffer into dest
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 a buffer for io buffer id, first three buffers are stdin, stdout, stderr
[in] | buffer_io_id | io buffer id |
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 |