FreeSWITCH API Documentation  1.7.0
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;
100  profile->pool = pool;
101  return profile;
102 }
103 
105 {
106  switch_caller_profile_t *profile = NULL;
107  char uuid_str[SWITCH_UUID_FORMATTED_LENGTH + 1];
108 
109  profile = switch_core_alloc(pool, sizeof(*profile));
110  switch_assert(profile != NULL);
111 
112  switch_uuid_str(uuid_str, sizeof(uuid_str));
113  profile->uuid_str = switch_core_strdup(pool, uuid_str);
114  profile->clone_of = switch_core_strdup(pool, tocopy->uuid_str);
115 
116  profile_dup(tocopy->username, profile->username, pool);
117  profile_dup(tocopy->dialplan, profile->dialplan, pool);
118  profile_dup(tocopy->caller_id_name, profile->caller_id_name, pool);
119  profile_dup(tocopy->caller_id_number, profile->caller_id_number, pool);
120  profile_dup(tocopy->callee_id_name, profile->callee_id_name, pool);
121  profile_dup(tocopy->callee_id_number, profile->callee_id_number, pool);
122  profile_dup(tocopy->orig_caller_id_name, profile->orig_caller_id_name, pool);
123  profile_dup(tocopy->orig_caller_id_number, profile->orig_caller_id_number, pool);
124  profile_dup(tocopy->network_addr, profile->network_addr, pool);
125  profile_dup(tocopy->ani, profile->ani, pool);
126  profile_dup(tocopy->aniii, profile->aniii, pool);
127  profile_dup(tocopy->rdnis, profile->rdnis, pool);
128  profile_dup(tocopy->source, profile->source, pool);
129  profile_dup(tocopy->context, profile->context, pool);
130  profile_dup(tocopy->destination_number, profile->destination_number, pool);
131  profile_dup(tocopy->uuid, profile->uuid, pool);
132  profile_dup(tocopy->chan_name, profile->chan_name, pool);
133 
134  profile->caller_ton = tocopy->caller_ton;
135  profile->caller_numplan = tocopy->caller_numplan;
136  profile->ani_ton = tocopy->ani_ton;
137  profile->ani_numplan = tocopy->ani_numplan;
138  profile->rdnis_ton = tocopy->rdnis_ton;
139  profile->rdnis_numplan = tocopy->rdnis_numplan;
140  profile->destination_number_ton = tocopy->destination_number_ton;
141  profile->destination_number_numplan = tocopy->destination_number_numplan;
142  profile->flags = tocopy->flags;
143  profile->pool = pool;
144  profile->direction = tocopy->direction;
145 
146  if (tocopy->times) {
148  *profile->old_times = *tocopy->times;
149  } else {
150  tocopy->times = (switch_channel_timetable_t *) switch_core_alloc(tocopy->pool, sizeof(*tocopy->times));
151  }
152 
153  if (tocopy->soft) {
154  profile_node_t *pn;
155 
156  for (pn = tocopy->soft; pn; pn = pn->next) {
157  profile_node_t *pp, *n = switch_core_alloc(profile->pool, sizeof(*n));
158 
159  n->var = switch_core_strdup(profile->pool, pn->var);
160  n->val = switch_core_strdup(profile->pool, pn->val);
161 
162  if (!profile->soft) {
163  profile->soft = n;
164  } else {
165  for(pp = profile->soft; pp && pp->next; pp = pp->next);
166 
167  if (pp) {
168  pp->next = n;
169  }
170  }
171  }
172 
173  }
174 
175  return profile;
176 }
177 
179 {
181 
182  pool = switch_core_session_get_pool(session);
183 
184  return switch_caller_profile_dup(pool, tocopy);
185 }
186 
187 SWITCH_DECLARE(const char *) switch_caller_get_field_by_name(switch_caller_profile_t *caller_profile, const char *name)
188 {
189  if (!strcasecmp(name, "dialplan")) {
190  return caller_profile->dialplan;
191  }
192  if (!strcasecmp(name, "username")) {
193  return caller_profile->username;
194  }
195  if (!strcasecmp(name, "caller_id_name")) {
196  return caller_profile->caller_id_name;
197  }
198  if (!strcasecmp(name, "caller_id_number")) {
199  return caller_profile->caller_id_number;
200  }
201  if (!strcasecmp(name, "orig_caller_id_name")) {
202  return caller_profile->orig_caller_id_name;
203  }
204  if (!strcasecmp(name, "orig_caller_id_number")) {
205  return caller_profile->orig_caller_id_number;
206  }
207  if (!strcasecmp(name, "callee_id_name")) {
208  return caller_profile->callee_id_name;
209  }
210  if (!strcasecmp(name, "callee_id_number")) {
211  return caller_profile->callee_id_number;
212  }
213  if (!strcasecmp(name, "ani")) {
214  return caller_profile->ani;
215  }
216  if (!strcasecmp(name, "aniii")) {
217  return caller_profile->aniii;
218  }
219  if (!strcasecmp(name, "network_addr")) {
220  return caller_profile->network_addr;
221  }
222  if (!strcasecmp(name, "rdnis")) {
223  return caller_profile->rdnis;
224  }
225  if (!strcasecmp(name, "destination_number")) {
226  return caller_profile->destination_number;
227  }
228  if (!strcasecmp(name, "uuid")) {
229  return caller_profile->uuid;
230  }
231  if (!strcasecmp(name, "source")) {
232  return caller_profile->source;
233  }
234  if (!strcasecmp(name, "transfer_source")) {
235  return caller_profile->transfer_source;
236  }
237  if (!strcasecmp(name, "context")) {
238  return caller_profile->context;
239  }
240 
241  if (!strcasecmp(name, "chan_name")) {
242  return caller_profile->chan_name;
243  }
244 
245  if (!strcasecmp(name, "profile_index")) {
246  return caller_profile->profile_index;
247  }
248 
249  if (!strcasecmp(name, "caller_ton")) {
250  return switch_core_sprintf(caller_profile->pool, "%u", caller_profile->caller_ton);
251  }
252  if (!strcasecmp(name, "caller_numplan")) {
253  return switch_core_sprintf(caller_profile->pool, "%u", caller_profile->caller_numplan);
254  }
255  if (!strcasecmp(name, "destination_number_ton")) {
256  return switch_core_sprintf(caller_profile->pool, "%u", caller_profile->destination_number_ton);
257  }
258  if (!strcasecmp(name, "destination_number_numplan")) {
259  return switch_core_sprintf(caller_profile->pool, "%u", caller_profile->destination_number_numplan);
260  }
261  if (!strcasecmp(name, "ani_ton")) {
262  return switch_core_sprintf(caller_profile->pool, "%u", caller_profile->ani_ton);
263  }
264  if (!strcasecmp(name, "ani_numplan")) {
265  return switch_core_sprintf(caller_profile->pool, "%u", caller_profile->ani_numplan);
266  }
267  if (!strcasecmp(name, "rdnis_ton")) {
268  return switch_core_sprintf(caller_profile->pool, "%u", caller_profile->rdnis_ton);
269  }
270  if (!strcasecmp(name, "rdnis_numplan")) {
271  return switch_core_sprintf(caller_profile->pool, "%u", caller_profile->rdnis_numplan);
272  }
273  if (!strcasecmp(name, "screen_bit")) {
274  return switch_test_flag(caller_profile, SWITCH_CPF_SCREEN) ? "true" : "false";
275  }
276  if (!strcasecmp(name, "privacy_hide_name")) {
277  return switch_test_flag(caller_profile, SWITCH_CPF_HIDE_NAME) ? "true" : "false";
278  }
279  if (!strcasecmp(name, "privacy_hide_number")) {
280  return switch_test_flag(caller_profile, SWITCH_CPF_HIDE_NUMBER) ? "true" : "false";
281  }
282  if (!strcasecmp(name, "profile_created_time")) {
283  return switch_core_sprintf(caller_profile->pool, "%" SWITCH_TIME_T_FMT, caller_profile->times->profile_created);
284  }
285  if (!strcasecmp(name, "created_time")) {
286  return switch_core_sprintf(caller_profile->pool, "%" SWITCH_TIME_T_FMT, caller_profile->times->created);
287  }
288  if (!strcasecmp(name, "answered_time")) {
289  return switch_core_sprintf(caller_profile->pool, "%" SWITCH_TIME_T_FMT, caller_profile->times->answered);
290  }
291  if (!strcasecmp(name, "progress_time")) {
292  return switch_core_sprintf(caller_profile->pool, "%" SWITCH_TIME_T_FMT, caller_profile->times->progress);
293  }
294  if (!strcasecmp(name, "progress_media_time")) {
295  return switch_core_sprintf(caller_profile->pool, "%" SWITCH_TIME_T_FMT, caller_profile->times->progress_media);
296  }
297  if (!strcasecmp(name, "hungup_time")) {
298  return switch_core_sprintf(caller_profile->pool, "%" SWITCH_TIME_T_FMT, caller_profile->times->hungup);
299  }
300  if (!strcasecmp(name, "transferred_time")) {
301  return switch_core_sprintf(caller_profile->pool, "%" SWITCH_TIME_T_FMT, caller_profile->times->transferred);
302  }
303 
304 
305  return NULL;
306 }
307 
309 {
310  char header_name[1024];
311  switch_channel_timetable_t *times = NULL;
312 
313  switch_snprintf(header_name, sizeof(header_name), "%s-Direction", prefix);
314  switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, header_name, caller_profile->direction == SWITCH_CALL_DIRECTION_INBOUND ?
315  "inbound" : "outbound");
316 
317  switch_snprintf(header_name, sizeof(header_name), "%s-Logical-Direction", prefix);
318  switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, header_name, caller_profile->logical_direction == SWITCH_CALL_DIRECTION_INBOUND ?
319  "inbound" : "outbound");
320 
321  if (!zstr(caller_profile->username)) {
322  switch_snprintf(header_name, sizeof(header_name), "%s-Username", prefix);
323  switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, header_name, caller_profile->username);
324  }
325  if (!zstr(caller_profile->dialplan)) {
326  switch_snprintf(header_name, sizeof(header_name), "%s-Dialplan", prefix);
327  switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, header_name, caller_profile->dialplan);
328  }
329  if (!zstr(caller_profile->caller_id_name)) {
330  switch_snprintf(header_name, sizeof(header_name), "%s-Caller-ID-Name", prefix);
331  switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, header_name, caller_profile->caller_id_name);
332  }
333  if (!zstr(caller_profile->caller_id_number)) {
334  switch_snprintf(header_name, sizeof(header_name), "%s-Caller-ID-Number", prefix);
335  switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, header_name, caller_profile->caller_id_number);
336  }
337  if (!zstr(caller_profile->caller_id_name)) {
338  switch_snprintf(header_name, sizeof(header_name), "%s-Orig-Caller-ID-Name", prefix);
339  switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, header_name, caller_profile->orig_caller_id_name);
340  }
341  if (!zstr(caller_profile->caller_id_number)) {
342  switch_snprintf(header_name, sizeof(header_name), "%s-Orig-Caller-ID-Number", prefix);
343  switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, header_name, caller_profile->orig_caller_id_number);
344  }
345  if (!zstr(caller_profile->callee_id_name)) {
346  switch_snprintf(header_name, sizeof(header_name), "%s-Callee-ID-Name", prefix);
347  switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, header_name, caller_profile->callee_id_name);
348  }
349  if (!zstr(caller_profile->callee_id_number)) {
350  switch_snprintf(header_name, sizeof(header_name), "%s-Callee-ID-Number", prefix);
351  switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, header_name, caller_profile->callee_id_number);
352  }
353  if (!zstr(caller_profile->network_addr)) {
354  switch_snprintf(header_name, sizeof(header_name), "%s-Network-Addr", prefix);
355  switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, header_name, caller_profile->network_addr);
356  }
357  if (!zstr(caller_profile->ani)) {
358  switch_snprintf(header_name, sizeof(header_name), "%s-ANI", prefix);
359  switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, header_name, caller_profile->ani);
360  }
361  if (!zstr(caller_profile->aniii)) {
362  switch_snprintf(header_name, sizeof(header_name), "%s-ANI-II", prefix);
363  switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, header_name, caller_profile->aniii);
364  }
365  if (!zstr(caller_profile->destination_number)) {
366  switch_snprintf(header_name, sizeof(header_name), "%s-Destination-Number", prefix);
367  switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, header_name, caller_profile->destination_number);
368  }
369  if (!zstr(caller_profile->uuid)) {
370  switch_snprintf(header_name, sizeof(header_name), "%s-Unique-ID", prefix);
371  switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, header_name, caller_profile->uuid);
372  }
373  if (!zstr(caller_profile->source)) {
374  switch_snprintf(header_name, sizeof(header_name), "%s-Source", prefix);
375  switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, header_name, caller_profile->source);
376  }
377  if (!zstr(caller_profile->transfer_source)) {
378  switch_snprintf(header_name, sizeof(header_name), "%s-Transfer-Source", prefix);
379  switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, header_name, caller_profile->transfer_source);
380  }
381  if (!zstr(caller_profile->context)) {
382  switch_snprintf(header_name, sizeof(header_name), "%s-Context", prefix);
383  switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, header_name, caller_profile->context);
384  }
385  if (!zstr(caller_profile->rdnis)) {
386  switch_snprintf(header_name, sizeof(header_name), "%s-RDNIS", prefix);
387  switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, header_name, caller_profile->rdnis);
388  }
389  if (!zstr(caller_profile->chan_name)) {
390  switch_snprintf(header_name, sizeof(header_name), "%s-Channel-Name", prefix);
391  switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, header_name, caller_profile->chan_name);
392  }
393  if (!zstr(caller_profile->profile_index)) {
394  switch_snprintf(header_name, sizeof(header_name), "%s-Profile-Index", prefix);
395  switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, header_name, caller_profile->profile_index);
396  }
397 
398  if (caller_profile->soft) {
399  profile_node_t *pn;
400 
401  for (pn = caller_profile->soft; pn; pn = pn->next) {
403  }
404 
405  }
406 
407  if (!(times = caller_profile->times)) {
408  times = caller_profile->old_times;
409  }
410 
411 
412  if (times) {
413  switch_snprintf(header_name, sizeof(header_name), "%s-Profile-Created-Time", prefix);
415  switch_snprintf(header_name, sizeof(header_name), "%s-Channel-Created-Time", prefix);
416  switch_event_add_header(event, SWITCH_STACK_BOTTOM, header_name, "%" SWITCH_TIME_T_FMT, times->created);
417  switch_snprintf(header_name, sizeof(header_name), "%s-Channel-Answered-Time", prefix);
418  switch_event_add_header(event, SWITCH_STACK_BOTTOM, header_name, "%" SWITCH_TIME_T_FMT, times->answered);
419  switch_snprintf(header_name, sizeof(header_name), "%s-Channel-Progress-Time", prefix);
420  switch_event_add_header(event, SWITCH_STACK_BOTTOM, header_name, "%" SWITCH_TIME_T_FMT, times->progress);
421  switch_snprintf(header_name, sizeof(header_name), "%s-Channel-Progress-Media-Time", prefix);
423  switch_snprintf(header_name, sizeof(header_name), "%s-Channel-Hangup-Time", prefix);
424  switch_event_add_header(event, SWITCH_STACK_BOTTOM, header_name, "%" SWITCH_TIME_T_FMT, times->hungup);
425  switch_snprintf(header_name, sizeof(header_name), "%s-Channel-Transfer-Time", prefix);
427  switch_snprintf(header_name, sizeof(header_name), "%s-Channel-Resurrect-Time", prefix);
429  switch_snprintf(header_name, sizeof(header_name), "%s-Channel-Bridged-Time", prefix);
430  switch_event_add_header(event, SWITCH_STACK_BOTTOM, header_name, "%" SWITCH_TIME_T_FMT, times->bridged);
431  switch_snprintf(header_name, sizeof(header_name), "%s-Channel-Last-Hold", prefix);
433  switch_snprintf(header_name, sizeof(header_name), "%s-Channel-Hold-Accum", prefix);
435  }
436 
437  switch_snprintf(header_name, sizeof(header_name), "%s-Screen-Bit", prefix);
438  switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, header_name, switch_test_flag(caller_profile, SWITCH_CPF_SCREEN) ? "true" : "false");
439 
440  switch_snprintf(header_name, sizeof(header_name), "%s-Privacy-Hide-Name", prefix);
441  switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, header_name, switch_test_flag(caller_profile, SWITCH_CPF_HIDE_NAME) ? "true" : "false");
442 
443  switch_snprintf(header_name, sizeof(header_name), "%s-Privacy-Hide-Number", prefix);
444  switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, header_name, switch_test_flag(caller_profile, SWITCH_CPF_HIDE_NUMBER) ? "true" : "false");
445 }
446 
449 {
450  switch_caller_extension_t *caller_extension = NULL;
451  switch_caller_application_t *caller_application = NULL, *ap = NULL;
452 
453  *new_ext = NULL;
454 
455  if ((caller_extension = switch_core_alloc(pool, sizeof(switch_caller_extension_t))) != 0) {
456  int match = 0;
457 
458  caller_extension->extension_name = switch_core_strdup(pool, orig->extension_name);
459  caller_extension->extension_number = switch_core_strdup(pool, orig->extension_number);
460 
461  for (ap = orig->applications; ap; ap = ap->next) {
462 
463  if (!match) {
464  if (ap == orig->current_application) {
465  match++;
466  } else {
467  continue;
468  }
469  }
470  caller_application = switch_core_alloc(pool, sizeof(switch_caller_application_t));
471 
472  caller_application->application_name = switch_core_strdup(pool, ap->application_name);
473  caller_application->application_data = switch_core_strdup(pool, ap->application_data);
474 
475  if (!caller_extension->applications) {
476  caller_extension->applications = caller_application;
477  } else if (caller_extension->last_application) {
478  caller_extension->last_application->next = caller_application;
479  }
480 
481  caller_extension->last_application = caller_application;
482 
483  if (ap == orig->current_application) {
484  caller_extension->current_application = caller_application;
485  }
486  }
487 
488  *new_ext = caller_extension;
489 
490  return SWITCH_STATUS_SUCCESS;
491  }
492 
493 
494  return SWITCH_STATUS_MEMERR;
495 }
496 
498  const char *extension_number)
499 {
500  switch_caller_extension_t *caller_extension = NULL;
501 
502  if ((caller_extension = switch_core_session_alloc(session, sizeof(switch_caller_extension_t))) != 0) {
503  caller_extension->extension_name = switch_core_session_strdup(session, extension_name);
504  caller_extension->extension_number = switch_core_session_strdup(session, extension_number);
505  caller_extension->current_application = caller_extension->last_application = caller_extension->applications;
506  }
507 
508  return caller_extension;
509 }
510 
511 
513  switch_caller_extension_t *caller_extension, const char *application_name,
514  const char *fmt, ...)
515 {
516  va_list ap;
517  char *data = NULL;
518 
519  va_start(ap, fmt);
520  if ( switch_vasprintf(&data, fmt, ap) != -1 ) {
521  if (strstr(data, "\\'")) {
522  switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "App not added, Invalid character sequence in data string [%s]\n",
523  data);
524  } else {
525  switch_caller_extension_add_application(session, caller_extension, application_name, data);
526  }
527  }
528  va_end(ap);
529 
530  switch_safe_free(data);
531 }
532 
533 
535  switch_caller_extension_t *caller_extension, const char *application_name,
536  const char *application_data)
537 {
538  switch_caller_application_t *caller_application = NULL;
539 
540  switch_assert(session != NULL);
541 
542  if ((caller_application = switch_core_session_alloc(session, sizeof(switch_caller_application_t))) != 0) {
543  caller_application->application_name = switch_core_session_strdup(session, application_name);
544  caller_application->application_data = switch_core_session_strdup(session, application_data);
545 
546 
547 
548  if (caller_application->application_data && strstr(caller_application->application_data, "\\'")) {
549  switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "App not added, Invalid character sequence in data string [%s]\n",
550  caller_application->application_data);
551  return;
552  }
553 
554  if (!caller_extension->applications) {
555  caller_extension->applications = caller_application;
556  } else if (caller_extension->last_application) {
557  caller_extension->last_application->next = caller_application;
558  }
559 
560  caller_extension->last_application = caller_application;
561  caller_extension->current_application = caller_extension->applications;
562  }
563 
564 }
565 
566 /* For Emacs:
567  * Local Variables:
568  * mode:c
569  * indent-tabs-mode:t
570  * tab-width:4
571  * c-basic-offset:4
572  * End:
573  * For VIM:
574  * vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet:
575  */
#define SWITCH_DEFAULT_CLID_NUMBER
Definition: switch_types.h:114
#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:631
#define SWITCH_NUMPLAN_UNDEF
Definition: switch_types.h:49
const char * orig_caller_id_name
Definition: switch_caller.h:83
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:729
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:281
struct switch_caller_application * next
#define SWITCH_DEFAULT_CLID_NAME
Definition: switch_types.h:113
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:682
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:789
#define SWITCH_BLANK_STRING
Definition: switch_types.h:47
#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
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:48
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)
const char * caller_id_number
Definition: switch_caller.h:81
#define switch_core_session_alloc(_session, _memory)
Allocate memory from a session's pool.
Definition: switch_core.h:694
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,...)
struct apr_pool_t switch_memory_pool_t
#define switch_test_flag(obj, flag)
Test for the existance of a flag on an arbitary object.
Definition: switch_utils.h:624
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
switch_caller_extension_t * switch_caller_extension_new(switch_core_session_t *session, const char *extension_name, const char *extension_number)
#define switch_core_session_strdup(_session, _todup)
Copy a string using memory allocation from a session's pool.
Definition: switch_core.h:717
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