|
eolib 0.5.0
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. | |
Functions | |
| EoResult | eo_string_to_windows_1252 (const char *value, char **out_value) |
| EoWriter | eo_writer_init (void) |
| EoWriter | eo_writer_init_with_capacity (size_t capacity) |
| void | eo_writer_free (EoWriter *writer) |
| EoResult | eo_writer_ensure_capacity (EoWriter *writer, size_t additional) |
| EoResult | eo_encode_number (int32_t number, uint8_t out_bytes[4]) |
| int32_t | eo_decode_number (const uint8_t *bytes, size_t length) |
| void | eo_decode_string (uint8_t *buf, size_t length) |
| void | eo_encode_string (uint8_t *buf, size_t length) |
| bool | eo_writer_get_string_sanitization_mode (const EoWriter *writer) |
| void | eo_writer_set_string_sanitization_mode (EoWriter *writer, bool enabled) |
| EoResult | eo_writer_add_byte (EoWriter *writer, uint8_t value) |
| EoResult | eo_writer_add_char (EoWriter *writer, int32_t value) |
| EoResult | eo_writer_add_short (EoWriter *writer, int32_t value) |
| EoResult | eo_writer_add_three (EoWriter *writer, int32_t value) |
| EoResult | eo_writer_add_int (EoWriter *writer, int32_t value) |
| EoResult | eo_writer_add_string (EoWriter *writer, const char *value) |
| EoResult | eo_writer_add_encoded_string (EoWriter *writer, const char *value) |
| EoResult | eo_writer_add_fixed_string (EoWriter *writer, const char *value, size_t length, bool padded) |
| EoResult | eo_writer_add_fixed_encoded_string (EoWriter *writer, const char *value, size_t length, bool padded) |
| EoResult | eo_writer_add_bytes (EoWriter *writer, const uint8_t *data, size_t length) |
| EoReader | eo_reader_init (const uint8_t *data, size_t length) |
| bool | eo_reader_get_chunked_reading_mode (const EoReader *reader) |
| void | eo_reader_set_chunked_reading_mode (EoReader *reader, bool enabled) |
| size_t | eo_reader_remaining (const EoReader *reader) |
| EoResult | eo_reader_next_chunk (EoReader *reader) |
| EoResult | eo_reader_get_byte (EoReader *reader, uint8_t *out_value) |
| EoResult | eo_reader_get_char (EoReader *reader, int32_t *out_value) |
| EoResult | eo_reader_get_short (EoReader *reader, int32_t *out_value) |
| EoResult | eo_reader_get_three (EoReader *reader, int32_t *out_value) |
| EoResult | eo_reader_get_int (EoReader *reader, int32_t *out_value) |
| EoResult | eo_reader_get_string (EoReader *reader, char **out_value) |
| EoResult | eo_reader_get_encoded_string (EoReader *reader, char **out_value) |
| EoResult | eo_reader_get_fixed_string (EoReader *reader, size_t length, char **out_value) |
| EoResult | eo_reader_get_fixed_encoded_string (EoReader *reader, size_t length, char **out_value) |
| EoResult | eo_reader_get_bytes (EoReader *reader, size_t length, uint8_t **out_value) |
| static EoResult | eo_deserialize (EoSerialize *serialize, EoReader *reader) |
| static EoResult | eo_serialize (const EoSerialize *serialize, EoWriter *writer) |
| static size_t | eo_get_size (const EoSerialize *serialize) |
| static void | eo_free (EoSerialize *serialize) |
| static uint8_t | eo_packet_get_family (const EoPacket *packet) |
| Gets the family of an EO packet. | |
| static uint8_t | eo_packet_get_action (const EoPacket *packet) |
| Gets the action of an EO packet. | |
| #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.
| int32_t eo_decode_number | ( | const uint8_t * | bytes, |
| size_t | length ) |
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. |
|
inlinestatic |
Deserializes data from a reader into a struct implementing EoSerialize.
| serialize | Struct to populate. |
| reader | Reader to consume from. |
| EoResult eo_encode_number | ( | int32_t | number, |
| uint8_t | out_bytes[4] ) |
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. |
|
inlinestatic |
Frees any heap-allocated memory owned by a struct implementing EoSerialize.
| serialize | Struct to free. |
|
inlinestatic |
Returns the size in bytes of the serialized form of a struct implementing EoSerialize.
| serialize | Struct to query. |
|
inlinestatic |
|
inlinestatic |
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. | bool eo_reader_get_chunked_reading_mode | ( | const EoReader * | reader | ) |
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. | EoReader eo_reader_init | ( | const uint8_t * | data, |
| size_t | length ) |
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 | ) |
| void eo_reader_set_chunked_reading_mode | ( | EoReader * | reader, |
| bool | enabled ) |
|
inlinestatic |
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. |
| bool eo_writer_get_string_sanitization_mode | ( | const EoWriter * | writer | ) |
| EoWriter eo_writer_init | ( | void | ) |
| EoWriter eo_writer_init_with_capacity | ( | size_t | capacity | ) |