2012-04-21 21:13:50 +00:00
|
|
|
/* RetroArch - A frontend for libretro.
|
2014-01-01 00:50:59 +00:00
|
|
|
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
|
2010-12-30 00:50:37 +00:00
|
|
|
*
|
2012-04-21 21:13:50 +00:00
|
|
|
* RetroArch is free software: you can redistribute it and/or modify it under the terms
|
2010-12-30 00:50:37 +00:00
|
|
|
* of the GNU General Public License as published by the Free Software Found-
|
|
|
|
* ation, either version 3 of the License, or (at your option) any later version.
|
|
|
|
*
|
2012-04-21 21:13:50 +00:00
|
|
|
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
2010-12-30 00:50:37 +00:00
|
|
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
|
|
|
* PURPOSE. See the GNU General Public License for more details.
|
|
|
|
*
|
2012-04-21 21:31:57 +00:00
|
|
|
* You should have received a copy of the GNU General Public License along with RetroArch.
|
2010-12-30 00:50:37 +00:00
|
|
|
* If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2010-12-29 13:27:44 +00:00
|
|
|
#include "config_file.h"
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <ctype.h>
|
2011-09-05 15:00:28 +00:00
|
|
|
#include <errno.h>
|
2012-03-16 22:26:57 +00:00
|
|
|
#include "../compat/strl.h"
|
|
|
|
#include "../compat/posix_string.h"
|
2011-12-24 23:59:46 +00:00
|
|
|
#include "../msvc/msvc_compat.h"
|
2012-11-18 16:08:28 +00:00
|
|
|
#include "../file.h"
|
2014-06-01 10:06:01 +00:00
|
|
|
#include "../miscellaneous.h"
|
2014-06-11 12:19:34 +00:00
|
|
|
#include "../general.h"
|
2011-01-09 01:58:26 +00:00
|
|
|
|
2012-01-05 21:46:11 +00:00
|
|
|
#if !defined(_WIN32) && !defined(__CELLOS_LV2__) && !defined(_XBOX)
|
2014-09-02 17:20:03 +00:00
|
|
|
#include <sys/param.h> /* PATH_MAX */
|
2012-01-05 21:46:11 +00:00
|
|
|
#elif defined(_WIN32) && !defined(_XBOX)
|
2011-10-17 17:30:52 +00:00
|
|
|
#define WIN32_LEAN_AND_MEAN
|
|
|
|
#include <windows.h>
|
2012-01-05 21:46:11 +00:00
|
|
|
#elif defined(_XBOX)
|
|
|
|
#include <xtl.h>
|
2011-10-17 17:11:31 +00:00
|
|
|
#endif
|
|
|
|
|
2011-10-17 18:09:57 +00:00
|
|
|
#define MAX_INCLUDE_DEPTH 16
|
2011-10-17 17:11:31 +00:00
|
|
|
|
2012-11-23 21:46:21 +00:00
|
|
|
struct config_entry_list
|
2010-12-29 13:27:44 +00:00
|
|
|
{
|
2014-09-02 17:20:03 +00:00
|
|
|
/* If we got this from an #include,
|
|
|
|
* do not allow overwrite. */
|
|
|
|
bool readonly;
|
2010-12-29 13:27:44 +00:00
|
|
|
char *key;
|
|
|
|
char *value;
|
2012-11-23 21:46:21 +00:00
|
|
|
struct config_entry_list *next;
|
2010-12-29 13:27:44 +00:00
|
|
|
};
|
|
|
|
|
2011-10-17 17:11:31 +00:00
|
|
|
struct include_list
|
|
|
|
{
|
|
|
|
char *path;
|
|
|
|
struct include_list *next;
|
|
|
|
};
|
|
|
|
|
2010-12-29 13:27:44 +00:00
|
|
|
struct config_file
|
|
|
|
{
|
2011-10-17 17:11:31 +00:00
|
|
|
char *path;
|
2012-11-23 21:46:21 +00:00
|
|
|
struct config_entry_list *entries;
|
|
|
|
struct config_entry_list *tail;
|
2011-10-17 18:09:57 +00:00
|
|
|
unsigned include_depth;
|
2011-10-17 17:11:31 +00:00
|
|
|
|
|
|
|
struct include_list *includes;
|
2010-12-29 13:27:44 +00:00
|
|
|
};
|
|
|
|
|
2014-09-14 22:20:13 +00:00
|
|
|
static config_file_t *config_file_new_internal(const char *path, unsigned depth);
|
|
|
|
void config_file_free(config_file_t *conf);
|
2011-10-17 17:11:31 +00:00
|
|
|
|
2010-12-29 13:27:44 +00:00
|
|
|
static char *getaline(FILE *file)
|
|
|
|
{
|
2014-09-14 22:20:13 +00:00
|
|
|
char* newline = (char*)malloc(9);
|
|
|
|
char* newline_tmp = NULL;
|
2010-12-29 13:27:44 +00:00
|
|
|
size_t cur_size = 8;
|
|
|
|
size_t index = 0;
|
|
|
|
int in = getc(file);
|
2014-09-14 22:20:13 +00:00
|
|
|
|
|
|
|
if (!newline)
|
|
|
|
return NULL;
|
|
|
|
|
2010-12-29 13:27:44 +00:00
|
|
|
while (in != EOF && in != '\n')
|
|
|
|
{
|
|
|
|
if (index == cur_size)
|
|
|
|
{
|
|
|
|
cur_size *= 2;
|
2014-09-15 00:18:39 +00:00
|
|
|
newline_tmp = (char*)realloc(newline, cur_size + 1);
|
2014-09-14 22:20:13 +00:00
|
|
|
|
2014-09-19 07:22:25 +00:00
|
|
|
if (!newline_tmp)
|
2014-09-14 22:20:13 +00:00
|
|
|
{
|
|
|
|
free(newline);
|
|
|
|
return NULL;
|
|
|
|
}
|
2014-09-19 07:22:25 +00:00
|
|
|
|
|
|
|
newline = newline_tmp;
|
2010-12-29 13:27:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
newline[index++] = in;
|
|
|
|
in = getc(file);
|
|
|
|
}
|
2010-12-29 16:52:53 +00:00
|
|
|
newline[index] = '\0';
|
2010-12-29 13:27:44 +00:00
|
|
|
return newline;
|
|
|
|
}
|
|
|
|
|
2011-11-02 18:31:36 +00:00
|
|
|
static char *extract_value(char *line, bool is_value)
|
2011-10-17 17:11:31 +00:00
|
|
|
{
|
|
|
|
if (is_value)
|
|
|
|
{
|
|
|
|
while (isspace(*line))
|
|
|
|
line++;
|
|
|
|
|
2014-09-02 17:20:03 +00:00
|
|
|
/* If we don't have an equal sign here,
|
|
|
|
* we've got an invalid string. */
|
2011-10-17 17:11:31 +00:00
|
|
|
if (*line != '=')
|
2011-12-24 12:46:12 +00:00
|
|
|
return NULL;
|
2011-10-17 17:11:31 +00:00
|
|
|
|
|
|
|
line++;
|
|
|
|
}
|
|
|
|
|
|
|
|
while (isspace(*line))
|
|
|
|
line++;
|
|
|
|
|
2012-06-24 00:11:22 +00:00
|
|
|
char *save;
|
2013-02-25 01:36:42 +00:00
|
|
|
char *tok;
|
2012-06-24 00:11:22 +00:00
|
|
|
|
2014-09-02 17:20:03 +00:00
|
|
|
/* We have a full string. Read until next ". */
|
2011-10-17 17:11:31 +00:00
|
|
|
if (*line == '"')
|
|
|
|
{
|
|
|
|
line++;
|
2013-02-25 01:36:42 +00:00
|
|
|
tok = strtok_r(line, "\"", &save);
|
2011-10-17 17:11:31 +00:00
|
|
|
if (!tok)
|
2011-12-24 12:46:12 +00:00
|
|
|
return NULL;
|
2011-10-17 17:11:31 +00:00
|
|
|
return strdup(tok);
|
|
|
|
}
|
2014-09-02 17:20:03 +00:00
|
|
|
else if (*line == '\0') /* Nothing */
|
2011-10-17 17:11:31 +00:00
|
|
|
return NULL;
|
2014-09-02 17:20:03 +00:00
|
|
|
|
|
|
|
/* We don't have that. Read until next space. */
|
|
|
|
tok = strtok_r(line, " \n\t\f\r\v", &save);
|
|
|
|
if (tok)
|
|
|
|
return strdup(tok);
|
|
|
|
return NULL;
|
2011-10-17 17:11:31 +00:00
|
|
|
}
|
|
|
|
|
2012-11-23 21:46:21 +00:00
|
|
|
static void set_list_readonly(struct config_entry_list *list)
|
2011-10-17 17:11:31 +00:00
|
|
|
{
|
|
|
|
while (list)
|
|
|
|
{
|
|
|
|
list->readonly = true;
|
|
|
|
list = list->next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-09-02 17:20:03 +00:00
|
|
|
/* Move semantics? */
|
2011-10-17 17:11:31 +00:00
|
|
|
static void add_child_list(config_file_t *parent, config_file_t *child)
|
|
|
|
{
|
|
|
|
if (parent->entries)
|
|
|
|
{
|
2012-11-23 21:46:21 +00:00
|
|
|
struct config_entry_list *head = parent->entries;
|
2011-10-17 17:11:31 +00:00
|
|
|
while (head->next)
|
|
|
|
head = head->next;
|
|
|
|
|
|
|
|
set_list_readonly(child->entries);
|
|
|
|
head->next = child->entries;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
set_list_readonly(child->entries);
|
|
|
|
parent->entries = child->entries;
|
|
|
|
}
|
|
|
|
|
|
|
|
child->entries = NULL;
|
|
|
|
|
2014-09-02 17:20:03 +00:00
|
|
|
/* Rebase tail. */
|
2011-10-17 17:11:31 +00:00
|
|
|
if (parent->entries)
|
|
|
|
{
|
2014-09-19 07:22:25 +00:00
|
|
|
struct config_entry_list *head =
|
|
|
|
(struct config_entry_list*)parent->entries;
|
|
|
|
|
2011-10-17 17:11:31 +00:00
|
|
|
while (head->next)
|
|
|
|
head = head->next;
|
|
|
|
parent->tail = head;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
parent->tail = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void add_include_list(config_file_t *conf, const char *path)
|
|
|
|
{
|
|
|
|
struct include_list *head = conf->includes;
|
2011-12-24 12:46:12 +00:00
|
|
|
struct include_list *node = (struct include_list*)calloc(1, sizeof(*node));
|
2014-09-14 22:20:13 +00:00
|
|
|
|
|
|
|
if (!node)
|
|
|
|
return;
|
|
|
|
|
2011-10-17 17:11:31 +00:00
|
|
|
node->path = strdup(path);
|
|
|
|
|
|
|
|
if (head)
|
|
|
|
{
|
|
|
|
while (head->next)
|
|
|
|
head = head->next;
|
|
|
|
|
|
|
|
head->next = node;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
conf->includes = node;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void add_sub_conf(config_file_t *conf, char *line)
|
|
|
|
{
|
|
|
|
char *path = extract_value(line, false);
|
|
|
|
if (!path)
|
|
|
|
return;
|
|
|
|
|
|
|
|
add_include_list(conf, path);
|
2012-01-02 12:32:25 +00:00
|
|
|
char real_path[PATH_MAX];
|
2011-10-17 17:11:31 +00:00
|
|
|
|
2011-12-02 20:24:33 +00:00
|
|
|
#ifdef _WIN32
|
2014-09-02 17:20:03 +00:00
|
|
|
fill_pathname_resolve_relative(real_path, conf->path,
|
|
|
|
path, sizeof(real_path));
|
2011-12-02 20:24:33 +00:00
|
|
|
#else
|
|
|
|
#ifndef __CELLOS_LV2__
|
2012-11-18 16:08:28 +00:00
|
|
|
if (*path == '~')
|
2011-10-17 17:11:31 +00:00
|
|
|
{
|
|
|
|
const char *home = getenv("HOME");
|
2012-11-18 16:08:28 +00:00
|
|
|
strlcpy(real_path, home ? home : "", sizeof(real_path));
|
2011-10-17 17:11:31 +00:00
|
|
|
strlcat(real_path, path + 1, sizeof(real_path));
|
|
|
|
}
|
|
|
|
else
|
2012-11-18 16:08:28 +00:00
|
|
|
#endif
|
2014-09-02 17:20:03 +00:00
|
|
|
fill_pathname_resolve_relative(real_path, conf->path,
|
|
|
|
path, sizeof(real_path));
|
2011-10-17 17:11:31 +00:00
|
|
|
#endif
|
|
|
|
|
2014-09-02 17:20:03 +00:00
|
|
|
config_file_t *sub_conf = (config_file_t*)
|
|
|
|
config_file_new_internal(real_path, conf->include_depth + 1);
|
2011-10-17 17:30:52 +00:00
|
|
|
if (!sub_conf)
|
2011-10-17 17:11:31 +00:00
|
|
|
{
|
|
|
|
free(path);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-09-02 17:20:03 +00:00
|
|
|
/* Pilfer internal list. */
|
2011-10-17 17:11:31 +00:00
|
|
|
add_child_list(conf, sub_conf);
|
|
|
|
config_file_free(sub_conf);
|
|
|
|
free(path);
|
|
|
|
}
|
|
|
|
|
2013-10-24 21:27:47 +00:00
|
|
|
static char *strip_comment(char *str)
|
|
|
|
{
|
2014-09-02 17:20:03 +00:00
|
|
|
/* Remove everything after comment.
|
|
|
|
* Keep #s inside string literals. */
|
2013-10-24 21:27:47 +00:00
|
|
|
char *strend = str + strlen(str);
|
|
|
|
bool cut_comment = true;
|
|
|
|
|
|
|
|
while (*str)
|
|
|
|
{
|
|
|
|
char *literal = strchr(str, '\"');
|
|
|
|
if (!literal)
|
|
|
|
literal = strend;
|
|
|
|
char *comment = strchr(str, '#');
|
|
|
|
if (!comment)
|
|
|
|
comment = strend;
|
|
|
|
|
|
|
|
if (cut_comment && literal < comment)
|
|
|
|
{
|
|
|
|
cut_comment = false;
|
|
|
|
str = literal + 1;
|
|
|
|
}
|
|
|
|
else if (!cut_comment && literal)
|
|
|
|
{
|
|
|
|
cut_comment = true;
|
|
|
|
str = literal + 1;
|
|
|
|
}
|
|
|
|
else if (comment)
|
|
|
|
{
|
|
|
|
*comment = '\0';
|
|
|
|
str = comment;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
str = strend;
|
|
|
|
}
|
|
|
|
|
|
|
|
return str;
|
|
|
|
}
|
|
|
|
|
2014-09-02 17:20:03 +00:00
|
|
|
static bool parse_line(config_file_t *conf,
|
|
|
|
struct config_entry_list *list, char *line)
|
2010-12-29 13:27:44 +00:00
|
|
|
{
|
2014-09-14 22:20:13 +00:00
|
|
|
char* comment = NULL;
|
|
|
|
char* key = (char*)malloc(9);
|
|
|
|
char* key_tmp = NULL;
|
|
|
|
size_t cur_size = 8;
|
|
|
|
size_t index = 0;
|
|
|
|
|
2014-09-15 15:20:05 +00:00
|
|
|
if (!key)
|
2014-09-14 22:20:13 +00:00
|
|
|
return false;
|
|
|
|
|
2014-09-15 15:20:05 +00:00
|
|
|
if (!line || !*line)
|
|
|
|
{
|
|
|
|
free(key);
|
2013-10-24 21:47:11 +00:00
|
|
|
return false;
|
2014-09-15 15:20:05 +00:00
|
|
|
}
|
2013-10-24 21:47:11 +00:00
|
|
|
|
2014-09-14 22:20:13 +00:00
|
|
|
comment = strip_comment(line);
|
2010-12-29 13:27:44 +00:00
|
|
|
|
2014-09-02 17:20:03 +00:00
|
|
|
/* Starting line with # and include includes config files. */
|
2011-10-17 18:09:57 +00:00
|
|
|
if ((comment == line) && (conf->include_depth < MAX_INCLUDE_DEPTH))
|
2011-10-17 17:11:31 +00:00
|
|
|
{
|
|
|
|
comment++;
|
|
|
|
if (strstr(comment, "include ") == comment)
|
|
|
|
{
|
|
|
|
add_sub_conf(conf, comment + strlen("include "));
|
2014-09-15 15:20:05 +00:00
|
|
|
free(key);
|
2011-10-17 17:11:31 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
2011-10-17 18:09:57 +00:00
|
|
|
else if (conf->include_depth >= MAX_INCLUDE_DEPTH)
|
2014-09-14 22:20:13 +00:00
|
|
|
{
|
2012-02-11 20:11:36 +00:00
|
|
|
fprintf(stderr, "!!! #include depth exceeded for config. Might be a cycle.\n");
|
2014-09-14 22:20:13 +00:00
|
|
|
}
|
2011-10-17 17:11:31 +00:00
|
|
|
|
2014-09-02 17:20:03 +00:00
|
|
|
/* Skips to first character. */
|
2010-12-29 13:27:44 +00:00
|
|
|
while (isspace(*line))
|
|
|
|
line++;
|
|
|
|
|
|
|
|
while (isgraph(*line))
|
|
|
|
{
|
|
|
|
if (index == cur_size)
|
|
|
|
{
|
|
|
|
cur_size *= 2;
|
2014-09-14 22:20:13 +00:00
|
|
|
key_tmp = (char*)realloc(key, cur_size + 1);
|
|
|
|
|
2014-09-19 07:22:25 +00:00
|
|
|
if (!key_tmp)
|
2014-09-14 22:20:13 +00:00
|
|
|
{
|
|
|
|
free(key);
|
|
|
|
return false;
|
|
|
|
}
|
2014-09-19 07:22:25 +00:00
|
|
|
|
|
|
|
key = key_tmp;
|
2010-12-29 13:27:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
key[index++] = *line++;
|
|
|
|
}
|
2010-12-29 16:52:53 +00:00
|
|
|
key[index] = '\0';
|
2010-12-29 13:27:44 +00:00
|
|
|
list->key = key;
|
|
|
|
|
2011-10-17 17:11:31 +00:00
|
|
|
list->value = extract_value(line, true);
|
|
|
|
if (!list->value)
|
2010-12-29 13:27:44 +00:00
|
|
|
{
|
|
|
|
list->key = NULL;
|
|
|
|
free(key);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-09-10 22:10:44 +00:00
|
|
|
bool config_append_file(config_file_t *conf, const char *path)
|
|
|
|
{
|
|
|
|
config_file_t *new_conf = config_file_new(path);
|
|
|
|
if (!new_conf)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if (new_conf->tail)
|
|
|
|
{
|
|
|
|
new_conf->tail->next = conf->entries;
|
2014-09-02 17:20:03 +00:00
|
|
|
conf->entries = new_conf->entries; /* Pilfer. */
|
2012-09-10 22:10:44 +00:00
|
|
|
new_conf->entries = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
config_file_free(new_conf);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-09-02 17:20:03 +00:00
|
|
|
static config_file_t *config_file_new_internal(
|
|
|
|
const char *path, unsigned depth)
|
2010-12-29 13:27:44 +00:00
|
|
|
{
|
2011-12-24 12:46:12 +00:00
|
|
|
struct config_file *conf = (struct config_file*)calloc(1, sizeof(*conf));
|
2011-10-17 17:11:31 +00:00
|
|
|
if (!conf)
|
2010-12-29 13:27:44 +00:00
|
|
|
return NULL;
|
|
|
|
|
2011-10-17 17:11:31 +00:00
|
|
|
if (!path)
|
2011-01-09 01:58:26 +00:00
|
|
|
return conf;
|
|
|
|
|
2011-10-17 17:11:31 +00:00
|
|
|
conf->path = strdup(path);
|
|
|
|
if (!conf->path)
|
|
|
|
{
|
|
|
|
free(conf);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2011-10-17 18:09:57 +00:00
|
|
|
conf->include_depth = depth;
|
2012-08-06 22:23:25 +00:00
|
|
|
FILE *file = fopen(path, "r");
|
2012-07-29 16:17:53 +00:00
|
|
|
|
2012-07-30 05:58:07 +00:00
|
|
|
if (!file)
|
2011-01-09 01:58:26 +00:00
|
|
|
{
|
2011-10-17 17:11:31 +00:00
|
|
|
free(conf->path);
|
2011-01-09 01:58:26 +00:00
|
|
|
free(conf);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2010-12-29 13:27:44 +00:00
|
|
|
while (!feof(file))
|
|
|
|
{
|
2014-09-02 17:20:03 +00:00
|
|
|
struct config_entry_list *list = (struct config_entry_list*)
|
|
|
|
calloc(1, sizeof(*list));
|
2014-09-14 22:20:13 +00:00
|
|
|
char *line = NULL;
|
|
|
|
|
|
|
|
if (!list)
|
|
|
|
{
|
|
|
|
config_file_free(conf);
|
|
|
|
fclose(file);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
line = getaline(file);
|
2010-12-29 13:27:44 +00:00
|
|
|
|
|
|
|
if (line)
|
|
|
|
{
|
2011-10-17 17:11:31 +00:00
|
|
|
if (parse_line(conf, list, line))
|
2010-12-29 13:27:44 +00:00
|
|
|
{
|
2011-10-17 17:11:31 +00:00
|
|
|
if (conf->entries)
|
|
|
|
conf->tail->next = list;
|
2010-12-29 13:27:44 +00:00
|
|
|
else
|
2011-10-17 17:11:31 +00:00
|
|
|
conf->entries = list;
|
2014-09-14 22:20:13 +00:00
|
|
|
|
2014-09-02 17:20:03 +00:00
|
|
|
conf->tail = list;
|
2010-12-29 13:27:44 +00:00
|
|
|
}
|
2011-10-17 17:11:31 +00:00
|
|
|
|
2010-12-29 13:27:44 +00:00
|
|
|
free(line);
|
|
|
|
}
|
2011-10-17 17:11:31 +00:00
|
|
|
|
|
|
|
if (list != conf->tail)
|
|
|
|
free(list);
|
2010-12-29 13:27:44 +00:00
|
|
|
}
|
|
|
|
fclose(file);
|
|
|
|
|
|
|
|
return conf;
|
|
|
|
}
|
|
|
|
|
2013-09-04 20:57:13 +00:00
|
|
|
config_file_t *config_file_new_from_string(const char *from_string)
|
|
|
|
{
|
2013-10-19 17:39:38 +00:00
|
|
|
size_t i;
|
2013-09-04 20:57:13 +00:00
|
|
|
struct config_file *conf = (struct config_file*)calloc(1, sizeof(*conf));
|
|
|
|
if (!conf)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
if (!from_string)
|
|
|
|
return conf;
|
|
|
|
|
|
|
|
conf->path = NULL;
|
|
|
|
conf->include_depth = 0;
|
|
|
|
|
2013-09-06 12:36:29 +00:00
|
|
|
struct string_list *lines = string_split(from_string, "\n");
|
|
|
|
if (!lines)
|
|
|
|
return conf;
|
2013-09-04 20:57:13 +00:00
|
|
|
|
2013-10-19 17:39:38 +00:00
|
|
|
for (i = 0; i < lines->size; i++)
|
2013-09-04 20:57:13 +00:00
|
|
|
{
|
2014-09-02 17:20:03 +00:00
|
|
|
struct config_entry_list *list = (struct config_entry_list*)
|
|
|
|
calloc(1, sizeof(*list));
|
2013-09-06 12:36:29 +00:00
|
|
|
char* line = lines->elems[i].data;
|
2014-09-14 22:20:13 +00:00
|
|
|
|
|
|
|
if (!list)
|
|
|
|
{
|
2014-09-15 00:18:39 +00:00
|
|
|
string_list_free(lines);
|
2014-09-14 22:20:13 +00:00
|
|
|
config_file_free(conf);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2013-09-04 20:57:13 +00:00
|
|
|
if (line)
|
|
|
|
{
|
|
|
|
if (parse_line(conf, list, line))
|
|
|
|
{
|
|
|
|
if (conf->entries)
|
|
|
|
conf->tail->next = list;
|
|
|
|
else
|
|
|
|
conf->entries = list;
|
2014-09-14 22:20:13 +00:00
|
|
|
|
2014-09-02 17:20:03 +00:00
|
|
|
conf->tail = list;
|
2013-09-04 20:57:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (list != conf->tail)
|
|
|
|
free(list);
|
|
|
|
}
|
2014-09-15 00:18:39 +00:00
|
|
|
|
2013-09-06 12:36:29 +00:00
|
|
|
string_list_free(lines);
|
2013-09-04 20:57:13 +00:00
|
|
|
|
|
|
|
return conf;
|
|
|
|
}
|
|
|
|
|
2011-10-17 17:11:31 +00:00
|
|
|
config_file_t *config_file_new(const char *path)
|
|
|
|
{
|
2012-07-30 05:58:07 +00:00
|
|
|
return config_file_new_internal(path, 0);
|
2011-10-17 17:11:31 +00:00
|
|
|
}
|
|
|
|
|
2010-12-29 13:27:44 +00:00
|
|
|
void config_file_free(config_file_t *conf)
|
|
|
|
{
|
2011-10-17 17:11:31 +00:00
|
|
|
if (!conf)
|
|
|
|
return;
|
|
|
|
|
2012-11-23 21:46:21 +00:00
|
|
|
struct config_entry_list *tmp = conf->entries;
|
2011-10-17 17:11:31 +00:00
|
|
|
while (tmp)
|
2010-12-29 13:27:44 +00:00
|
|
|
{
|
2011-10-17 17:11:31 +00:00
|
|
|
free(tmp->key);
|
|
|
|
free(tmp->value);
|
2012-11-23 21:46:21 +00:00
|
|
|
struct config_entry_list *hold = tmp;
|
2011-10-17 17:11:31 +00:00
|
|
|
tmp = tmp->next;
|
|
|
|
free(hold);
|
2010-12-29 13:27:44 +00:00
|
|
|
}
|
2011-10-17 17:11:31 +00:00
|
|
|
|
|
|
|
struct include_list *inc_tmp = conf->includes;
|
|
|
|
while (inc_tmp)
|
|
|
|
{
|
|
|
|
free(inc_tmp->path);
|
|
|
|
struct include_list *hold = inc_tmp;
|
|
|
|
inc_tmp = inc_tmp->next;
|
|
|
|
free(hold);
|
|
|
|
}
|
|
|
|
|
|
|
|
free(conf->path);
|
|
|
|
free(conf);
|
2010-12-29 13:27:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool config_get_double(config_file_t *conf, const char *key, double *in)
|
|
|
|
{
|
2012-11-23 21:46:21 +00:00
|
|
|
struct config_entry_list *list = conf->entries;
|
2010-12-29 13:27:44 +00:00
|
|
|
|
2011-10-17 17:11:31 +00:00
|
|
|
while (list)
|
2010-12-29 13:27:44 +00:00
|
|
|
{
|
|
|
|
if (strcmp(key, list->key) == 0)
|
|
|
|
{
|
|
|
|
*in = strtod(list->value, NULL);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
list = list->next;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2012-01-12 23:08:55 +00:00
|
|
|
bool config_get_float(config_file_t *conf, const char *key, float *in)
|
|
|
|
{
|
2012-11-23 21:46:21 +00:00
|
|
|
struct config_entry_list *list = conf->entries;
|
2012-01-12 23:08:55 +00:00
|
|
|
|
|
|
|
while (list)
|
|
|
|
{
|
|
|
|
if (strcmp(key, list->key) == 0)
|
|
|
|
{
|
2014-09-02 17:20:03 +00:00
|
|
|
/* strtof() is C99/POSIX. Just use the more portable kind. */
|
2012-01-12 23:08:55 +00:00
|
|
|
*in = (float)strtod(list->value, NULL);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
list = list->next;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2010-12-29 13:27:44 +00:00
|
|
|
bool config_get_int(config_file_t *conf, const char *key, int *in)
|
|
|
|
{
|
2012-11-23 21:46:21 +00:00
|
|
|
struct config_entry_list *list = conf->entries;
|
2010-12-29 13:27:44 +00:00
|
|
|
|
2011-10-17 17:11:31 +00:00
|
|
|
while (list)
|
2010-12-29 13:27:44 +00:00
|
|
|
{
|
|
|
|
if (strcmp(key, list->key) == 0)
|
|
|
|
{
|
2011-09-05 15:00:28 +00:00
|
|
|
errno = 0;
|
|
|
|
int val = strtol(list->value, NULL, 0);
|
|
|
|
if (errno == 0)
|
|
|
|
{
|
|
|
|
*in = val;
|
|
|
|
return true;
|
|
|
|
}
|
2014-09-02 17:20:03 +00:00
|
|
|
return false;
|
2010-12-29 13:27:44 +00:00
|
|
|
}
|
|
|
|
list = list->next;
|
2011-05-27 00:25:26 +00:00
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2012-03-04 12:55:35 +00:00
|
|
|
bool config_get_uint64(config_file_t *conf, const char *key, uint64_t *in)
|
|
|
|
{
|
2012-11-23 21:46:21 +00:00
|
|
|
struct config_entry_list *list = conf->entries;
|
2012-03-04 12:55:35 +00:00
|
|
|
|
|
|
|
while (list)
|
|
|
|
{
|
|
|
|
if (strcmp(key, list->key) == 0)
|
|
|
|
{
|
|
|
|
errno = 0;
|
|
|
|
uint64_t val = strtoull(list->value, NULL, 0);
|
|
|
|
if (errno == 0)
|
|
|
|
{
|
|
|
|
*in = val;
|
|
|
|
return true;
|
|
|
|
}
|
2014-09-02 17:20:03 +00:00
|
|
|
return false;
|
2012-03-04 12:55:35 +00:00
|
|
|
}
|
|
|
|
list = list->next;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2012-01-11 00:04:17 +00:00
|
|
|
bool config_get_uint(config_file_t *conf, const char *key, unsigned *in)
|
|
|
|
{
|
2012-11-26 21:11:39 +00:00
|
|
|
struct config_entry_list *list = conf->entries;
|
|
|
|
|
|
|
|
while (list != NULL)
|
|
|
|
{
|
|
|
|
if (strcmp(key, list->key) == 0)
|
|
|
|
{
|
|
|
|
errno = 0;
|
|
|
|
unsigned val = strtoul(list->value, NULL, 0);
|
|
|
|
if (errno == 0)
|
|
|
|
{
|
|
|
|
*in = val;
|
|
|
|
return true;
|
|
|
|
}
|
2014-09-02 17:20:03 +00:00
|
|
|
return false;
|
2012-11-26 21:11:39 +00:00
|
|
|
}
|
|
|
|
list = list->next;
|
2012-01-11 00:04:17 +00:00
|
|
|
}
|
2012-11-26 21:11:39 +00:00
|
|
|
|
2012-01-11 00:04:17 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2011-05-27 00:25:26 +00:00
|
|
|
bool config_get_hex(config_file_t *conf, const char *key, unsigned *in)
|
|
|
|
{
|
2012-11-23 21:46:21 +00:00
|
|
|
struct config_entry_list *list = conf->entries;
|
2011-05-27 00:25:26 +00:00
|
|
|
|
2011-10-17 17:11:31 +00:00
|
|
|
while (list)
|
2011-05-27 00:25:26 +00:00
|
|
|
{
|
|
|
|
if (strcmp(key, list->key) == 0)
|
|
|
|
{
|
2011-09-05 15:00:28 +00:00
|
|
|
errno = 0;
|
|
|
|
unsigned val = strtoul(list->value, NULL, 16);
|
|
|
|
if (errno == 0)
|
|
|
|
{
|
|
|
|
*in = val;
|
|
|
|
return true;
|
|
|
|
}
|
2014-09-02 17:20:03 +00:00
|
|
|
return false;
|
2011-05-27 00:25:26 +00:00
|
|
|
}
|
|
|
|
list = list->next;
|
2010-12-29 13:27:44 +00:00
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool config_get_char(config_file_t *conf, const char *key, char *in)
|
|
|
|
{
|
2012-11-23 21:46:21 +00:00
|
|
|
struct config_entry_list *list = conf->entries;
|
2010-12-29 13:27:44 +00:00
|
|
|
|
2011-10-17 17:11:31 +00:00
|
|
|
while (list)
|
2010-12-29 13:27:44 +00:00
|
|
|
{
|
|
|
|
if (strcmp(key, list->key) == 0)
|
|
|
|
{
|
2011-08-25 14:15:34 +00:00
|
|
|
if (list->value[0] && list->value[1])
|
2010-12-29 13:27:44 +00:00
|
|
|
return false;
|
|
|
|
*in = *list->value;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
list = list->next;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool config_get_string(config_file_t *conf, const char *key, char **str)
|
|
|
|
{
|
2012-11-23 21:46:21 +00:00
|
|
|
struct config_entry_list *list = conf->entries;
|
2010-12-29 13:27:44 +00:00
|
|
|
|
2011-10-17 17:11:31 +00:00
|
|
|
while (list)
|
2010-12-29 13:27:44 +00:00
|
|
|
{
|
|
|
|
if (strcmp(key, list->key) == 0)
|
|
|
|
{
|
|
|
|
*str = strdup(list->value);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
list = list->next;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2014-09-02 17:20:03 +00:00
|
|
|
bool config_get_array(config_file_t *conf, const char *key,
|
|
|
|
char *buf, size_t size)
|
2011-08-25 14:15:34 +00:00
|
|
|
{
|
2012-11-23 21:46:21 +00:00
|
|
|
struct config_entry_list *list = conf->entries;
|
2011-08-25 14:15:34 +00:00
|
|
|
|
2012-09-07 22:31:30 +00:00
|
|
|
while (list)
|
|
|
|
{
|
|
|
|
if (strcmp(key, list->key) == 0)
|
|
|
|
return strlcpy(buf, list->value, size) < size;
|
|
|
|
list = list->next;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2014-09-02 17:20:03 +00:00
|
|
|
bool config_get_path(config_file_t *conf, const char *key,
|
|
|
|
char *buf, size_t size)
|
2012-09-07 22:31:30 +00:00
|
|
|
{
|
2013-03-17 11:27:33 +00:00
|
|
|
#if defined(RARCH_CONSOLE)
|
2012-09-07 22:31:30 +00:00
|
|
|
return config_get_array(conf, key, buf, size);
|
|
|
|
#else
|
2012-11-23 21:46:21 +00:00
|
|
|
struct config_entry_list *list = conf->entries;
|
2012-09-07 22:31:30 +00:00
|
|
|
|
2011-10-17 17:11:31 +00:00
|
|
|
while (list)
|
2011-08-25 14:15:34 +00:00
|
|
|
{
|
|
|
|
if (strcmp(key, list->key) == 0)
|
|
|
|
{
|
2013-12-24 17:23:21 +00:00
|
|
|
fill_pathname_expand_special(buf, list->value, size);
|
|
|
|
return true;
|
2011-08-25 14:15:34 +00:00
|
|
|
}
|
|
|
|
list = list->next;
|
|
|
|
}
|
|
|
|
return false;
|
2012-09-07 22:31:30 +00:00
|
|
|
#endif
|
2011-08-25 14:15:34 +00:00
|
|
|
}
|
|
|
|
|
2010-12-29 13:27:44 +00:00
|
|
|
bool config_get_bool(config_file_t *conf, const char *key, bool *in)
|
|
|
|
{
|
2012-11-23 21:46:21 +00:00
|
|
|
struct config_entry_list *list = conf->entries;
|
2010-12-29 13:27:44 +00:00
|
|
|
|
2011-10-17 17:11:31 +00:00
|
|
|
while (list)
|
2010-12-29 13:27:44 +00:00
|
|
|
{
|
|
|
|
if (strcmp(key, list->key) == 0)
|
|
|
|
{
|
|
|
|
if (strcasecmp(list->value, "true") == 0)
|
|
|
|
*in = true;
|
|
|
|
else if (strcasecmp(list->value, "1") == 0)
|
|
|
|
*in = true;
|
|
|
|
else if (strcasecmp(list->value, "false") == 0)
|
|
|
|
*in = false;
|
|
|
|
else if (strcasecmp(list->value, "0") == 0)
|
|
|
|
*in = false;
|
|
|
|
else
|
|
|
|
return false;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
list = list->next;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2011-01-09 01:58:26 +00:00
|
|
|
void config_set_string(config_file_t *conf, const char *key, const char *val)
|
|
|
|
{
|
2012-11-23 21:46:21 +00:00
|
|
|
struct config_entry_list *list = conf->entries;
|
|
|
|
struct config_entry_list *last = list;
|
2011-10-17 17:11:31 +00:00
|
|
|
while (list)
|
2011-01-09 01:58:26 +00:00
|
|
|
{
|
2011-10-17 17:11:31 +00:00
|
|
|
if (!list->readonly && (strcmp(key, list->key) == 0))
|
2011-01-09 01:58:26 +00:00
|
|
|
{
|
|
|
|
free(list->value);
|
|
|
|
list->value = strdup(val);
|
|
|
|
return;
|
|
|
|
}
|
2011-10-17 17:11:31 +00:00
|
|
|
|
2011-01-09 01:58:26 +00:00
|
|
|
last = list;
|
|
|
|
list = list->next;
|
|
|
|
}
|
|
|
|
|
2014-09-02 17:20:03 +00:00
|
|
|
struct config_entry_list *elem = (struct config_entry_list*)
|
|
|
|
calloc(1, sizeof(*elem));
|
2014-09-14 22:20:13 +00:00
|
|
|
|
|
|
|
if (!elem)
|
|
|
|
return;
|
|
|
|
|
2011-01-09 01:58:26 +00:00
|
|
|
elem->key = strdup(key);
|
|
|
|
elem->value = strdup(val);
|
|
|
|
|
|
|
|
if (last)
|
|
|
|
last->next = elem;
|
|
|
|
else
|
|
|
|
conf->entries = elem;
|
|
|
|
}
|
|
|
|
|
2013-12-24 17:23:21 +00:00
|
|
|
void config_set_path(config_file_t *conf, const char *entry, const char *val)
|
|
|
|
{
|
|
|
|
#if defined(RARCH_CONSOLE)
|
|
|
|
config_set_string(conf, entry, val);
|
|
|
|
#else
|
|
|
|
char buf[PATH_MAX];
|
|
|
|
fill_pathname_abbreviate_special(buf, val, sizeof(buf));
|
|
|
|
config_set_string(conf, entry, buf);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2011-01-09 01:58:26 +00:00
|
|
|
void config_set_double(config_file_t *conf, const char *key, double val)
|
|
|
|
{
|
|
|
|
char buf[128];
|
2011-12-24 12:46:12 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
snprintf(buf, sizeof(buf), "%f", (float)val);
|
|
|
|
#else
|
2011-01-09 01:58:26 +00:00
|
|
|
snprintf(buf, sizeof(buf), "%lf", val);
|
2011-12-24 12:46:12 +00:00
|
|
|
#endif
|
2011-01-09 01:58:26 +00:00
|
|
|
config_set_string(conf, key, buf);
|
|
|
|
}
|
2010-12-29 13:27:44 +00:00
|
|
|
|
2012-01-30 14:14:30 +00:00
|
|
|
void config_set_float(config_file_t *conf, const char *key, float val)
|
|
|
|
{
|
|
|
|
char buf[128];
|
|
|
|
snprintf(buf, sizeof(buf), "%f", val);
|
|
|
|
config_set_string(conf, key, buf);
|
|
|
|
}
|
|
|
|
|
2011-01-09 01:58:26 +00:00
|
|
|
void config_set_int(config_file_t *conf, const char *key, int val)
|
|
|
|
{
|
|
|
|
char buf[128];
|
|
|
|
snprintf(buf, sizeof(buf), "%d", val);
|
|
|
|
config_set_string(conf, key, buf);
|
|
|
|
}
|
|
|
|
|
2013-04-06 09:30:56 +00:00
|
|
|
void config_set_hex(config_file_t *conf, const char *key, unsigned val)
|
|
|
|
{
|
|
|
|
char buf[128];
|
|
|
|
snprintf(buf, sizeof(buf), "%x", val);
|
|
|
|
config_set_string(conf, key, buf);
|
|
|
|
}
|
|
|
|
|
2012-03-04 12:55:35 +00:00
|
|
|
void config_set_uint64(config_file_t *conf, const char *key, uint64_t val)
|
|
|
|
{
|
|
|
|
char buf[128];
|
2012-03-07 11:42:22 +00:00
|
|
|
#ifdef _WIN32
|
|
|
|
snprintf(buf, sizeof(buf), "%I64u", val);
|
|
|
|
#else
|
2012-03-04 12:55:35 +00:00
|
|
|
snprintf(buf, sizeof(buf), "%llu", (long long unsigned)val);
|
2012-03-07 11:42:22 +00:00
|
|
|
#endif
|
2012-03-04 12:55:35 +00:00
|
|
|
config_set_string(conf, key, buf);
|
|
|
|
}
|
|
|
|
|
2011-01-09 01:58:26 +00:00
|
|
|
void config_set_char(config_file_t *conf, const char *key, char val)
|
|
|
|
{
|
|
|
|
char buf[2];
|
|
|
|
snprintf(buf, sizeof(buf), "%c", val);
|
|
|
|
config_set_string(conf, key, buf);
|
|
|
|
}
|
|
|
|
|
|
|
|
void config_set_bool(config_file_t *conf, const char *key, bool val)
|
|
|
|
{
|
|
|
|
config_set_string(conf, key, val ? "true" : "false");
|
|
|
|
}
|
|
|
|
|
|
|
|
bool config_file_write(config_file_t *conf, const char *path)
|
|
|
|
{
|
2011-01-09 14:44:35 +00:00
|
|
|
FILE *file;
|
|
|
|
|
|
|
|
if (path)
|
|
|
|
{
|
|
|
|
file = fopen(path, "w");
|
|
|
|
if (!file)
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
file = stdout;
|
2011-01-09 01:58:26 +00:00
|
|
|
|
2011-01-09 14:50:30 +00:00
|
|
|
config_file_dump(conf, file);
|
|
|
|
|
|
|
|
if (path)
|
|
|
|
fclose(file);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void config_file_dump(config_file_t *conf, FILE *file)
|
2011-10-17 17:11:31 +00:00
|
|
|
{
|
|
|
|
struct include_list *includes = conf->includes;
|
|
|
|
while (includes)
|
|
|
|
{
|
|
|
|
fprintf(file, "#include \"%s\"\n", includes->path);
|
|
|
|
includes = includes->next;
|
|
|
|
}
|
|
|
|
|
2012-11-23 21:46:21 +00:00
|
|
|
struct config_entry_list *list = conf->entries;
|
2011-10-17 17:11:31 +00:00
|
|
|
while (list)
|
|
|
|
{
|
|
|
|
if (!list->readonly)
|
|
|
|
fprintf(file, "%s = \"%s\"\n", list->key, list->value);
|
|
|
|
list = list->next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-06-11 12:19:34 +00:00
|
|
|
void config_file_dump_all(config_file_t *conf)
|
2011-10-17 17:11:31 +00:00
|
|
|
{
|
|
|
|
struct include_list *includes = conf->includes;
|
|
|
|
while (includes)
|
|
|
|
{
|
2014-06-11 12:19:34 +00:00
|
|
|
RARCH_LOG("#include \"%s\"\n", includes->path);
|
2011-10-17 17:11:31 +00:00
|
|
|
includes = includes->next;
|
|
|
|
}
|
|
|
|
|
2012-11-23 21:46:21 +00:00
|
|
|
struct config_entry_list *list = conf->entries;
|
2011-10-17 17:11:31 +00:00
|
|
|
while (list)
|
|
|
|
{
|
2014-09-02 17:20:03 +00:00
|
|
|
RARCH_LOG("%s = \"%s\" %s\n", list->key,
|
|
|
|
list->value, list->readonly ? "(included)" : "");
|
2011-10-17 17:11:31 +00:00
|
|
|
list = list->next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool config_entry_exists(config_file_t *conf, const char *entry)
|
2011-01-09 14:50:30 +00:00
|
|
|
{
|
2012-11-23 21:46:21 +00:00
|
|
|
struct config_entry_list *list = conf->entries;
|
2011-01-09 01:58:26 +00:00
|
|
|
|
2011-10-17 17:11:31 +00:00
|
|
|
while (list)
|
2011-01-09 01:58:26 +00:00
|
|
|
{
|
2011-10-17 17:11:31 +00:00
|
|
|
if (strcmp(entry, list->key) == 0)
|
|
|
|
return true;
|
2011-01-09 01:58:26 +00:00
|
|
|
list = list->next;
|
|
|
|
}
|
2011-10-17 17:11:31 +00:00
|
|
|
|
|
|
|
return false;
|
2011-01-09 01:58:26 +00:00
|
|
|
}
|
2011-10-17 17:11:31 +00:00
|
|
|
|
2014-09-02 17:20:03 +00:00
|
|
|
bool config_get_entry_list_head(config_file_t *conf,
|
|
|
|
struct config_file_entry *entry)
|
2012-11-23 21:46:21 +00:00
|
|
|
{
|
|
|
|
const struct config_entry_list *head = conf->entries;
|
|
|
|
if (!head)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
entry->key = head->key;
|
|
|
|
entry->value = head->value;
|
|
|
|
entry->next = head->next;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool config_get_entry_list_next(struct config_file_entry *entry)
|
|
|
|
{
|
|
|
|
const struct config_entry_list *next = entry->next;
|
|
|
|
if (!next)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
entry->key = next->key;
|
|
|
|
entry->value = next->value;
|
|
|
|
entry->next = next->next;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|