From: Anthony Minessale Date: Fri, 9 Sep 2011 19:31:02 +0000 (-0500) Subject: add optional format string after myevent X-Git-Tag: v1.2-rc1~51^2~123 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7ed7f539b0283ab848c2fdecb5c2d844ed9e6ff5;p=thirdparty%2Ffreeswitch.git add optional format string after myevent --- diff --git a/src/mod/event_handlers/mod_event_socket/mod_event_socket.c b/src/mod/event_handlers/mod_event_socket/mod_event_socket.c index 37c238852c..aaf270cb26 100644 --- a/src/mod/event_handlers/mod_event_socket/mod_event_socket.c +++ b/src/mod/event_handlers/mod_event_socket/mod_event_socket.c @@ -1883,11 +1883,30 @@ static switch_status_t parse_command(listener_t *listener, switch_event_t **even char *uuid; if ((uuid = cmd + 9)) { + char *fmt; strip_cr(uuid); - + + if ((fmt = strchr(uuid, ' '))) { + *fmt++ = '\0'; + } + if (!(listener->session = switch_core_session_locate(uuid))) { - switch_snprintf(reply, reply_len, "-ERR invalid uuid"); - goto done; + if (fmt) { + switch_snprintf(reply, reply_len, "-ERR invalid uuid"); + goto done; + } else { + fmt = uuid; + } + } + + if ((fmt = strchr(uuid, ' '))) { + if (!strcasecmp(fmt, "xml")) { + listener->format = EVENT_FORMAT_XML; + } else if (!strcasecmp(fmt, "plain")) { + listener->format = EVENT_FORMAT_PLAIN; + } else if (!strcasecmp(fmt, "json")) { + listener->format = EVENT_FORMAT_JSON; + } } switch_set_flag_locked(listener, LFLAG_SESSION);