aboutsummaryrefslogtreecommitdiffstats
path: root/Alc/alcConfig.c
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2011-09-18 16:16:55 -0700
committerChris Robinson <[email protected]>2011-09-18 16:16:55 -0700
commit7e06a10f73d5955de7bba35da09e5941cee56dc8 (patch)
tree4e2394246a4912ee762c7a01fa365cceade58e50 /Alc/alcConfig.c
parentd46db2f648e7d00ae138fb98bd0ee49014c501a6 (diff)
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.
Diffstat (limited to 'Alc/alcConfig.c')
-rw-r--r--Alc/alcConfig.c25
1 files changed, 18 insertions, 7 deletions
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)