XIni
Represents a parsed INI source
typedef struct XIni{
char *pool;
size_t pool_size;
size_t pool_cap;
XIniSection *sections;
int sections_count;
int sections_cap;
XIniEntry *entries;
int entries_count;
int entries_cap;
int global_section;
}XIni;
XIniEntry
Ini Entry
typedef struct XIniEntry{
int section;
const char *key;
const char *value;
}XIniEntry;
XIniError
Ini error information
typedef struct XIniError{
XIniErrorCode code;
int line;
int column;
const char *message;
}XIniError;
XIniErrorCode
Ini parsing status.
typedef enum XIniErrorCode{
XINI_OK=0,
XINI_ERR_IO,
XINI_ERR_MEMORY,
XINI_ERR_SYNTAX,
XINI_ERR_EXPECT_EQUALS,
XINI_ERR_EXPECT_RBRACKET,
XINI_ERR_UNTERMINATED_STRING
}XIniErrorCode;
XIniSection
Ini section information
typedef struct XIniSection{
const char *name;
int first_entry;
}XIniSection;
x_ini_err_str
Get a human-readable string for an INI error code.
X_INI_API const char * x_ini_err_str(XIniErrorCode code);
Returns
Pointer to a static, thread-safe error string.
x_ini_free
Free all resources associated with an INI structure.
X_INI_API void x_ini_free(XIni *ini);
Parameters
XIni *ini
- INI structure to free.
x_ini_load_file
Load and parse an INI file from disk.
X_INI_API bool x_ini_load_file(
const char *path,
XIni *out_ini,
XIniError *err
);
Parameters
const char *path
- Path to the INI file.
XIni *out_ini
- Output structure receiving the parsed INI data.
XIniError *err
- Optional output error information (may be NULL).
Returns
True on success, false on failure.
x_ini_load_mem
Load and parse INI data from a memory buffer.
X_INI_API bool x_ini_load_mem(
const void *data,
size_t size,
XIni *out_ini,
XIniError *err
);
Parameters
const void *data
- Pointer to the INI data in memory.
size_t size
- Size of the data buffer in bytes.
XIni *out_ini
- Output structure receiving the parsed INI data.
XIniError *err
- Optional output error information (may be NULL).
Returns
True on success, false on failure.
x_ini_write_file
Write INI data to a file.
X_INI_API bool x_ini_write_file(
const char *path,
const XIni *ini,
XIniError *err
);
Parameters
const char *path
- Path to the INI file.
const XIni *ini
- INI data to write.
XIniError *err
- Optional output error information (may be NULL).
Returns
True on success, false on failure.