RTS API Documentation  1.10.11
switch_caller.c
Go to the documentation of this file.
1 /*
2  * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
3  * Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
4  *
5  * Version: MPL 1.1
6  *
7  * The contents of this file are subject to the Mozilla Public License Version
8  * 1.1 (the "License"); you may not use this file except in compliance with
9  * the License. You may obtain a copy of the License at
10  * http://www.mozilla.org/MPL/
11  *
12  * Software distributed under the License is distributed on an "AS IS" basis,
13  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
14  * for the specific language governing rights and limitations under the
15  * License.
16  *
17  * The Original Code is FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
18  *
19  * The Initial Developer of the Original Code is
20  * Anthony Minessale II <anthm@freeswitch.org>
21  * Portions created by the Initial Developer are Copyright (C)
22  * the Initial Developer. All Rights Reserved.
23  *
24 
25  *
26  * Anthony Minessale II <anthm@freeswitch.org>
27  *
28  *
29  * switch_caller.c -- Caller Identification
30  *
31  */
32 
33 #include <switch.h>
34 #include <switch_caller.h>
35 
37  const char *username,
38  const char *dialplan,
39  const char *caller_id_name,
40  const char *caller_id_number,
41  const char *network_addr,
42  const char *ani,
43  const char *aniii,
44  const char *rdnis,
45  const char *source, const char *context, const char *destination_number)
46 {
47  switch_caller_profile_t *profile = NULL;
48  char uuid_str[SWITCH_UUID_FORMATTED_LENGTH + 1];
49 
50  profile = switch_core_alloc(pool, sizeof(*profile));
51  switch_assert(profile != NULL);
52  memset(profile, 0, sizeof(*profile));
53 
54  switch_uuid_str(uuid_str, sizeof(uuid_str));
55  profile->uuid_str = switch_core_strdup(pool, uuid_str);
56 
57  if (!context) {
58  context = "default";
59  }
60 
61  if (zstr(caller_id_name)) {
62  caller_id_name = SWITCH_DEFAULT_CLID_NAME;
63  }
64 
65  if (zstr(caller_id_number)) {
66  caller_id_number = SWITCH_DEFAULT_CLID_NUMBER;
67  }
68 
69  /* ANI defaults to Caller ID Number when not specified */
70  if (zstr(ani)) {
71  ani = caller_id_number;
72  }
73 
74  profile_dup_clean(username, profile->username, pool);
75  profile_dup_clean(dialplan, profile->dialplan, pool);
76  profile_dup_clean(caller_id_name, profile->caller_id_name, pool);
77  profile_dup_clean(caller_id_number, profile->caller_id_number, pool);
78  profile_dup_clean(caller_id_name, profile->orig_caller_id_name, pool);
79  profile_dup_clean(caller_id_number, profile->orig_caller_id_number, pool);
80  profile->caller_ton = SWITCH_TON_UNDEF;
82  profile_dup_clean(network_addr, profile->network_addr, pool);
83  profile_dup_clean(ani, profile->ani, pool);
84  profile->ani_ton = SWITCH_TON_UNDEF;
86  profile_dup_clean(aniii, profile->aniii, pool);
87  profile_dup_clean(rdnis, profile->rdnis, pool);
88  profile->rdnis_ton = SWITCH_TON_UNDEF;
90  profile_dup_clean(source, profile->source, pool);
91  profile_dup_clean(context, profile->context, pool);
92  profile_dup_clean(destination_number, profile->destination_number, pool);
95  profile->uuid = SWITCH_BLANK_STRING;
96  profile->chan_name = SWITCH_BLANK_STRING;
102  }
105  }
106  profile->pool = pool;
107  return profile;
108 }
109 
111 {
112  switch_caller_profile_t *profile = NULL;
113  char uuid_str[SWITCH_UUID_FORMATTED_LENGTH + 1];
114 
115  profile = switch_core_alloc(pool, sizeof(*profile));
116  switch_assert(profile != NULL);
117 
118  switch_uuid_str(uuid_str, sizeof(uuid_str));
119  profile->uuid_str = switch_core_strdup(pool, uuid_str);
120  profile->clone_of = switch_core_strdup(pool, tocopy->uuid_str);
121 
122  profile_dup(tocopy->username, profile->username, pool);
123  profile_dup(tocopy->dialplan, profile->dialplan, pool);
124  profile_dup(tocopy->caller_id_name, profile->caller_id_name, pool);
125  profile_dup(tocopy->caller_id_number, profile->caller_id_number, pool);
126  profile_dup(tocopy->callee_id_name, profile->callee_id_name, pool);
127  profile_dup(tocopy->callee_id_number, profile->callee_id_number, pool);
128  profile_dup(tocopy->orig_caller_id_name, profile->orig_caller_id_name, pool);
130  profile_dup(tocopy->network_addr, profile->network_addr, pool);
131  profile_dup(tocopy->ani, profile->ani, pool);
132  profile_dup(tocopy->aniii, profile->aniii, pool);
133  profile_dup(tocopy->rdnis, profile->rdnis, pool);
134  profile_dup(tocopy->source, profile->source, pool);
135  profile_dup(tocopy->context, profile->context, pool);
136  profile_dup(tocopy->destination_number, profile->destination_number, pool);
137  profile_dup(tocopy->uuid, profile->uuid, pool);
138  profile_dup(tocopy->chan_name, profile->chan_name, pool);
139 
140  profile->caller_ton = tocopy->caller_ton;
141  profile->caller_numplan = tocopy->caller_numplan;
142  profile->ani_ton = tocopy->ani_ton;
143  profile->ani_numplan = tocopy->ani_numplan;
144  profile->rdnis_ton = tocopy->rdnis_ton;
145  profile->rdnis_numplan = tocopy->rdnis_numplan;
148  profile->flags = tocopy->flags;
149  profile->pool = pool;
150  profile->direction = tocopy->direction;
151 
152  if (tocopy->times) {
154  *profile->old_times = *tocopy->times;
155  } else {
156  tocopy->times = (switch_channel_timetable_t *) switch_core_alloc(tocopy->pool, sizeof(*tocopy->times));
157  }
158 
159  if (tocopy->soft) {
160  profile_node_t *pn;
161 
162  for (pn = tocopy->soft; pn; pn = pn->next) {
163  profile_node_t *pp, *n = switch_core_alloc(profile->pool, sizeof(*n));
164 
165  n->var = switch_core_strdup(profile->pool, pn->var);
166  n->val = switch_core_strdup(profile->pool, pn->val);
167 
168  if (!profile->soft) {
169  profile->soft = n;
170  } else {
171  for(pp = profile->soft; pp && pp->next; pp = pp->next);
172 
173  if (pp) {
174  pp->next = n;
175  }
176  }
177  }
178 
179  }
180 
181  return profile;
182 }
183 
185 {
187 
188  pool = switch_core_session_get_pool(session);
189 
190  return switch_caller_profile_dup(pool, tocopy);
191 }
192 
194 {
195  if (!strcasecmp(name, "dialplan")) {
196  return caller_profile->dialplan;
197  }
198  if (!strcasecmp(name, "username")) {
199  return caller_profile->username;
200  }
201  if (!strcasecmp(name, "caller_id_name")) {
202  return caller_profile->caller_id_name;
203  }
204  if (!strcasecmp(name, "caller_id_number")) {
205  return caller_profile->caller_id_number;
206  }
207  if (!strcasecmp(name, "orig_caller_id_name")) {
208  return caller_profile->orig_caller_id_name;
209  }
210  if (!strcasecmp(name, "orig_caller_id_number")) {
211  return caller_profile->orig_caller_id_number;
212  }
213  if (!strcasecmp(name, "callee_id_name")) {
214  return caller_profile->callee_id_name;
215  }
216  if (!strcasecmp(name, "callee_id_number")) {
217  return caller_profile->callee_id_number;
218  }
219  if (!strcasecmp(name, "ani")) {
220  return caller_profile->ani;
221  }
222  if (!strcasecmp(name, "aniii")) {
223  return caller_profile->aniii;
224  }
225  if (!strcasecmp(name, "network_addr")) {
226  return caller_profile->network_addr;
227  }
228  if (!strcasecmp(name, "rdnis")) {
229  return caller_profile->rdnis;
230  }
231  if (!strcasecmp(name, "destination_number")) {
232  return caller_profile->destination_number;
233  }
234  if (!strcasecmp(name, "uuid")) {
235  return caller_profile->uuid;
236  }
237  if (!strcasecmp(name, "source")) {
238  return caller_profile->source;
239  }
240  if (!strcasecmp(name, "transfer_source")) {
241  return caller_profile->transfer_source;
242  }
243  if (!strcasecmp(name, "context")) {
244  return caller_profile->context;
245  }
246 
247  if (!strcasecmp(name, "chan_name")) {
248  return caller_profile->chan_name;
249  }
250 
251  if (!strcasecmp(name, "profile_index")) {
252  return caller_profile->profile_index;
253  }
254 
255  if (!strcasecmp(name, "caller_ton")) {
256  return switch_core_sprintf(caller_profile->pool, "%u", caller_profile->caller_ton);
257  }
258  if (!strcasecmp(name, "caller_numplan")) {
259  return switch_core_sprintf(caller_profile->pool, "%u", caller_profile->caller_numplan);
260  }
261  if (!strcasecmp(name, "destination_number_ton")) {
262  return switch_core_sprintf(caller_profile->pool, "%u", caller_profile->destination_number_ton);
263  }
264  if (!strcasecmp(name, "destination_number_numplan")) {
265  return switch_core_sprintf(caller_profile->pool, "%u", caller_profile->destination_number_numplan);
266  }
267  if (!strcasecmp(name, "ani_ton")) {
268  return switch_core_sprintf(caller_profile->pool, "%u", caller_profile->ani_ton);
269  }
270  if (!strcasecmp(name, "ani_numplan")) {
271  return switch_core_sprintf(caller_profile->pool, "%u", caller_profile->ani_numplan);
272  }
273  if (!strcasecmp(name, "rdnis_ton")) {
274  return switch_core_sprintf(caller_profile->pool, "%u", caller_profile->rdnis_ton);
275  }
276  if (!strcasecmp(name, "rdnis_numplan")) {
277  return switch_core_sprintf(caller_profile->pool, "%u", caller_profile->rdnis_numplan);
278  }
279  if (!strcasecmp(name, "screen_bit")) {
280  return switch_test_flag(caller_profile, SWITCH_CPF_SCREEN) ? "true" : "false";
281  }
282  if (!strcasecmp(name, "privacy_hide_name")) {
283  return switch_test_flag(caller_profile, SWITCH_CPF_HIDE_NAME) ? "true" : "false";
284  }
285  if (!strcasecmp(name, "privacy_hide_number")) {
286  return switch_test_flag(caller_profile, SWITCH_CPF_HIDE_NUMBER) ? "true" : "false";
287  }
288  if (!strcasecmp(name, "profile_created_time")) {
289  return switch_core_sprintf(caller_profile->pool, "%" SWITCH_TIME_T_FMT, caller_profile->times->profile_created);
290  }
291  if (!strcasecmp(name, "created_time")) {
292  return switch_core_sprintf(caller_profile->pool, "%" SWITCH_TIME_T_FMT, caller_profile->times->created);
293  }
294  if (!strcasecmp(name, "answered_time")) {
295  return switch_core_sprintf(caller_profile->pool, "%" SWITCH_TIME_T_FMT, caller_profile->times->answered);
296  }
297  if (!strcasecmp(name, "progress_time")) {
298  return switch_core_sprintf(caller_profile->pool, "%" SWITCH_TIME_T_FMT, caller_profile->times->progress);
299  }
300  if (!strcasecmp(name, "progress_media_time")) {
301  return switch_core_sprintf(caller_profile->pool, "%" SWITCH_TIME_T_FMT, caller_profile->times->progress_media);
302  }
303  if (!strcasecmp(name, "hungup_time")) {
304  return switch_core_sprintf(caller_profile->pool, "%" SWITCH_TIME_T_FMT, caller_profile->times->hungup);
305  }
306  if (!strcasecmp(name, "transferred_time")) {
307  return switch_core_sprintf(caller_profile->pool, "%" SWITCH_TIME_T_FMT, caller_profile->times->transferred);
308  }
309 
310  if (caller_profile->soft && switch_test_flag(caller_profile, SWITCH_CPF_SOFT_LOOKUP)) {
311  profile_node_t *pn;
312  for (pn = caller_profile->soft; pn; pn = pn->next) {
313  if (!strcasecmp(name, pn->var)) {
314  return pn->val;
315  }
316  }
317  }
318 
319  return NULL;
320 }
321 
323 {
324  char header_name[1024];
325  switch_channel_timetable_t *times = NULL;
326 
327  switch_snprintf(header_name, sizeof(header_name), "%s-Direction", prefix);
329  "inbound" : "outbound");
330 
331  switch_snprintf(header_name, sizeof(header_name), "%s-Logical-Direction", prefix);
333  "inbound" : "outbound");
334 
335  if (!zstr(caller_profile->username)) {
336  switch_snprintf(header_name, sizeof(header_name), "%s-Username", prefix);
337  switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, header_name, caller_profile->username);
338  }
339  if (!zstr(caller_profile->dialplan)) {
340  switch_snprintf(header_name, sizeof(header_name), "%s-Dialplan", prefix);
341  switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, header_name, caller_profile->dialplan);
342  }
343  if (!zstr(caller_profile->caller_id_name)) {
344  switch_snprintf(header_name, sizeof(header_name), "%s-Caller-ID-Name", prefix);
345  switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, header_name, caller_profile->caller_id_name);
346  }
347  if (!zstr(caller_profile->caller_id_number)) {
348  switch_snprintf(header_name, sizeof(header_name), "%s-Caller-ID-Number", prefix);
349  switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, header_name, caller_profile->caller_id_number);
350  }
351  if (!zstr(caller_profile->caller_id_name)) {
352  switch_snprintf(header_name, sizeof(header_name), "%s-Orig-Caller-ID-Name", prefix);
353  switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, header_name, caller_profile->orig_caller_id_name);
354  }
355  if (!zstr(caller_profile->caller_id_number)) {
356  switch_snprintf(header_name, sizeof(header_name), "%s-Orig-Caller-ID-Number", prefix);
357  switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, header_name, caller_profile->orig_caller_id_number);
358  }
359  if (!zstr(caller_profile->callee_id_name)) {
360  switch_snprintf(header_name, sizeof(header_name), "%s-Callee-ID-Name", prefix);
361  switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, header_name, caller_profile->callee_id_name);
362  }
363  if (!zstr(caller_profile->callee_id_number)) {
364  switch_snprintf(header_name, sizeof(header_name), "%s-Callee-ID-Number", prefix);
365  switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, header_name, caller_profile->callee_id_number);
366  }
367  if (!zstr(caller_profile->network_addr)) {
368  switch_snprintf(header_name, sizeof(header_name), "%s-Network-Addr", prefix);
369  switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, header_name, caller_profile->network_addr);
370  }
371  if (!zstr(caller_profile->ani)) {
372  switch_snprintf(header_name, sizeof(header_name), "%s-ANI", prefix);
373  switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, header_name, caller_profile->ani);
374  }
375  if (!zstr(caller_profile->aniii)) {
376  switch_snprintf(header_name, sizeof(header_name), "%s-ANI-II", prefix);
377  switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, header_name, caller_profile->aniii);
378  }
379  if (!zstr(caller_profile->destination_number)) {
380  switch_snprintf(header_name, sizeof(header_name), "%s-Destination-Number", prefix);
381  switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, header_name, caller_profile->destination_number);
382  }
383  if (!zstr(caller_profile->uuid)) {
384  switch_snprintf(header_name, sizeof(header_name), "%s-Unique-ID", prefix);
385  switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, header_name, caller_profile->uuid);
386  }
387  if (!zstr(caller_profile->source)) {
388  switch_snprintf(header_name, sizeof(header_name), "%s-Source", prefix);
389  switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, header_name, caller_profile->source);
390  }
391  if (!zstr(caller_profile->transfer_source)) {
392  switch_snprintf(header_name, sizeof(header_name), "%s-Transfer-Source", prefix);
393  switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, header_name, caller_profile->transfer_source);
394  }
395  if (!zstr(caller_profile->context)) {
396  switch_snprintf(header_name, sizeof(header_name), "%s-Context", prefix);
397  switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, header_name, caller_profile->context);
398  }
399  if (!zstr(caller_profile->rdnis)) {
400  switch_snprintf(header_name, sizeof(header_name), "%s-RDNIS", prefix);
401  switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, header_name, caller_profile->rdnis);
402  }
403  if (!zstr(caller_profile->chan_name)) {
404  switch_snprintf(header_name, sizeof(header_name), "%s-Channel-Name", prefix);
405  switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, header_name, caller_profile->chan_name);
406  }
407  if (!zstr(caller_profile->profile_index)) {
408  switch_snprintf(header_name, sizeof(header_name), "%s-Profile-Index", prefix);
409  switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, header_name, caller_profile->profile_index);
410  }
411 
412  if (caller_profile->soft) {
413  profile_node_t *pn;
414 
415  for (pn = caller_profile->soft; pn; pn = pn->next) {
416  if (switch_test_flag(caller_profile, SWITCH_CPF_SOFT_PREFIX)) {
417  switch_snprintf(header_name, sizeof(header_name), "%s-%s", prefix, pn->var);
418  switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, header_name, pn->val);
419  } else {
421  }
422  }
423 
424  }
425 
426  if (!(times = caller_profile->times)) {
427  times = caller_profile->old_times;
428  }
429 
430 
431  if (times) {
432  switch_snprintf(header_name, sizeof(header_name), "%s-Profile-Created-Time", prefix);
434  switch_snprintf(header_name, sizeof(header_name), "%s-Channel-Created-Time", prefix);
435  switch_event_add_header(event, SWITCH_STACK_BOTTOM, header_name, "%" SWITCH_TIME_T_FMT, times->created);
436  switch_snprintf(header_name, sizeof(header_name), "%s-Channel-Answered-Time", prefix);
437  switch_event_add_header(event, SWITCH_STACK_BOTTOM, header_name, "%" SWITCH_TIME_T_FMT, times->answered);
438  switch_snprintf(header_name, sizeof(header_name), "%s-Channel-Progress-Time", prefix);
439  switch_event_add_header(event, SWITCH_STACK_BOTTOM, header_name, "%" SWITCH_TIME_T_FMT, times->progress);
440  switch_snprintf(header_name, sizeof(header_name), "%s-Channel-Progress-Media-Time", prefix);
442  switch_snprintf(header_name, sizeof(header_name), "%s-Channel-Hangup-Time", prefix);
443  switch_event_add_header(event, SWITCH_STACK_BOTTOM, header_name, "%" SWITCH_TIME_T_FMT, times->hungup);
444  switch_snprintf(header_name, sizeof(header_name), "%s-Channel-Transfer-Time", prefix);
446  switch_snprintf(header_name, sizeof(header_name), "%s-Channel-Resurrect-Time", prefix);
448  switch_snprintf(header_name, sizeof(header_name), "%s-Channel-Bridged-Time", prefix);
449  switch_event_add_header(event, SWITCH_STACK_BOTTOM, header_name, "%" SWITCH_TIME_T_FMT, times->bridged);
450  switch_snprintf(header_name, sizeof(header_name), "%s-Channel-Last-Hold", prefix);
452  switch_snprintf(header_name, sizeof(header_name), "%s-Channel-Hold-Accum", prefix);
454  }
455 
456  switch_snprintf(header_name, sizeof(header_name), "%s-Screen-Bit", prefix);
457  switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, header_name, switch_test_flag(caller_profile, SWITCH_CPF_SCREEN) ? "true" : "false");
458 
459  switch_snprintf(header_name, sizeof(header_name), "%s-Privacy-Hide-Name", prefix);
460  switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, header_name, switch_test_flag(caller_profile, SWITCH_CPF_HIDE_NAME) ? "true" : "false");
461 
462  switch_snprintf(header_name, sizeof(header_name), "%s-Privacy-Hide-Number", prefix);
463  switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, header_name, switch_test_flag(caller_profile, SWITCH_CPF_HIDE_NUMBER) ? "true" : "false");
464 }
465 
468 {
469  switch_caller_extension_t *caller_extension = NULL;
470  switch_caller_application_t *caller_application = NULL, *ap = NULL;
471 
472  *new_ext = NULL;
473 
474  if ((caller_extension = switch_core_alloc(pool, sizeof(switch_caller_extension_t))) != 0) {
475  int match = 0;
476 
477  caller_extension->extension_name = switch_core_strdup(pool, orig->extension_name);
478  caller_extension->extension_number = switch_core_strdup(pool, orig->extension_number);
479 
480  for (ap = orig->applications; ap; ap = ap->next) {
481 
482  if (!match) {
483  if (ap == orig->current_application) {
484  match++;
485  } else {
486  continue;
487  }
488  }
489  caller_application = switch_core_alloc(pool, sizeof(switch_caller_application_t));
490 
491  caller_application->application_name = switch_core_strdup(pool, ap->application_name);
492  caller_application->application_data = switch_core_strdup(pool, ap->application_data);
493 
494  if (!caller_extension->applications) {
495  caller_extension->applications = caller_application;
496  } else if (caller_extension->last_application) {
497  caller_extension->last_application->next = caller_application;
498  }
499 
500  caller_extension->last_application = caller_application;
501 
502  if (ap == orig->current_application) {
503  caller_extension->current_application = caller_application;
504  }
505  }
506 
507  *new_ext = caller_extension;
508 
509  return SWITCH_STATUS_SUCCESS;
510  }
511 
512 
513  return SWITCH_STATUS_MEMERR;
514 }
515 
517  const char *extension_number)
518 {
519  switch_caller_extension_t *caller_extension = NULL;
520 
521  if ((caller_extension = switch_core_session_alloc(session, sizeof(switch_caller_extension_t))) != 0) {
522  caller_extension->extension_name = switch_core_session_strdup(session, extension_name);
523  caller_extension->extension_number = switch_core_session_strdup(session, extension_number);
524  caller_extension->current_application = caller_extension->last_application = caller_extension->applications;
525  }
526 
527  return caller_extension;
528 }
529 
530 
532  switch_caller_extension_t *caller_extension, const char *application_name,
533  const char *fmt, ...)
534 {
535  va_list ap;
536  char *data = NULL;
537 
538  va_start(ap, fmt);
539  if ( switch_vasprintf(&data, fmt, ap) != -1 ) {
540  if (strstr(data, "\\'")) {
541  switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "App not added, Invalid character sequence in data string [%s]\n",
542  data);
543  } else {
544  switch_caller_extension_add_application(session, caller_extension, application_name, data);
545  }
546  }
547  va_end(ap);
548 
549  switch_safe_free(data);
550 }
551 
552 
554  switch_caller_extension_t *caller_extension, const char *application_name,
555  const char *application_data)
556 {
557  switch_caller_application_t *caller_application = NULL;
558 
559  switch_assert(session != NULL);
560 
561  if ((caller_application = switch_core_session_alloc(session, sizeof(switch_caller_application_t))) != 0) {
562  caller_application->application_name = switch_core_session_strdup(session, application_name);
563  caller_application->application_data = switch_core_session_strdup(session, application_data);
564 
565 
566 
567  if (caller_application->application_data && strstr(caller_application->application_data, "\\'")) {
568  switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "App not added, Invalid character sequence in data string [%s]\n",
569  caller_application->application_data);
570  return;
571  }
572 
573  if (!caller_extension->applications) {
574  caller_extension->applications = caller_application;
575  } else if (caller_extension->last_application) {
576  caller_extension->last_application->next = caller_application;
577  }
578 
579  caller_extension->last_application = caller_application;
580  caller_extension->current_application = caller_extension->applications;
581  }
582 
583 }
584 
585 /* For Emacs:
586  * Local Variables:
587  * mode:c
588  * indent-tabs-mode:t
589  * tab-width:4
590  * c-basic-offset:4
591  * End:
592  * For VIM:
593  * vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet:
594  */
#define SWITCH_DEFAULT_CLID_NUMBER
Definition: switch_types.h:115
#define SWITCH_CHANNEL_SESSION_LOG(x)
An Abstract Representation of a dialplan extension.
Call Specific Data.
Definition: switch_caller.h:73
#define switch_set_flag(obj, flag)
Set a flag on an arbitrary object.
Definition: switch_utils.h:700
switch_call_direction_t logical_direction
#define SWITCH_NUMPLAN_UNDEF
Definition: switch_types.h:50
const char * orig_caller_id_name
Definition: switch_caller.h:83
int switch_core_test_flag(int flag)
Definition: switch_core.c:1792
const char * switch_caller_get_field_by_name(switch_caller_profile_t *caller_profile, const char *name)
#define switch_core_strdup(_pool, _todup)
Copy a string using memory allocation from a given pool.
Definition: switch_core.h:733
const char * network_addr
Definition: switch_caller.h:93
switch_memory_pool_t * pool
switch_status_t switch_event_add_header(switch_event_t *event, switch_stack_t stack, const char *header_name, const char *fmt,...) PRINTF_FUNCTION(4
Add a header to an event.
Representation of an event.
Definition: switch_event.h:80
An Abstract Representation of a dialplan Application.
void switch_caller_profile_event_set_data(switch_caller_profile_t *caller_profile, const char *prefix, switch_event_t *event)
switch_caller_application_t * last_application
const char * dialplan
Definition: switch_caller.h:77
Caller Identification.
int switch_snprintf(_Out_z_cap_(len) char *buf, _In_ switch_size_t len, _In_z_ _Printf_format_string_ const char *format,...)
const char * username
Definition: switch_caller.h:75
#define zstr(x)
Definition: switch_utils.h:314
int cJSON_bool fmt
Definition: switch_cJSON.h:150
struct switch_caller_application * next
#define SWITCH_DEFAULT_CLID_NAME
Definition: switch_types.h:114
switch_caller_profile_t * switch_caller_profile_dup(switch_memory_pool_t *pool, switch_caller_profile_t *tocopy)
const char * orig_caller_id_number
Definition: switch_caller.h:85
switch_byte_t * data
Definition: switch_buffer.c:43
const char * callee_id_number
Definition: switch_caller.h:89
#define switch_core_alloc(_pool, _mem)
Allocate memory directly from a memory pool.
Definition: switch_core.h:684
switch_caller_profile_t * switch_caller_profile_clone(switch_core_session_t *session, switch_caller_profile_t *tocopy)
switch_caller_application_t * applications
switch_status_t switch_event_add_header_string(switch_event_t *event, switch_stack_t stack, const char *header_name, const char *data)
Add a string header to an event.
const char * caller_id_name
Definition: switch_caller.h:79
#define switch_safe_free(it)
Free a pointer and set it to NULL unless it already is NULL.
Definition: switch_utils.h:885
#define SWITCH_BLANK_STRING
Definition: switch_types.h:48
#define SWITCH_TIME_T_FMT
struct profile_node_s * next
Definition: switch_caller.h:66
switch_time_t profile_created
switch_call_direction_t direction
int switch_vasprintf(_Out_opt_ char **buf, _In_z_ _Printf_format_string_ const char *format, _In_ va_list ap)
uint8_t destination_number_numplan
const char * profile_index
switch_status_t switch_caller_extension_clone(switch_caller_extension_t **new_ext, switch_caller_extension_t *orig, switch_memory_pool_t *pool)
switch_caller_application_t * current_application
switch_caller_profile_flag_t flags
#define SWITCH_TON_UNDEF
Definition: switch_types.h:49
switch_status_t
Common return values.
#define profile_dup(a, b, p)
Definition: switch_caller.h:60
struct switch_channel_timetable * old_times
char * switch_uuid_str(char *buf, switch_size_t len)
void switch_caller_extension_add_application(switch_core_session_t *session, switch_caller_extension_t *caller_extension, const char *application_name, const char *application_data)
Main Library Header.
#define SWITCH_DECLARE(type)
struct switch_channel_timetable * times
const char * caller_id_number
Definition: switch_caller.h:81
#define switch_core_session_alloc(_session, _memory)
Allocate memory from a session&#39;s pool.
Definition: switch_core.h:696
void switch_caller_extension_add_application_printf(switch_core_session_t *session, switch_caller_extension_t *caller_extension, const char *application_name, const char *fmt,...)
#define switch_test_flag(obj, flag)
Test for the existance of a flag on an arbitary object.
Definition: switch_utils.h:693
void switch_log_printf(_In_ switch_text_channel_t channel, _In_z_ const char *file, _In_z_ const char *func, _In_ int line, _In_opt_z_ const char *userdata, _In_ switch_log_level_t level, _In_z_ _Printf_format_string_ const char *fmt,...) PRINTF_FUNCTION(7
Write log data to the logging engine.
profile_node_t * soft
struct fspr_pool_t switch_memory_pool_t
switch_caller_extension_t * switch_caller_extension_new(switch_core_session_t *session, const char *extension_name, const char *extension_number)
const char *const name
Definition: switch_cJSON.h:250
#define switch_core_session_strdup(_session, _todup)
Copy a string using memory allocation from a session&#39;s pool.
Definition: switch_core.h:719
char * switch_core_sprintf(_In_ switch_memory_pool_t *pool, _In_z_ _Printf_format_string_ const char *fmt,...)
printf-style style printing routine. The data is output to a string allocated from the pool ...
#define switch_assert(expr)
memset(buf, 0, buflen)
#define profile_dup_clean(a, b, p)
Definition: switch_caller.h:61
const char * callee_id_name
Definition: switch_caller.h:87
switch_caller_profile_t * switch_caller_profile_new(switch_memory_pool_t *pool, const char *username, const char *dialplan, const char *caller_id_name, const char *caller_id_number, const char *network_addr, const char *ani, const char *aniii, const char *rdnis, const char *source, const char *context, const char *destination_number)
Definition: switch_caller.c:36
switch_memory_pool_t * switch_core_session_get_pool(_In_ switch_core_session_t *session)
Retrieve the memory pool from a session.
switch_time_t progress_media
#define SWITCH_UUID_FORMATTED_LENGTH
Definition: switch_apr.h:545
switch_memory_pool_t * pool