add export app (set + adding to export_vars) in 1
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@4299 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
c78bd99d80
commit
9626393ef8
|
@ -76,6 +76,7 @@ SWITCH_BEGIN_EXTERN_C
|
|||
#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"
|
||||
|
|
|
@ -210,6 +210,43 @@ static void set_function(switch_core_session_t *session, char *data)
|
|||
}
|
||||
}
|
||||
|
||||
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 @@ static const switch_application_interface_t set_application_interface = {
|
|||
/*.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 = {
|
||||
|
|
|
@ -1641,7 +1641,7 @@ SWITCH_DECLARE(switch_call_cause_t) switch_core_session_outgoing_channel(switch_
|
|||
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];
|
||||
|
|
Loading…
Reference in New Issue