Compare commits
No commits in common. "02227ff3181b0943367fb900a9d310ebb525ef80" and "15424dfc1c4e096747c3db07e148ad2113bb3e71" have entirely different histories.
02227ff318
...
15424dfc1c
4
HISTORY
4
HISTORY
|
|
@ -1,8 +1,6 @@
|
||||||
|
|
||||||
Version 1.88 2026-09-04
|
Version 1.88 2026-09-03
|
||||||
* local_host_ip_addrs_to_string: fix buffer overflow
|
* local_host_ip_addrs_to_string: fix buffer overflow
|
||||||
* shared_func.[hc]: add function parse_timestamp
|
|
||||||
* ini_file_reader.[hc]: add function iniGetTimestampValueEx
|
|
||||||
|
|
||||||
Version 1.87 2026-07-10
|
Version 1.87 2026-07-10
|
||||||
* ini_file_readers can refer env variable such as %{env::FASTDFS_IPADDR}
|
* ini_file_readers can refer env variable such as %{env::FASTDFS_IPADDR}
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
%define CommitVersion %(echo $COMMIT_VERSION)
|
%define CommitVersion %(echo $COMMIT_VERSION)
|
||||||
|
|
||||||
Name: libfastcommon
|
Name: libfastcommon
|
||||||
Version: 1.0.88
|
Version: 1.0.87
|
||||||
Release: 1%{?dist}
|
Release: 1%{?dist}
|
||||||
Summary: c common functions library extracted from my open source projects FastDFS
|
Summary: c common functions library extracted from my open source projects FastDFS
|
||||||
License: LGPL
|
License: LGPL
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@
|
||||||
|
|
||||||
#define FC_MAJOR_VERSION 1
|
#define FC_MAJOR_VERSION 1
|
||||||
#define FC_MINOR_VERSION 0
|
#define FC_MINOR_VERSION 0
|
||||||
#define FC_PATCH_VERSION 88
|
#define FC_PATCH_VERSION 87
|
||||||
|
|
||||||
#define FC_VERSION_INT FC_VERSION_TO_INT(FC_MAJOR_VERSION, \
|
#define FC_VERSION_INT FC_VERSION_TO_INT(FC_MAJOR_VERSION, \
|
||||||
FC_MINOR_VERSION, FC_PATCH_VERSION)
|
FC_MINOR_VERSION, FC_PATCH_VERSION)
|
||||||
|
|
|
||||||
|
|
@ -3531,26 +3531,3 @@ int iniGetPercentValueEx(IniFullContext *ini_ctx,
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t iniGetTimestampValueEx(const char *szSectionName,
|
|
||||||
const char *szItemName, IniContext *pContext,
|
|
||||||
const int64_t nDefaultValue, const int nDefaultUnitTS,
|
|
||||||
const bool bRetryGlobal)
|
|
||||||
{
|
|
||||||
char *pValue;
|
|
||||||
int64_t nValue;
|
|
||||||
|
|
||||||
pValue = iniGetStrValueEx(szSectionName,
|
|
||||||
szItemName, pContext, bRetryGlobal);
|
|
||||||
if (pValue == NULL)
|
|
||||||
{
|
|
||||||
return nDefaultValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (parse_timestamp(pValue, nDefaultUnitTS, &nValue) != 0)
|
|
||||||
{
|
|
||||||
return nDefaultValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
return nValue;
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -140,10 +140,6 @@ extern "C" {
|
||||||
#define iniGetPercentValue(ini_ctx, item_name, item_value, default_value) \
|
#define iniGetPercentValue(ini_ctx, item_name, item_value, default_value) \
|
||||||
iniGetPercentValueEx(ini_ctx, item_name, item_value, default_value, false)
|
iniGetPercentValueEx(ini_ctx, item_name, item_value, default_value, false)
|
||||||
|
|
||||||
#define iniGetTimestampValue(szSectionName, szItemName, pContext, nDefaultValue) \
|
|
||||||
iniGetTimestampValueEx(szSectionName, szItemName, \
|
|
||||||
pContext, nDefaultValue, 1, false)
|
|
||||||
|
|
||||||
#define iniGetByteValue(szSectionName, szItemName, pContext, nDefaultValue) \
|
#define iniGetByteValue(szSectionName, szItemName, pContext, nDefaultValue) \
|
||||||
iniGetByteValueEx(szSectionName, szItemName, \
|
iniGetByteValueEx(szSectionName, szItemName, \
|
||||||
pContext, nDefaultValue, 1, false)
|
pContext, nDefaultValue, 1, false)
|
||||||
|
|
@ -428,22 +424,6 @@ int64_t iniGetByteCorrectValueEx(IniFullContext *pIniContext,
|
||||||
const int nDefaultUnitBytes, const int64_t nMinValue,
|
const int nDefaultUnitBytes, const int64_t nMinValue,
|
||||||
const int64_t nMaxValue, const bool bRetryGlobal);
|
const int64_t nMaxValue, const bool bRetryGlobal);
|
||||||
|
|
||||||
/** get item timestamp value (64 bits integer)
|
|
||||||
* parameters:
|
|
||||||
* szSectionName: the section name, NULL or empty string for
|
|
||||||
* global section
|
|
||||||
* szItemName: the item name
|
|
||||||
* pContext: the ini context
|
|
||||||
* nDefaultValue: the default value
|
|
||||||
* nDefaultUnitBytes: the default timestamp unit, such as 1 for second, 86400 for day
|
|
||||||
* bRetryGlobal: if fetch from global section when the item not exist
|
|
||||||
* return: int64 value, return nDefaultValue when the item not exist
|
|
||||||
*/
|
|
||||||
int64_t iniGetTimestampValueEx(const char *szSectionName,
|
|
||||||
const char *szItemName, IniContext *pContext,
|
|
||||||
const int64_t nDefaultValue, const int nDefaultUnitTS,
|
|
||||||
const bool bRetryGlobal);
|
|
||||||
|
|
||||||
/** get item boolean value
|
/** get item boolean value
|
||||||
* parameters:
|
* parameters:
|
||||||
* szSectionName: the section name, NULL or empty string for
|
* szSectionName: the section name, NULL or empty string for
|
||||||
|
|
|
||||||
|
|
@ -2484,88 +2484,6 @@ int parse_bytes(const char *pStr, const int default_unit_bytes, int64_t *bytes)
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
int parse_timestamp(const char *str, const int default_unit_secs, int64_t *seconds)
|
|
||||||
{
|
|
||||||
char *pReservedEnd;
|
|
||||||
int result;
|
|
||||||
|
|
||||||
pReservedEnd = NULL;
|
|
||||||
*seconds = strtoll(str, &pReservedEnd, 10);
|
|
||||||
if (*seconds < 0)
|
|
||||||
{
|
|
||||||
logError("file: "__FILE__", line: %d, "
|
|
||||||
"timestamp: %"PRId64" < 0, input string: %s",
|
|
||||||
__LINE__, *seconds, str);
|
|
||||||
return EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pReservedEnd == NULL || *pReservedEnd == '\0')
|
|
||||||
{
|
|
||||||
*seconds *= default_unit_secs;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (*pReservedEnd == ' ' || *pReservedEnd == '\t')
|
|
||||||
{
|
|
||||||
do {
|
|
||||||
++pReservedEnd;
|
|
||||||
} while (*pReservedEnd == ' ' || *pReservedEnd == '\t');
|
|
||||||
|
|
||||||
if (*pReservedEnd == '\0')
|
|
||||||
{
|
|
||||||
*seconds *= default_unit_secs;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (*(pReservedEnd + 1) != '\0')
|
|
||||||
{
|
|
||||||
logError("file: "__FILE__", line: %d, "
|
|
||||||
"unkown timestamp unit: \"%s\", input string: \"%s\"",
|
|
||||||
__LINE__, pReservedEnd, str);
|
|
||||||
return EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (*pReservedEnd)
|
|
||||||
{
|
|
||||||
case 's':
|
|
||||||
result = 0;
|
|
||||||
break;
|
|
||||||
case 'm':
|
|
||||||
*seconds *= 60;
|
|
||||||
result = 0;
|
|
||||||
break;
|
|
||||||
case 'h':
|
|
||||||
*seconds *= 3600;
|
|
||||||
result = 0;
|
|
||||||
break;
|
|
||||||
case 'd':
|
|
||||||
*seconds *= 86400;
|
|
||||||
result = 0;
|
|
||||||
break;
|
|
||||||
case 'W':
|
|
||||||
*seconds *= 7 * 86400;
|
|
||||||
result = 0;
|
|
||||||
break;
|
|
||||||
case 'M':
|
|
||||||
*seconds *= 30 * 86400;
|
|
||||||
result = 0;
|
|
||||||
break;
|
|
||||||
case 'Y':
|
|
||||||
*seconds *= 365 * 86400;
|
|
||||||
result = 0;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
result = EINVAL;
|
|
||||||
logError("file: "__FILE__", line: %d, "
|
|
||||||
"unkown timestamp unit: \"%s\", input string: \"%s\"",
|
|
||||||
__LINE__, pReservedEnd, str);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
int set_rand_seed()
|
int set_rand_seed()
|
||||||
{
|
{
|
||||||
time_t ts;
|
time_t ts;
|
||||||
|
|
|
||||||
|
|
@ -979,22 +979,12 @@ int fc_compare_int64_ptr(const int64_t *n1, const int64_t *n2);
|
||||||
/** parse bytes
|
/** parse bytes
|
||||||
* parameters:
|
* parameters:
|
||||||
* pStr: the string to parse
|
* pStr: the string to parse
|
||||||
* default_unit_bytes: default unit if not specified, the unit like MB etc.
|
* default_unit_bytes: default unit if not specified the unit like MB etc.
|
||||||
* bytes: store the parsed bytes
|
* bytes: store the parsed bytes
|
||||||
* return: error no , 0 success, != 0 fail
|
* return: error no , 0 success, != 0 fail
|
||||||
*/
|
*/
|
||||||
int parse_bytes(const char *pStr, const int default_unit_bytes, int64_t *bytes);
|
int parse_bytes(const char *pStr, const int default_unit_bytes, int64_t *bytes);
|
||||||
|
|
||||||
/** parse timestamp
|
|
||||||
* parameters:
|
|
||||||
* str: the string to parse
|
|
||||||
* default_unit_secs: default unit if not specified
|
|
||||||
* seconds: store the parsed seconds
|
|
||||||
* return: error no , 0 success, != 0 fail
|
|
||||||
*/
|
|
||||||
int parse_timestamp(const char *str, const int default_unit_secs, int64_t *seconds);
|
|
||||||
|
|
||||||
|
|
||||||
/** set rand seed
|
/** set rand seed
|
||||||
* return: error no , 0 success, != 0 fail
|
* return: error no , 0 success, != 0 fail
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue