mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-03 11:25:35 +00:00
core: Add PARSE_TIMELEN support to ast_parse_arg and ACO.
This adds support for parsing timelen values from config files. This includes support for all flags which apply to PARSE_INT32. Support for this parser is added to ACO via the OPT_TIMELEN_T option type. Fixes an issue where extra characters provided to ast_app_parse_timelen were ignored, they now cause an error. Testing is included. ASTERISK-27117 #close Change-Id: I6b333feca7e3f83b4ef5bf2636fc0fd613742554
This commit is contained in:
13
main/app.c
13
main/app.c
@@ -3060,19 +3060,32 @@ int ast_app_parse_timelen(const char *timestr, int *result, enum ast_timelen uni
|
||||
case 'h':
|
||||
case 'H':
|
||||
unit = TIMELEN_HOURS;
|
||||
if (u[1] != '\0') {
|
||||
return -1;
|
||||
}
|
||||
break;
|
||||
case 's':
|
||||
case 'S':
|
||||
unit = TIMELEN_SECONDS;
|
||||
if (u[1] != '\0') {
|
||||
return -1;
|
||||
}
|
||||
break;
|
||||
case 'm':
|
||||
case 'M':
|
||||
if (toupper(u[1]) == 'S') {
|
||||
unit = TIMELEN_MILLISECONDS;
|
||||
if (u[2] != '\0') {
|
||||
return -1;
|
||||
}
|
||||
} else if (u[1] == '\0') {
|
||||
unit = TIMELEN_MINUTES;
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user