Add config_get_float.

This commit is contained in:
Themaister 2012-01-13 00:08:55 +01:00
parent c305f4347d
commit 751761d99c
2 changed files with 18 additions and 0 deletions

View File

@ -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;

View File

@ -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.