Functions | |
| ImplList (Buffer) | |
| ListBuffer | ListBuffer_deserialize (Buffer buf) |
| Deserialize a ListBuffer from a Buffer. | |
| bool | mkdir_p (SafeStr fpath, mode_t mode) |
| Recursively create directories. | |
| void | Buffer_deinit (Buffer kod) |
| Deinitializes a Buffer. | |
| void | Buffer_write (Buffer buf, FILE *f) |
| Writes data from a Buffer to a file. | |
| Buffer | Buffer_read (FILE *f) |
| Reads data from a file. | |
| Byte * | copy (Byte *src, size_t nbytes) |
| Byte by Byte copy. | |
| Buffer | bufcpy (Buffer src) |
| Allocates new memory from src and returns a buffer to that memory. | |
| Buffer | validate_str (Buffer str, size_t max_len) |
| Checks whether the buffer contains a valid string and that the size provided matches the size of that string. | |
| size_t | safe_strlen (Str str, size_t max_len) |
| Does an strlen using a max size. | |
| Buffer | atob (const char *str) |
| Converts a CString to a Byte Buffer. | |
| Buffer | SafeStr_serialize (SafeStr str) |
| Serializes a string. | |
| SafeStr | SafeStr_deserialize (Buffer buf) |
| Deserializes a string from a Buffer. | |
| Buffer | size_t_serialize (size_t a) |
| Serializes a size_t length. | |
| size_t | size_t_deserialize (Buffer buf) |
| Deserializes a size_t length. | |
| Buffer | concat (Buffer l, Buffer r) |
| Concatenate two Buffer's. | |
| bool | Str_eq (Str l, Str r) |
| Compares two strings. | |
| Buffer | Buffer_serialize (Buffer buf) |
| Serialize a Buffer to a Buffer. | |
| Buffer | Buffer_deserialize (Buffer buf) |
| Deserialize a Buffer from a Buffer. | |
| Buffer | to_buffer (const void *thing, size_t nbytes) |
| Convert a thing to a buffer. | |
| Buffer | uint8_t_serialize (uint8_t n) |
| Serialize a uint8_t to a Buffer. | |
| uint8_t | uint8_t_deserialize (Buffer buf) |
| Deserialize a uint8_t from a Buffer. | |
| Buffer | uint16_t_serialize (uint16_t n) |
| Serialize a uint16_t to a Buffer. | |
| uint16_t | uint16_t_deserialize (Buffer buf) |
| Deserialize a uint16_t from a Buffer. | |
| Buffer | uint32_t_serialize (uint32_t n) |
| Serialize a uint32_t to a Buffer. | |
| uint32_t | uint32_t_deserialize (Buffer buf) |
| Deserialize a uint32_t from a Buffer. | |
| SafeStr | atoss (Str str) |
| Convert a string literal to a safe string WARNING: DO NOT USE THIS TO CONVERT THINGS THAT ARE NOT STRING LITERALS! | |
| size_t | min (size_t l, size_t r) |
| Simply returns the minimum of the two. | |
| LazyBuffer | open (Str fpath) |
| Open a LazyBuffer. | |
| LazyBuffer | next_chunk (LazyBuffer b) |
| Reads the next chunk of the file, if it can. | |
Convert a string literal to a safe string WARNING: DO NOT USE THIS TO CONVERT THINGS THAT ARE NOT STRING LITERALS!
| str | the string literal that you want to convert |
Allocates new memory from src and returns a buffer to that memory.
Make a copy of a Buffer.
The user must free that memory.
| void Buffer_deinit | ( | Buffer | kod | ) |
| Buffer Buffer_read | ( | FILE * | f | ) |
| void Buffer_write | ( | Buffer | buf, |
| FILE * | f ) |
| ImplList | ( | Buffer | ) |
| ListBuffer ListBuffer_deserialize | ( | Buffer | buf | ) |
| size_t min | ( | size_t | l, |
| size_t | r ) |
Simply returns the minimum of the two.
| l | the lhs |
| r | the rhs |
| bool mkdir_p | ( | SafeStr | fpath, |
| mode_t | mode ) |
Recursively create directories.
The following code:
is equivalent to the following Shell code:
| fpath | the filepath where you want to create a directory |
| mode | the mode in which you want to create the directory |
| LazyBuffer next_chunk | ( | LazyBuffer | b | ) |
Reads the next chunk of the file, if it can.
In the case where the entire file was read, the LazyBuffer::len will be 0. I'm not sure in what case you wouldn't want to do it this way, but you probably always want to use this like this:
| b | the LazyBuffer that you want to get the next chunk for |
| LazyBuffer open | ( | Str | fpath | ) |
Open a LazyBuffer.
INFO: This does not fill the LazyBuffer with anything. Consider it similar to just executing:
| fpath | the file path to the file that you want to open |
| size_t safe_strlen | ( | Str | str, |
| size_t | max_len ) |
Does an strlen using a max size.
Avoids buffer overflows.
| str | the string to look at |
| max_len | the maximum length that the string can have |
Serializes a string.
INFO: ONLY SERIALIZE STRINGS WITH THIS.
| str | a safe string to serialize |
| size_t size_t_deserialize | ( | Buffer | buf | ) |
| Buffer size_t_serialize | ( | size_t | a | ) |
Compares two strings.
| lhs | left-hand side string |
| rhs | right-hand side string |
| Buffer to_buffer | ( | const void * | thing, |
| size_t | nbytes ) |
Convert a thing to a buffer.
This can be used for types whose size is known at compile-time.
| thing | a pointer to the thing that you want to serialize |
| uint16_t uint16_t_deserialize | ( | Buffer | buf | ) |
| Buffer uint16_t_serialize | ( | uint16_t | n | ) |
| uint32_t uint32_t_deserialize | ( | Buffer | buf | ) |
| Buffer uint32_t_serialize | ( | uint32_t | n | ) |
| uint8_t uint8_t_deserialize | ( | Buffer | buf | ) |
| Buffer uint8_t_serialize | ( | uint8_t | n | ) |