libsuperderpy/src/config.c

48 lines
1.5 KiB
C
Raw Normal View History

2012-02-28 13:09:12 +01:00
/*! \file config.c
* \brief Configuration manager code.
*/
2012-03-04 13:32:42 +01:00
/*
* Copyright (c) Sebastian Krzyszkowiak <dos@dosowisko.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include <allegro5/allegro.h>
2012-02-29 12:16:11 +01:00
#include "config.h"
2012-02-24 13:03:30 +01:00
ALLEGRO_CONFIG *config;
2012-02-26 00:47:41 +01:00
2012-02-24 13:03:30 +01:00
void InitConfig() {
config = al_load_config_file("SuperDerpy.ini");
if (!config) config=al_create_config();
2012-02-24 13:03:30 +01:00
}
2012-02-26 00:47:41 +01:00
void SetConfigOption(char* section, char* name, char* value) {
al_set_config_value(config, section, name, value);
2012-02-26 00:47:41 +01:00
}
const char* GetConfigOption(char* section, char* name) {
return al_get_config_value(config, section, name);
2012-02-24 13:03:30 +01:00
}
const char* GetConfigOptionDefault(char* section, char* name, const char* def) {
const char* ret = GetConfigOption(section, name);
2012-02-26 00:47:41 +01:00
if (!ret) return def; else return ret;
}
2012-02-24 13:03:30 +01:00
void DeinitConfig() {
al_save_config_file("SuperDerpy.ini", config);
al_destroy_config(config);
2012-02-26 00:47:41 +01:00
}