From 7e06a10f73d5955de7bba35da09e5941cee56dc8 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Sun, 18 Sep 2011 16:16:55 -0700 Subject: Return int and float config values through a parameter This allows the getter functions to return whether or not the option exists without a separate call and check. --- Alc/alcConfig.c | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) (limited to 'Alc/alcConfig.c') diff --git a/Alc/alcConfig.c b/Alc/alcConfig.c index b8c04743..60fb733a 100644 --- a/Alc/alcConfig.c +++ b/Alc/alcConfig.c @@ -313,24 +313,35 @@ int ConfigValueExists(const char *blockName, const char *keyName) return !!val[0]; } -int GetConfigValueInt(const char *blockName, const char *keyName, int def) +int ConfigValueInt(const char *blockName, const char *keyName, int *ret) { const char *val = GetConfigValue(blockName, keyName, ""); + if(!val[0]) return 0; - if(!val[0]) return def; - return strtol(val, NULL, 0); + *ret = strtol(val, NULL, 0); + return 1; } -float GetConfigValueFloat(const char *blockName, const char *keyName, float def) +int ConfigValueUInt(const char *blockName, const char *keyName, unsigned int *ret) { const char *val = GetConfigValue(blockName, keyName, ""); + if(!val[0]) return 0; + + *ret = strtoul(val, NULL, 0); + return 1; +} + +int ConfigValueFloat(const char *blockName, const char *keyName, float *ret) +{ + const char *val = GetConfigValue(blockName, keyName, ""); + if(!val[0]) return 0; - if(!val[0]) return def; #ifdef HAVE_STRTOF - return strtof(val, NULL); + *ret = strtof(val, NULL); #else - return (float)strtod(val, NULL); + *ret = (float)strtod(val, NULL); #endif + return 1; } int GetConfigValueBool(const char *blockName, const char *keyName, int def) -- cgit v1.2.3