[utils]: Update iniparser

Change-Id: Id29dc65a732aa62f4614f1d602545c04e7de054b
Signed-off-by: Herman Chen <herman.chen@rock-chips.com>
This commit is contained in:
Herman Chen
2020-02-27 17:24:21 +08:00
parent 001b637afa
commit 52c93a4955
2 changed files with 38 additions and 1 deletions

View File

@@ -493,6 +493,28 @@ int iniparser_getint(const dictionary * d, const char * key, int notfound)
return (int)iniparser_getlongint(d, key, notfound); return (int)iniparser_getlongint(d, key, notfound);
} }
/*-------------------------------------------------------------------------*/
/**
@brief Get the string associated to a key, convert to a double
@param d Dictionary to search
@param key Key string to look for
@param notfound Value to return in case of error
@return double
This function queries a dictionary for a key. A key as read from an
ini file is given as "section:key". If the key cannot be found,
the notfound value is returned.
*/
/*--------------------------------------------------------------------------*/
double iniparser_getdouble(const dictionary * d, const char * key, double notfound)
{
const char * str ;
str = iniparser_getstring(d, key, INI_INVALID_KEY);
if (str == INI_INVALID_KEY) return notfound ;
return atof(str);
}
/*-------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/
/** /**
@brief Get the string associated to a key, convert to a boolean @brief Get the string associated to a key, convert to a boolean
@@ -696,7 +718,7 @@ dictionary * iniparser_load(const char * ininame)
char line [ASCIILINESZ + 1] ; char line [ASCIILINESZ + 1] ;
char section [ASCIILINESZ + 1] ; char section [ASCIILINESZ + 1] ;
char key [ASCIILINESZ + 1] ; char key [ASCIILINESZ + 1] ;
char tmp [(ASCIILINESZ * 2) + 1] ; char tmp [(ASCIILINESZ * 2) + 2] ;
char val [ASCIILINESZ + 1] ; char val [ASCIILINESZ + 1] ;
int last = 0 ; int last = 0 ;

View File

@@ -230,6 +230,21 @@ int iniparser_getint(const dictionary * d, const char * key, int notfound);
long int iniparser_getlongint(const dictionary * d, const char * key, long int notfound); long int iniparser_getlongint(const dictionary * d, const char * key, long int notfound);
/*-------------------------------------------------------------------------*/
/**
@brief Get the string associated to a key, convert to a double
@param d Dictionary to search
@param key Key string to look for
@param notfound Value to return in case of error
@return double
This function queries a dictionary for a key. A key as read from an
ini file is given as "section:key". If the key cannot be found,
the notfound value is returned.
*/
/*--------------------------------------------------------------------------*/
double iniparser_getdouble(const dictionary * d, const char * key, double notfound);
/*-------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/
/** /**
@brief Get the string associated to a key, convert to a boolean @brief Get the string associated to a key, convert to a boolean