xemu/ui/xemu-settings.h

67 lines
1.8 KiB
C
Raw Normal View History

2020-03-12 09:22:32 +00:00
/*
* xemu Settings Management
*
* Primary storage for non-volatile user configuration. Basic key-value storage
* that gets saved to an INI file. All entries should be accessed through the
* appropriate getter/setter functions.
*
2021-03-03 10:24:24 +00:00
* Copyright (C) 2020-2021 Matt Borgerson
2020-03-12 09:22:32 +00:00
*
* 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, see <http://www.gnu.org/licenses/>.
*/
#ifndef XEMU_SETTINGS_H
#define XEMU_SETTINGS_H
2022-04-24 03:43:28 +00:00
#include <stdlib.h>
#include <string.h>
2020-03-12 09:22:32 +00:00
#ifdef __cplusplus
extern "C" {
#endif
2022-04-22 08:32:28 +00:00
#include "xemu-config.h"
2020-03-12 09:22:32 +00:00
2022-04-22 08:32:28 +00:00
extern struct config g_config;
// Override the default config file paths
void xemu_settings_set_path(const char *path);
2020-03-12 09:22:32 +00:00
// Get path of the config file on disk
const char *xemu_settings_get_path(void);
// Get path of the default generated eeprom file on disk
const char *xemu_settings_get_default_eeprom_path(void);
2022-04-24 03:43:28 +00:00
// Get error message on failure to parse settings
const char *xemu_settings_get_error_message(void);
// Load config file from disk, or load defaults. Return true on success, false if an error occured.
bool xemu_settings_load(void);
2020-03-12 09:22:32 +00:00
// Save config file to disk
void xemu_settings_save(void);
2020-03-12 09:22:32 +00:00
2022-04-22 08:32:28 +00:00
static inline void xemu_settings_set_string(const char **str, const char *new_str)
{
free((char*)*str);
*str = strdup(new_str);
}
2020-03-12 09:22:32 +00:00
#ifdef __cplusplus
}
#endif
#endif