|
eolib 0.5.0
A core C library for writing applications related to Endless Online
|
#include "eolib/data.h"#include "eolib/result.h"#include <limits.h>#include <stdlib.h>#include <string.h>#include <stdio.h>Go to the source code of this file.
Functions | |
| static size_t | eo_reader_next_break_index (const EoReader *reader) |
| static uint8_t | unicode_to_cp1252 (uint32_t codepoint) |
| static size_t | normalize_to_cp1252 (const char *input, char *output, size_t input_len) |
| EoResult | eo_string_to_windows_1252 (const char *value, char **out_value) |
| const char * | eo_result_string (EoResult result) |
| 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) |
Variables | |
| static const uint32_t | cp1252_unicode_extras [32] |
| 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. |
| 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. |
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. |
|
static |
| size_t eo_reader_remaining | ( | const EoReader * | reader | ) |
| void eo_reader_set_chunked_reading_mode | ( | EoReader * | reader, |
| bool | enabled ) |
| const char * eo_result_string | ( | EoResult | result | ) |
| 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 | ) |
| void eo_writer_set_string_sanitization_mode | ( | EoWriter * | writer, |
| bool | enabled ) |
|
static |