mirror of
https://github.com/asterisk/asterisk.git
synced 2025-11-16 23:08:32 +00:00
add 'consumed' argument to ast_get_time_t, so callers can know how many characters were used in the parser
update pbx_dundi to use ast_get_time_t eliminate some compiler warnings git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@10871 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
7
utils.c
7
utils.c
@@ -1051,9 +1051,10 @@ void __ast_string_field_index_build(struct ast_string_field_mgr *mgr,
|
||||
/*
|
||||
* get values from config variables.
|
||||
*/
|
||||
int ast_get_time_t(const char *src, time_t *dst, time_t _default)
|
||||
int ast_get_time_t(const char *src, time_t *dst, time_t _default, int *consumed)
|
||||
{
|
||||
long t;
|
||||
int scanned;
|
||||
|
||||
if (dst == NULL)
|
||||
return -1;
|
||||
@@ -1064,8 +1065,10 @@ int ast_get_time_t(const char *src, time_t *dst, time_t _default)
|
||||
return -1;
|
||||
|
||||
/* only integer at the moment, but one day we could accept more formats */
|
||||
if (sscanf(src, "%ld", &t) == 1) {
|
||||
if (sscanf(src, "%ld%n", &t, &scanned) == 1) {
|
||||
*dst = t;
|
||||
if (consumed)
|
||||
*consumed = scanned;
|
||||
return 0;
|
||||
} else
|
||||
return -1;
|
||||
|
||||
Reference in New Issue
Block a user