aboutsummaryrefslogtreecommitdiffstats
path: root/utils.c
diff options
context:
space:
mode:
authorkpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b>2006-02-15 00:24:24 +0000
committerkpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b>2006-02-15 00:24:24 +0000
commit15db46a445a4d6d71993475369b4a4906861f362 (patch)
tree6572dc8ac1336a5e0c0859186138a5313e88bd85 /utils.c
parent69f7e69869d726709046bffd71fd109b7dc4560d (diff)
add API function for parsing strings to time_t (issue #6320, with mods)
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@10105 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'utils.c')
-rw-r--r--utils.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/utils.c b/utils.c
index 8e4cc4acc..23c239295 100644
--- a/utils.c
+++ b/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;
+}