[Freeswitch-svn] [commit] r9744 - in freeswitch/trunk/src: . include
Freeswitch SVN
mikej at freeswitch.org
Mon Sep 29 13:48:43 EDT 2008
Author: mikej
Date: Mon Sep 29 13:48:43 2008
New Revision: 9744
Modified:
freeswitch/trunk/src/include/switch_channel.h
freeswitch/trunk/src/switch_channel.c
freeswitch/trunk/src/switch_event.c
Log:
add switch_channel_set_variable_printf
Modified: freeswitch/trunk/src/include/switch_channel.h
==============================================================================
--- freeswitch/trunk/src/include/switch_channel.h (original)
+++ freeswitch/trunk/src/include/switch_channel.h Mon Sep 29 13:48:43 2008
@@ -220,6 +220,7 @@
\returns SWITCH_STATUS_SUCCESS if successful
*/
SWITCH_DECLARE(switch_status_t) switch_channel_set_variable(switch_channel_t *channel, const char *varname, const char *value);
+SWITCH_DECLARE(switch_status_t) switch_channel_set_variable_printf(switch_channel_t *channel, const char *varname, const char *fmt, ...);
SWITCH_DECLARE(switch_status_t) switch_channel_set_variable_partner(switch_channel_t *channel, const char *varname, const char *value);
SWITCH_DECLARE(const char *) switch_channel_get_variable_partner(switch_channel_t *channel, const char *varname);
Modified: freeswitch/trunk/src/switch_channel.c
==============================================================================
--- freeswitch/trunk/src/switch_channel.c (original)
+++ freeswitch/trunk/src/switch_channel.c Mon Sep 29 13:48:43 2008
@@ -578,6 +578,37 @@
return SWITCH_STATUS_FALSE;
}
+switch_status_t switch_event_base_add_header(switch_event_t *event, switch_stack_t stack, const char *header_name, char *data);
+
+SWITCH_DECLARE(switch_status_t) switch_channel_set_variable_printf(switch_channel_t *channel, const char *varname, const char *fmt, ...)
+{
+ int ret = 0;
+ char *data;
+ va_list ap;
+ switch_assert(channel != NULL);
+
+ if (!switch_strlen_zero(varname)) {
+ switch_mutex_lock(channel->profile_mutex);
+ switch_event_del_header(channel->variables, varname);
+
+ va_start(ap, fmt);
+ ret = switch_vasprintf(&data, fmt, ap);
+ va_end(ap);
+
+ if (ret == -1) {
+ switch_mutex_unlock(channel->profile_mutex);
+ return SWITCH_STATUS_MEMERR;
+ }
+
+ switch_event_base_add_header(channel->variables, SWITCH_STACK_BOTTOM, varname, data);
+
+ switch_mutex_unlock(channel->profile_mutex);
+ return SWITCH_STATUS_SUCCESS;
+ }
+
+ return SWITCH_STATUS_FALSE;
+}
+
SWITCH_DECLARE(switch_status_t) switch_channel_set_variable_partner(switch_channel_t *channel, const char *varname, const char *value)
{
Modified: freeswitch/trunk/src/switch_event.c
==============================================================================
--- freeswitch/trunk/src/switch_event.c (original)
+++ freeswitch/trunk/src/switch_event.c Mon Sep 29 13:48:43 2008
@@ -625,7 +625,7 @@
return status;
}
-static switch_status_t switch_event_base_add_header(switch_event_t *event, switch_stack_t stack, const char *header_name, char *data)
+switch_status_t switch_event_base_add_header(switch_event_t *event, switch_stack_t stack, const char *header_name, char *data)
{
switch_event_header_t *header;
void *pop;
More information about the Freeswitch-svn
mailing list