mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-05 20:20:07 +00:00
add API function for parsing strings to time_t (issue #6320, with mods)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@10105 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
24
utils.c
24
utils.c
@@ -1046,3 +1046,27 @@ void __ast_string_field_index_build(struct ast_string_field_mgr *mgr,
|
||||
|
||||
va_end(ap2);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* get values from config variables.
|
||||
*/
|
||||
int ast_get_time_t(const char *src, time_t *dst, time_t _default)
|
||||
{
|
||||
long t;
|
||||
|
||||
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, "%ld", &t) == 1) {
|
||||
*dst = t;
|
||||
return 0;
|
||||
} else
|
||||
return -1;
|
||||
}
|
||||
|
Reference in New Issue
Block a user