diff options
author | Mark Murawki <markm@intellasoft.net> | 2012-04-03 19:31:25 +0000 |
---|---|---|
committer | Mark Murawki <markm@intellasoft.net> | 2012-04-03 19:31:25 +0000 |
commit | e4252eac1010af969007afb525871242855d39e7 (patch) | |
tree | 27f4bcb1ede2c708c34454ba98e5880a7df836a5 /main/utils.c | |
parent | 9cc6f2c59e41c0d5fa34f03950131a4eb81cc7ab (diff) |
Allow the Hangup manager action to match channels by regex
* Hangup now can take a regular expression as the Channel option. If you want
to hangup multiple channels, use /regex/ as the Channel option. Existing
behavior to hanging up a single channel is unchanged, but if you pass a regex,
the manager will send you a list of channels back that were hung up.
(closes issue ASTERISK-19575)
Reported by: Mark Murawski
Tested by: Mark Murawski
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@361038 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'main/utils.c')
-rw-r--r-- | main/utils.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/main/utils.c b/main/utils.c index ffcd37c2a..379a17995 100644 --- a/main/utils.c +++ b/main/utils.c @@ -1350,6 +1350,26 @@ int ast_build_string(char **buffer, size_t *space, const char *fmt, ...) return result; } +int ast_regex_string_to_regex_pattern(const char *regex_string, struct ast_str *regex_pattern) +{ + int regex_len = strlen(regex_string); + int ret = 3; + + /* Chop off the leading / if there is one */ + if ((regex_len >= 1) && (regex_string[0] == '/')) { + ast_str_set(®ex_pattern, 0, "%s", regex_string + 1); + ret -= 2; + } + + /* Chop off the ending / if there is one */ + if ((regex_len > 1) && (regex_string[regex_len - 1] == '/')) { + ast_str_truncate(regex_pattern, -1); + ret -= 1; + } + + return ret; +} + int ast_true(const char *s) { if (ast_strlen_zero(s)) |