|
eolib 0.6.1
A core C library for writing applications related to Endless Online
|
Go to the source code of this file.
Data Structures | |
| struct | EoWriter |
| struct | EoReader |
| struct | EoSerializeVTable |
| struct | EoSerialize |
| struct | EoPacketVTable |
| struct | EoPacket |
Macros | |
| #define | EO_CHAR_MAX 253 |
| #define | EO_SHORT_MAX 64009 |
| #define | EO_THREE_MAX 16194277 |
| #define | EO_INT_MAX 4097152081 |
| #define | EO_NUMBER_PADDING 0xFE |
| #define | EO_BREAK_BYTE 0xFF |
Typedefs | |
| typedef struct EoWriter | EoWriter |
| typedef struct EoReader | EoReader |
| typedef struct EoSerialize | EoSerialize |
| Interface for serializable objects. | |
| typedef struct EoPacket | EoPacket |
| Interface for EO packets, which are serializable objects with a family and action. | |
| #define EO_BREAK_BYTE 0xFF |
| #define EO_CHAR_MAX 253 |
| #define EO_INT_MAX 4097152081 |
| #define EO_NUMBER_PADDING 0xFE |
| #define EO_SHORT_MAX 64009 |
| #define EO_THREE_MAX 16194277 |
| typedef struct EoPacket EoPacket |
| typedef struct EoReader EoReader |
Reader that parses EO-encoded bytes.
| typedef struct EoSerialize EoSerialize |
| typedef struct EoWriter EoWriter |
Writer that accumulates EO-encoded bytes.
Decodes an EO-encoded integer.
| bytes | Input bytes. |
| length | Number of bytes to decode (1-4). |
| void eo_decode_string | ( | uint8_t * | buf, |
| size_t | length ) |
Decodes a string in place using the EO string transform.
| buf | Buffer to decode. |
| length | Number of bytes in the buffer. |
|
static |
Deserializes data from a reader into a struct implementing EoSerialize.
| serialize | Struct to populate. |
| reader | Reader to consume from. |
Encodes an integer into EO byte format.
| number | Value to encode. |
| out_bytes | Buffer for up to 4 encoded bytes. |
| void eo_encode_string | ( | uint8_t * | buf, |
| size_t | length ) |
Encodes a string in place using the EO string transform.
| buf | Buffer to encode. |
| length | Number of bytes in the buffer. |
|
static |
Frees any heap-allocated memory owned by a struct implementing EoSerialize.
| serialize | Struct to free. |
|
static |
Returns the size in bytes of the serialized form of a struct implementing EoSerialize.
| serialize | Struct to query. |
| void eo_reader_activate_chunked_reading | ( | EoReader * | reader | ) |
Reads a raw byte from the reader.
| reader | Reader to consume from. |
| out_value | Output for the byte. |
out_value set to 0 rather than EO_BUFFER_UNDERRUN. Use eo_reader_remaining() to check available bytes before reading. Reads raw bytes from the reader.
| reader | Reader to consume from. |
| length | Number of bytes to read. |
| out_value | Output buffer, heap-allocated — caller must free. |
Reads a 1-byte EO-encoded number.
| reader | Reader to consume from. |
| out_value | Output for the value. |
out_value set to 0 rather than EO_BUFFER_UNDERRUN. Use eo_reader_remaining() to check available bytes before reading. Reads the remaining bytes as an EO-encoded string.
| reader | Reader to consume from. |
| out_value | Output string, heap-allocated — caller must free. |
Reads a fixed-length EO-encoded string.
| reader | Reader to consume from. |
| length | Number of bytes to read. |
| out_value | Output string, heap-allocated — caller must free. |
Reads a fixed-length raw string.
| reader | Reader to consume from. |
| length | Number of bytes to read. |
| out_value | Output string, heap-allocated — caller must free. |
Reads a 4-byte EO-encoded number.
| reader | Reader to consume from. |
| out_value | Output for the value. |
out_value set to 0 rather than EO_BUFFER_UNDERRUN. Use eo_reader_remaining() to check available bytes before reading. Reads a 2-byte EO-encoded number.
| reader | Reader to consume from. |
| out_value | Output for the value. |
out_value set to 0 rather than EO_BUFFER_UNDERRUN. Use eo_reader_remaining() to check available bytes before reading. Reads the remaining bytes as a raw string.
| reader | Reader to consume from. |
| out_value | Output string, heap-allocated — caller must free. |
Reads a 3-byte EO-encoded number.
| reader | Reader to consume from. |
| out_value | Output for the value. |
out_value set to 0 rather than EO_BUFFER_UNDERRUN. Use eo_reader_remaining() to check available bytes before reading. Initializes a reader over an existing byte buffer.
| data | Pointer to the byte buffer. The caller must ensure it remains valid for the lifetime of the reader. |
| length | Number of bytes in the buffer. |
| size_t eo_reader_remaining | ( | const EoReader * | reader | ) |
|
static |
Serializes a struct implementing EoSerialize into a writer.
| serialize | Struct to serialize. |
| writer | Writer to append to. |
| EoResult eo_string_to_windows_1252 | ( | const char * | value, |
| char ** | out_value ) |
Converts a UTF-8 string to Windows-1252 (CP1252) encoding.
| value | UTF-8 input string. If NULL, out_value is set to NULL and EO_SUCCESS is returned. |
| out_value | Output string in Windows-1252, heap-allocated — caller must free. |
out_value is NULL, or EO_ALLOC_FAILED if memory allocation fails. | EoResult eo_writer_add_fixed_encoded_string | ( | EoWriter * | writer, |
| const char * | value, | ||
| size_t | length, | ||
| bool | padded ) |
Appends a fixed-length string encoded with the EO string transform, with optional padding.
| writer | Writer to append to. |
| value | String to encode and append (without terminator). |
| length | Fixed length of the string in bytes. |
| padded | If true, shorter strings will be padded with 0xFF bytes. |
| EoResult eo_writer_add_fixed_string | ( | EoWriter * | writer, |
| const char * | value, | ||
| size_t | length, | ||
| bool | padded ) |
Appends a fixed-length string to the writer, with optional padding.
| writer | Writer to append to. |
| value | String to append (without terminator). |
| length | Fixed length of the string in bytes. |
| padded | If true, shorter strings will be padded with 0xFF bytes. |
Appends a 4-byte EO-encoded number.
| writer | Writer to append to. |
| value | Value to encode. |
Ensures a writer has space for additional bytes, reallocating if necessary.
| writer | Writer to grow. |
| additional | Additional bytes required. |
| void eo_writer_free | ( | EoWriter * | writer | ) |
Frees the memory allocated by a writer and zeroes the struct.
| writer | Writer to free. If NULL, this function does nothing. |
| EoWriter eo_writer_init | ( | void | ) |
| EoWriter eo_writer_init_with_capacity | ( | size_t | capacity | ) |