add function iniGetCharValueEx

vote_node
YuQing 2022-05-26 10:37:52 +08:00
parent 1f83e66306
commit f24c558761
3 changed files with 52 additions and 17 deletions

View File

@ -1,6 +1,8 @@
Version 1.58 2022-05-07
Version 1.58 2022-05-26
* add function conn_pool_connect_server_ex1 to support service name
* add function conn_pool_get_connection_ex to support service name
* add function iniGetCharValueEx
Version 1.57 2022-04-22
* add function fc_format_path

View File

@ -2868,6 +2868,21 @@ char *iniGetStrValueEx(const char *szSectionName, const char *szItemName,
return pFound->value;
}
char iniGetCharValueEx(const char *szSectionName, const char *szItemName,
IniContext *pContext, const char cDefaultValue,
const bool bRetryGlobal)
{
char *value;
value = iniGetStrValueEx(szSectionName, szItemName,
pContext, bRetryGlobal);
if (value == NULL) {
return cDefaultValue;
} else {
return value[0];
}
}
#define INI_FILL_SECTION_PROMPT(prompt, size, section_name) \
do { \
if (section_name != NULL && *(section_name) != '\0') { \

View File

@ -117,28 +117,32 @@ extern "C" {
#define iniGetStrValue(szSectionName, szItemName, pContext) \
iniGetStrValueEx(szSectionName, szItemName, pContext, false)
#define iniGetCharValue(szSectionName, szItemName, pContext, cDefaultValue) \
iniGetCharValueEx(szSectionName, szItemName, \
pContext, cDefaultValue, false)
#define iniGetIntValue(szSectionName, szItemName, pContext, nDefaultValue) \
iniGetIntValueEx(szSectionName, szItemName, pContext, \
nDefaultValue, false)
iniGetIntValueEx(szSectionName, szItemName, \
pContext, nDefaultValue, false)
#define iniGetInt64Value(szSectionName, szItemName, pContext, nDefaultValue) \
iniGetInt64ValueEx(szSectionName, szItemName, pContext, \
nDefaultValue, false)
iniGetInt64ValueEx(szSectionName, szItemName, \
pContext, nDefaultValue, false)
#define iniGetDoubleValue(szSectionName, szItemName, pContext, dbDefaultValue) \
iniGetDoubleValueEx(szSectionName, szItemName, pContext, \
dbDefaultValue, false)
iniGetDoubleValueEx(szSectionName, szItemName, \
pContext, dbDefaultValue, false)
#define iniGetBoolValue(szSectionName, szItemName, pContext, bDefaultValue) \
iniGetBoolValueEx(szSectionName, szItemName, pContext, \
bDefaultValue, false)
iniGetBoolValueEx(szSectionName, szItemName, \
pContext, bDefaultValue, false)
#define iniGetPercentValue(ini_ctx, item_name, item_value, default_value) \
iniGetPercentValueEx(ini_ctx, item_name, item_value, default_value, false)
#define iniGetByteValue(szSectionName, szItemName, pContext, nDefaultValue) \
iniGetByteValueEx(szSectionName, szItemName, pContext, \
nDefaultValue, 1, false)
iniGetByteValueEx(szSectionName, szItemName, \
pContext, nDefaultValue, 1, false)
#define iniGetIntCorrectValue(ini_ctx, item_name, \
default_value, min_value, max_value) \
@ -243,6 +247,20 @@ void iniFreeContext(IniContext *pContext);
char *iniGetStrValueEx(const char *szSectionName, const char *szItemName,
IniContext *pContext, const bool bRetryGlobal);
/** get the first charactor
* parameters:
* szSectionName: the section name, NULL or empty string for
* global section
* szItemName: the item name
* pContext: the ini context
* cDefaultValue: the default value
* bRetryGlobal: if fetch from global section when the item not exist
* return: item value, return default value when the item not exist
*/
char iniGetCharValueEx(const char *szSectionName, const char *szItemName,
IniContext *pContext, const char cDefaultValue,
const bool bRetryGlobal);
/** get item string value
* parameters:
* szSectionName: the section name, NULL or empty string for