|
@@ -14,25 +14,25 @@ typedef struct { |
|
|
|
|
|
|
|
|
struct INI_ConfigItem; |
|
|
struct INI_ConfigItem; |
|
|
|
|
|
|
|
|
typedef void INI_ConfigLoadType(struct INI_ConfigItem*, const char*); |
|
|
|
|
|
|
|
|
typedef void INI_ConfigTypeLoad(struct INI_ConfigItem*, const char*); |
|
|
|
|
|
|
|
|
typedef enum { |
|
|
typedef enum { |
|
|
INI_CONFIG_SAVE_ITEM_ERROR = -1, |
|
|
INI_CONFIG_SAVE_ITEM_ERROR = -1, |
|
|
INI_CONFIG_SAVE_ITEM_OK, |
|
|
INI_CONFIG_SAVE_ITEM_OK, |
|
|
} INI_ConfigSaveItemResult; |
|
|
} INI_ConfigSaveItemResult; |
|
|
|
|
|
|
|
|
typedef INI_ConfigSaveItemResult INI_ConfigSaveType(struct INI_ConfigItem*, const char*); |
|
|
|
|
|
|
|
|
typedef INI_ConfigSaveItemResult INI_ConfigTypeSave(struct INI_ConfigItem*, const char*); |
|
|
|
|
|
|
|
|
typedef void INI_ConfigOverrideType(struct INI_ConfigItem*, uint8_t, const char*[]); |
|
|
|
|
|
|
|
|
typedef void INI_ConfigTypeOverride(struct INI_ConfigItem*, uint8_t, const char*[]); |
|
|
typedef struct { |
|
|
typedef struct { |
|
|
size_t size; |
|
|
size_t size; |
|
|
INI_ConfigLoadType* load; |
|
|
|
|
|
INI_ConfigSaveType* save; |
|
|
|
|
|
INI_ConfigOverrideType* override; |
|
|
|
|
|
} INI_ConfigTypeFns; |
|
|
|
|
|
|
|
|
INI_ConfigTypeLoad* load; |
|
|
|
|
|
INI_ConfigTypeSave* save; |
|
|
|
|
|
INI_ConfigTypeOverride* override; |
|
|
|
|
|
} INI_ConfigType; |
|
|
|
|
|
|
|
|
typedef struct INI_ConfigItem { |
|
|
typedef struct INI_ConfigItem { |
|
|
INI_ConfigTypeFns fns; |
|
|
|
|
|
|
|
|
INI_ConfigType type; |
|
|
const char* section; |
|
|
const char* section; |
|
|
const char* key; |
|
|
const char* key; |
|
|
const char* cmdline_option; |
|
|
const char* cmdline_option; |
|
@@ -60,65 +60,95 @@ INI_ConfigSaveResult INI_ConfigSave(INI_ConfigItem[], const char*); |
|
|
|
|
|
|
|
|
void INI_ConfigLoadU8(INI_ConfigItem*, const char*); |
|
|
void INI_ConfigLoadU8(INI_ConfigItem*, const char*); |
|
|
void INI_ConfigLoadU16(INI_ConfigItem*, const char*); |
|
|
void INI_ConfigLoadU16(INI_ConfigItem*, const char*); |
|
|
|
|
|
void INI_ConfigLoadU32(INI_ConfigItem*, const char*); |
|
|
|
|
|
void INI_ConfigLoadI8(INI_ConfigItem*, const char*); |
|
|
|
|
|
void INI_ConfigLoadI16(INI_ConfigItem*, const char*); |
|
|
void INI_ConfigLoadI32(INI_ConfigItem*, const char*); |
|
|
void INI_ConfigLoadI32(INI_ConfigItem*, const char*); |
|
|
void INI_ConfigLoadString(INI_ConfigItem*, const char*); |
|
|
void INI_ConfigLoadString(INI_ConfigItem*, const char*); |
|
|
|
|
|
|
|
|
INI_ConfigSaveItemResult INI_ConfigSaveU8(INI_ConfigItem*, const char*); |
|
|
INI_ConfigSaveItemResult INI_ConfigSaveU8(INI_ConfigItem*, const char*); |
|
|
INI_ConfigSaveItemResult INI_ConfigSaveU16(INI_ConfigItem*, const char*); |
|
|
INI_ConfigSaveItemResult INI_ConfigSaveU16(INI_ConfigItem*, const char*); |
|
|
|
|
|
INI_ConfigSaveItemResult INI_ConfigSaveU32(INI_ConfigItem*, const char*); |
|
|
|
|
|
INI_ConfigSaveItemResult INI_ConfigSaveI8(INI_ConfigItem*, const char*); |
|
|
|
|
|
INI_ConfigSaveItemResult INI_ConfigSaveI16(INI_ConfigItem*, const char*); |
|
|
INI_ConfigSaveItemResult INI_ConfigSaveI32(INI_ConfigItem*, const char*); |
|
|
INI_ConfigSaveItemResult INI_ConfigSaveI32(INI_ConfigItem*, const char*); |
|
|
INI_ConfigSaveItemResult INI_ConfigSaveString(INI_ConfigItem*, const char*); |
|
|
INI_ConfigSaveItemResult INI_ConfigSaveString(INI_ConfigItem*, const char*); |
|
|
|
|
|
|
|
|
void INI_ConfigOverrideU8(INI_ConfigItem*, uint8_t, const char*[]); |
|
|
void INI_ConfigOverrideU8(INI_ConfigItem*, uint8_t, const char*[]); |
|
|
void INI_ConfigOverrideU16(INI_ConfigItem*, uint8_t, const char*[]); |
|
|
void INI_ConfigOverrideU16(INI_ConfigItem*, uint8_t, const char*[]); |
|
|
|
|
|
void INI_ConfigOverrideU32(INI_ConfigItem*, uint8_t, const char*[]); |
|
|
|
|
|
void INI_ConfigOverrideI8(INI_ConfigItem*, uint8_t, const char*[]); |
|
|
|
|
|
void INI_ConfigOverrideI16(INI_ConfigItem*, uint8_t, const char*[]); |
|
|
void INI_ConfigOverrideI32(INI_ConfigItem*, uint8_t, const char*[]); |
|
|
void INI_ConfigOverrideI32(INI_ConfigItem*, uint8_t, const char*[]); |
|
|
void INI_ConfigOverrideString(INI_ConfigItem*, uint8_t, const char*[]); |
|
|
void INI_ConfigOverrideString(INI_ConfigItem*, uint8_t, const char*[]); |
|
|
|
|
|
|
|
|
#define INI_CONFIG_TYPE_FNS_I32 (INI_ConfigTypeFns) { \ |
|
|
|
|
|
.size = sizeof(int32_t), \ |
|
|
|
|
|
.load = INI_ConfigLoadI32, \ |
|
|
|
|
|
.save = INI_ConfigSaveI32, \ |
|
|
|
|
|
.override = INI_ConfigOverrideI32, \ |
|
|
|
|
|
|
|
|
#define INI_CONFIG_TYPE_U8 (INI_ConfigType) { \ |
|
|
|
|
|
.size = sizeof(uint8_t), \ |
|
|
|
|
|
.load = INI_ConfigLoadU8, \ |
|
|
|
|
|
.save = INI_ConfigSaveU8, \ |
|
|
|
|
|
.override = INI_ConfigOverrideU8, \ |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
#define INI_CONFIG_TYPE_FNS_U16 (INI_ConfigTypeFns) { \ |
|
|
|
|
|
|
|
|
#define INI_CONFIG_TYPE_U16 (INI_ConfigType) { \ |
|
|
.size = sizeof(uint16_t), \ |
|
|
.size = sizeof(uint16_t), \ |
|
|
.load = INI_ConfigLoadU16, \ |
|
|
.load = INI_ConfigLoadU16, \ |
|
|
.save = INI_ConfigSaveU16, \ |
|
|
.save = INI_ConfigSaveU16, \ |
|
|
.override = INI_ConfigOverrideU16, \ |
|
|
.override = INI_ConfigOverrideU16, \ |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
#define INI_CONFIG_TYPE_FNS_U8 (INI_ConfigTypeFns) { \ |
|
|
|
|
|
.size = sizeof(uint8_t), \ |
|
|
|
|
|
.load = INI_ConfigLoadU8, \ |
|
|
|
|
|
.save = INI_ConfigSaveU8, \ |
|
|
|
|
|
.override = INI_ConfigOverrideU8, \ |
|
|
|
|
|
|
|
|
#define INI_CONFIG_TYPE_U32 (INI_ConfigType) { \ |
|
|
|
|
|
.size = sizeof(uint32_t), \ |
|
|
|
|
|
.load = INI_ConfigLoadU32, \ |
|
|
|
|
|
.save = INI_ConfigSaveU32, \ |
|
|
|
|
|
.override = INI_ConfigOverrideU32, \ |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#define INI_CONFIG_TYPE_I8 (INI_ConfigType) { \ |
|
|
|
|
|
.size = sizeof(int8_t), \ |
|
|
|
|
|
.load = INI_ConfigLoadI8, \ |
|
|
|
|
|
.save = INI_ConfigSaveI8, \ |
|
|
|
|
|
.override = INI_ConfigOverrideI8, \ |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
#define INI_CONFIG_TYPE_FNS_VOID (INI_ConfigTypeFns) { \ |
|
|
|
|
|
.size = 0, \ |
|
|
|
|
|
.load = NULL, \ |
|
|
|
|
|
.save = NULL, \ |
|
|
|
|
|
.override = NULL, \ |
|
|
|
|
|
|
|
|
#define INI_CONFIG_TYPE_I16 (INI_ConfigType) { \ |
|
|
|
|
|
.size = sizeof(int16_t), \ |
|
|
|
|
|
.load = INI_ConfigLoadI16, \ |
|
|
|
|
|
.save = INI_ConfigSaveI16, \ |
|
|
|
|
|
.override = INI_ConfigOverrideI16, \ |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
#define INI_CONFIG_TYPE_FNS_STRING(X) (INI_ConfigTypeFns) { \ |
|
|
|
|
|
.size = (X), \ |
|
|
|
|
|
|
|
|
#define INI_CONFIG_TYPE_I32 (INI_ConfigType) { \ |
|
|
|
|
|
.size = sizeof(int32_t), \ |
|
|
|
|
|
.load = INI_ConfigLoadI32, \ |
|
|
|
|
|
.save = INI_ConfigSaveI32, \ |
|
|
|
|
|
.override = INI_ConfigOverrideI32, \ |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#define INI_CONFIG_TYPE_FNS_STRING(X) (INI_ConfigType) { \ |
|
|
|
|
|
.size = (sizeof(char) * X), \ |
|
|
.load = INI_ConfigLoadString, \ |
|
|
.load = INI_ConfigLoadString, \ |
|
|
.save = INI_ConfigSaveString, \ |
|
|
.save = INI_ConfigSaveString, \ |
|
|
.override = INI_ConfigOverrideString, \ |
|
|
.override = INI_ConfigOverrideString, \ |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#define INI_CONFIG_SERIALIZER_PAIR_NONE (INI_ConfigSerializerPair) { \ |
|
|
|
|
|
.serialize = NULL, \ |
|
|
|
|
|
.deserialize = NULL, \ |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
#define INI_CONFIG_ITEM_NULL (INI_ConfigItem) { \ |
|
|
#define INI_CONFIG_ITEM_NULL (INI_ConfigItem) { \ |
|
|
INI_CONFIG_TYPE_FNS_VOID, \ |
|
|
|
|
|
|
|
|
(INI_ConfigType) { \ |
|
|
|
|
|
.size = 0, \ |
|
|
|
|
|
.load = NULL, \ |
|
|
|
|
|
.save = NULL, \ |
|
|
|
|
|
.override = NULL, \ |
|
|
|
|
|
}, \ |
|
|
NULL, \ |
|
|
NULL, \ |
|
|
NULL, \ |
|
|
NULL, \ |
|
|
NULL, \ |
|
|
NULL, \ |
|
|
NULL, \ |
|
|
NULL, \ |
|
|
NULL, \ |
|
|
NULL, \ |
|
|
{ \ |
|
|
|
|
|
.serialize = NULL, \ |
|
|
|
|
|
.deserialize = NULL, \ |
|
|
|
|
|
}, \ |
|
|
|
|
|
|
|
|
INI_CONFIG_SERIALIZER_PAIR_NONE, \ |
|
|
NULL, \ |
|
|
NULL, \ |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|