mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-06 12:36:58 +00:00
Merge in ast_strftime branch, which changes timestamps to be accurate to the microsecond, instead of only to the second
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@75706 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
27
main/utils.c
27
main/utils.c
@@ -973,6 +973,33 @@ int ast_atomic_fetchadd_int_slow(volatile int *p, int v)
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*! \brief
|
||||
* get values from config variables.
|
||||
*/
|
||||
int ast_get_timeval(const char *src, struct timeval *dst, struct timeval _default, int *consumed)
|
||||
{
|
||||
long double dtv = 0.0;
|
||||
int scanned;
|
||||
|
||||
if (dst == NULL)
|
||||
return -1;
|
||||
|
||||
*dst = _default;
|
||||
|
||||
if (ast_strlen_zero(src))
|
||||
return -1;
|
||||
|
||||
/* only integer at the moment, but one day we could accept more formats */
|
||||
if (sscanf(src, "%Lf%n", &dtv, &scanned) > 0) {
|
||||
dst->tv_sec = dtv;
|
||||
dst->tv_usec = (dtv - dst->tv_sec) * 1000000.0;
|
||||
if (consumed)
|
||||
*consumed = scanned;
|
||||
return 0;
|
||||
} else
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*! \brief
|
||||
* get values from config variables.
|
||||
*/
|
||||
|
Reference in New Issue
Block a user