get rid of _ char in special vars and add an unset dialplan app for clarity sake

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@4124 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Anthony Minessale 2007-02-05 19:35:31 +00:00
parent 96e32a8d4c
commit c6d0188af0
3 changed files with 44 additions and 20 deletions

View File

@ -76,21 +76,21 @@ SWITCH_BEGIN_EXTERN_C
#define SWITCH_GRAMMAR_DIR SWITCH_PREFIX_DIR SWITCH_PATH_SEPARATOR "grammar"
#endif
#define SWITCH_R_SDP_VARIABLE "_switch_r_sdp_"
#define SWITCH_L_SDP_VARIABLE "_switch_l_sdp_"
#define SWITCH_B_SDP_VARIABLE "_switch_m_sdp_"
#define SWITCH_BRIDGE_VARIABLE "_bridge_to_"
#define SWITCH_SIGNAL_BRIDGE_VARIABLE "_signal_bridge_to_"
#define SWITCH_ORIGINATOR_VARIABLE "_originator_"
#define SWITCH_ORIGINATOR_CODEC_VARIABLE "_originator_codec_"
#define SWITCH_LOCAL_MEDIA_IP_VARIABLE "_local_media_ip_"
#define SWITCH_LOCAL_MEDIA_PORT_VARIABLE "_local_media_port_"
#define SWITCH_REMOTE_MEDIA_IP_VARIABLE "_remote_media_ip_"
#define SWITCH_REMOTE_MEDIA_PORT_VARIABLE "_remote_media_port_"
#define SWITCH_R_SDP_VARIABLE "switch_r_sdp"
#define SWITCH_L_SDP_VARIABLE "switch_l_sdp"
#define SWITCH_B_SDP_VARIABLE "switch_m_sdp"
#define SWITCH_BRIDGE_VARIABLE "bridge_to"
#define SWITCH_SIGNAL_BRIDGE_VARIABLE "signal_bridge_to"
#define SWITCH_ORIGINATOR_VARIABLE "originator"
#define SWITCH_ORIGINATOR_CODEC_VARIABLE "originator_codec"
#define SWITCH_LOCAL_MEDIA_IP_VARIABLE "local_media_ip"
#define SWITCH_LOCAL_MEDIA_PORT_VARIABLE "local_media_port"
#define SWITCH_REMOTE_MEDIA_IP_VARIABLE "remote_media_ip"
#define SWITCH_REMOTE_MEDIA_PORT_VARIABLE "remote_media_port"
#define SWITCH_HANGUP_AFTER_BRIDGE_VARIABLE "hangup_after_bridge"
#define SWITCH_SPEECH_KEY "_speech_"
#define SWITCH_UUID_BRIDGE "_uuid_bridge_"
#define SWITCH_SPEECH_KEY "speech"
#define SWITCH_UUID_BRIDGE "uuid_bridge"
#define SWITCH_BITS_PER_BYTE 8
typedef uint8_t switch_byte_t;

View File

@ -176,7 +176,6 @@ static void redirect_function(switch_core_session_t *session, char *data)
}
static void set_function(switch_core_session_t *session, char *data)
{
switch_channel_t *channel;
@ -193,7 +192,7 @@ static void set_function(switch_core_session_t *session, char *data)
if (val) {
*val++ = '\0';
if (!strcmp(val, "_UNDEF_")) {
if (switch_strlen_zero(val)) {
val = NULL;
}
}
@ -203,6 +202,22 @@ static void set_function(switch_core_session_t *session, char *data)
}
}
static void unset_function(switch_core_session_t *session, char *data)
{
switch_channel_t *channel;
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 {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "UNSET [%s]\n", (char *) data);
switch_channel_set_variable(channel, (char *) data, NULL);
}
}
static void log_function(switch_core_session_t *session, char *data)
{
switch_channel_t *channel;
@ -524,13 +539,22 @@ static const switch_application_interface_t ringback_application_interface = {
/*.next */ &detect_speech_application_interface
};
static const switch_application_interface_t unset_application_interface = {
/*.interface_name */ "unset",
/*.application_function */ unset_function,
/* long_desc */ "Unset a channel varaible for the channel calling the application.",
/* short_desc */ "Unset a channel varaible",
/* syntax */ "<varname>",
/*.next */ &ringback_application_interface
};
static const switch_application_interface_t set_application_interface = {
/*.interface_name */ "set",
/*.application_function */ set_function,
/* long_desc */ "Set a channel varaible for the channel calling the application.",
/* short_desc */ "Set a channel varaible",
/* syntax */ "<varname>=[<value>|_UNDEF_]",
/*.next */ &ringback_application_interface
/* syntax */ "<varname>=<value>",
/*.next */ &unset_application_interface
};
static const switch_application_interface_t info_application_interface = {

View File

@ -363,7 +363,7 @@ SWITCH_DECLARE(switch_status_t) switch_channel_set_variable(switch_channel_t *ch
if (varname) {
switch_core_hash_delete(channel->variables, varname);
if (value) {
if (!switch_strlen_zero(value)) {
switch_core_hash_insert_dup(channel->variables, varname, switch_core_session_strdup(channel->session, value));
} else {
switch_core_hash_delete(channel->variables, varname);