mirror of
https://github.com/libretro/RetroArch
synced 2025-04-18 05:43:34 +00:00
(XDK1) C89 build fixes for config_file.c - Salamander build fixes
This commit is contained in:
parent
37ef0a4ce6
commit
0b95e3f2d7
@ -19,7 +19,7 @@
|
|||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "../conf/config_file.h"
|
#include <file/config_file.h>
|
||||||
#include "../general.h"
|
#include "../general.h"
|
||||||
#include "../file_ext.h"
|
#include "../file_ext.h"
|
||||||
#include <file/file_path.h>
|
#include <file/file_path.h>
|
||||||
|
@ -23,8 +23,6 @@
|
|||||||
|
|
||||||
#include <xbdm.h>
|
#include <xbdm.h>
|
||||||
|
|
||||||
#include "../../conf/config_file.h"
|
|
||||||
#include "../../conf/config_file_macros.h"
|
|
||||||
#include "../../general.h"
|
#include "../../general.h"
|
||||||
#include <file/file_path.h>
|
#include <file/file_path.h>
|
||||||
|
|
||||||
|
@ -82,6 +82,8 @@ static char *getaline(FILE *file)
|
|||||||
|
|
||||||
static char *extract_value(char *line, bool is_value)
|
static char *extract_value(char *line, bool is_value)
|
||||||
{
|
{
|
||||||
|
char *save = NULL, *tok = NULL;
|
||||||
|
|
||||||
if (is_value)
|
if (is_value)
|
||||||
{
|
{
|
||||||
while (isspace(*line))
|
while (isspace(*line))
|
||||||
@ -98,9 +100,6 @@ static char *extract_value(char *line, bool is_value)
|
|||||||
while (isspace(*line))
|
while (isspace(*line))
|
||||||
line++;
|
line++;
|
||||||
|
|
||||||
char *save;
|
|
||||||
char *tok;
|
|
||||||
|
|
||||||
/* We have a full string. Read until next ". */
|
/* We have a full string. Read until next ". */
|
||||||
if (*line == '"')
|
if (*line == '"')
|
||||||
{
|
{
|
||||||
@ -186,12 +185,13 @@ static void add_include_list(config_file_t *conf, const char *path)
|
|||||||
|
|
||||||
static void add_sub_conf(config_file_t *conf, char *line)
|
static void add_sub_conf(config_file_t *conf, char *line)
|
||||||
{
|
{
|
||||||
|
char real_path[PATH_MAX];
|
||||||
|
config_file_t *sub_conf = NULL;
|
||||||
char *path = extract_value(line, false);
|
char *path = extract_value(line, false);
|
||||||
if (!path)
|
if (!path)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
add_include_list(conf, path);
|
add_include_list(conf, path);
|
||||||
char real_path[PATH_MAX];
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
fill_pathname_resolve_relative(real_path, conf->path,
|
fill_pathname_resolve_relative(real_path, conf->path,
|
||||||
@ -210,7 +210,7 @@ static void add_sub_conf(config_file_t *conf, char *line)
|
|||||||
path, sizeof(real_path));
|
path, sizeof(real_path));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
config_file_t *sub_conf = (config_file_t*)
|
sub_conf = (config_file_t*)
|
||||||
config_file_new_internal(real_path, conf->include_depth + 1);
|
config_file_new_internal(real_path, conf->include_depth + 1);
|
||||||
if (!sub_conf)
|
if (!sub_conf)
|
||||||
{
|
{
|
||||||
@ -233,10 +233,11 @@ static char *strip_comment(char *str)
|
|||||||
|
|
||||||
while (*str)
|
while (*str)
|
||||||
{
|
{
|
||||||
|
char *comment = NULL;
|
||||||
char *literal = strchr(str, '\"');
|
char *literal = strchr(str, '\"');
|
||||||
if (!literal)
|
if (!literal)
|
||||||
literal = strend;
|
literal = strend;
|
||||||
char *comment = strchr(str, '#');
|
comment = (char*)strchr(str, '#');
|
||||||
if (!comment)
|
if (!comment)
|
||||||
comment = strend;
|
comment = strend;
|
||||||
|
|
||||||
@ -354,6 +355,7 @@ bool config_append_file(config_file_t *conf, const char *path)
|
|||||||
static config_file_t *config_file_new_internal(
|
static config_file_t *config_file_new_internal(
|
||||||
const char *path, unsigned depth)
|
const char *path, unsigned depth)
|
||||||
{
|
{
|
||||||
|
FILE *file = NULL;
|
||||||
struct config_file *conf = (struct config_file*)calloc(1, sizeof(*conf));
|
struct config_file *conf = (struct config_file*)calloc(1, sizeof(*conf));
|
||||||
if (!conf)
|
if (!conf)
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -369,7 +371,7 @@ static config_file_t *config_file_new_internal(
|
|||||||
}
|
}
|
||||||
|
|
||||||
conf->include_depth = depth;
|
conf->include_depth = depth;
|
||||||
FILE *file = fopen(path, "r");
|
file = fopen(path, "r");
|
||||||
|
|
||||||
if (!file)
|
if (!file)
|
||||||
{
|
{
|
||||||
@ -419,6 +421,7 @@ static config_file_t *config_file_new_internal(
|
|||||||
config_file_t *config_file_new_from_string(const char *from_string)
|
config_file_t *config_file_new_from_string(const char *from_string)
|
||||||
{
|
{
|
||||||
size_t i;
|
size_t i;
|
||||||
|
struct string_list *lines = NULL;
|
||||||
struct config_file *conf = (struct config_file*)calloc(1, sizeof(*conf));
|
struct config_file *conf = (struct config_file*)calloc(1, sizeof(*conf));
|
||||||
if (!conf)
|
if (!conf)
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -429,7 +432,7 @@ config_file_t *config_file_new_from_string(const char *from_string)
|
|||||||
conf->path = NULL;
|
conf->path = NULL;
|
||||||
conf->include_depth = 0;
|
conf->include_depth = 0;
|
||||||
|
|
||||||
struct string_list *lines = string_split(from_string, "\n");
|
lines = string_split(from_string, "\n");
|
||||||
if (!lines)
|
if (!lines)
|
||||||
return conf;
|
return conf;
|
||||||
|
|
||||||
@ -475,24 +478,27 @@ config_file_t *config_file_new(const char *path)
|
|||||||
|
|
||||||
void config_file_free(config_file_t *conf)
|
void config_file_free(config_file_t *conf)
|
||||||
{
|
{
|
||||||
|
struct config_include_list *inc_tmp = NULL, *hold = NULL;
|
||||||
|
struct config_entry_list *tmp = NULL;
|
||||||
if (!conf)
|
if (!conf)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
struct config_entry_list *tmp = conf->entries;
|
tmp = conf->entries;
|
||||||
while (tmp)
|
while (tmp)
|
||||||
{
|
{
|
||||||
|
struct config_entry_list *hold = NULL;
|
||||||
free(tmp->key);
|
free(tmp->key);
|
||||||
free(tmp->value);
|
free(tmp->value);
|
||||||
struct config_entry_list *hold = tmp;
|
hold = tmp;
|
||||||
tmp = tmp->next;
|
tmp = tmp->next;
|
||||||
free(hold);
|
free(hold);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct config_include_list *inc_tmp = conf->includes;
|
inc_tmp = (struct config_include_list*)conf->includes;
|
||||||
while (inc_tmp)
|
while (inc_tmp)
|
||||||
{
|
{
|
||||||
free(inc_tmp->path);
|
free(inc_tmp->path);
|
||||||
struct config_include_list *hold = inc_tmp;
|
hold = (struct config_include_list*)inc_tmp;
|
||||||
inc_tmp = inc_tmp->next;
|
inc_tmp = inc_tmp->next;
|
||||||
free(hold);
|
free(hold);
|
||||||
}
|
}
|
||||||
@ -542,8 +548,9 @@ bool config_get_int(config_file_t *conf, const char *key, int *in)
|
|||||||
{
|
{
|
||||||
if (strcmp(key, list->key) == 0)
|
if (strcmp(key, list->key) == 0)
|
||||||
{
|
{
|
||||||
|
int val;
|
||||||
errno = 0;
|
errno = 0;
|
||||||
int val = strtol(list->value, NULL, 0);
|
val = strtol(list->value, NULL, 0);
|
||||||
if (errno == 0)
|
if (errno == 0)
|
||||||
{
|
{
|
||||||
*in = val;
|
*in = val;
|
||||||
@ -564,8 +571,9 @@ bool config_get_uint64(config_file_t *conf, const char *key, uint64_t *in)
|
|||||||
{
|
{
|
||||||
if (strcmp(key, list->key) == 0)
|
if (strcmp(key, list->key) == 0)
|
||||||
{
|
{
|
||||||
|
uint64_t val;
|
||||||
errno = 0;
|
errno = 0;
|
||||||
uint64_t val = strtoull(list->value, NULL, 0);
|
val = strtoull(list->value, NULL, 0);
|
||||||
if (errno == 0)
|
if (errno == 0)
|
||||||
{
|
{
|
||||||
*in = val;
|
*in = val;
|
||||||
@ -586,8 +594,9 @@ bool config_get_uint(config_file_t *conf, const char *key, unsigned *in)
|
|||||||
{
|
{
|
||||||
if (strcmp(key, list->key) == 0)
|
if (strcmp(key, list->key) == 0)
|
||||||
{
|
{
|
||||||
|
unsigned val;
|
||||||
errno = 0;
|
errno = 0;
|
||||||
unsigned val = strtoul(list->value, NULL, 0);
|
val = strtoul(list->value, NULL, 0);
|
||||||
if (errno == 0)
|
if (errno == 0)
|
||||||
{
|
{
|
||||||
*in = val;
|
*in = val;
|
||||||
@ -609,8 +618,9 @@ bool config_get_hex(config_file_t *conf, const char *key, unsigned *in)
|
|||||||
{
|
{
|
||||||
if (strcmp(key, list->key) == 0)
|
if (strcmp(key, list->key) == 0)
|
||||||
{
|
{
|
||||||
|
unsigned val;
|
||||||
errno = 0;
|
errno = 0;
|
||||||
unsigned val = strtoul(list->value, NULL, 16);
|
val = strtoul(list->value, NULL, 16);
|
||||||
if (errno == 0)
|
if (errno == 0)
|
||||||
{
|
{
|
||||||
*in = val;
|
*in = val;
|
||||||
@ -720,6 +730,7 @@ bool config_get_bool(config_file_t *conf, const char *key, bool *in)
|
|||||||
|
|
||||||
void config_set_string(config_file_t *conf, const char *key, const char *val)
|
void config_set_string(config_file_t *conf, const char *key, const char *val)
|
||||||
{
|
{
|
||||||
|
struct config_entry_list *elem = NULL;
|
||||||
struct config_entry_list *list = conf->entries;
|
struct config_entry_list *list = conf->entries;
|
||||||
struct config_entry_list *last = list;
|
struct config_entry_list *last = list;
|
||||||
while (list)
|
while (list)
|
||||||
@ -735,8 +746,7 @@ void config_set_string(config_file_t *conf, const char *key, const char *val)
|
|||||||
list = list->next;
|
list = list->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct config_entry_list *elem = (struct config_entry_list*)
|
elem = (struct config_entry_list*)calloc(1, sizeof(*elem));
|
||||||
calloc(1, sizeof(*elem));
|
|
||||||
|
|
||||||
if (!elem)
|
if (!elem)
|
||||||
return;
|
return;
|
||||||
@ -839,6 +849,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 config_entry_list *list = NULL;
|
||||||
struct config_include_list *includes = conf->includes;
|
struct config_include_list *includes = conf->includes;
|
||||||
while (includes)
|
while (includes)
|
||||||
{
|
{
|
||||||
@ -846,7 +857,7 @@ void config_file_dump(config_file_t *conf, FILE *file)
|
|||||||
includes = includes->next;
|
includes = includes->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct config_entry_list *list = conf->entries;
|
list = (struct config_entry_list*)conf->entries;
|
||||||
while (list)
|
while (list)
|
||||||
{
|
{
|
||||||
if (!list->readonly)
|
if (!list->readonly)
|
||||||
|
@ -272,39 +272,6 @@
|
|||||||
Name="Source Files"
|
Name="Source Files"
|
||||||
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
|
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
|
||||||
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}">
|
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}">
|
||||||
<File
|
|
||||||
RelativePath="..\..\conf\config_file.c">
|
|
||||||
<FileConfiguration
|
|
||||||
Name="Debug|Xbox">
|
|
||||||
<Tool
|
|
||||||
Name="VCCLCompilerTool"
|
|
||||||
CompileAs="2"/>
|
|
||||||
</FileConfiguration>
|
|
||||||
<FileConfiguration
|
|
||||||
Name="Profile|Xbox">
|
|
||||||
<Tool
|
|
||||||
Name="VCCLCompilerTool"
|
|
||||||
CompileAs="2"/>
|
|
||||||
</FileConfiguration>
|
|
||||||
<FileConfiguration
|
|
||||||
Name="Profile_FastCap|Xbox">
|
|
||||||
<Tool
|
|
||||||
Name="VCCLCompilerTool"
|
|
||||||
CompileAs="2"/>
|
|
||||||
</FileConfiguration>
|
|
||||||
<FileConfiguration
|
|
||||||
Name="Release|Xbox">
|
|
||||||
<Tool
|
|
||||||
Name="VCCLCompilerTool"
|
|
||||||
CompileAs="2"/>
|
|
||||||
</FileConfiguration>
|
|
||||||
<FileConfiguration
|
|
||||||
Name="Release_LTCG|Xbox">
|
|
||||||
<Tool
|
|
||||||
Name="VCCLCompilerTool"
|
|
||||||
CompileAs="2"/>
|
|
||||||
</FileConfiguration>
|
|
||||||
</File>
|
|
||||||
<File
|
<File
|
||||||
RelativePath="..\..\frontend\frontend_context.c">
|
RelativePath="..\..\frontend\frontend_context.c">
|
||||||
<FileConfiguration
|
<FileConfiguration
|
||||||
@ -420,6 +387,9 @@
|
|||||||
<Filter
|
<Filter
|
||||||
Name="file"
|
Name="file"
|
||||||
Filter="">
|
Filter="">
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\libretro-sdk\file\config_file.c">
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\..\libretro-sdk\file\dir_list.c">
|
RelativePath="..\..\libretro-sdk\file\dir_list.c">
|
||||||
<FileConfiguration
|
<FileConfiguration
|
||||||
|
Loading…
x
Reference in New Issue
Block a user