[Freeswitch-svn] [commit] r4299 - in freeswitch/trunk/src: . include mod/applications/mod_dptools
Freeswitch SVN
anthm at freeswitch.org
Fri Feb 16 15:07:36 EST 2007
Author: anthm
Date: Fri Feb 16 15:07:35 2007
New Revision: 4299
Modified:
freeswitch/trunk/src/include/switch_types.h
freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c
freeswitch/trunk/src/switch_core.c
Log:
add export app (set + adding to export_vars) in 1
Modified: freeswitch/trunk/src/include/switch_types.h
==============================================================================
--- freeswitch/trunk/src/include/switch_types.h (original)
+++ freeswitch/trunk/src/include/switch_types.h Fri Feb 16 15:07:35 2007
@@ -76,6 +76,7 @@
#define SWITCH_GRAMMAR_DIR SWITCH_PREFIX_DIR SWITCH_PATH_SEPARATOR "grammar"
#endif
+#define SWITCH_EXPORT_VARS_VARIABLE "export_vars"
#define SWITCH_R_SDP_VARIABLE "switch_r_sdp"
#define SWITCH_L_SDP_VARIABLE "switch_l_sdp"
#define SWITCH_B_SDP_VARIABLE "switch_m_sdp"
Modified: freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c (original)
+++ freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c Fri Feb 16 15:07:35 2007
@@ -210,6 +210,43 @@
}
}
+static void export_function(switch_core_session_t *session, char *data)
+{
+ switch_channel_t *channel;
+ char *exports, *new_exports = NULL, *new_exports_d = NULL, *var, *val = NULL;
+
+ channel = switch_core_session_get_channel(session);
+ assert(channel != NULL);
+
+ if (switch_strlen_zero(data)) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No variable name specified.\n");
+ } else {
+ exports = switch_channel_get_variable(channel, SWITCH_EXPORT_VARS_VARIABLE);
+ var = switch_core_session_strdup(session, data);
+ val = strchr(var, '=');
+
+ if (val) {
+ *val++ = '\0';
+ if (switch_strlen_zero(val)) {
+ val = NULL;
+ }
+ }
+
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "EXPORT [%s]=[%s]\n", var, val ? val : "UNDEF");
+ switch_channel_set_variable(channel, var, val);
+
+ if (var && val) {
+ if (exports) {
+ new_exports_d = switch_mprintf("%s,%s", exports, var);
+ new_exports = new_exports_d;
+ } else {
+ new_exports = var;
+ }
+ switch_channel_set_variable(channel, SWITCH_EXPORT_VARS_VARIABLE, new_exports);
+ switch_safe_free(new_exports_d);
+ }
+ }
+}
static void unset_function(switch_core_session_t *session, char *data)
{
@@ -567,13 +604,22 @@
/*.next */ &unset_application_interface
};
+static const switch_application_interface_t export_application_interface = {
+ /*.interface_name */ "export",
+ /*.application_function */ export_function,
+ /* long_desc */ "Set and export a channel varaible for the channel calling the application.",
+ /* short_desc */ "Export a channel varaible across a bridge",
+ /* syntax */ "<varname>=<value>",
+ /*.next */ &set_application_interface
+};
+
static const switch_application_interface_t info_application_interface = {
/*.interface_name */ "info",
/*.application_function */ info_function,
/* long_desc */ "Display Call Info",
/* short_desc */ "Display Call Info",
/* syntax */ "",
- /*.next */ &set_application_interface
+ /*.next */ &export_application_interface
};
static const switch_application_interface_t log_application_interface = {
Modified: freeswitch/trunk/src/switch_core.c
==============================================================================
--- freeswitch/trunk/src/switch_core.c (original)
+++ freeswitch/trunk/src/switch_core.c Fri Feb 16 15:07:35 2007
@@ -1641,7 +1641,7 @@
switch_channel_set_variable(peer_channel, SWITCH_ORIGINATOR_VARIABLE, switch_core_session_get_uuid(session));
/* A comma (,) separated list of variable names that should ne propagated from originator to originatee */
- if ((export_vars = switch_channel_get_variable(channel, "export_vars"))) {
+ if ((export_vars = switch_channel_get_variable(channel, SWITCH_EXPORT_VARS_VARIABLE))) {
char *cptmp = switch_core_session_strdup(session, export_vars);
int argc;
char *argv[256];
More information about the Freeswitch-svn
mailing list