From 751761d99cee5e21e8154e994ef7999a4fa983f4 Mon Sep 17 00:00:00 2001 From: Themaister Date: Fri, 13 Jan 2012 00:08:55 +0100 Subject: [PATCH] Add config_get_float. --- conf/config_file.c | 16 ++++++++++++++++ conf/config_file.h | 2 ++ 2 files changed, 18 insertions(+) diff --git a/conf/config_file.c b/conf/config_file.c index e3e70fdd73..3b6c398645 100644 --- a/conf/config_file.c +++ b/conf/config_file.c @@ -419,6 +419,22 @@ bool config_get_double(config_file_t *conf, const char *key, double *in) return false; } +bool config_get_float(config_file_t *conf, const char *key, float *in) +{ + struct entry_list *list = conf->entries; + + while (list) + { + if (strcmp(key, list->key) == 0) + { + *in = (float)strtod(list->value, NULL); + return true; + } + list = list->next; + } + return false; +} + bool config_get_int(config_file_t *conf, const char *key, int *in) { struct entry_list *list = conf->entries; diff --git a/conf/config_file.h b/conf/config_file.h index 6c8e26a190..e8b6eb1d3a 100644 --- a/conf/config_file.h +++ b/conf/config_file.h @@ -49,6 +49,8 @@ bool config_entry_exists(config_file_t *conf, const char *entry); // Extracts a double from config file. bool config_get_double(config_file_t *conf, const char *entry, double *in); +// Extracts a float from config file. +bool config_get_float(config_file_t *conf, const char *entry, float *in); // Extracts an int from config file. bool config_get_int(config_file_t *conf, const char *entry, int *in); // Extracts an uint from config file.