summaryrefslogtreecommitdiff
path: root/main/config.c
diff options
context:
space:
mode:
authorJenkins2 <jenkins2@gerrit.asterisk.org>2017-07-19 09:25:59 -0500
committerGerrit Code Review <gerrit2@gerrit.digium.api>2017-07-19 09:25:59 -0500
commit62c381afdbbf4bfa3f04d7b820c566c5eeb60272 (patch)
treed6b414552bd08f80f15da3801071aa93afc81f25 /main/config.c
parent47084ad09e30ad75a97500de7378414edccc01c0 (diff)
parent78a50b034368d3a21f81dfce0fc740021092d7f1 (diff)
Merge "core: Add PARSE_TIMELEN support to ast_parse_arg and ACO."
Diffstat (limited to 'main/config.c')
-rw-r--r--main/config.c49
1 files changed, 49 insertions, 0 deletions
diff --git a/main/config.c b/main/config.c
index a3e09f67e..3d8dcfb3d 100644
--- a/main/config.c
+++ b/main/config.c
@@ -3741,6 +3741,55 @@ uint32_done:
break;
}
+ case PARSE_TIMELEN:
+ {
+ int x = 0;
+ int *result = p_result;
+ int def = result ? *result : 0;
+ int high = INT_MAX;
+ int low = INT_MIN;
+ enum ast_timelen defunit;
+
+ defunit = va_arg(ap, enum ast_timelen);
+ /* optional arguments: default value and/or (low, high) */
+ if (flags & PARSE_DEFAULT) {
+ def = va_arg(ap, int);
+ }
+ if (flags & (PARSE_IN_RANGE | PARSE_OUT_RANGE)) {
+ low = va_arg(ap, int);
+ high = va_arg(ap, int);
+ }
+ if (ast_strlen_zero(arg)) {
+ error = 1;
+ goto timelen_done;
+ }
+ error = ast_app_parse_timelen(arg, &x, defunit);
+ if (error || x < INT_MIN || x > INT_MAX) {
+ /* Parse error, or type out of int bounds */
+ error = 1;
+ goto timelen_done;
+ }
+ error = (x < low) || (x > high);
+ if (flags & PARSE_RANGE_DEFAULTS) {
+ if (x < low) {
+ def = low;
+ } else if (x > high) {
+ def = high;
+ }
+ }
+ if (flags & PARSE_OUT_RANGE) {
+ error = !error;
+ }
+timelen_done:
+ if (result) {
+ *result = error ? def : x;
+ }
+
+ ast_debug(3, "extract timelen from [%s] in [%d, %d] gives [%d](%d)\n",
+ arg, low, high, result ? *result : x, error);
+ break;
+ }
+
case PARSE_DOUBLE:
{
double *result = p_result;