Struct in stdx_ini.h

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;
Struct in stdx_ini.h

XIniEntry

Ini Entry

typedef struct XIniEntry{
  int section;
  const char *key;
  const char *value;
}XIniEntry;
Struct in stdx_ini.h

XIniError

Ini error information

typedef struct XIniError{
  XIniErrorCode code;
  int line;
  int column;
  const char *message;
}XIniError;
Enum in stdx_ini.h

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;
Struct in stdx_ini.h

XIniSection

Ini section information

typedef struct XIniSection{
  const char *name;
  int first_entry;
}XIniSection;
Function in stdx_ini.h

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);

Parameters

XIniErrorCode code
Error code.

Returns

Pointer to a static, thread-safe error string.

Function in stdx_ini.h

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.

Returns

Nothing.

Function in stdx_ini.h

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.

Function in stdx_ini.h

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.

Function in stdx_ini.h

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.