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>
|
2022-04-05 07:22:59 +00:00
|
|
|
#include <assert.h>
|
2022-04-24 03:43:28 +00:00
|
|
|
|
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;
|
2020-05-31 00:42:09 +00:00
|
|
|
|
2021-02-18 14:38:50 +00:00
|
|
|
// Override the default config file paths
|
|
|
|
void xemu_settings_set_path(const char *path);
|
|
|
|
|
2022-03-09 02:29:46 +00:00
|
|
|
// Get the path of the base settings dir
|
|
|
|
const char *xemu_settings_get_base_path(void);
|
|
|
|
|
2020-03-12 09:22:32 +00:00
|
|
|
// Get path of the config file on disk
|
|
|
|
const char *xemu_settings_get_path(void);
|
|
|
|
|
2020-11-04 05:00:38 +00:00
|
|
|
// 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
|
2022-03-15 23:31:27 +00:00
|
|
|
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)
|
|
|
|
{
|
2022-04-05 07:22:59 +00:00
|
|
|
assert(new_str);
|
|
|
|
free((char*)*str);
|
|
|
|
*str = strdup(new_str);
|
2022-04-22 08:32:28 +00:00
|
|
|
}
|
2020-03-12 09:22:32 +00:00
|
|
|
|
2022-05-03 10:07:22 +00:00
|
|
|
void add_net_nat_forward_ports(int host, int guest, CONFIG_NET_NAT_FORWARD_PORTS_PROTOCOL protocol);
|
|
|
|
void remove_net_nat_forward_ports(unsigned int index);
|
|
|
|
|
2020-03-12 09:22:32 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|