mirror of
https://github.com/libretro/RetroArch
synced 2025-02-28 12:40:23 +00:00
config_file.c - get rid of general.h dependency
This commit is contained in:
parent
cbae1583f3
commit
d6890783da
@ -23,7 +23,6 @@
|
|||||||
#include <compat/posix_string.h>
|
#include <compat/posix_string.h>
|
||||||
#include <compat/msvc.h>
|
#include <compat/msvc.h>
|
||||||
#include <file/file_path.h>
|
#include <file/file_path.h>
|
||||||
#include "../general.h"
|
|
||||||
|
|
||||||
#if !defined(_WIN32) && !defined(__CELLOS_LV2__) && !defined(_XBOX)
|
#if !defined(_WIN32) && !defined(__CELLOS_LV2__) && !defined(_XBOX)
|
||||||
#include <sys/param.h> /* PATH_MAX */
|
#include <sys/param.h> /* PATH_MAX */
|
||||||
@ -36,31 +35,6 @@
|
|||||||
|
|
||||||
#define MAX_INCLUDE_DEPTH 16
|
#define MAX_INCLUDE_DEPTH 16
|
||||||
|
|
||||||
struct config_entry_list
|
|
||||||
{
|
|
||||||
/* If we got this from an #include,
|
|
||||||
* do not allow overwrite. */
|
|
||||||
bool readonly;
|
|
||||||
char *key;
|
|
||||||
char *value;
|
|
||||||
struct config_entry_list *next;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct include_list
|
|
||||||
{
|
|
||||||
char *path;
|
|
||||||
struct include_list *next;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct config_file
|
|
||||||
{
|
|
||||||
char *path;
|
|
||||||
struct config_entry_list *entries;
|
|
||||||
struct config_entry_list *tail;
|
|
||||||
unsigned include_depth;
|
|
||||||
|
|
||||||
struct include_list *includes;
|
|
||||||
};
|
|
||||||
|
|
||||||
static config_file_t *config_file_new_internal(const char *path, unsigned depth);
|
static config_file_t *config_file_new_internal(const char *path, unsigned depth);
|
||||||
void config_file_free(config_file_t *conf);
|
void config_file_free(config_file_t *conf);
|
||||||
@ -184,8 +158,8 @@ static void add_child_list(config_file_t *parent, config_file_t *child)
|
|||||||
|
|
||||||
static void add_include_list(config_file_t *conf, const char *path)
|
static void add_include_list(config_file_t *conf, const char *path)
|
||||||
{
|
{
|
||||||
struct include_list *head = conf->includes;
|
struct config_include_list *head = conf->includes;
|
||||||
struct include_list *node = (struct include_list*)calloc(1, sizeof(*node));
|
struct config_include_list *node = (struct config_include_list*)calloc(1, sizeof(*node));
|
||||||
|
|
||||||
if (!node)
|
if (!node)
|
||||||
return;
|
return;
|
||||||
@ -507,11 +481,11 @@ void config_file_free(config_file_t *conf)
|
|||||||
free(hold);
|
free(hold);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct include_list *inc_tmp = conf->includes;
|
struct config_include_list *inc_tmp = conf->includes;
|
||||||
while (inc_tmp)
|
while (inc_tmp)
|
||||||
{
|
{
|
||||||
free(inc_tmp->path);
|
free(inc_tmp->path);
|
||||||
struct include_list *hold = inc_tmp;
|
struct config_include_list *hold = inc_tmp;
|
||||||
inc_tmp = inc_tmp->next;
|
inc_tmp = inc_tmp->next;
|
||||||
free(hold);
|
free(hold);
|
||||||
}
|
}
|
||||||
@ -858,7 +832,7 @@ bool config_file_write(config_file_t *conf, const char *path)
|
|||||||
|
|
||||||
void config_file_dump(config_file_t *conf, FILE *file)
|
void config_file_dump(config_file_t *conf, FILE *file)
|
||||||
{
|
{
|
||||||
struct include_list *includes = conf->includes;
|
struct config_include_list *includes = conf->includes;
|
||||||
while (includes)
|
while (includes)
|
||||||
{
|
{
|
||||||
fprintf(file, "#include \"%s\"\n", includes->path);
|
fprintf(file, "#include \"%s\"\n", includes->path);
|
||||||
@ -874,26 +848,6 @@ void config_file_dump(config_file_t *conf, FILE *file)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef RARCH_INTERNAL
|
|
||||||
void config_file_dump_all(config_file_t *conf)
|
|
||||||
{
|
|
||||||
struct include_list *includes = conf->includes;
|
|
||||||
while (includes)
|
|
||||||
{
|
|
||||||
RARCH_LOG("#include \"%s\"\n", includes->path);
|
|
||||||
includes = includes->next;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct config_entry_list *list = conf->entries;
|
|
||||||
while (list)
|
|
||||||
{
|
|
||||||
RARCH_LOG("%s = \"%s\" %s\n", list->key,
|
|
||||||
list->value, list->readonly ? "(included)" : "");
|
|
||||||
list = list->next;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
bool config_entry_exists(config_file_t *conf, const char *entry)
|
bool config_entry_exists(config_file_t *conf, const char *entry)
|
||||||
{
|
{
|
||||||
struct config_entry_list *list = conf->entries;
|
struct config_entry_list *list = conf->entries;
|
||||||
|
@ -26,6 +26,32 @@ extern "C" {
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
|
||||||
|
struct config_entry_list
|
||||||
|
{
|
||||||
|
/* If we got this from an #include,
|
||||||
|
* do not allow overwrite. */
|
||||||
|
bool readonly;
|
||||||
|
char *key;
|
||||||
|
char *value;
|
||||||
|
struct config_entry_list *next;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct config_include_list
|
||||||
|
{
|
||||||
|
char *path;
|
||||||
|
struct config_include_list *next;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct config_file
|
||||||
|
{
|
||||||
|
char *path;
|
||||||
|
struct config_entry_list *entries;
|
||||||
|
struct config_entry_list *tail;
|
||||||
|
unsigned include_depth;
|
||||||
|
|
||||||
|
struct config_include_list *includes;
|
||||||
|
};
|
||||||
|
|
||||||
typedef struct config_file config_file_t;
|
typedef struct config_file config_file_t;
|
||||||
|
|
||||||
/* Config file format
|
/* Config file format
|
||||||
@ -126,11 +152,6 @@ bool config_file_write(config_file_t *conf, const char *path);
|
|||||||
* Does not close the file. */
|
* Does not close the file. */
|
||||||
void config_file_dump(config_file_t *conf, FILE *file);
|
void config_file_dump(config_file_t *conf, FILE *file);
|
||||||
|
|
||||||
#ifdef RARCH_INTERNAL
|
|
||||||
/* Also dumps inherited values, useful for logging. */
|
|
||||||
void config_file_dump_all(config_file_t *conf);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
20
settings.c
20
settings.c
@ -801,6 +801,26 @@ static config_file_t *open_default_config_file(void)
|
|||||||
|
|
||||||
static void config_read_keybinds_conf(config_file_t *conf);
|
static void config_read_keybinds_conf(config_file_t *conf);
|
||||||
|
|
||||||
|
/* Also dumps inherited values, useful for logging. */
|
||||||
|
|
||||||
|
static void config_file_dump_all(config_file_t *conf)
|
||||||
|
{
|
||||||
|
struct config_include_list *includes = conf->includes;
|
||||||
|
while (includes)
|
||||||
|
{
|
||||||
|
RARCH_LOG("#include \"%s\"\n", includes->path);
|
||||||
|
includes = includes->next;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct config_entry_list *list = conf->entries;
|
||||||
|
while (list)
|
||||||
|
{
|
||||||
|
RARCH_LOG("%s = \"%s\" %s\n", list->key,
|
||||||
|
list->value, list->readonly ? "(included)" : "");
|
||||||
|
list = list->next;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static bool config_load_file(const char *path, bool set_defaults)
|
static bool config_load_file(const char *path, bool set_defaults)
|
||||||
{
|
{
|
||||||
unsigned i;
|
unsigned i;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user