Skip to content

Commit

Permalink
fixed a few bugs with config files, and replaced a boolean parameter …
Browse files Browse the repository at this point in the history
…with an enum
  • Loading branch information
jp9000 committed Nov 24, 2013
1 parent e1da909 commit 3c6494a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
12 changes: 7 additions & 5 deletions libobs/util/config-file.c
Original file line number Diff line number Diff line change
Expand Up @@ -232,9 +232,11 @@ static int config_parse(struct darray *sections, const char *file,
return CONFIG_SUCCESS;
}

int config_open(config_t *config, const char *file, bool always_open)
int config_open(config_t *config, const char *file,
enum config_open_type open_type)
{
int errorcode;
bool always_open = open_type == CONFIG_OPEN_ALWAYS;

if (!config)
return CONFIG_ERROR;
Expand Down Expand Up @@ -405,7 +407,7 @@ void config_set_int(config_t config, const char *section,
{
struct dstr str;
dstr_init(&str);
dstr_printf(&str, "%dll", value);
dstr_printf(&str, "%lld", value);
config_set_item(&config->sections, section, name, str.array);
}

Expand All @@ -414,7 +416,7 @@ void config_set_uint(config_t config, const char *section,
{
struct dstr str;
dstr_init(&str);
dstr_printf(&str, "%ull", value);
dstr_printf(&str, "%llu", value);
config_set_item(&config->sections, section, name, str.array);
}

Expand Down Expand Up @@ -447,7 +449,7 @@ void config_set_default_int(config_t config, const char *section,
{
struct dstr str;
dstr_init(&str);
dstr_printf(&str, "%dll", value);
dstr_printf(&str, "%lld", value);
config_set_item(&config->defaults, section, name, str.array);
}

Expand All @@ -456,7 +458,7 @@ void config_set_default_uint(config_t config, const char *section,
{
struct dstr str;
dstr_init(&str);
dstr_printf(&str, "%ull", value);
dstr_printf(&str, "%llu", value);
config_set_item(&config->defaults, section, name, str.array);
}

Expand Down
8 changes: 7 additions & 1 deletion libobs/util/config-file.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,14 @@ typedef struct config_data *config_t;
#define CONFIG_FILENOTFOUND -1
#define CONFIG_ERROR -2

enum config_open_type {
CONFIG_OPEN_EXISTING,
CONFIG_OPEN_ALWAYS,
};

EXPORT config_t config_create(const char *file);
EXPORT int config_open(config_t *config, const char *file, bool always_open);
EXPORT int config_open(config_t *config, const char *file,
enum config_open_type open_type);
EXPORT int config_open_defaults(config_t config, const char *file);
EXPORT int config_save(config_t config);
EXPORT void config_close(config_t config);
Expand Down

0 comments on commit 3c6494a

Please sign in to comment.