186 return channel->hold_record;
192 const char *str =
"UNKNOWN";
195 if (CAUSE_CHART[x].cause == cause) {
196 str = CAUSE_CHART[x].
name;
210 if (*str > 47 && *str < 58) {
214 if (!strcasecmp(CAUSE_CHART[x].name, str)) {
215 cause = CAUSE_CHART[x].
cause;
227 return channel->hangup_cause;
233 return &channel->hangup_cause;
271 const
char *file, const
char *func,
int line)
276 if (o_callstate == callstate || o_callstate ==
CCS_HANGUP)
return;
278 channel->callstate = callstate;
279 if (channel->device_node) {
280 channel->device_node->callstate = callstate;
283 "(%s) Callstate Change %s -> %s\n", channel->name,
298 return channel->callstate;
305 const char *str =
"UNKNOWN";
308 if (CALLSTATE_CHART[x].callstate == callstate) {
309 str = CALLSTATE_CHART[x].
name;
320 const char *str =
"UNKNOWN";
323 if (DEVICE_STATE_CHART[x].device_state == device_state) {
324 str = DEVICE_STATE_CHART[x].
name;
338 if (*str > 47 && *str < 58) {
339 callstate = atoi(str);
342 if (!strcasecmp(CALLSTATE_CHART[x].
name, str)) {
343 callstate = CALLSTATE_CHART[x].
callstate;
361 msg->
from = channel->name;
380 msg->
from = channel->name;
410 if (channel->caller_profile) {
412 times = channel->caller_profile->times;
422 channel->direction = channel->logical_direction = direction;
429 return channel->direction;
434 return channel->logical_direction;
457 (*channel)->name =
"";
458 (*channel)->direction = (*channel)->logical_direction = direction;
518 if (new_dtmf.
digit !=
'w' && new_dtmf.
digit !=
'W') {
571 if (
zstr(dtmf_string)) {
578 if (*dtmf_string ==
'~') {
586 for (i = 0; i < argc; i++) {
589 if ((p = strchr(argv[i],
'@'))) {
596 for (p = argv[i]; p && *p; p++) {
652 }
else if (!dtmf->duration) {
661 const char *dtmf_source_str = NULL;
665 switch(dtmf->source) {
667 dtmf_source_str =
"INBAND_AUDIO";
670 dtmf_source_str =
"RTP";
673 dtmf_source_str =
"ENDPOINT";
676 dtmf_source_str =
"APP";
680 dtmf_source_str =
"UNKNOWN";
702 dtmf_str[x++] = dtmf.
digit;
731 if (channel->private_hash) {
735 if (channel->app_flag_hash) {
751 channel->state = state;
753 channel->session = session;
754 channel->running_state =
CS_NONE;
759 const
char *file, const
char *func,
int line)
763 const char *call_info = NULL;
764 char *call_info_state =
"active";
802 call_info_state =
"idle";
803 }
else if (!strcasecmp(status,
"hold-private")) {
804 call_info_state =
"held-private";
805 }
else if (!strcasecmp(status,
"hold")) {
806 call_info_state =
"held";
809 call_info_state =
"progressing";
812 call_info_state =
"idle";
814 call_info_state =
"alerting";
885 if (expanded != var) {
898 const char *r = NULL;
912 if (event && *event) {
913 (*event)->next = channel->scope_variables;
914 channel->scope_variables = *event;
916 }
else if (channel->scope_variables) {
918 channel->scope_variables = channel->scope_variables->
next;
932 if (channel->scope_variables) {
940 for (ep = channel->scope_variables; ep; ep = ep->
next) {
955 const char *v = NULL, *r = NULL, *vdup = NULL;
960 if (!
zstr(varname)) {
961 if (channel->scope_variables) {
964 for (ep = channel->scope_variables; ep; ep = ep->
next) {
975 if (!strncmp(varname,
"aleg_", 5)) {
978 }
else if (!strncmp(varname,
"bleg_", 5)) {
992 if (dup && v != vdup) {
1008 const char *val = NULL, *r = NULL;
1011 if (!
zstr(varname)) {
1046 if (channel->variables && (hi = channel->variables->headers)) {
1090 const char *old = NULL;
1093 if (!
zstr(channel->name)) {
1094 old = channel->name;
1096 channel->name = NULL;
1113 return (!
zstr(channel->name)) ? channel->name :
"N/A";
1124 if (!strcasecmp(name,
"device_id") && !
zstr(val)) {
1125 const char *device_id;
1141 if (!strcasecmp(name,
"dialplan")) {
1142 channel->caller_profile->dialplan = v;
1143 }
else if (!strcasecmp(name,
"username")) {
1144 channel->caller_profile->username = v;
1145 }
else if (!strcasecmp(name,
"caller_id_name")) {
1146 channel->caller_profile->caller_id_name = v;
1147 }
else if (!strcasecmp(name,
"caller_id_number")) {
1148 channel->caller_profile->caller_id_number = v;
1149 }
else if (!strcasecmp(name,
"callee_id_name")) {
1150 channel->caller_profile->callee_id_name = v;
1151 }
else if (!strcasecmp(name,
"callee_id_number")) {
1152 channel->caller_profile->callee_id_number = v;
1153 }
else if (val && !strcasecmp(name,
"caller_ton")) {
1154 channel->caller_profile->caller_ton = (uint8_t) atoi(v);
1155 }
else if (val && !strcasecmp(name,
"caller_numplan")) {
1156 channel->caller_profile->caller_numplan = (uint8_t) atoi(v);
1157 }
else if (val && !strcasecmp(name,
"destination_number_ton")) {
1158 channel->caller_profile->destination_number_ton = (uint8_t) atoi(v);
1159 }
else if (val && !strcasecmp(name,
"destination_number_numplan")) {
1160 channel->caller_profile->destination_number_numplan = (uint8_t) atoi(v);
1161 }
else if (!strcasecmp(name,
"ani")) {
1162 channel->caller_profile->ani = v;
1163 }
else if (!strcasecmp(name,
"aniii")) {
1164 channel->caller_profile->aniii = v;
1165 }
else if (!strcasecmp(name,
"network_addr")) {
1166 channel->caller_profile->network_addr = v;
1167 }
else if (!strcasecmp(name,
"rdnis")) {
1168 channel->caller_profile->rdnis = v;
1169 }
else if (!strcasecmp(name,
"destination_number")) {
1170 channel->caller_profile->destination_number = v;
1171 }
else if (!strcasecmp(name,
"uuid")) {
1172 channel->caller_profile->uuid = v;
1173 }
else if (!strcasecmp(name,
"source")) {
1174 channel->caller_profile->source = v;
1175 }
else if (!strcasecmp(name,
"context")) {
1176 channel->caller_profile->context = v;
1177 }
else if (!strcasecmp(name,
"chan_name")) {
1178 channel->caller_profile->chan_name = v;
1186 if (!channel->caller_profile->soft) {
1187 channel->caller_profile->soft = n;
1191 for(pn = channel->caller_profile->soft; pn ; pn = pn->
next) {
1192 if (!strcasecmp(pn->
var,n->
var)) {
1203 if (pn && !pn->
next && !var_found) {
1223 if (
zstr(export_vars))
return;
1238 for (x = 0; x < argc; x++) {
1241 char *vvar = argv[x];
1242 if (!strncasecmp(vvar,
"nolocal:", 8)) {
1244 }
else if (!strncasecmp(vvar,
"_nolocal_", 9)) {
1251 "%s EXPORTING[%s] [%s]=[%s] to event\n",
1258 "%s EXPORTING[%s] [%s]=[%s] to %s\n",
1272 const
char *varname, const
char *val,
1275 char *var_name = NULL;
1276 const char *exports;
1277 char *var, *new_exports, *new_exports_d = NULL;
1285 if (!strncasecmp(var,
"nolocal:", 8)) {
1288 }
else if (!strncasecmp(var,
"_nolocal_", 9)) {
1297 export_varname, local ?
"" :
"(REMOTE ONLY) ",
1298 var_name ? var_name :
"", val ? val :
"UNDEF");
1306 new_exports = new_exports_d;
1320 const
char *export_varname, const
char *fmt, ...)
1355 if (
zstr(prefix) || !strncasecmp(hp->
name, prefix, strlen(prefix))) {
1372 for (; hi; hi = hi->
next) {
1373 char *var = hi->
name;
1374 char *val = hi->
value;
1376 if (
zstr(prefix) || !strncasecmp(var, prefix, strlen(prefix))) {
1389 char *cols[128] = { 0 };
1390 char header_name[128] =
"";
1391 int col_count = 0, i = 0;
1392 char *data_copy = NULL;
1394 if (
zstr(presence_data_cols)) {
1396 if (
zstr(presence_data_cols)) {
1401 data_copy = strdup(presence_data_cols);
1405 for (i = 0; i < col_count; i++) {
1406 const char *val = NULL;
1417 const
char *varname, const
char *value,
switch_bool_t var_check)
1424 if (channel->variables && !
zstr(varname)) {
1455 if (channel->variables && !
zstr(varname)) {
1490 if (channel->variables && !
zstr(varname)) {
1542 const
char *varname, const
char *value,
switch_bool_t var_check)
1547 if (!
zstr(varname)) {
1569 r = channel->flags[flag];
1635 if ((channel->state <
CS_HANGUP && channel->state == channel->running_state && channel->running_state == want_state) ||
1651 if ((channel->state == channel->running_state && channel->running_state == want_state) || channel->state >=
CS_HANGUP) {
1659 if (++count >= timeout) {
1710 channel->caps[cap] = value;
1720 channel->caps[cap] = 0;
1727 return channel->caps[cap] ? 1 : 0;
1758 if (channel->flags[i]) {
1764 r = (
char *) stream.
data;
1784 if (channel->caps[i]) {
1790 r = (
char *) stream.
data;
1812 if (channel->flags[flag] != value) {
1814 channel->flags[flag] = value;
1829 if (channel->device_node) {
1834 if (channel->device_node) {
1854 if (channel->hold_record) {
1855 hr->
next = channel->hold_record;
1857 channel->hold_record = hr;
1885 channel->flags[flag]++;
1902 channel->private_flags |= flags;
1910 channel->private_flags &= ~flags;
1917 return (channel->private_flags & flags);
1922 uint32_t *flagp = NULL;
1928 if (!channel->app_flag_hash) {
1946 uint32_t *flagp = NULL;
1963 uint32_t *flagp = NULL;
1968 r = (*flagp & flags);
1981 channel->state_flags[0] = 1;
1982 channel->state_flags[flag] = 1;
1991 channel->state_flags[flag] = 0;
2011 if (channel->flags[flag]) {
2016 channel->flags[flag] = 0;
2022 if (channel->device_node) {
2031 if (channel->caller_profile->times->last_hold) {
2032 channel->caller_profile->times->hold_accum += (
switch_time_now() - channel->caller_profile->times->last_hold);
2035 if (channel->hold_record) {
2075 if (channel->flags[flag]) {
2076 channel->flags[flag]--;
2090 state = channel->state;
2100 state = channel->running_state;
2111 return channel->running_state != channel->state;
2160 "CS_EXCHANGE_MEDIA",
2174 return state_names[state];
2181 for (x = 0; state_names[x]; x++) {
2182 if (!strcasecmp(state_names[x], name)) {
2199 for (x = 0; x < 100; x++) {
2217 const
char *file, const
char *func,
int line)
2222 if (channel->state_flags[0]) {
2224 if (channel->state_flags[x]) {
2225 channel->flags[x] = 1;
2226 channel->state_flags[x] = 0;
2229 channel->state_flags[0] = 0;
2237 channel->name, state_names[state]);
2241 careful_set(channel, &channel->running_state, state);
2279 last_state = channel->state;
2282 if (last_state == state) {
2286 if (last_state >=
CS_HANGUP && state < last_state) {
2309 switch (last_state) {
2466 channel->name, state_names[last_state], state_names[state]);
2470 if (state ==
CS_HANGUP && !channel->hangup_cause) {
2479 "(%s) Invalid State Change %s -> %s\n", channel->name, state_names[last_state], state_names[state]);
2487 return channel->state;
2509 switch_caller_profile_t *caller_profile, *originator_caller_profile = NULL, *originatee_caller_profile = NULL;
2516 if ((caller_profile = channel->caller_profile)) {
2568 if (channel->hangup_cause) {
2590 if (caller_profile) {
2595 if (originator_caller_profile && channel->last_profile_type ==
LP_ORIGINATOR) {
2598 }
else if (originatee_caller_profile && channel->last_profile_type ==
LP_ORIGINATEE) {
2610 int global_verbose_events = -1;
2616 if (global_verbose_events ||
2649 if (channel->scope_variables) {
2652 for (ep = channel->scope_variables; ep; ep = ep->
next) {
2655 char *vvar = NULL, *vval = NULL;
2657 vvar = (
char *) hi->
name;
2658 vval = (
char *) hi->
value;
2670 if (channel->variables) {
2671 for (hi = channel->variables->headers; hi; hi = hi->
next) {
2673 char *vvar = NULL, *vval = NULL;
2675 vvar = (
char *) hi->
name;
2676 vval = (
char *) hi->
value;
2717 caller_profile->direction = channel->direction;
2718 caller_profile->logical_direction = channel->logical_direction;
2721 if (!caller_profile->uuid || strcasecmp(caller_profile->uuid, uuid)) {
2725 if (!caller_profile->chan_name || strcasecmp(caller_profile->chan_name, channel->name)) {
2729 if (!caller_profile->context) {
2733 if (!caller_profile->times) {
2738 if (channel->caller_profile && channel->caller_profile->times) {
2739 channel->caller_profile->times->transferred = caller_profile->times->profile_created;
2740 caller_profile->times->answered = channel->caller_profile->times->answered;
2741 caller_profile->times->progress = channel->caller_profile->times->progress;
2742 caller_profile->times->progress_media = channel->caller_profile->times->progress_media;
2743 caller_profile->times->created = channel->caller_profile->times->created;
2744 caller_profile->times->hungup = channel->caller_profile->times->hungup;
2745 if (channel->caller_profile->caller_extension) {
2753 caller_profile->next = channel->caller_profile;
2754 channel->caller_profile = caller_profile;
2755 caller_profile->profile_index =
switch_core_sprintf(caller_profile->pool,
"%d", ++channel->profile_index);
2778 if (!caller_profile->times) {
2782 if (channel->caller_profile) {
2783 caller_profile->next = channel->caller_profile->originator_caller_profile;
2784 channel->caller_profile->originator_caller_profile = caller_profile;
2787 switch_assert(channel->caller_profile->originator_caller_profile->next != channel->caller_profile->originator_caller_profile);
2798 channel->caller_profile->hunt_caller_profile = NULL;
2799 if (channel->caller_profile && caller_profile) {
2800 caller_profile->direction = channel->direction;
2801 caller_profile->logical_direction = channel->logical_direction;
2802 channel->caller_profile->hunt_caller_profile = caller_profile;
2814 if (channel->caller_profile) {
2815 caller_profile->next = channel->caller_profile->origination_caller_profile;
2816 channel->caller_profile->origination_caller_profile = caller_profile;
2818 switch_assert(channel->caller_profile->origination_caller_profile->next != channel->caller_profile->origination_caller_profile);
2828 if (channel->caller_profile) {
2844 if (channel->caller_profile) {
2845 caller_profile->next = channel->caller_profile->originatee_caller_profile;
2846 channel->caller_profile->originatee_caller_profile = caller_profile;
2849 switch_assert(channel->caller_profile->originatee_caller_profile->next != channel->caller_profile->originatee_caller_profile);
2860 if (channel->caller_profile) {
2874 if (channel->caller_profile) {
2896 if (channel->state_handlers[x] == state_handler) {
2901 index = channel->state_handler_index++;
2903 if (channel->state_handler_index >= SWITCH_MAX_STATE_HANDLERS) {
2908 channel->state_handlers[index] = state_handler;
2926 h = channel->state_handlers[index];
2934 int index, i = channel->state_handler_index;
2940 channel->state_handler_index = 0;
2942 if (state_handler) {
2943 for (index = 0; index < i; index++) {
2944 if (channel->state_handlers[index] != state_handler) {
2945 new_handlers[channel->state_handler_index++] = channel->state_handlers[index];
2949 for (index = 0; index < i; index++) {
2951 new_handlers[channel->state_handler_index++] = channel->state_handlers[index];
2957 channel->state_handlers[index] = NULL;
2960 if (channel->state_handler_index > 0) {
2961 for (index = 0; index < channel->state_handler_index; index++) {
2962 channel->state_handlers[index] = new_handlers[index];
3013 if (extension && orig_extension) {
3014 for (ap = orig_extension->current_application; ap && offset > 0; offset--) {
3018 for (; ap; ap = ap->
next) {
3026 for (hi = orig_channel->variables->headers; hi; hi = hi->
next) {
3028 for (i = 0; i < argc; i++) {
3029 if (!strcasecmp(argv[i], hi->
name)) {
3054 const char *tname, *tnum;
3062 #ifdef DEEP_DEBUG_CID
3085 const char *tmp = NULL;
3088 if (channel->caller_profile->callee_id_name) {
3089 tmp = channel->caller_profile->caller_id_name;
3091 channel->caller_profile->caller_id_name =
switch_core_strdup(channel->caller_profile->pool, channel->caller_profile->callee_id_name);
3097 channel->caller_profile->callee_id_name = tmp;
3100 if (channel->caller_profile->callee_id_number) {
3101 tmp = channel->caller_profile->caller_id_number;
3103 channel->caller_profile->caller_id_number =
switch_core_strdup(channel->caller_profile->pool, channel->caller_profile->callee_id_number);
3109 channel->caller_profile->callee_id_number = tmp;
3131 channel->caller_profile->caller_id_name,
3132 channel->caller_profile->caller_id_number
3154 caller_extension = channel->queued_extension;
3155 channel->queued_extension = NULL;
3158 return caller_extension;
3164 channel->queued_extension = caller_extension;
3178 caller_extension->next = channel->caller_profile->caller_extension;
3179 channel->caller_profile->caller_extension = caller_extension;
3190 if (channel->caller_profile) {
3191 extension = channel->caller_profile->caller_extension;
3201 if (channel->caller_profile && channel->caller_profile->times) {
3210 if (channel->caller_profile && channel->caller_profile->times && !channel->caller_profile->times->hungup) {
3239 return channel->state;
3251 if (channel->hold_record && !channel->hold_record->off) {
3257 last_state = channel->state;
3261 channel->hangup_cause = hangup_cause;
3293 return channel->state;
3308 const
char *file, const
char *func,
int line)
3317 if (channel->caller_profile && channel->caller_profile->times) {
3320 if (channel->caller_profile->originator_caller_profile) {
3330 channel->caller_profile->originator_caller_profile->times->progress = channel->caller_profile->times->progress;
3428 if (channel->caller_profile && channel->caller_profile->times) {
3431 if (channel->caller_profile->originator_caller_profile) {
3441 channel->caller_profile->originator_caller_profile->times->progress_media = channel->caller_profile->times->progress_media;
3490 if (channel->hangup_cause || channel->state >=
CS_HANGUP) {
3504 msg.
from = channel->name;
3519 const
char *file, const
char *func,
int line)
3526 if (channel->hangup_cause || channel->state >=
CS_HANGUP) {
3540 msg.
from = channel->name;
3563 if ((arg = strchr(app,
' '))) {
3585 char *var = hp->
name;
3586 char *val = hp->
value;
3588 if (!strncasecmp(var, variable_prefix, strlen(variable_prefix))) {
3591 for (i = 0; i < hp->
idx; i++) {
3616 for(p = app; p && *p; p++) {
3617 if (*p ==
' ' || (*p ==
':' && (*(p+1) !=
':'))) {
3621 }
else if (*p ==
':' && (*(p+1) ==
':')) {
3627 if (!strncasecmp(app,
"perl", 4)) {
3649 char *var = hp->
name;
3650 char *val = hp->
value;
3652 if (!strncasecmp(var, variable_prefix, strlen(variable_prefix))) {
3655 for (i = 0; i < hp->
idx; i++) {
3681 if (channel->hangup_cause || channel->state >=
CS_HANGUP) {
3691 if (channel->caller_profile && channel->caller_profile->times) {
3725 uint32_t seconds = 60;
3790 if (channel->hangup_cause || channel->state >=
CS_HANGUP) {
3799 msg.
from = channel->name;
3817 uint32_t msec = atoi(delay);
3829 #define resize(l) {\
3831 olen += (len + l + block);\
3833 if ((dp = realloc(data, olen))) {\
3836 memset(c, 0, olen - cpos);\
3842 char *data, *indup, *endof_indup;
3843 size_t sp = 0, len = 0, olen = 0, vtype = 0, br = 0, cpos, block = 128;
3844 char *cloned_sub_val = NULL, *sub_val = NULL, *expanded_sub_val = NULL;
3845 char *func_val = NULL, *sb = NULL;
3864 olen = strlen(in) + 1;
3868 if ((data = malloc(olen))) {
3871 for (p = indup; p && p < endof_indup && *p; p++) {
3876 if (*(p + 1) ==
'$') {
3879 if (*(p + 1) ==
'$') {
3882 }
else if (*(p + 1) ==
'\'') {
3885 }
else if (*(p + 1) ==
'\\') {
3892 if (*p ==
'$' && !nv) {
3894 if (*(p + 1) ==
'$') {
3900 if (*(p + 1) ==
'{') {
3901 vtype = global ? 3 : 1;
3918 char *s = p, *e, *vname, *vval = NULL;
3923 if ((vtype == 1 || vtype == 3) && *s ==
'{') {
3931 if (br == 1 && *e ==
'}') {
3938 if (e != s && *e ==
'{') {
3940 }
else if (br > 1 && *e ==
'}') {
3947 p = e > endof_indup ? endof_indup : e;
3950 for(sb = vname; sb && *sb; sb++) {
3954 }
else if (*sb ==
'(') {
3972 }
else if (br > 1 && *e ==
')') {
3974 }
else if (br == 1 && *e ==
')') {
3984 if (vtype == 1 || vtype == 3) {
3985 char *expanded = NULL;
3997 if ((ptr = strchr(vname,
':'))) {
4000 if ((ptr = strchr(ptr,
':'))) {
4002 ooffset = atoi(ptr);
4006 if ((ptr = strchr(vname,
'[')) && strchr(ptr,
']')) {
4013 sub_val =
"<Variable Expansion Permission Denied>";
4017 expanded_sub_val = NULL;
4019 sub_val = expanded_sub_val;
4022 if (offset || ooffset) {
4023 cloned_sub_val = strdup(sub_val);
4025 sub_val = cloned_sub_val;
4029 if ((
size_t) offset > strlen(sub_val)) {
4034 }
else if ((
size_t) abs(offset) <= strlen(sub_val)) {
4035 sub_val = cloned_sub_val + (strlen(cloned_sub_val) + offset);
4038 if (ooffset > 0 && (
size_t) ooffset < strlen(sub_val)) {
4039 if ((ptr = (
char *) sub_val + ooffset)) {
4048 char *expanded = NULL;
4053 char *expanded_vname = NULL;
4056 expanded_vname = NULL;
4058 vname = expanded_vname;
4069 sub_val =
"<API Execute Permission Denied>";
4072 func_val = stream.
data;
4089 if ((nlen = sub_val ? strlen(sub_val) : 0)) {
4090 if (len + nlen >= olen) {
4106 if (len + 1 >= olen) {
4133 char *encode_buf = NULL;
4134 const char *prof[13] = { 0 }, *prof_names[13] = {
4146 encode_buf = malloc(encode_len);
4149 if (!caller_profile) {
4155 prof[0] = caller_profile->context;
4156 prof[1] = caller_profile->destination_number;
4157 prof[2] = caller_profile->caller_id_name;
4158 prof[3] = caller_profile->caller_id_number;
4159 prof[4] = caller_profile->network_addr;
4160 prof[5] = caller_profile->ani;
4161 prof[6] = caller_profile->aniii;
4162 prof[7] = caller_profile->rdnis;
4163 prof[8] = caller_profile->source;
4164 prof[9] = caller_profile->chan_name;
4165 prof[10] = caller_profile->uuid;
4166 prof[11] = caller_profile->transfer_source;
4168 prof_names[0] =
"context";
4169 prof_names[1] =
"destination_number";
4170 prof_names[2] =
"caller_id_name";
4171 prof_names[3] =
"caller_id_number";
4172 prof_names[4] =
"network_addr";
4173 prof_names[5] =
"ani";
4174 prof_names[6] =
"aniii";
4175 prof_names[7] =
"rdnis";
4176 prof_names[8] =
"source";
4177 prof_names[9] =
"chan_name";
4178 prof_names[10] =
"uuid";
4179 prof_names[11] =
"transfer_source";
4181 for (x = 0; prof[x]; x++) {
4182 if (
zstr(prof[x])) {
4185 new_len = (strlen(prof[x]) * 3) + 1;
4186 if (encode_len < new_len) {
4189 encode_len = new_len;
4191 if (!(tmp = realloc(encode_buf, encode_len))) {
4198 stream.
write_function(&stream,
"%s=%s&", prof_names[x], encode_buf);
4201 if (channel->caller_profile->soft) {
4204 for(pn = channel->caller_profile->soft; pn; pn = pn->
next) {
4205 char *var = pn->
var;
4206 char *val = pn->
val;
4208 new_len = (strlen((
char *) var) * 3) + 1;
4209 if (encode_len < new_len) {
4212 encode_len = new_len;
4214 tmp = realloc(encode_buf, encode_len);
4220 stream.
write_function(&stream,
"%s=%s&", (
char *) var, encode_buf);
4226 for (; hi; hi = hi->
next) {
4227 char *var = hi->
name;
4228 char *val = hi->
value;
4230 new_len = (strlen((
char *) var) * 3) + 1;
4231 if (encode_len < new_len) {
4234 encode_len = new_len;
4236 tmp = realloc(encode_buf, encode_len);
4242 stream.
write_function(&stream,
"%s=%s&", (
char *) var, encode_buf);
4248 e = (
char *) stream.
data + (strlen((
char *) stream.
data) - 1);
4250 if (e && *e ==
'&') {
4269 if (!
zstr(channel->caller_profile->callee_id_name)) {
4270 other_channel->caller_profile->callee_id_name =
switch_core_strdup(other_channel->caller_profile->pool, channel->caller_profile->callee_id_name);
4274 if (!
zstr(channel->caller_profile->callee_id_number)) {
4275 other_channel->caller_profile->callee_id_number =
switch_core_strdup(other_channel->caller_profile->pool, channel->caller_profile->callee_id_number);
4289 if (channel->variables) {
4301 return channel->session;
4307 const char *cid_buf = NULL;
4310 char *last_app = NULL, *last_arg = NULL;
4311 char start[80] =
"", resurrect[80] =
"", answer[80] =
"", hold[80],
4312 bridge[80] =
"", progress[80] =
"", progress_media[80] =
"", end[80] =
"", tmp[80] =
"",
4313 profile_start[80] =
"";
4314 int32_t duration = 0, legbillsec = 0, billsec = 0, mduration = 0, billmsec = 0, legbillmsec = 0, progressmsec = 0, progress_mediamsec = 0;
4315 int32_t answersec = 0, answermsec = 0, waitsec = 0, waitmsec = 0;
4317 switch_time_t uduration = 0, legbillusec = 0, billusec = 0, progresssec = 0, progressusec = 0, progress_mediasec = 0, progress_mediausec = 0, waitusec = 0;
4318 time_t tt_created = 0, tt_answered = 0, tt_resurrected = 0, tt_bridged, tt_last_hold, tt_hold_accum,
4319 tt_progress = 0, tt_progress_media = 0, tt_hungup = 0, mtt_created = 0, mtt_answered = 0, mtt_bridged = 0,
4320 mtt_hungup = 0, tt_prof_created, mtt_progress = 0, mtt_progress_media = 0;
4332 if (!(caller_profile = channel->caller_profile) || !channel->variables) {
4340 for (ap = app_log; ap && ap->
next; ap = ap->
next);
4356 dtstr[x++] = dt->
digit;
4364 char *digit_string = dtstr;
4367 char *substituted = NULL;
4373 if ((proceed =
switch_regex_perform(dtstr, var, &re, ovector,
sizeof(ovector) /
sizeof(ovector[0])))) {
4374 int len = (strlen(dtstr) + strlen(var) + 10) * proceed;
4376 const char *replace = NULL;
4380 for (i = 0; i < proceed; i++) {
4381 if (pcre_get_substring(dtstr, ovector, proceed, i, &replace) > 0) {
4389 pcre_free_substring(replace);
4393 if (!
zstr(substituted)) {
4394 digit_string = substituted;
4407 if (caller_profile->
times) {
4410 const char *fmt =
"%Y-%m-%d %T";
4456 if (channel->hold_record) {
4464 for (hr = channel->hold_record; hr; hr = hr->
next) {
4477 tt_created = (time_t) (caller_profile->
times->
created / 1000000);
4478 mtt_created = (time_t) (caller_profile->
times->
created / 1000);
4490 tt_answered = (time_t) (caller_profile->
times->
answered / 1000000);
4491 mtt_answered = (time_t) (caller_profile->
times->
answered / 1000);
4497 tt_bridged = (time_t) (caller_profile->
times->
bridged / 1000000);
4498 mtt_bridged = (time_t) (caller_profile->
times->
bridged / 1000);
4504 tt_last_hold = (time_t) (caller_profile->
times->
last_hold / 1000000);
4510 tt_hold_accum = (time_t) (caller_profile->
times->
hold_accum / 1000000);
4524 tt_progress = (time_t) (caller_profile->
times->
progress / 1000000);
4525 mtt_progress = (time_t) (caller_profile->
times->
progress / 1000);
4538 tt_hungup = (time_t) (caller_profile->
times->
hungup / 1000000);
4539 mtt_hungup = (time_t) (caller_profile->
times->
hungup / 1000);
4545 duration = (int32_t) (tt_hungup - tt_created);
4546 mduration = (int32_t) (mtt_hungup - mtt_created);
4550 waitsec = (int32_t) (tt_bridged - tt_created);
4551 waitmsec = (int32_t) (mtt_bridged - mtt_created);
4560 billsec = (int32_t) (tt_hungup - tt_answered);
4561 billmsec = (int32_t) (mtt_hungup - mtt_answered);
4564 legbillsec = (int32_t) (tt_hungup - tt_created);
4565 legbillmsec = (int32_t) (mtt_hungup - mtt_created);
4568 answersec = (int32_t) (tt_answered - tt_created);
4569 answermsec = (int32_t) (mtt_answered - mtt_created);
4574 progresssec = (int32_t) (tt_progress - tt_created);
4575 progressmsec = (int32_t) (mtt_progress - mtt_created);
4580 progress_mediasec = (int32_t) (tt_progress_media - tt_created);
4581 progress_mediamsec = (int32_t) (mtt_progress_media - mtt_created);
4661 const char *uuid = NULL;
4673 const char *transfer_on_fail = NULL;
4674 char *tof_data = NULL;
4675 char *tof_array[4] = { 0 };
4685 transfer_on_fail = tof_array[0];
4696 const char *continue_on_fail = NULL, *failure_causes = NULL;
4701 if (continue_on_fail || failure_causes) {
4702 const char *cause_str;
4703 char cause_num[35] =
"";
4708 if (failure_causes) {
4710 char *argv[256] = { 0 };
4714 for (i = 0; i < argc; i++) {
4715 if (!strcasecmp(argv[i], cause_str) || !strcasecmp(argv[i], cause_num)) {
4722 "Failure causes [%s]: Cause: %s\n", failure_causes, cause_str);
4727 if (continue_on_fail) {
4732 char *argv[256] = { 0 };
4736 for (i = 0; i < argc; i++) {
4737 if (!strcasecmp(argv[i], cause_str) || !strcasecmp(argv[i], cause_num)) {
4739 "Continue on fail [%s]: Cause: %s\n", continue_on_fail, cause_str);
4752 if (transfer_on_fail || failure_causes) {
4753 const char *cause_str;
4754 char cause_num[35] =
"";
4759 if ((tof_array[1] == NULL ) || (!strcasecmp(tof_array[1],
"auto_cause"))){
4760 tof_array[1] = (
char *) cause_str;
4763 if (failure_causes) {
4765 char *argv[256] = { 0 };
4769 for (i = 0; i < argc; i++) {
4770 if (!strcasecmp(argv[i], cause_str) || !strcasecmp(argv[i], cause_num)) {
4777 "Failure causes [%s]: Cause: %s\n", failure_causes, cause_str);
4783 if (transfer_on_fail) {
4788 char *argv[256] = { 0 };
4792 for (i = 0; i < argc; i++) {
4793 if (!strcasecmp(argv[i], cause_str) || !strcasecmp(argv[i], cause_num)) {
4795 "Transfer on fail [%s]: Cause: %s\n", transfer_on_fail, cause_str);
4921 while(--sanity && channel->device_node->parent->refs) {
4926 channel->device_node->parent->uuid,
4927 channel->device_node->parent->device_id);
4931 char prefix[80] =
"";
4957 pool = channel->device_node->parent->pool;