config: Add DeleteConfigOption function

This commit is contained in:
Sebastian Krzyszkowiak 2020-03-13 03:21:10 +01:00
parent e57db1d127
commit 58f97730db
No known key found for this signature in database
GPG key ID: E8F235CF3BDBC3FF
2 changed files with 9 additions and 2 deletions

View file

@ -62,6 +62,11 @@ SYMBOL_EXPORT const char* GetConfigOptionDefault(struct Game* game, char* sectio
return ret; return ret;
} }
SYMBOL_EXPORT void DeleteConfigOption(struct Game* game, char* section, char* name) {
al_remove_config_key(game->_priv.config, section, name);
StoreConfig(game);
}
SYMBOL_EXPORT void DeinitConfig(struct Game* game) { SYMBOL_EXPORT void DeinitConfig(struct Game* game) {
al_destroy_config(game->_priv.config); al_destroy_config(game->_priv.config);
} }

View file

@ -27,10 +27,12 @@
void InitConfig(struct Game* game); void InitConfig(struct Game* game);
/*! \brief Returns value of requested config entry. */ /*! \brief Returns value of requested config entry. */
const char* GetConfigOption(struct Game* game, char* section, char* name); const char* GetConfigOption(struct Game* game, char* section, char* name);
/*! \brief Returns value of requested config entry, or def if no such entry exists. */ /*! \brief Returns value of requested config entry, or `def` if no such entry exists. */
const char* GetConfigOptionDefault(struct Game* game, char* section, char* name, const char* def); const char* GetConfigOptionDefault(struct Game* game, char* section, char* name, const char* def);
/*! \brief Sets new value of requested config entry, or created new if no such entry exists. */ /*! \brief Sets a new value of requested config entry, or creates a new one if no such entry exists. */
void SetConfigOption(struct Game* game, char* section, char* name, char* value); void SetConfigOption(struct Game* game, char* section, char* name, char* value);
/*! \brief Deletes an existing config entry. */
void DeleteConfigOption(struct Game* game, char* section, char* name);
/*! \brief Writes config from memory to file. */ /*! \brief Writes config from memory to file. */
void DeinitConfig(struct Game* game); void DeinitConfig(struct Game* game);