diff options
Diffstat (limited to 'android/utils')
-rw-r--r-- | android/utils/ini.c | 9 | ||||
-rw-r--r-- | android/utils/ini.h | 9 |
2 files changed, 9 insertions, 9 deletions
diff --git a/android/utils/ini.c b/android/utils/ini.c index 1a1449c..a5914dd 100644 --- a/android/utils/ini.c +++ b/android/utils/ini.c @@ -326,12 +326,15 @@ iniFile_saveToFile( IniFile* f, const char* filepath ) } char* -iniFile_getString( IniFile* f, const char* key ) +iniFile_getString( IniFile* f, const char* key, const char* defaultValue ) { const char* val = iniFile_getValue(f, key); - if (!val) - return NULL; + if (!val) { + if (!defaultValue) + return NULL; + val= defaultValue; + } return ASTRDUP(val); } diff --git a/android/utils/ini.h b/android/utils/ini.h index 77d760f..5730ee0 100644 --- a/android/utils/ini.h +++ b/android/utils/ini.h @@ -48,9 +48,10 @@ int iniFile_getPairCount( IniFile* f ); */ const char* iniFile_getValue( IniFile* f, const char* key ); -/* returns a copy of the value of a given key, or NULL +/* returns a copy of the value of a given key, or NULL if defaultValue is NULL. + * caller must free() it. */ -char* iniFile_getString( IniFile* f, const char* key ); +char* iniFile_getString( IniFile* f, const char* key, const char* defaultValue ); /* returns an integer value, or a default in case the value string is * missing or badly formatted @@ -67,10 +68,6 @@ int64_t iniFile_getInt64( IniFile* f, const char* key, int64_t defaultValue ) */ double iniFile_getDouble( IniFile* f, const char* key, double defaultValue ); -/* returns a copy of a given key's value, if any, or NULL if it is missing - * caller must call free() to release it */ -char* iniFile_getString( IniFile* f, const char* key ); - /* parses a key value as a boolean. Accepted values are "1", "0", "yes", "YES", * "no" and "NO". Returns either 1 or 0. * note that the default value must be provided as a string too |