fix filters (reported on mailing list use jira next time =/)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@16527 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
35fb1f546f
commit
f859964993
|
@ -254,7 +254,7 @@ ESL_DECLARE(char *)esl_event_get_body(esl_event_t *event)
|
||||||
return (event ? event->body : NULL);
|
return (event ? event->body : NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
ESL_DECLARE(esl_status_t) esl_event_del_header(esl_event_t *event, const char *header_name)
|
ESL_DECLARE(esl_status_t) esl_event_del_header_val(esl_event_t *event, const char *header_name, const char *val)
|
||||||
{
|
{
|
||||||
esl_event_header_t *hp, *lp = NULL, *tp;
|
esl_event_header_t *hp, *lp = NULL, *tp;
|
||||||
esl_status_t status = ESL_FAIL;
|
esl_status_t status = ESL_FAIL;
|
||||||
|
@ -271,7 +271,7 @@ ESL_DECLARE(esl_status_t) esl_event_del_header(esl_event_t *event, const char *h
|
||||||
esl_assert(x < 1000);
|
esl_assert(x < 1000);
|
||||||
hash = esl_ci_hashfunc_default(header_name, &hlen);
|
hash = esl_ci_hashfunc_default(header_name, &hlen);
|
||||||
|
|
||||||
if (hp->name && (!hp->hash || hash == hp->hash) && !strcasecmp(header_name, hp->name)) {
|
if (hp->name && (!hp->hash || hash == hp->hash) && !strcasecmp(header_name, hp->name) && (esl_strlen_zero(val) || !strcmp(hp->value, val))) {
|
||||||
if (lp) {
|
if (lp) {
|
||||||
lp->next = hp->next;
|
lp->next = hp->next;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -226,7 +226,8 @@ ESL_DECLARE(esl_status_t) esl_event_add_header(esl_event_t *event, esl_stack_t s
|
||||||
*/
|
*/
|
||||||
ESL_DECLARE(esl_status_t) esl_event_add_header_string(esl_event_t *event, esl_stack_t stack, const char *header_name, const char *data);
|
ESL_DECLARE(esl_status_t) esl_event_add_header_string(esl_event_t *event, esl_stack_t stack, const char *header_name, const char *data);
|
||||||
|
|
||||||
ESL_DECLARE(esl_status_t) esl_event_del_header(esl_event_t *event, const char *header_name);
|
ESL_DECLARE(esl_status_t) esl_event_del_header_val(esl_event_t *event, const char *header_name, const char *var);
|
||||||
|
#define esl_event_del_header(_e, _h) esl_event_del_header_val(_e, _h, NULL)
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Destroy an event
|
\brief Destroy an event
|
||||||
|
|
|
@ -182,7 +182,8 @@ SWITCH_DECLARE(switch_status_t) switch_event_set_subclass_name(switch_event_t *e
|
||||||
*/
|
*/
|
||||||
SWITCH_DECLARE(switch_status_t) switch_event_add_header_string(switch_event_t *event, switch_stack_t stack, const char *header_name, const char *data);
|
SWITCH_DECLARE(switch_status_t) switch_event_add_header_string(switch_event_t *event, switch_stack_t stack, const char *header_name, const char *data);
|
||||||
|
|
||||||
SWITCH_DECLARE(switch_status_t) switch_event_del_header(switch_event_t *event, const char *header_name);
|
SWITCH_DECLARE(switch_status_t) switch_event_del_header_val(switch_event_t *event, const char *header_name, const char *val);
|
||||||
|
#define switch_event_del_header(_e, _h) switch_event_del_header_val(_e, _h, NULL)
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Destroy an event
|
\brief Destroy an event
|
||||||
|
|
|
@ -1705,19 +1705,15 @@ static switch_status_t parse_command(listener_t *listener, switch_event_t **even
|
||||||
|
|
||||||
if (!strncasecmp(cmd, "filter ", 7)) {
|
if (!strncasecmp(cmd, "filter ", 7)) {
|
||||||
char *header_name = cmd + 7;
|
char *header_name = cmd + 7;
|
||||||
char *header_val;
|
char *header_val = NULL;
|
||||||
|
|
||||||
strip_cr(header_name);
|
strip_cr(header_name);
|
||||||
|
|
||||||
while(header_name && *header_name && *header_name == ' ') header_name++;
|
while(header_name && *header_name && *header_name == ' ') header_name++;
|
||||||
|
|
||||||
if (!(header_val = strchr(header_name, ' '))) {
|
if ((header_val = strchr(header_name, ' '))) {
|
||||||
switch_snprintf(reply, reply_len, "-ERR invalid syntax");
|
|
||||||
goto done;
|
|
||||||
}
|
|
||||||
|
|
||||||
*header_val++ = '\0';
|
*header_val++ = '\0';
|
||||||
|
}
|
||||||
|
|
||||||
switch_mutex_lock(listener->filter_mutex);
|
switch_mutex_lock(listener->filter_mutex);
|
||||||
if (!listener->filters) {
|
if (!listener->filters) {
|
||||||
|
@ -1725,16 +1721,28 @@ static switch_status_t parse_command(listener_t *listener, switch_event_t **even
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!strcasecmp(header_name, "delete")) {
|
if (!strcasecmp(header_name, "delete")) {
|
||||||
if (!strcasecmp(header_val, "all")) {
|
header_name = header_val;
|
||||||
|
if ((header_val = strchr(header_name, ' '))) {
|
||||||
|
*header_val++ = '\0';
|
||||||
|
}
|
||||||
|
if (!strcasecmp(header_name, "all")) {
|
||||||
switch_event_destroy(&listener->filters);
|
switch_event_destroy(&listener->filters);
|
||||||
switch_event_create_plain(&listener->filters, SWITCH_EVENT_CHANNEL_DATA);
|
switch_event_create_plain(&listener->filters, SWITCH_EVENT_CHANNEL_DATA);
|
||||||
} else {
|
} else {
|
||||||
switch_event_del_header(listener->filters, header_val);
|
switch_event_del_header_val(listener->filters, header_name, header_val);
|
||||||
|
}
|
||||||
|
switch_snprintf(reply, reply_len, "+OK filter deleted. [%s][%s]", header_name, switch_str_nil(header_val));
|
||||||
|
} else if (header_val) {
|
||||||
|
if (!strcasecmp(header_name, "add")) {
|
||||||
|
header_name = header_val;
|
||||||
|
if ((header_val = strchr(header_name, ' '))) {
|
||||||
|
*header_val++ = '\0';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
switch_snprintf(reply, reply_len, "+OK filter deleted. [%s]", header_val);
|
|
||||||
} else {
|
|
||||||
switch_event_add_header_string(listener->filters, SWITCH_STACK_BOTTOM, header_name, header_val);
|
switch_event_add_header_string(listener->filters, SWITCH_STACK_BOTTOM, header_name, header_val);
|
||||||
switch_snprintf(reply, reply_len, "+OK filter added. [%s]=[%s]", header_name, header_val);
|
switch_snprintf(reply, reply_len, "+OK filter added. [%s]=[%s]", header_name, header_val);
|
||||||
|
} else {
|
||||||
|
switch_snprintf(reply, reply_len, "-ERR invalid syntax");
|
||||||
}
|
}
|
||||||
switch_mutex_unlock(listener->filter_mutex);
|
switch_mutex_unlock(listener->filter_mutex);
|
||||||
|
|
||||||
|
|
|
@ -697,7 +697,7 @@ SWITCH_DECLARE(char *) switch_event_get_body(switch_event_t *event)
|
||||||
return (event ? event->body : NULL);
|
return (event ? event->body : NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
SWITCH_DECLARE(switch_status_t) switch_event_del_header(switch_event_t *event, const char *header_name)
|
SWITCH_DECLARE(switch_status_t) switch_event_del_header_val(switch_event_t *event, const char *header_name, const char *val)
|
||||||
{
|
{
|
||||||
switch_event_header_t *hp, *lp = NULL, *tp;
|
switch_event_header_t *hp, *lp = NULL, *tp;
|
||||||
switch_status_t status = SWITCH_STATUS_FALSE;
|
switch_status_t status = SWITCH_STATUS_FALSE;
|
||||||
|
@ -714,7 +714,7 @@ SWITCH_DECLARE(switch_status_t) switch_event_del_header(switch_event_t *event, c
|
||||||
switch_assert(x < 1000);
|
switch_assert(x < 1000);
|
||||||
hash = switch_ci_hashfunc_default(header_name, &hlen);
|
hash = switch_ci_hashfunc_default(header_name, &hlen);
|
||||||
|
|
||||||
if ((!hp->hash || hash == hp->hash) && !strcasecmp(header_name, hp->name)) {
|
if ((!hp->hash || hash == hp->hash) && !strcasecmp(header_name, hp->name) && (zstr(val) || !strcmp(hp->value, val))) {
|
||||||
if (lp) {
|
if (lp) {
|
||||||
lp->next = hp->next;
|
lp->next = hp->next;
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue