#include "asterisk/sched.h"
#include "asterisk/channel.h"
Go to the source code of this file.
Data Structures | |
struct | ast_custom_function |
struct | ast_pbx |
struct | ast_switch |
struct | ast_timing |
struct | cfextension_states |
Defines | |
#define | AST_MAX_APP 32 |
#define | AST_PBX_KEEP 0 |
#define | AST_PBX_KEEPALIVE 10 |
#define | AST_PBX_NO_HANGUP_PEER 11 |
#define | AST_PBX_REPLACE 1 |
#define | PRIORITY_HINT -1 |
Typedefs | |
typedef int(* | ast_state_cb_type )(char *context, char *id, enum ast_extension_states state, void *data) |
Enumerations | |
enum | ast_extension_states { AST_EXTENSION_REMOVED = -2, AST_EXTENSION_DEACTIVATED = -1, AST_EXTENSION_NOT_INUSE = 0, AST_EXTENSION_INUSE = 1 << 0, AST_EXTENSION_BUSY = 1 << 1, AST_EXTENSION_UNAVAILABLE = 1 << 2, AST_EXTENSION_RINGING = 1 << 3 } |
enum | ast_pbx_result { AST_PBX_SUCCESS = 0, AST_PBX_FAILED = -1, AST_PBX_CALL_LIMIT = -2 } |
Functions | |
int | ast_active_calls (void) |
int | ast_add_extension (const char *context, int replace, const char *extension, int priority, const char *label, const char *callerid, const char *application, void *data, void(*datad)(void *), const char *registrar) |
int | ast_add_extension2 (struct ast_context *con, int replace, const char *extension, int priority, const char *label, const char *callerid, const char *application, void *data, void(*datad)(void *), const char *registrar) |
int | ast_async_goto (struct ast_channel *chan, const char *context, const char *exten, int priority) |
int | ast_async_goto_by_name (const char *chan, const char *context, const char *exten, int priority) |
int | ast_async_goto_if_exists (struct ast_channel *chan, char *context, char *exten, int priority) |
int | ast_build_timing (struct ast_timing *i, char *info) |
int | ast_canmatch_extension (struct ast_channel *c, const char *context, const char *exten, int priority, const char *callerid) |
int | ast_check_timing (struct ast_timing *i) |
int | ast_context_add_ignorepat (const char *context, const char *ignorepat, const char *registrar) |
int | ast_context_add_ignorepat2 (struct ast_context *con, const char *ignorepat, const char *registrar) |
int | ast_context_add_include (const char *context, const char *include, const char *registrar) |
int | ast_context_add_include2 (struct ast_context *con, const char *include, const char *registrar) |
int | ast_context_add_switch (const char *context, const char *sw, const char *data, int eval, const char *registrar) |
int | ast_context_add_switch2 (struct ast_context *con, const char *sw, const char *data, int eval, const char *registrar) |
ast_context * | ast_context_create (struct ast_context **extcontexts, const char *name, const char *registrar) |
void | ast_context_destroy (struct ast_context *con, const char *registrar) |
ast_context * | ast_context_find (const char *name) |
int | ast_context_remove_extension (const char *context, const char *extension, int priority, const char *registrar) |
int | ast_context_remove_extension2 (struct ast_context *con, const char *extension, int priority, const char *registrar) |
This functionc locks given context, search for the right extension and fires out all peer in this extensions with given priority. If priority is set to 0, all peers are removed. After that, unlock context and return. | |
int | ast_context_remove_ignorepat (const char *context, const char *ignorepat, const char *registrar) |
int | ast_context_remove_ignorepat2 (struct ast_context *con, const char *ignorepat, const char *registrar) |
int | ast_context_remove_include (const char *context, const char *include, const char *registrar) |
int | ast_context_remove_include2 (struct ast_context *con, const char *include, const char *registrar) |
int | ast_context_remove_switch (const char *context, const char *sw, const char *data, const char *registrar) |
int | ast_context_remove_switch2 (struct ast_context *con, const char *sw, const char *data, const char *registrar) |
This function locks given context, removes switch, unlock context and return. | |
int | ast_context_verify_includes (struct ast_context *con) |
ast_custom_function * | ast_custom_function_find (char *name) |
int | ast_custom_function_register (struct ast_custom_function *acf) |
int | ast_custom_function_unregister (struct ast_custom_function *acf) |
int | ast_exec_extension (struct ast_channel *c, const char *context, const char *exten, int priority, const char *callerid) |
int | ast_exists_extension (struct ast_channel *c, const char *context, const char *exten, int priority, const char *callerid) |
int | ast_explicit_goto (struct ast_channel *chan, const char *context, const char *exten, int priority) |
int | ast_extension_close (const char *pattern, const char *data, int needmore) |
int | ast_extension_match (const char *pattern, const char *extension) |
int | ast_extension_patmatch (const char *pattern, const char *data) |
int | ast_extension_state (struct ast_channel *c, char *context, char *exten) |
ast_extension_state: Check extension state for an extension by using hint | |
const char * | ast_extension_state2str (int extension_state) |
ast_extension_state2str: Return extension_state as string | |
int | ast_extension_state_add (const char *context, const char *exten, ast_state_cb_type callback, void *data) |
ast_extension_state_add: Add watcher for extension states | |
int | ast_extension_state_del (int id, ast_state_cb_type callback) |
ast_extension_state_del: Remove a watcher from the callback list | |
int | ast_findlabel_extension (struct ast_channel *c, const char *context, const char *exten, const char *label, const char *callerid) |
int | ast_findlabel_extension2 (struct ast_channel *c, struct ast_context *con, const char *exten, const char *label, const char *callerid) |
char * | ast_func_read (struct ast_channel *chan, const char *in, char *workspace, size_t len) |
void | ast_func_write (struct ast_channel *chan, const char *in, const char *value) |
const char * | ast_get_context_name (struct ast_context *con) |
const char * | ast_get_context_registrar (struct ast_context *c) |
const char * | ast_get_extension_app (struct ast_exten *e) |
void * | ast_get_extension_app_data (struct ast_exten *e) |
const char * | ast_get_extension_cidmatch (struct ast_exten *e) |
const char * | ast_get_extension_label (struct ast_exten *e) |
int | ast_get_extension_matchcid (struct ast_exten *e) |
const char * | ast_get_extension_name (struct ast_exten *exten) |
int | ast_get_extension_priority (struct ast_exten *exten) |
const char * | ast_get_extension_registrar (struct ast_exten *e) |
int | ast_get_hint (char *hint, int maxlen, char *name, int maxnamelen, struct ast_channel *c, const char *context, const char *exten) |
ast_get_hint: Get hint for channel | |
const char * | ast_get_ignorepat_name (struct ast_ignorepat *ip) |
const char * | ast_get_ignorepat_registrar (struct ast_ignorepat *ip) |
const char * | ast_get_include_name (struct ast_include *include) |
const char * | ast_get_include_registrar (struct ast_include *i) |
const char * | ast_get_switch_data (struct ast_sw *sw) |
const char * | ast_get_switch_name (struct ast_sw *sw) |
const char * | ast_get_switch_registrar (struct ast_sw *sw) |
int | ast_goto_if_exists (struct ast_channel *chan, char *context, char *exten, int priority) |
void | ast_hint_state_changed (const char *device) |
int | ast_ignore_pattern (const char *context, const char *pattern) |
int | ast_lock_context (struct ast_context *con) |
int | ast_lock_contexts (void) |
int | ast_matchmore_extension (struct ast_channel *c, const char *context, const char *exten, int priority, const char *callerid) |
void | ast_merge_contexts_and_delete (struct ast_context **extcontexts, const char *registrar) |
int | ast_parseable_goto (struct ast_channel *chan, const char *goto_string) |
int | ast_pbx_outgoing_app (const char *type, int format, void *data, int timeout, const char *app, const char *appdata, int *reason, int sync, const char *cid_num, const char *cid_name, struct ast_variable *vars, const char *account, struct ast_channel **locked_channel) |
int | ast_pbx_outgoing_exten (const char *type, int format, void *data, int timeout, const char *context, const char *exten, int priority, int *reason, int sync, const char *cid_num, const char *cid_name, struct ast_variable *vars, const char *account, struct ast_channel **locked_channel) |
enum ast_pbx_result | ast_pbx_run (struct ast_channel *c) |
enum ast_pbx_result | ast_pbx_start (struct ast_channel *c) |
int | ast_register_application (const char *app, int(*execute)(struct ast_channel *, void *), const char *synopsis, const char *description) |
Dynamically register a new dial plan application. | |
int | ast_register_switch (struct ast_switch *sw) |
int | ast_spawn_extension (struct ast_channel *c, const char *context, const char *exten, int priority, const char *callerid) |
int | ast_unlock_context (struct ast_context *con) |
int | ast_unlock_contexts (void) |
int | ast_unregister_application (const char *app) |
void | ast_unregister_switch (struct ast_switch *sw) |
ast_exten * | ast_walk_context_extensions (struct ast_context *con, struct ast_exten *priority) |
ast_ignorepat * | ast_walk_context_ignorepats (struct ast_context *con, struct ast_ignorepat *ip) |
ast_include * | ast_walk_context_includes (struct ast_context *con, struct ast_include *inc) |
ast_sw * | ast_walk_context_switches (struct ast_context *con, struct ast_sw *sw) |
ast_context * | ast_walk_contexts (struct ast_context *con) |
ast_exten * | ast_walk_extension_priorities (struct ast_exten *exten, struct ast_exten *priority) |
void | pbx_builtin_clear_globals (void) |
char * | pbx_builtin_getvar_helper (struct ast_channel *chan, const char *name) |
void | pbx_builtin_pushvar_helper (struct ast_channel *chan, const char *name, const char *value) |
int | pbx_builtin_serialize_variables (struct ast_channel *chan, char *buf, size_t size) |
int | pbx_builtin_setvar (struct ast_channel *chan, void *data) |
void | pbx_builtin_setvar_helper (struct ast_channel *chan, const char *name, const char *value) |
int | pbx_checkcondition (char *condition) |
int | pbx_exec (struct ast_channel *c, struct ast_app *app, void *data, int newstack) |
ast_app * | pbx_findapp (const char *app) |
Find application handle in linked list. | |
void | pbx_retrieve_variable (struct ast_channel *c, const char *var, char **ret, char *workspace, int workspacelen, struct varshead *headp) |
pbx_retrieve_variable: Support for Asterisk built-in variables and functions in the dialplan --- | |
int | pbx_set_autofallthrough (int newval) |
void | pbx_substitute_variables_helper (struct ast_channel *c, const char *cp1, char *cp2, int count) |
void | pbx_substitute_variables_varshead (struct varshead *headp, const char *cp1, char *cp2, int count) |
Variables | |
static const struct cfextension_states | extension_states [] |
Definition in file pbx.h.
|
Max length of an application Definition at line 37 of file pbx.h. Referenced by handle_show_application(), and handle_show_function(). |
|
|
|
Special return values from applications to the PBX Definition at line 40 of file pbx.h. Referenced by agi_handle_command(), builtin_blindtransfer(), feature_exec_app(), macro_exec(), park_call_exec(), and run_agi(). |
|
Definition at line 41 of file pbx.h. Referenced by builtin_blindtransfer(), feature_exec_app(), and park_exec(). |
|
|
|
Special Priority for an hint Definition at line 44 of file pbx.h. Referenced by ast_add_extension2(), ast_context_remove_extension2(), ast_hint_extension(), destroy_exten(), handle_context_add_extension(), handle_context_remove_extension(), handle_save_dialplan(), pbx_load_module(), and show_dialplan_helper(). |
|
|
|
Extension states
Definition at line 47 of file pbx.h. 00047 { 00048 /*! Extension removed */ 00049 AST_EXTENSION_REMOVED = -2, 00050 /*! Extension hint removed */ 00051 AST_EXTENSION_DEACTIVATED = -1, 00052 /*! No device INUSE or BUSY */ 00053 AST_EXTENSION_NOT_INUSE = 0, 00054 /*! One or more devices INUSE */ 00055 AST_EXTENSION_INUSE = 1 << 0, 00056 /*! All devices BUSY */ 00057 AST_EXTENSION_BUSY = 1 << 1, 00058 /*! All devices UNAVAILABLE/UNREGISTERED */ 00059 AST_EXTENSION_UNAVAILABLE = 1 << 2, 00060 /*! All devices RINGING */ 00061 AST_EXTENSION_RINGING = 1 << 3, 00062 };
|
|
Definition at line 209 of file pbx.h. 00209 { 00210 AST_PBX_SUCCESS = 0, 00211 AST_PBX_FAILED = -1, 00212 AST_PBX_CALL_LIMIT = -2, 00213 };
|
|
Definition at line 2562 of file pbx.c. Referenced by handle_chanlist(). 02563 { 02564 return countcalls; 02565 }
|
|
Definition at line 4505 of file pbx.c. References ast_add_extension2(), ast_get_context_name(), ast_lock_contexts(), ast_unlock_contexts(), and ast_walk_contexts(). Referenced by handle_context_add_extension(), and register_peer_exten(). 04507 { 04508 struct ast_context *c; 04509 04510 if (ast_lock_contexts()) { 04511 errno = EBUSY; 04512 return -1; 04513 } 04514 04515 c = ast_walk_contexts(NULL); 04516 while (c) { 04517 if (!strcmp(context, ast_get_context_name(c))) { 04518 int ret = ast_add_extension2(c, replace, extension, priority, label, callerid, 04519 application, data, datad, registrar); 04520 ast_unlock_contexts(); 04521 return ret; 04522 } 04523 c = ast_walk_contexts(c); 04524 } 04525 04526 ast_unlock_contexts(); 04527 errno = ENOENT; 04528 return -1; 04529 }
|
|
For details about the arguements, check ast_add_extension() Definition at line 4644 of file pbx.c. References ast_add_hint(), ast_change_hint(), AST_LIST_FIRST, ast_log(), ast_mutex_lock(), ast_mutex_unlock(), ast_exten::cidmatch, ast_exten::data, ast_exten::datad, el, ext_strncpy(), ast_exten::exten, free, ast_context::lock, LOG, LOG_ERROR, LOG_WARNING, malloc, ast_exten::matchcid, ast_context::name, ast_exten::next, null_datad(), pbx_substitute_variables_varshead(), ast_exten::peer, ast_exten::priority, PRIORITY_HINT, ast_context::registrar, ast_context::root, and VAR_BUF_SIZE. Referenced by __build_step(), ast_add_extension(), do_parking_thread(), fillin_process(), handle_macro(), load_config(), and pbx_load_module(). 04648 { 04649 04650 #define LOG do { if (option_debug) {\ 04651 if (tmp->matchcid) { \ 04652 ast_log(LOG_DEBUG, "Added extension '%s' priority %d (CID match '%s') to %s\n", tmp->exten, tmp->priority, tmp->cidmatch, con->name); \ 04653 } else { \ 04654 ast_log(LOG_DEBUG, "Added extension '%s' priority %d to %s\n", tmp->exten, tmp->priority, con->name); \ 04655 } \ 04656 } \ 04657 if (option_verbose > 2) { \ 04658 if (tmp->matchcid) { \ 04659 ast_verbose( VERBOSE_PREFIX_3 "Added extension '%s' priority %d (CID match '%s')to %s\n", tmp->exten, tmp->priority, tmp->cidmatch, con->name); \ 04660 } else { \ 04661 ast_verbose( VERBOSE_PREFIX_3 "Added extension '%s' priority %d to %s\n", tmp->exten, tmp->priority, con->name); \ 04662 } \ 04663 } } while(0) 04664 04665 /* 04666 * This is a fairly complex routine. Different extensions are kept 04667 * in order by the extension number. Then, extensions of different 04668 * priorities (same extension) are kept in a list, according to the 04669 * peer pointer. 04670 */ 04671 struct ast_exten *tmp, *e, *el = NULL, *ep = NULL; 04672 int res; 04673 int length; 04674 char *p; 04675 char expand_buf[VAR_BUF_SIZE] = { 0, }; 04676 04677 /* if we are adding a hint, and there are global variables, and the hint 04678 contains variable references, then expand them 04679 */ 04680 ast_mutex_lock(&globalslock); 04681 if ((priority == PRIORITY_HINT) && AST_LIST_FIRST(&globals) && strstr(application, "${")) { 04682 pbx_substitute_variables_varshead(&globals, application, expand_buf, sizeof(expand_buf)); 04683 application = expand_buf; 04684 } 04685 ast_mutex_unlock(&globalslock); 04686 04687 length = sizeof(struct ast_exten); 04688 length += strlen(extension) + 1; 04689 length += strlen(application) + 1; 04690 if (label) 04691 length += strlen(label) + 1; 04692 if (callerid) 04693 length += strlen(callerid) + 1; 04694 else 04695 length ++; 04696 04697 /* Be optimistic: Build the extension structure first */ 04698 if (datad == NULL) 04699 datad = null_datad; 04700 tmp = malloc(length); 04701 if (tmp) { 04702 memset(tmp, 0, length); 04703 p = tmp->stuff; 04704 if (label) { 04705 tmp->label = p; 04706 strcpy(tmp->label, label); 04707 p += strlen(label) + 1; 04708 } 04709 tmp->exten = p; 04710 p += ext_strncpy(tmp->exten, extension, strlen(extension) + 1) + 1; 04711 tmp->priority = priority; 04712 tmp->cidmatch = p; 04713 if (callerid) { 04714 p += ext_strncpy(tmp->cidmatch, callerid, strlen(callerid) + 1) + 1; 04715 tmp->matchcid = 1; 04716 } else { 04717 tmp->cidmatch[0] = '\0'; 04718 tmp->matchcid = 0; 04719 p++; 04720 } 04721 tmp->app = p; 04722 strcpy(tmp->app, application); 04723 tmp->parent = con; 04724 tmp->data = data; 04725 tmp->datad = datad; 04726 tmp->registrar = registrar; 04727 tmp->peer = NULL; 04728 tmp->next = NULL; 04729 } else { 04730 ast_log(LOG_ERROR, "Out of memory\n"); 04731 errno = ENOMEM; 04732 return -1; 04733 } 04734 if (ast_mutex_lock(&con->lock)) { 04735 free(tmp); 04736 /* And properly destroy the data */ 04737 datad(data); 04738 ast_log(LOG_WARNING, "Failed to lock context '%s'\n", con->name); 04739 errno = EBUSY; 04740 return -1; 04741 } 04742 e = con->root; 04743 while(e) { 04744 /* Make sure patterns are always last! */ 04745 if ((e->exten[0] != '_') && (extension[0] == '_')) 04746 res = -1; 04747 else if ((e->exten[0] == '_') && (extension[0] != '_')) 04748 res = 1; 04749 else 04750 res= strcmp(e->exten, extension); 04751 if (!res) { 04752 if (!e->matchcid && !tmp->matchcid) 04753 res = 0; 04754 else if (tmp->matchcid && !e->matchcid) 04755 res = 1; 04756 else if (e->matchcid && !tmp->matchcid) 04757 res = -1; 04758 else 04759 res = strcasecmp(e->cidmatch, tmp->cidmatch); 04760 } 04761 if (res == 0) { 04762 /* We have an exact match, now we find where we are 04763 and be sure there's no duplicates */ 04764 while(e) { 04765 if (e->priority == tmp->priority) { 04766 /* Can't have something exactly the same. Is this a 04767 replacement? If so, replace, otherwise, bonk. */ 04768 if (replace) { 04769 if (ep) { 04770 /* We're in the peer list, insert ourselves */ 04771 ep->peer = tmp; 04772 tmp->peer = e->peer; 04773 } else if (el) { 04774 /* We're the first extension. Take over e's functions */ 04775 el->next = tmp; 04776 tmp->next = e->next; 04777 tmp->peer = e->peer; 04778 } else { 04779 /* We're the very first extension. */ 04780 con->root = tmp; 04781 tmp->next = e->next; 04782 tmp->peer = e->peer; 04783 } 04784 if (tmp->priority == PRIORITY_HINT) 04785 ast_change_hint(e,tmp); 04786 /* Destroy the old one */ 04787 e->datad(e->data); 04788 free(e); 04789 ast_mutex_unlock(&con->lock); 04790 if (tmp->priority == PRIORITY_HINT) 04791 ast_change_hint(e, tmp); 04792 /* And immediately return success. */ 04793 LOG; 04794 return 0; 04795 } else { 04796 ast_log(LOG_WARNING, "Unable to register extension '%s', priority %d in '%s', already in use\n", tmp->exten, tmp->priority, con->name); 04797 tmp->datad(tmp->data); 04798 free(tmp); 04799 ast_mutex_unlock(&con->lock); 04800 errno = EEXIST; 04801 return -1; 04802 } 04803 } else if (e->priority > tmp->priority) { 04804 /* Slip ourselves in just before e */ 04805 if (ep) { 04806 /* Easy enough, we're just in the peer list */ 04807 ep->peer = tmp; 04808 tmp->peer = e; 04809 } else if (el) { 04810 /* We're the first extension in this peer list */ 04811 el->next = tmp; 04812 tmp->next = e->next; 04813 e->next = NULL; 04814 tmp->peer = e; 04815 } else { 04816 /* We're the very first extension altogether */ 04817 tmp->next = con->root->next; 04818 /* Con->root must always exist or we couldn't get here */ 04819 tmp->peer = con->root; 04820 con->root = tmp; 04821 } 04822 ast_mutex_unlock(&con->lock); 04823 04824 /* And immediately return success. */ 04825 if (tmp->priority == PRIORITY_HINT) 04826 ast_add_hint(tmp); 04827 04828 LOG; 04829 return 0; 04830 } 04831 ep = e; 04832 e = e->peer; 04833 } 04834 /* If we make it here, then it's time for us to go at the very end. 04835 ep *must* be defined or we couldn't have gotten here. */ 04836 ep->peer = tmp; 04837 ast_mutex_unlock(&con->lock); 04838 if (tmp->priority == PRIORITY_HINT) 04839 ast_add_hint(tmp); 04840 04841 /* And immediately return success. */ 04842 LOG; 04843 return 0; 04844 04845 } else if (res > 0) { 04846 /* Insert ourselves just before 'e'. We're the first extension of 04847 this kind */ 04848 tmp->next = e; 04849 if (el) { 04850 /* We're in the list somewhere */ 04851 el->next = tmp; 04852 } else { 04853 /* We're at the top of the list */ 04854 con->root = tmp; 04855 } 04856 ast_mutex_unlock(&con->lock); 04857 if (tmp->priority == PRIORITY_HINT) 04858 ast_add_hint(tmp); 04859 04860 /* And immediately return success. */ 04861 LOG; 04862 return 0; 04863 } 04864 04865 el = e; 04866 e = e->next; 04867 } 04868 /* If we fall all the way through to here, then we need to be on the end. */ 04869 if (el) 04870 el->next = tmp; 04871 else 04872 con->root = tmp; 04873 ast_mutex_unlock(&con->lock); 04874 if (tmp->priority == PRIORITY_HINT) 04875 ast_add_hint(tmp); 04876 LOG; 04877 return 0; 04878 }
|
|
Definition at line 4550 of file pbx.c. References ast_channel::_state, ast_channel_alloc(), ast_channel_masquerade(), ast_do_masquerade(), ast_explicit_goto(), ast_hangup(), ast_log(), ast_mutex_lock(), ast_mutex_unlock(), ast_pbx_start(), ast_setstate(), AST_SOFTHANGUP_ASYNCGOTO, ast_softhangup_nolock(), ast_strlen_zero(), ast_channel::context, ast_channel::exten, ast_channel::lock, LOG_WARNING, ast_channel::name, ast_channel::pbx, ast_channel::readformat, and ast_channel::writeformat. Referenced by __ast_goto_if_exists(), action_redirect(), ast_async_goto_by_name(), builtin_blindtransfer(), console_transfer(), handle_request_bye(), handle_request_refer(), monitor_handle_owned(), process_ast_dsp(), socket_read(), and zt_read(). 04551 { 04552 int res = 0; 04553 04554 ast_mutex_lock(&chan->lock); 04555 04556 if (chan->pbx) { 04557 /* This channel is currently in the PBX */ 04558 ast_explicit_goto(chan, context, exten, priority); 04559 ast_softhangup_nolock(chan, AST_SOFTHANGUP_ASYNCGOTO); 04560 } else { 04561 /* In order to do it when the channel doesn't really exist within 04562 the PBX, we have to make a new channel, masquerade, and start the PBX 04563 at the new location */ 04564 struct ast_channel *tmpchan; 04565 tmpchan = ast_channel_alloc(0); 04566 if (tmpchan) { 04567 snprintf(tmpchan->name, sizeof(tmpchan->name), "AsyncGoto/%s", chan->name); 04568 ast_setstate(tmpchan, chan->_state); 04569 /* Make formats okay */ 04570 tmpchan->readformat = chan->readformat; 04571 tmpchan->writeformat = chan->writeformat; 04572 /* Setup proper location */ 04573 ast_explicit_goto(tmpchan, 04574 (!ast_strlen_zero(context)) ? context : chan->context, 04575 (!ast_strlen_zero(exten)) ? exten : chan->exten, 04576 priority); 04577 04578 /* Masquerade into temp channel */ 04579 ast_channel_masquerade(tmpchan, chan); 04580 04581 /* Grab the locks and get going */ 04582 ast_mutex_lock(&tmpchan->lock); 04583 ast_do_masquerade(tmpchan); 04584 ast_mutex_unlock(&tmpchan->lock); 04585 /* Start the PBX going on our stolen channel */ 04586 if (ast_pbx_start(tmpchan)) { 04587 ast_log(LOG_WARNING, "Unable to start PBX on %s\n", tmpchan->name); 04588 ast_hangup(tmpchan); 04589 res = -1; 04590 } 04591 } else { 04592 res = -1; 04593 } 04594 } 04595 ast_mutex_unlock(&chan->lock); 04596 return res; 04597 }
|
|
Definition at line 4599 of file pbx.c. References ast_async_goto(), ast_get_channel_by_name_locked(), ast_mutex_unlock(), and ast_channel::lock. 04600 { 04601 struct ast_channel *chan; 04602 int res = -1; 04603 04604 chan = ast_get_channel_by_name_locked(channame); 04605 if (chan) { 04606 res = ast_async_goto(chan, context, exten, priority); 04607 ast_mutex_unlock(&chan->lock); 04608 } 04609 return res; 04610 }
|
|
Definition at line 6472 of file pbx.c. References __ast_goto_if_exists(). 06472 { 06473 return __ast_goto_if_exists(chan, context, exten, priority, 1); 06474 }
|
|
Definition at line 4083 of file pbx.c. References ast_strlen_zero(), ast_timing::daymask, ast_timing::dowmask, FIND_NEXT, get_day(), get_dow(), get_month(), get_timerange(), and ast_timing::monthmask. Referenced by ast_context_add_include2(), builtin_function_iftime(), pbx_builtin_execiftime(), and pbx_builtin_gotoiftime(). 04084 { 04085 char info_save[256]; 04086 char *info; 04087 char *c; 04088 04089 /* Check for empty just in case */ 04090 if (ast_strlen_zero(info_in)) 04091 return 0; 04092 /* make a copy just in case we were passed a static string */ 04093 ast_copy_string(info_save, info_in, sizeof(info_save)); 04094 info = info_save; 04095 /* Assume everything except time */ 04096 i->monthmask = (1 << 12) - 1; 04097 i->daymask = (1 << 30) - 1 + (1 << 30); 04098 i->dowmask = (1 << 7) - 1; 04099 /* Avoid using str tok */ 04100 FIND_NEXT; 04101 /* Info has the time range, start with that */ 04102 get_timerange(i, info); 04103 info = c; 04104 if (!info) 04105 return 1; 04106 FIND_NEXT; 04107 /* Now check for day of week */ 04108 i->dowmask = get_dow(info); 04109 04110 info = c; 04111 if (!info) 04112 return 1; 04113 FIND_NEXT; 04114 /* Now check for the day of the month */ 04115 i->daymask = get_day(info); 04116 info = c; 04117 if (!info) 04118 return 1; 04119 FIND_NEXT; 04120 /* And finally go for the month */ 04121 i->monthmask = get_month(info); 04122 04123 return 1; 04124 }
|
|
Definition at line 2218 of file pbx.c. References HELPER_CANMATCH, and pbx_extension_helper(). Referenced by background_detect_exec(), cb_events(), dp_lookup(), dundi_lookup_local(), get_also_info(), get_destination(), get_refer_info(), handle_link_data(), handle_link_phone_dtmf(), loopback_canmatch(), mgcp_ss(), monitor_handle_notowned(), phone_check_exception(), rpt(), skinny_ss(), ss_thread(), and valid_exit(). 02219 { 02220 return pbx_extension_helper(c, NULL, context, exten, priority, NULL, callerid, HELPER_CANMATCH); 02221 }
|
|
Definition at line 4126 of file pbx.c. References ast_log(), ast_timing::daymask, ast_timing::dowmask, LOG_WARNING, ast_timing::minmask, ast_timing::monthmask, and t. Referenced by builtin_function_iftime(), include_valid(), pbx_builtin_execiftime(), and pbx_builtin_gotoiftime(). 04127 { 04128 struct tm tm; 04129 time_t t; 04130 04131 time(&t); 04132 localtime_r(&t,&tm); 04133 04134 /* If it's not the right month, return */ 04135 if (!(i->monthmask & (1 << tm.tm_mon))) { 04136 return 0; 04137 } 04138 04139 /* If it's not that time of the month.... */ 04140 /* Warning, tm_mday has range 1..31! */ 04141 if (!(i->daymask & (1 << (tm.tm_mday-1)))) 04142 return 0; 04143 04144 /* If it's not the right day of the week */ 04145 if (!(i->dowmask & (1 << tm.tm_wday))) 04146 return 0; 04147 04148 /* Sanity check the hour just to be safe */ 04149 if ((tm.tm_hour < 0) || (tm.tm_hour > 23)) { 04150 ast_log(LOG_WARNING, "Insane time...\n"); 04151 return 0; 04152 } 04153 04154 /* Now the tough part, we calculate if it fits 04155 in the right time based on min/hour */ 04156 if (!(i->minmask[tm.tm_hour] & (1 << (tm.tm_min / 2)))) 04157 return 0; 04158 04159 /* If we got this far, then we're good */ 04160 return 1; 04161 }
|
|
Definition at line 4422 of file pbx.c. References ast_context_add_ignorepat2(), ast_get_context_name(), ast_lock_contexts(), ast_unlock_contexts(), and ast_walk_contexts(). Referenced by handle_context_add_ignorepat(). 04423 { 04424 struct ast_context *c; 04425 04426 if (ast_lock_contexts()) { 04427 errno = EBUSY; 04428 return -1; 04429 } 04430 04431 c = ast_walk_contexts(NULL); 04432 while (c) { 04433 if (!strcmp(ast_get_context_name(c), con)) { 04434 int ret = ast_context_add_ignorepat2(c, value, registrar); 04435 ast_unlock_contexts(); 04436 return ret; 04437 } 04438 c = ast_walk_contexts(c); 04439 } 04440 04441 ast_unlock_contexts(); 04442 errno = ENOENT; 04443 return -1; 04444 }
|
|
Definition at line 4446 of file pbx.c. References ast_log(), ast_mutex_lock(), ast_mutex_unlock(), ast_context::ignorepats, ast_context::lock, LOG_ERROR, malloc, ast_ignorepat::next, ast_ignorepat::pattern, and ast_ignorepat::registrar. Referenced by ast_context_add_ignorepat(), handle_context(), and pbx_load_module(). 04447 { 04448 struct ast_ignorepat *ignorepat, *ignorepatc, *ignorepatl = NULL; 04449 int length; 04450 length = sizeof(struct ast_ignorepat); 04451 length += strlen(value) + 1; 04452 ignorepat = malloc(length); 04453 if (!ignorepat) { 04454 ast_log(LOG_ERROR, "Out of memory\n"); 04455 errno = ENOMEM; 04456 return -1; 04457 } 04458 memset(ignorepat, 0, length); 04459 strcpy(ignorepat->pattern, value); 04460 ignorepat->next = NULL; 04461 ignorepat->registrar = registrar; 04462 ast_mutex_lock(&con->lock); 04463 ignorepatc = con->ignorepats; 04464 while(ignorepatc) { 04465 ignorepatl = ignorepatc; 04466 if (!strcasecmp(ignorepatc->pattern, value)) { 04467 /* Already there */ 04468 ast_mutex_unlock(&con->lock); 04469 errno = EEXIST; 04470 return -1; 04471 } 04472 ignorepatc = ignorepatc->next; 04473 } 04474 if (ignorepatl) 04475 ignorepatl->next = ignorepat; 04476 else 04477 con->ignorepats = ignorepat; 04478 ast_mutex_unlock(&con->lock); 04479 return 0; 04480 04481 }
|
|
Definition at line 3805 of file pbx.c. References ast_context_add_include2(), ast_get_context_name(), ast_lock_contexts(), ast_unlock_contexts(), and ast_walk_contexts(). Referenced by handle_context_add_include(). 03806 { 03807 struct ast_context *c; 03808 03809 if (ast_lock_contexts()) { 03810 errno = EBUSY; 03811 return -1; 03812 } 03813 03814 /* walk contexts ... */ 03815 c = ast_walk_contexts(NULL); 03816 while (c) { 03817 /* ... search for the right one ... */ 03818 if (!strcmp(ast_get_context_name(c), context)) { 03819 int ret = ast_context_add_include2(c, include, registrar); 03820 /* ... unlock contexts list and return */ 03821 ast_unlock_contexts(); 03822 return ret; 03823 } 03824 c = ast_walk_contexts(c); 03825 } 03826 03827 /* we can't find the right context */ 03828 ast_unlock_contexts(); 03829 errno = ENOENT; 03830 return -1; 03831 }
|
|
Definition at line 4170 of file pbx.c. References ast_build_timing(), ast_get_context_name(), ast_log(), ast_mutex_lock(), ast_mutex_unlock(), ast_verbose(), free, ast_include::hastime, ast_context::includes, ast_context::lock, LOG_ERROR, malloc, ast_include::name, ast_include::next, option_verbose, ast_include::registrar, ast_include::rname, ast_include::stuff, ast_include::timing, and VERBOSE_PREFIX_3. Referenced by ast_context_add_include(), handle_context(), and pbx_load_module(). 04172 { 04173 struct ast_include *new_include; 04174 char *c; 04175 struct ast_include *i, *il = NULL; /* include, include_last */ 04176 int length; 04177 char *p; 04178 04179 length = sizeof(struct ast_include); 04180 length += 2 * (strlen(value) + 1); 04181 04182 /* allocate new include structure ... */ 04183 if (!(new_include = malloc(length))) { 04184 ast_log(LOG_ERROR, "Out of memory\n"); 04185 errno = ENOMEM; 04186 return -1; 04187 } 04188 04189 /* ... fill in this structure ... */ 04190 memset(new_include, 0, length); 04191 p = new_include->stuff; 04192 new_include->name = p; 04193 strcpy(new_include->name, value); 04194 p += strlen(value) + 1; 04195 new_include->rname = p; 04196 strcpy(new_include->rname, value); 04197 c = new_include->rname; 04198 /* Strip off timing info */ 04199 while(*c && (*c != '|')) 04200 c++; 04201 /* Process if it's there */ 04202 if (*c) { 04203 new_include->hastime = ast_build_timing(&(new_include->timing), c+1); 04204 *c = '\0'; 04205 } 04206 new_include->next = NULL; 04207 new_include->registrar = registrar; 04208 04209 /* ... try to lock this context ... */ 04210 if (ast_mutex_lock(&con->lock)) { 04211 free(new_include); 04212 errno = EBUSY; 04213 return -1; 04214 } 04215 04216 /* ... go to last include and check if context is already included too... */ 04217 i = con->includes; 04218 while (i) { 04219 if (!strcasecmp(i->name, new_include->name)) { 04220 free(new_include); 04221 ast_mutex_unlock(&con->lock); 04222 errno = EEXIST; 04223 return -1; 04224 } 04225 il = i; 04226 i = i->next; 04227 } 04228 04229 /* ... include new context into context list, unlock, return */ 04230 if (il) 04231 il->next = new_include; 04232 else 04233 con->includes = new_include; 04234 if (option_verbose > 2) 04235 ast_verbose(VERBOSE_PREFIX_3 "Including context '%s' in context '%s'\n", new_include->name, ast_get_context_name(con)); 04236 ast_mutex_unlock(&con->lock); 04237 04238 return 0; 04239 }
|
|
Definition at line 4246 of file pbx.c. References ast_context_add_switch2(), ast_get_context_name(), ast_lock_contexts(), ast_unlock_contexts(), and ast_walk_contexts(). 04247 { 04248 struct ast_context *c; 04249 04250 if (ast_lock_contexts()) { 04251 errno = EBUSY; 04252 return -1; 04253 } 04254 04255 /* walk contexts ... */ 04256 c = ast_walk_contexts(NULL); 04257 while (c) { 04258 /* ... search for the right one ... */ 04259 if (!strcmp(ast_get_context_name(c), context)) { 04260 int ret = ast_context_add_switch2(c, sw, data, eval, registrar); 04261 /* ... unlock contexts list and return */ 04262 ast_unlock_contexts(); 04263 return ret; 04264 } 04265 c = ast_walk_contexts(c); 04266 } 04267 04268 /* we can't find the right context */ 04269 ast_unlock_contexts(); 04270 errno = ENOENT; 04271 return -1; 04272 }
|
|
Definition at line 4281 of file pbx.c. References ast_context::alts, ast_get_context_name(), ast_log(), ast_mutex_lock(), ast_mutex_unlock(), ast_verbose(), ast_sw::data, ast_sw::eval, free, ast_context::lock, LOG_ERROR, malloc, ast_sw::name, ast_sw::next, option_verbose, ast_sw::registrar, ast_sw::stuff, SWITCH_DATA_LENGTH, ast_sw::tmpdata, and VERBOSE_PREFIX_3. Referenced by ast_context_add_switch(), handle_context(), and pbx_load_module(). 04283 { 04284 struct ast_sw *new_sw; 04285 struct ast_sw *i, *il = NULL; /* sw, sw_last */ 04286 int length; 04287 char *p; 04288 04289 length = sizeof(struct ast_sw); 04290 length += strlen(value) + 1; 04291 if (data) 04292 length += strlen(data); 04293 length++; 04294 if (eval) { 04295 /* Create buffer for evaluation of variables */ 04296 length += SWITCH_DATA_LENGTH; 04297 length++; 04298 } 04299 04300 /* allocate new sw structure ... */ 04301 if (!(new_sw = malloc(length))) { 04302 ast_log(LOG_ERROR, "Out of memory\n"); 04303 errno = ENOMEM; 04304 return -1; 04305 } 04306 04307 /* ... fill in this structure ... */ 04308 memset(new_sw, 0, length); 04309 p = new_sw->stuff; 04310 new_sw->name = p; 04311 strcpy(new_sw->name, value); 04312 p += strlen(value) + 1; 04313 new_sw->data = p; 04314 if (data) { 04315 strcpy(new_sw->data, data); 04316 p += strlen(data) + 1; 04317 } else { 04318 strcpy(new_sw->data, ""); 04319 p++; 04320 } 04321 if (eval) 04322 new_sw->tmpdata = p; 04323 new_sw->next = NULL; 04324 new_sw->eval = eval; 04325 new_sw->registrar = registrar; 04326 04327 /* ... try to lock this context ... */ 04328 if (ast_mutex_lock(&con->lock)) { 04329 free(new_sw); 04330 errno = EBUSY; 04331 return -1; 04332 } 04333 04334 /* ... go to last sw and check if context is already swd too... */ 04335 i = con->alts; 04336 while (i) { 04337 if (!strcasecmp(i->name, new_sw->name) && !strcasecmp(i->data, new_sw->data)) { 04338 free(new_sw); 04339 ast_mutex_unlock(&con->lock); 04340 errno = EEXIST; 04341 return -1; 04342 } 04343 il = i; 04344 i = i->next; 04345 } 04346 04347 /* ... sw new context into context list, unlock, return */ 04348 if (il) 04349 il->next = new_sw; 04350 else 04351 con->alts = new_sw; 04352 if (option_verbose > 2) 04353 ast_verbose(VERBOSE_PREFIX_3 "Including switch '%s/%s' in context '%s'\n", new_sw->name, new_sw->data, ast_get_context_name(con)); 04354 ast_mutex_unlock(&con->lock); 04355 04356 return 0; 04357 }
|
|
Definition at line 3640 of file pbx.c. References ast_log(), ast_mutex_init(), ast_mutex_lock(), ast_mutex_unlock(), ast_verbose(), contexts, ast_context::includes, local_contexts, LOG_DEBUG, LOG_ERROR, LOG_WARNING, malloc, ast_context::name, ast_context::next, option_verbose, and VERBOSE_PREFIX_3. Referenced by do_parking_thread(), handle_context(), handle_macro(), load_config(), pbx_load_module(), reload_config(), and set_config(). 03641 { 03642 struct ast_context *tmp, **local_contexts; 03643 int length; 03644 length = sizeof(struct ast_context); 03645 length += strlen(name) + 1; 03646 if (!extcontexts) { 03647 local_contexts = &contexts; 03648 ast_mutex_lock(&conlock); 03649 } else 03650 local_contexts = extcontexts; 03651 03652 tmp = *local_contexts; 03653 while(tmp) { 03654 if (!strcasecmp(tmp->name, name)) { 03655 ast_log(LOG_WARNING, "Tried to register context '%s', already in use\n", name); 03656 if (!extcontexts) 03657 ast_mutex_unlock(&conlock); 03658 return NULL; 03659 } 03660 tmp = tmp->next; 03661 } 03662 tmp = malloc(length); 03663 if (tmp) { 03664 memset(tmp, 0, length); 03665 ast_mutex_init(&tmp->lock); 03666 strcpy(tmp->name, name); 03667 tmp->root = NULL; 03668 tmp->registrar = registrar; 03669 tmp->next = *local_contexts; 03670 tmp->includes = NULL; 03671 tmp->ignorepats = NULL; 03672 *local_contexts = tmp; 03673 if (option_debug) 03674 ast_log(LOG_DEBUG, "Registered context '%s'\n", tmp->name); 03675 if (option_verbose > 2) 03676 ast_verbose( VERBOSE_PREFIX_3 "Registered extension context '%s'\n", tmp->name); 03677 } else 03678 ast_log(LOG_ERROR, "Out of memory\n"); 03679 03680 if (!extcontexts) 03681 ast_mutex_unlock(&conlock); 03682 return tmp; 03683 }
|
|
Definition at line 5387 of file pbx.c. References __ast_context_destroy(). Referenced by ael_reload(), reload(), and unload_module(). 05388 { 05389 __ast_context_destroy(con,registrar); 05390 }
|
|
Definition at line 736 of file pbx.c. References ast_mutex_lock(), ast_mutex_unlock(), contexts, ast_context::name, and ast_context::next. Referenced by ast_context_verify_includes(), ast_ignore_pattern(), do_parking_thread(), load_config(), macro_exec(), park_exec(), reload_config(), and set_config(). 00737 { 00738 struct ast_context *tmp; 00739 ast_mutex_lock(&conlock); 00740 if (name) { 00741 tmp = contexts; 00742 while(tmp) { 00743 if (!strcasecmp(name, tmp->name)) 00744 break; 00745 tmp = tmp->next; 00746 } 00747 } else 00748 tmp = contexts; 00749 ast_mutex_unlock(&conlock); 00750 return tmp; 00751 }
|
|
Definition at line 2725 of file pbx.c. References ast_context_remove_extension2(), ast_get_context_name(), ast_lock_contexts(), ast_unlock_contexts(), and ast_walk_contexts(). Referenced by handle_context_remove_extension(), and register_peer_exten(). 02726 { 02727 struct ast_context *c; 02728 02729 if (ast_lock_contexts()) return -1; 02730 02731 /* walk contexts ... */ 02732 c = ast_walk_contexts(NULL); 02733 while (c) { 02734 /* ... search for the right one ... */ 02735 if (!strcmp(ast_get_context_name(c), context)) { 02736 /* ... remove extension ... */ 02737 int ret = ast_context_remove_extension2(c, extension, priority, 02738 registrar); 02739 /* ... unlock contexts list and return */ 02740 ast_unlock_contexts(); 02741 return ret; 02742 } 02743 c = ast_walk_contexts(c); 02744 } 02745 02746 /* we can't find the right context */ 02747 ast_unlock_contexts(); 02748 return -1; 02749 }
|
|
This functionc locks given context, search for the right extension and fires out all peer in this extensions with given priority. If priority is set to 0, all peers are removed. After that, unlock context and return.
Definition at line 2761 of file pbx.c. References ast_mutex_lock(), ast_mutex_unlock(), ast_remove_hint(), exten, free, ast_context::lock, ast_exten::next, ast_exten::peer, ast_exten::priority, PRIORITY_HINT, ast_exten::registrar, and ast_context::root. Referenced by ast_context_remove_extension(), do_parking_thread(), load_config(), and park_exec(). 02762 { 02763 struct ast_exten *exten, *prev_exten = NULL; 02764 02765 if (ast_mutex_lock(&con->lock)) return -1; 02766 02767 /* go through all extensions in context and search the right one ... */ 02768 exten = con->root; 02769 while (exten) { 02770 02771 /* look for right extension */ 02772 if (!strcmp(exten->exten, extension) && 02773 (!registrar || !strcmp(exten->registrar, registrar))) { 02774 struct ast_exten *peer; 02775 02776 /* should we free all peers in this extension? (priority == 0)? */ 02777 if (priority == 0) { 02778 /* remove this extension from context list */ 02779 if (prev_exten) 02780 prev_exten->next = exten->next; 02781 else 02782 con->root = exten->next; 02783 02784 /* fire out all peers */ 02785 peer = exten; 02786 while (peer) { 02787 exten = peer->peer; 02788 02789 if (!peer->priority==PRIORITY_HINT) 02790 ast_remove_hint(peer); 02791 02792 peer->datad(peer->data); 02793 free(peer); 02794 02795 peer = exten; 02796 } 02797 02798 ast_mutex_unlock(&con->lock); 02799 return 0; 02800 } else { 02801 /* remove only extension with exten->priority == priority */ 02802 struct ast_exten *previous_peer = NULL; 02803 02804 peer = exten; 02805 while (peer) { 02806 /* is this our extension? */ 02807 if (peer->priority == priority && 02808 (!registrar || !strcmp(peer->registrar, registrar) )) { 02809 /* we are first priority extension? */ 02810 if (!previous_peer) { 02811 /* exists previous extension here? */ 02812 if (prev_exten) { 02813 /* yes, so we must change next pointer in 02814 * previous connection to next peer 02815 */ 02816 if (peer->peer) { 02817 prev_exten->next = peer->peer; 02818 peer->peer->next = exten->next; 02819 } else 02820 prev_exten->next = exten->next; 02821 } else { 02822 /* no previous extension, we are first 02823 * extension, so change con->root ... 02824 */ 02825 if (peer->peer) 02826 con->root = peer->peer; 02827 else 02828 con->root = exten->next; 02829 } 02830 } else { 02831 /* we are not first priority in extension */ 02832 previous_peer->peer = peer->peer; 02833 } 02834 02835 /* now, free whole priority extension */ 02836 if (peer->priority==PRIORITY_HINT) 02837 ast_remove_hint(peer); 02838 peer->datad(peer->data); 02839 free(peer); 02840 02841 ast_mutex_unlock(&con->lock); 02842 return 0; 02843 } else { 02844 /* this is not right extension, skip to next peer */ 02845 previous_peer = peer; 02846 peer = peer->peer; 02847 } 02848 } 02849 02850 ast_mutex_unlock(&con->lock); 02851 return -1; 02852 } 02853 } 02854 02855 prev_exten = exten; 02856 exten = exten->next; 02857 } 02858 02859 /* we can't find right extension */ 02860 ast_mutex_unlock(&con->lock); 02861 return -1; 02862 }
|
|
Definition at line 4363 of file pbx.c. References ast_context_remove_ignorepat2(), ast_get_context_name(), ast_lock_contexts(), ast_unlock_contexts(), and ast_walk_contexts(). Referenced by handle_context_remove_ignorepat(). 04364 { 04365 struct ast_context *c; 04366 04367 if (ast_lock_contexts()) { 04368 errno = EBUSY; 04369 return -1; 04370 } 04371 04372 c = ast_walk_contexts(NULL); 04373 while (c) { 04374 if (!strcmp(ast_get_context_name(c), context)) { 04375 int ret = ast_context_remove_ignorepat2(c, ignorepat, registrar); 04376 ast_unlock_contexts(); 04377 return ret; 04378 } 04379 c = ast_walk_contexts(c); 04380 } 04381 04382 ast_unlock_contexts(); 04383 errno = ENOENT; 04384 return -1; 04385 }
|
|
Definition at line 4387 of file pbx.c. References ast_mutex_lock(), ast_mutex_unlock(), free, ast_context::ignorepats, ast_context::lock, ast_ignorepat::next, ast_ignorepat::pattern, and ast_ignorepat::registrar. Referenced by ast_context_remove_ignorepat(). 04388 { 04389 struct ast_ignorepat *ip, *ipl = NULL; 04390 04391 if (ast_mutex_lock(&con->lock)) { 04392 errno = EBUSY; 04393 return -1; 04394 } 04395 04396 ip = con->ignorepats; 04397 while (ip) { 04398 if (!strcmp(ip->pattern, ignorepat) && 04399 (!registrar || (registrar == ip->registrar))) { 04400 if (ipl) { 04401 ipl->next = ip->next; 04402 free(ip); 04403 } else { 04404 con->ignorepats = ip->next; 04405 free(ip); 04406 } 04407 ast_mutex_unlock(&con->lock); 04408 return 0; 04409 } 04410 ipl = ip; ip = ip->next; 04411 } 04412 04413 ast_mutex_unlock(&con->lock); 04414 errno = EINVAL; 04415 return -1; 04416 }
|
|
See add_include Definition at line 2581 of file pbx.c. References ast_context_remove_include2(), ast_get_context_name(), ast_lock_contexts(), ast_unlock_contexts(), and ast_walk_contexts(). Referenced by handle_context_dont_include(). 02582 { 02583 struct ast_context *c; 02584 02585 if (ast_lock_contexts()) return -1; 02586 02587 /* walk contexts and search for the right one ...*/ 02588 c = ast_walk_contexts(NULL); 02589 while (c) { 02590 /* we found one ... */ 02591 if (!strcmp(ast_get_context_name(c), context)) { 02592 int ret; 02593 /* remove include from this context ... */ 02594 ret = ast_context_remove_include2(c, include, registrar); 02595 02596 ast_unlock_contexts(); 02597 02598 /* ... return results */ 02599 return ret; 02600 } 02601 c = ast_walk_contexts(c); 02602 } 02603 02604 /* we can't find the right one context */ 02605 ast_unlock_contexts(); 02606 return -1; 02607 }
|
|
See add_include2 Definition at line 2617 of file pbx.c. References ast_mutex_lock(), ast_mutex_unlock(), free, ast_context::includes, ast_context::lock, ast_include::name, ast_include::next, and ast_include::registrar. Referenced by ast_context_remove_include(). 02618 { 02619 struct ast_include *i, *pi = NULL; 02620 02621 if (ast_mutex_lock(&con->lock)) return -1; 02622 02623 /* walk includes */ 02624 i = con->includes; 02625 while (i) { 02626 /* find our include */ 02627 if (!strcmp(i->name, include) && 02628 (!registrar || !strcmp(i->registrar, registrar))) { 02629 /* remove from list */ 02630 if (pi) 02631 pi->next = i->next; 02632 else 02633 con->includes = i->next; 02634 /* free include and return */ 02635 free(i); 02636 ast_mutex_unlock(&con->lock); 02637 return 0; 02638 } 02639 pi = i; 02640 i = i->next; 02641 } 02642 02643 /* we can't find the right include */ 02644 ast_mutex_unlock(&con->lock); 02645 return -1; 02646 }
|
|
Definition at line 2653 of file pbx.c. References ast_context_remove_switch2(), ast_get_context_name(), ast_lock_contexts(), ast_unlock_contexts(), and ast_walk_contexts(). 02654 { 02655 struct ast_context *c; 02656 02657 if (ast_lock_contexts()) return -1; 02658 02659 /* walk contexts and search for the right one ...*/ 02660 c = ast_walk_contexts(NULL); 02661 while (c) { 02662 /* we found one ... */ 02663 if (!strcmp(ast_get_context_name(c), context)) { 02664 int ret; 02665 /* remove switch from this context ... */ 02666 ret = ast_context_remove_switch2(c, sw, data, registrar); 02667 02668 ast_unlock_contexts(); 02669 02670 /* ... return results */ 02671 return ret; 02672 } 02673 c = ast_walk_contexts(c); 02674 } 02675 02676 /* we can't find the right one context */ 02677 ast_unlock_contexts(); 02678 return -1; 02679 }
|
|
This function locks given context, removes switch, unlock context and return.
Definition at line 2689 of file pbx.c. References ast_context::alts, ast_mutex_lock(), ast_mutex_unlock(), ast_sw::data, free, ast_context::lock, ast_sw::name, ast_sw::next, and ast_sw::registrar. Referenced by ast_context_remove_switch(). 02690 { 02691 struct ast_sw *i, *pi = NULL; 02692 02693 if (ast_mutex_lock(&con->lock)) return -1; 02694 02695 /* walk switchs */ 02696 i = con->alts; 02697 while (i) { 02698 /* find our switch */ 02699 if (!strcmp(i->name, sw) && !strcmp(i->data, data) && 02700 (!registrar || !strcmp(i->registrar, registrar))) { 02701 /* remove from list */ 02702 if (pi) 02703 pi->next = i->next; 02704 else 02705 con->alts = i->next; 02706 /* free switch and return */ 02707 free(i); 02708 ast_mutex_unlock(&con->lock); 02709 return 0; 02710 } 02711 pi = i; 02712 i = i->next; 02713 } 02714 02715 /* we can't find the right switch */ 02716 ast_mutex_unlock(&con->lock); 02717 return -1; 02718 }
|
|
Definition at line 6436 of file pbx.c. References ast_context_find(), ast_get_context_name(), ast_log(), ast_walk_context_includes(), LOG_WARNING, and ast_include::rname. Referenced by pbx_load_module(). 06437 { 06438 struct ast_include *inc; 06439 int res = 0; 06440 06441 for (inc = ast_walk_context_includes(con, NULL); inc; inc = ast_walk_context_includes(con, inc)) 06442 if (!ast_context_find(inc->rname)) { 06443 res = -1; 06444 ast_log(LOG_WARNING, "Context '%s' tries includes nonexistent context '%s'\n", 06445 ast_get_context_name(con), inc->rname); 06446 } 06447 return res; 06448 }
|
|
Definition at line 1267 of file pbx.c. References acf_root, ast_log(), ast_mutex_lock(), LOG_ERROR, ast_custom_function::name, and ast_custom_function::next. Referenced by ast_custom_function_register(), ast_func_read(), ast_func_write(), and handle_show_function(). 01268 { 01269 struct ast_custom_function *acfptr; 01270 01271 /* try to lock functions list ... */ 01272 if (ast_mutex_lock(&acflock)) { 01273 ast_log(LOG_ERROR, "Unable to lock function list\n"); 01274 return NULL; 01275 } 01276 01277 for (acfptr = acf_root; acfptr; acfptr = acfptr->next) { 01278 if (!strcmp(name, acfptr->name)) { 01279 break; 01280 } 01281 } 01282 01283 ast_mutex_unlock(&acflock); 01284 01285 return acfptr; 01286 }
|
|
Definition at line 1323 of file pbx.c. References acf_root, ast_custom_function_find(), ast_log(), ast_mutex_lock(), ast_mutex_unlock(), ast_verbose(), LOG_ERROR, ast_custom_function::name, ast_custom_function::next, option_verbose, and VERBOSE_PREFIX_2. Referenced by load_module(). 01324 { 01325 if (!acf) 01326 return -1; 01327 01328 /* try to lock functions list ... */ 01329 if (ast_mutex_lock(&acflock)) { 01330 ast_log(LOG_ERROR, "Unable to lock function list. Failed registering function %s\n", acf->name); 01331 return -1; 01332 } 01333 01334 if (ast_custom_function_find(acf->name)) { 01335 ast_log(LOG_ERROR, "Function %s already registered.\n", acf->name); 01336 ast_mutex_unlock(&acflock); 01337 return -1; 01338 } 01339 01340 acf->next = acf_root; 01341 acf_root = acf; 01342 01343 ast_mutex_unlock(&acflock); 01344 01345 if (option_verbose > 1) 01346 ast_verbose(VERBOSE_PREFIX_2 "Registered custom function %s\n", acf->name); 01347 01348 return 0; 01349 }
|
|
Definition at line 1288 of file pbx.c. References acf_root, ast_log(), ast_mutex_lock(), LOG_ERROR, and ast_custom_function::next. Referenced by unload_module(). 01289 { 01290 struct ast_custom_function *acfptr, *lastacf = NULL; 01291 int res = -1; 01292 01293 if (!acf) 01294 return -1; 01295 01296 /* try to lock functions list ... */ 01297 if (ast_mutex_lock(&acflock)) { 01298 ast_log(LOG_ERROR, "Unable to lock function list\n"); 01299 return -1; 01300 } 01301 01302 for (acfptr = acf_root; acfptr; acfptr = acfptr->next) { 01303 if (acfptr == acf) { 01304 if (lastacf) { 01305 lastacf->next = acf->next; 01306 } else { 01307 acf_root = acf->next; 01308 } 01309 res = 0; 01310 break; 01311 } 01312 lastacf = acfptr; 01313 } 01314 01315 ast_mutex_unlock(&acflock); 01316 01317 if (!res && (option_verbose > 1)) 01318 ast_verbose(VERBOSE_PREFIX_2 "Unregistered custom function %s\n", acf->name); 01319 01320 return res; 01321 }
|
|
Definition at line 2233 of file pbx.c. References HELPER_EXEC, and pbx_extension_helper(). Referenced by loopback_exec(). 02234 { 02235 return pbx_extension_helper(c, NULL, context, exten, priority, NULL, callerid, HELPER_EXEC); 02236 }
|
|
|
Definition at line 4531 of file pbx.c. References AST_FLAG_IN_AUTOLOOP, ast_strlen_zero(), ast_test_flag, ast_channel::context, ast_channel::exten, and ast_channel::priority. Referenced by __ast_goto_if_exists(), ast_async_goto(), ast_parseable_goto(), builtin_atxfer(), and handle_setpriority(). 04532 { 04533 if (!chan) 04534 return -1; 04535 04536 if (!ast_strlen_zero(context)) 04537 ast_copy_string(chan->context, context, sizeof(chan->context)); 04538 if (!ast_strlen_zero(exten)) 04539 ast_copy_string(chan->exten, exten, sizeof(chan->exten)); 04540 if (priority > -1) { 04541 chan->priority = priority; 04542 /* see flag description in channel.h for explanation */ 04543 if (ast_test_flag(chan, AST_FLAG_IN_AUTOLOOP)) 04544 chan->priority--; 04545 } 04546 04547 return 0; 04548 }
|
|
Definition at line 715 of file pbx.c. References ast_strlen_zero(), EXTENSION_MATCH_CORE, and match(). Referenced by realtime_switch_common(). 00716 { 00717 int match; 00718 /* If "data" is longer, it can'be a subset of pattern unless 00719 pattern is a pattern match */ 00720 if ((strlen(pattern) < strlen(data)) && (pattern[0] != '_')) 00721 return 0; 00722 00723 if ((ast_strlen_zero((char *)data) || !strncasecmp(pattern, data, strlen(data))) && 00724 (!needmore || (strlen(pattern) > strlen(data)))) { 00725 return 1; 00726 } 00727 EXTENSION_MATCH_CORE(data,pattern,match); 00728 /* If there's more or we don't care about more, or if it's a possible early match, 00729 return non-zero; otherwise it's a miss */ 00730 if (!needmore || *pattern || match == 2) { 00731 return match; 00732 } else 00733 return 0; 00734 }
|
|
Definition at line 702 of file pbx.c. References EXTENSION_MATCH_CORE, and match(). Referenced by ast_ignore_pattern(), find_matching_priority(), loopback_canmatch(), loopback_exec(), loopback_exists(), loopback_matchmore(), matchcid(), misdn_cfg_is_msn_valid(), realtime_switch_common(), and show_dialplan_helper(). 00703 { 00704 int match; 00705 /* If they're the same return */ 00706 if (!strcmp(pattern, data)) 00707 return 1; 00708 EXTENSION_MATCH_CORE(data,pattern,match); 00709 /* Must be at the end of both */ 00710 if (*data || (*pattern && (*pattern != '/'))) 00711 match = 0; 00712 return match; 00713 }
|
|
|
|
ast_extension_state: Check extension state for an extension by using hint
Definition at line 1875 of file pbx.c. References ast_extension_state2(), and ast_hint_extension(). Referenced by action_extensionstate(), and handle_request_subscribe(). 01876 { 01877 struct ast_exten *e; 01878 01879 e = ast_hint_extension(c, context, exten); /* Do we have a hint for this extension ? */ 01880 if (!e) 01881 return -1; /* No hint, return -1 */ 01882 01883 return ast_extension_state2(e); /* Check all devices in the hint */ 01884 }
|
|
ast_extension_state2str: Return extension_state as string
Definition at line 1862 of file pbx.c. References extension_states. Referenced by __sip_show_channels(), cb_extensionstate(), handle_request_subscribe(), and handle_show_hints(). 01863 { 01864 int i; 01865 01866 for (i = 0; (i < (sizeof(extension_states) / sizeof(extension_states[0]))); i++) { 01867 if (extension_states[i].extension_state == extension_state) { 01868 return extension_states[i].text; 01869 } 01870 } 01871 return "Unknown"; 01872 }
|
|
ast_extension_state_add: Add watcher for extension states
Definition at line 1929 of file pbx.c. References ast_hint_extension(), ast_mutex_lock(), ast_mutex_unlock(), ast_state_cb::callback, ast_state_cb::data, hints, ast_state_cb::id, list, malloc, ast_imager::next, ast_state_cb::next, and statecbs. Referenced by handle_request_subscribe(), and init_manager(). 01931 { 01932 struct ast_hint *list; 01933 struct ast_state_cb *cblist; 01934 struct ast_exten *e; 01935 01936 /* If there's no context and extension: add callback to statecbs list */ 01937 if (!context && !exten) { 01938 ast_mutex_lock(&hintlock); 01939 01940 cblist = statecbs; 01941 while (cblist) { 01942 if (cblist->callback == callback) { 01943 cblist->data = data; 01944 ast_mutex_unlock(&hintlock); 01945 return 0; 01946 } 01947 cblist = cblist->next; 01948 } 01949 01950 /* Now insert the callback */ 01951 cblist = malloc(sizeof(struct ast_state_cb)); 01952 if (!cblist) { 01953 ast_mutex_unlock(&hintlock); 01954 return -1; 01955 } 01956 memset(cblist, 0, sizeof(struct ast_state_cb)); 01957 cblist->id = 0; 01958 cblist->callback = callback; 01959 cblist->data = data; 01960 01961 cblist->next = statecbs; 01962 statecbs = cblist; 01963 01964 ast_mutex_unlock(&hintlock); 01965 return 0; 01966 } 01967 01968 if (!context || !exten) 01969 return -1; 01970 01971 /* This callback type is for only one hint, so get the hint */ 01972 e = ast_hint_extension(NULL, context, exten); 01973 if (!e) { 01974 return -1; 01975 } 01976 01977 /* Find the hint in the list of hints */ 01978 ast_mutex_lock(&hintlock); 01979 list = hints; 01980 01981 while (list) { 01982 if (list->exten == e) 01983 break; 01984 list = list->next; 01985 } 01986 01987 if (!list) { 01988 /* We have no hint, sorry */ 01989 ast_mutex_unlock(&hintlock); 01990 return -1; 01991 } 01992 01993 /* Now insert the callback in the callback list */ 01994 cblist = malloc(sizeof(struct ast_state_cb)); 01995 if (!cblist) { 01996 ast_mutex_unlock(&hintlock); 01997 return -1; 01998 } 01999 memset(cblist, 0, sizeof(struct ast_state_cb)); 02000 cblist->id = stateid++; /* Unique ID for this callback */ 02001 cblist->callback = callback; /* Pointer to callback routine */ 02002 cblist->data = data; /* Data for the callback */ 02003 02004 cblist->next = list->callbacks; 02005 list->callbacks = cblist; 02006 02007 ast_mutex_unlock(&hintlock); 02008 return cblist->id; 02009 }
|
|
ast_extension_state_del: Remove a watcher from the callback list
Definition at line 2012 of file pbx.c. References ast_mutex_lock(), ast_mutex_unlock(), ast_state_cb::callback, free, hints, ast_state_cb::id, list, ast_imager::next, ast_state_cb::next, and statecbs. Referenced by __sip_destroy(). 02013 { 02014 struct ast_hint *list; 02015 struct ast_state_cb *cblist, *cbprev; 02016 02017 if (!id && !callback) 02018 return -1; 02019 02020 ast_mutex_lock(&hintlock); 02021 02022 /* id is zero is a callback without extension */ 02023 if (!id) { 02024 cbprev = NULL; 02025 cblist = statecbs; 02026 while (cblist) { 02027 if (cblist->callback == callback) { 02028 if (!cbprev) 02029 statecbs = cblist->next; 02030 else 02031 cbprev->next = cblist->next; 02032 02033 free(cblist); 02034 02035 ast_mutex_unlock(&hintlock); 02036 return 0; 02037 } 02038 cbprev = cblist; 02039 cblist = cblist->next; 02040 } 02041 02042 ast_mutex_unlock(&hintlock); 02043 return -1; 02044 } 02045 02046 /* id greater than zero is a callback with extension */ 02047 /* Find the callback based on ID */ 02048 list = hints; 02049 while (list) { 02050 cblist = list->callbacks; 02051 cbprev = NULL; 02052 while (cblist) { 02053 if (cblist->id==id) { 02054 if (!cbprev) 02055 list->callbacks = cblist->next; 02056 else 02057 cbprev->next = cblist->next; 02058 02059 free(cblist); 02060 02061 ast_mutex_unlock(&hintlock); 02062 return 0; 02063 } 02064 cbprev = cblist; 02065 cblist = cblist->next; 02066 } 02067 list = list->next; 02068 } 02069 02070 ast_mutex_unlock(&hintlock); 02071 return -1; 02072 }
|
|
Definition at line 2208 of file pbx.c. References HELPER_FINDLABEL, and pbx_extension_helper(). Referenced by ast_parseable_goto(), and handle_setpriority(). 02209 { 02210 return pbx_extension_helper(c, NULL, context, exten, 0, label, callerid, HELPER_FINDLABEL); 02211 }
|
|
Definition at line 2213 of file pbx.c. References HELPER_FINDLABEL, and pbx_extension_helper(). Referenced by pbx_load_module(). 02214 { 02215 return pbx_extension_helper(c, con, NULL, exten, 0, label, callerid, HELPER_FINDLABEL); 02216 }
|
|
Definition at line 1351 of file pbx.c. References ast_custom_function_find(), ast_log(), ast_strdupa, LOG_ERROR, LOG_WARNING, and ast_custom_function::read. Referenced by handle_getvariable(), and pbx_substitute_variables_helper_full(). 01352 { 01353 char *args = NULL, *function, *p; 01354 char *ret = "0"; 01355 struct ast_custom_function *acfptr; 01356 01357 function = ast_strdupa(in); 01358 if (!function) { 01359 ast_log(LOG_ERROR, "Out of memory\n"); 01360 return ret; 01361 } 01362 if ((args = strchr(function, '('))) { 01363 *args = '\0'; 01364 args++; 01365 if ((p = strrchr(args, ')'))) { 01366 *p = '\0'; 01367 } else { 01368 ast_log(LOG_WARNING, "Can't find trailing parenthesis?\n"); 01369 } 01370 } else { 01371 ast_log(LOG_WARNING, "Function doesn't contain parentheses. Assuming null argument.\n"); 01372 } 01373 01374 if ((acfptr = ast_custom_function_find(function))) { 01375 /* run the custom function */ 01376 if (acfptr->read) { 01377 return acfptr->read(chan, function, args, workspace, len); 01378 } else { 01379 ast_log(LOG_ERROR, "Function %s cannot be read\n", function); 01380 } 01381 } else { 01382 ast_log(LOG_ERROR, "Function %s not registered\n", function); 01383 } 01384 return ret; 01385 }
|
|
Definition at line 1387 of file pbx.c. References ast_custom_function_find(), ast_log(), ast_strdupa, LOG_ERROR, LOG_WARNING, and ast_custom_function::write. Referenced by pbx_builtin_pushvar_helper(), and pbx_builtin_setvar_helper(). 01388 { 01389 char *args = NULL, *function, *p; 01390 struct ast_custom_function *acfptr; 01391 01392 function = ast_strdupa(in); 01393 if (!function) { 01394 ast_log(LOG_ERROR, "Out of memory\n"); 01395 return; 01396 } 01397 if ((args = strchr(function, '('))) { 01398 *args = '\0'; 01399 args++; 01400 if ((p = strrchr(args, ')'))) { 01401 *p = '\0'; 01402 } else { 01403 ast_log(LOG_WARNING, "Can't find trailing parenthesis?\n"); 01404 } 01405 } else { 01406 ast_log(LOG_WARNING, "Function doesn't contain parentheses. Assuming null argument.\n"); 01407 } 01408 01409 if ((acfptr = ast_custom_function_find(function))) { 01410 /* run the custom function */ 01411 if (acfptr->write) { 01412 acfptr->write(chan, function, args, value); 01413 } else { 01414 ast_log(LOG_ERROR, "Function %s is read-only, it cannot be written to\n", function); 01415 } 01416 } else { 01417 ast_log(LOG_ERROR, "Function %s not registered\n", function); 01418 } 01419 }
|
|
Definition at line 6292 of file pbx.c. References ast_context::name. Referenced by ast_add_extension(), ast_context_add_ignorepat(), ast_context_add_include(), ast_context_add_include2(), ast_context_add_switch(), ast_context_add_switch2(), ast_context_remove_extension(), ast_context_remove_ignorepat(), ast_context_remove_include(), ast_context_remove_switch(), ast_context_verify_includes(), complete_context_add_extension(), complete_context_add_ignorepat(), complete_context_add_include(), complete_context_dont_include(), complete_context_remove_extension(), complete_context_remove_ignorepat(), complete_show_dialplan_context(), dundi_precache_full(), find_matching_endwhile(), handle_save_dialplan(), and show_dialplan_helper(). 06293 { 06294 return con ? con->name : NULL; 06295 }
|
|
Definition at line 6325 of file pbx.c. References ast_context::registrar. Referenced by handle_save_dialplan(), and show_dialplan_helper(). 06326 { 06327 return c ? c->registrar : NULL; 06328 }
|
|
Definition at line 6355 of file pbx.c. References ast_exten::app. Referenced by ast_add_hint(), ast_extension_state2(), ast_get_hint(), ast_hint_state_changed(), find_matching_endwhile(), handle_save_dialplan(), handle_show_hints(), and show_dialplan_helper(). 06356 { 06357 return e ? e->app : NULL; 06358 }
|
|
Definition at line 6360 of file pbx.c. References ast_exten::data. Referenced by ast_get_hint(), handle_save_dialplan(), and show_dialplan_helper(). 06361 { 06362 return e ? e->data : NULL; 06363 }
|
|
Definition at line 6350 of file pbx.c. References ast_exten::cidmatch. Referenced by find_matching_priority(), and handle_save_dialplan(). 06351 { 06352 return e ? e->cidmatch : NULL; 06353 }
|
|
Definition at line 6302 of file pbx.c. References exten. Referenced by handle_save_dialplan(), and show_dialplan_helper().
|
|
Definition at line 6345 of file pbx.c. References ast_exten::matchcid. Referenced by find_matching_priority(), and handle_save_dialplan(). 06346 { 06347 return e ? e->matchcid : 0; 06348 }
|
|
Definition at line 6297 of file pbx.c. References exten. Referenced by ast_add_hint(), complete_context_remove_extension(), dundi_precache_full(), find_matching_priority(), handle_save_dialplan(), handle_show_hints(), and show_dialplan_helper().
|
|
Definition at line 6317 of file pbx.c. References exten. Referenced by complete_context_remove_extension(), find_matching_priority(), handle_save_dialplan(), and show_dialplan_helper().
|
|
Definition at line 6330 of file pbx.c. References ast_exten::registrar. Referenced by handle_save_dialplan(), and show_dialplan_helper(). 06331 { 06332 return e ? e->registrar : NULL; 06333 }
|
|
ast_get_hint: Get hint for channel
Definition at line 2184 of file pbx.c. References ast_get_extension_app(), ast_get_extension_app_data(), and ast_hint_extension(). Referenced by action_extensionstate(), get_cid_name(), pbx_retrieve_variable(), and transmit_state_notify(). 02185 { 02186 struct ast_exten *e; 02187 void *tmp; 02188 02189 e = ast_hint_extension(c, context, exten); 02190 if (e) { 02191 if (hint) 02192 ast_copy_string(hint, ast_get_extension_app(e), hintsize); 02193 if (name) { 02194 tmp = ast_get_extension_app_data(e); 02195 if (tmp) 02196 ast_copy_string(name, (char *) tmp, namesize); 02197 } 02198 return -1; 02199 } 02200 return 0; 02201 }
|
|
Definition at line 6312 of file pbx.c. References ast_ignorepat::pattern. Referenced by complete_context_add_ignorepat(), complete_context_remove_ignorepat(), and handle_save_dialplan(). 06313 { 06314 return ip ? ip->pattern : NULL; 06315 }
|
|
Definition at line 6340 of file pbx.c. References ast_ignorepat::registrar. Referenced by handle_save_dialplan(). 06341 { 06342 return ip ? ip->registrar : NULL; 06343 }
|
|
Definition at line 6307 of file pbx.c. References ast_include::name. Referenced by complete_context_add_include(), complete_context_dont_include(), handle_save_dialplan(), and show_dialplan_helper().
|
|
Definition at line 6335 of file pbx.c. References ast_include::registrar. Referenced by handle_save_dialplan(). 06336 { 06337 return i ? i->registrar : NULL; 06338 }
|
|
Definition at line 6370 of file pbx.c. References ast_sw::data. Referenced by handle_save_dialplan(). 06371 { 06372 return sw ? sw->data : NULL; 06373 }
|
|
Definition at line 6365 of file pbx.c. References ast_sw::name. Referenced by handle_save_dialplan(). 06366 { 06367 return sw ? sw->name : NULL; 06368 }
|
|
Definition at line 6375 of file pbx.c. References ast_sw::registrar. Referenced by handle_save_dialplan(). 06376 { 06377 return sw ? sw->registrar : NULL; 06378 }
|
|
Definition at line 6468 of file pbx.c. References __ast_goto_if_exists(). Referenced by aqm_exec(), background_detect_exec(), chanavail_exec(), controlplayback_exec(), dial_exec_full(), do_directory(), enumlookup_exec(), get_exec(), group_check_exec(), hasvoicemail_exec(), leave_voicemail(), lookupblacklist_exec(), md5check_exec(), onedigit_goto(), ospfinished_exec(), osplookup_exec(), ospnext_exec(), play_mailbox_owner(), playback_exec(), pqm_exec(), privacy_exec(), rqm_exec(), sendimage_exec(), sendtext_exec(), sendurl_exec(), sip_getheader(), system_exec_helper(), transfer_exec(), txtcidname_exec(), upqm_exec(), valid_exit(), vm_box_exists(), vm_exec(), and wait_for_answer(). 06468 { 06469 return __ast_goto_if_exists(chan, context, exten, priority, 0); 06470 }
|
|
Definition at line 1886 of file pbx.c. References ast_extension_state2(), ast_get_extension_app(), AST_MAX_EXTENSION, ast_mutex_lock(), ast_state_cb::callback, ast_hint::callbacks, ast_state_cb::data, ast_exten::exten, ast_hint::exten, hints, ast_hint::laststate, ast_context::name, ast_state_cb::next, ast_hint::next, ast_exten::parent, parse(), statecbs, and strsep(). Referenced by do_state_change(). 01887 { 01888 struct ast_hint *hint; 01889 struct ast_state_cb *cblist; 01890 char buf[AST_MAX_EXTENSION]; 01891 char *parse; 01892 char *cur; 01893 int state; 01894 01895 ast_mutex_lock(&hintlock); 01896 01897 for (hint = hints; hint; hint = hint->next) { 01898 ast_copy_string(buf, ast_get_extension_app(hint->exten), sizeof(buf)); 01899 parse = buf; 01900 for (cur = strsep(&parse, "&"); cur; cur = strsep(&parse, "&")) { 01901 if (strcasecmp(cur, device)) 01902 continue; 01903 01904 /* Get device state for this hint */ 01905 state = ast_extension_state2(hint->exten); 01906 01907 if ((state == -1) || (state == hint->laststate)) 01908 continue; 01909 01910 /* Device state changed since last check - notify the watchers */ 01911 01912 /* For general callbacks */ 01913 for (cblist = statecbs; cblist; cblist = cblist->next) 01914 cblist->callback(hint->exten->parent->name, hint->exten->exten, state, cblist->data); 01915 01916 /* For extension callbacks */ 01917 for (cblist = hint->callbacks; cblist; cblist = cblist->next) 01918 cblist->callback(hint->exten->parent->name, hint->exten->exten, state, cblist->data); 01919 01920 hint->laststate = state; 01921 break; 01922 } 01923 } 01924 01925 ast_mutex_unlock(&hintlock); 01926 }
|
|
Definition at line 4483 of file pbx.c. References ast_context_find(), ast_extension_match(), ast_context::ignorepats, ast_ignorepat::next, and ast_ignorepat::pattern. Referenced by ast_app_dtget(), dp_lookup(), dundi_lookup_local(), mgcp_ss(), skinny_ss(), and ss_thread(). 04484 { 04485 struct ast_context *con; 04486 struct ast_ignorepat *pat; 04487 04488 con = ast_context_find(context); 04489 if (con) { 04490 pat = con->ignorepats; 04491 while (pat) { 04492 if (ast_extension_match(pat->pattern, pattern)) 04493 return 1; 04494 pat = pat->next; 04495 } 04496 } 04497 return 0; 04498 }
|
|
Definition at line 6279 of file pbx.c. References ast_mutex_lock(), and ast_context::lock. Referenced by complete_context_add_ignorepat(), complete_context_add_include(), complete_context_dont_include(), complete_context_remove_ignorepat(), dundi_precache_full(), find_matching_endwhile(), handle_save_dialplan(), and show_dialplan_helper(). 06280 { 06281 return ast_mutex_lock(&con->lock); 06282 }
|
|
Locks the context list Returns 0 on success, -1 on error Definition at line 6266 of file pbx.c. References ast_mutex_lock(). Referenced by ast_add_extension(), ast_context_add_ignorepat(), ast_context_add_include(), ast_context_add_switch(), ast_context_remove_extension(), ast_context_remove_ignorepat(), ast_context_remove_include(), ast_context_remove_switch(), complete_context_add_extension(), complete_context_add_ignorepat(), complete_context_add_include(), complete_context_dont_include(), complete_context_remove_extension(), complete_context_remove_ignorepat(), complete_show_dialplan_context(), dundi_precache_full(), find_matching_endwhile(), handle_save_dialplan(), and show_dialplan_helper(). 06267 { 06268 return ast_mutex_lock(&conlock); 06269 }
|
|
Definition at line 2223 of file pbx.c. References HELPER_MATCHMORE, and pbx_extension_helper(). Referenced by ast_app_dtget(), dp_lookup(), dundi_lookup_local(), loopback_matchmore(), mgcp_ss(), skinny_ss(), and ss_thread(). 02224 { 02225 return pbx_extension_helper(c, NULL, context, exten, priority, NULL, callerid, HELPER_MATCHMORE); 02226 }
|
|
Definition at line 3698 of file pbx.c. References AST_LIST_HEAD_INIT, ast_log(), ast_mutex_lock(), ast_hint::callbacks, calloc, ast_exten::exten, ast_hint::exten, store_hint::exten, hints, LOG_WARNING, ast_context::name, ast_hint::next, ast_exten::parent, and ast_context::registrar. Referenced by pbx_load_module(). 03699 { 03700 struct ast_context *tmp, *lasttmp = NULL; 03701 struct store_hints store; 03702 struct store_hint *this; 03703 struct ast_hint *hint; 03704 struct ast_exten *exten; 03705 int length; 03706 struct ast_state_cb *thiscb, *prevcb; 03707 03708 memset(&store, 0, sizeof(store)); 03709 AST_LIST_HEAD_INIT(&store); 03710 03711 /* it is very important that this function hold the hintlock _and_ the conlock 03712 during its operation; not only do we need to ensure that the list of contexts 03713 and extensions does not change, but also that no hint callbacks (watchers) are 03714 added or removed during the merge/delete process 03715 03716 in addition, the locks _must_ be taken in this order, because there are already 03717 other code paths that use this order 03718 */ 03719 ast_mutex_lock(&conlock); 03720 ast_mutex_lock(&hintlock); 03721 03722 /* preserve all watchers for hints associated with this registrar */ 03723 for (hint = hints; hint; hint = hint->next) { 03724 if (hint->callbacks && !strcmp(registrar, hint->exten->parent->registrar)) { 03725 length = strlen(hint->exten->exten) + strlen(hint->exten->parent->name) + 2 + sizeof(*this); 03726 this = calloc(1, length); 03727 if (!this) { 03728 ast_log(LOG_WARNING, "Could not allocate memory to preserve hint\n"); 03729 continue; 03730 } 03731 this->callbacks = hint->callbacks; 03732 hint->callbacks = NULL; 03733 this->laststate = hint->laststate; 03734 this->context = this->data; 03735 strcpy(this->data, hint->exten->parent->name); 03736 this->exten = this->data + strlen(this->context) + 1; 03737 strcpy(this->exten, hint->exten->exten); 03738 AST_LIST_INSERT_HEAD(&store, this, list); 03739 } 03740 } 03741 03742 tmp = *extcontexts; 03743 if (registrar) { 03744 __ast_context_destroy(NULL,registrar); 03745 while (tmp) { 03746 lasttmp = tmp; 03747 tmp = tmp->next; 03748 } 03749 } else { 03750 while (tmp) { 03751 __ast_context_destroy(tmp,tmp->registrar); 03752 lasttmp = tmp; 03753 tmp = tmp->next; 03754 } 03755 } 03756 if (lasttmp) { 03757 lasttmp->next = contexts; 03758 contexts = *extcontexts; 03759 *extcontexts = NULL; 03760 } else 03761 ast_log(LOG_WARNING, "Requested contexts didn't get merged\n"); 03762 03763 /* restore the watchers for hints that can be found; notify those that 03764 cannot be restored 03765 */ 03766 while ((this = AST_LIST_REMOVE_HEAD(&store, list))) { 03767 exten = ast_hint_extension(NULL, this->context, this->exten); 03768 /* Find the hint in the list of hints */ 03769 for (hint = hints; hint; hint = hint->next) { 03770 if (hint->exten == exten) 03771 break; 03772 } 03773 if (!exten || !hint) { 03774 /* this hint has been removed, notify the watchers */ 03775 prevcb = NULL; 03776 thiscb = this->callbacks; 03777 while (thiscb) { 03778 prevcb = thiscb; 03779 thiscb = thiscb->next; 03780 prevcb->callback(this->context, this->exten, AST_EXTENSION_REMOVED, prevcb->data); 03781 free(prevcb); 03782 } 03783 } else { 03784 thiscb = this->callbacks; 03785 while (thiscb->next) 03786 thiscb = thiscb->next; 03787 thiscb->next = hint->callbacks; 03788 hint->callbacks = this->callbacks; 03789 hint->laststate = this->laststate; 03790 } 03791 free(this); 03792 } 03793 03794 ast_mutex_unlock(&hintlock); 03795 ast_mutex_unlock(&conlock); 03796 03797 return; 03798 }
|
|
Definition at line 6476 of file pbx.c. References ast_cdr_update(), ast_explicit_goto(), ast_findlabel_extension(), ast_log(), ast_strdupa, ast_strlen_zero(), ast_channel::cid, ast_callerid::cid_num, ast_channel::context, ast_channel::exten, exten, LOG_WARNING, ast_channel::priority, s, and strsep(). Referenced by check_goto_on_transfer(), gosub_exec(), ivr_dispatch(), pbx_builtin_goto(), random_exec(), and return_exec(). 06477 { 06478 char *s; 06479 char *exten, *pri, *context; 06480 char *stringp=NULL; 06481 int ipri; 06482 int mode = 0; 06483 06484 if (ast_strlen_zero(goto_string)) { 06485 ast_log(LOG_WARNING, "Goto requires an argument (optional context|optional extension|priority)\n"); 06486 return -1; 06487 } 06488 s = ast_strdupa(goto_string); 06489 stringp=s; 06490 context = strsep(&stringp, "|"); 06491 exten = strsep(&stringp, "|"); 06492 if (!exten) { 06493 /* Only a priority in this one */ 06494 pri = context; 06495 exten = NULL; 06496 context = NULL; 06497 } else { 06498 pri = strsep(&stringp, "|"); 06499 if (!pri) { 06500 /* Only an extension and priority in this one */ 06501 pri = exten; 06502 exten = context; 06503 context = NULL; 06504 } 06505 } 06506 if (*pri == '+') { 06507 mode = 1; 06508 pri++; 06509 } else if (*pri == '-') { 06510 mode = -1; 06511 pri++; 06512 } 06513 if (sscanf(pri, "%d", &ipri) != 1) { 06514 if ((ipri = ast_findlabel_extension(chan, context ? context : chan->context, (exten && strcasecmp(exten, "BYEXTENSION")) ? exten : chan->exten, 06515 pri, chan->cid.cid_num)) < 1) { 06516 ast_log(LOG_WARNING, "Priority '%s' must be a number > 0, or valid label\n", pri); 06517 return -1; 06518 } else 06519 mode = 0; 06520 } 06521 /* At this point we have a priority and maybe an extension and a context */ 06522 06523 if (exten && !strcasecmp(exten, "BYEXTENSION")) 06524 exten = NULL; 06525 06526 if (mode) 06527 ipri = chan->priority + (ipri * mode); 06528 06529 ast_explicit_goto(chan, context, exten, ipri); 06530 ast_cdr_update(chan); 06531 return 0; 06532 06533 }
|
|
Definition at line 5159 of file pbx.c. References __ast_request_and_dial(), async_stat::app, async_stat::appdata, ast_cdr_alloc(), ast_cdr_disposition(), ast_cdr_failed(), ast_cdr_init(), ast_cdr_setaccount(), ast_cdr_start(), ast_hangup(), ast_log(), ast_mutex_lock(), ast_mutex_unlock(), ast_pbx_outgoing_cdr_failed(), ast_pbx_run_app(), ast_pthread_create, ast_set_variables(), AST_STATE_UP, ast_strlen_zero(), ast_variables_destroy(), ast_verbose(), async_wait(), ast_channel::cdr, async_stat::chan, free, LOG_ERROR, LOG_WARNING, malloc, ast_channel::name, option_verbose, async_stat::p, ast_channel::pbx, async_stat::timeout, outgoing_helper::vars, and VERBOSE_PREFIX_4. Referenced by action_originate(), attempt_thread(), fast_originate(), and page_thread(). 05160 { 05161 struct ast_channel *chan; 05162 struct async_stat *as; 05163 struct app_tmp *tmp; 05164 int res = -1, cdr_res = -1; 05165 struct outgoing_helper oh; 05166 pthread_attr_t attr; 05167 05168 memset(&oh, 0, sizeof(oh)); 05169 oh.vars = vars; 05170 oh.account = account; 05171 05172 if (locked_channel) 05173 *locked_channel = NULL; 05174 if (ast_strlen_zero(app)) { 05175 res = -1; 05176 goto outgoing_app_cleanup; 05177 } 05178 if (sync) { 05179 chan = __ast_request_and_dial(type, format, data, timeout, reason, cid_num, cid_name, &oh); 05180 if (chan) { 05181 if (chan->cdr) { /* check if the channel already has a cdr record, if not give it one */ 05182 ast_log(LOG_WARNING, "%s already has a call record??\n", chan->name); 05183 } else { 05184 chan->cdr = ast_cdr_alloc(); /* allocate a cdr for the channel */ 05185 if(!chan->cdr) { 05186 /* allocation of the cdr failed */ 05187 ast_log(LOG_WARNING, "Unable to create Call Detail Record\n"); 05188 free(chan->pbx); 05189 res = -1; 05190 goto outgoing_app_cleanup; 05191 } 05192 /* allocation of the cdr was successful */ 05193 ast_cdr_init(chan->cdr, chan); /* initilize our channel's cdr */ 05194 ast_cdr_start(chan->cdr); 05195 } 05196 ast_set_variables(chan, vars); 05197 if (account) 05198 ast_cdr_setaccount(chan, account); 05199 if (chan->_state == AST_STATE_UP) { 05200 res = 0; 05201 if (option_verbose > 3) 05202 ast_verbose(VERBOSE_PREFIX_4 "Channel %s was answered.\n", chan->name); 05203 tmp = malloc(sizeof(struct app_tmp)); 05204 if (tmp) { 05205 memset(tmp, 0, sizeof(struct app_tmp)); 05206 ast_copy_string(tmp->app, app, sizeof(tmp->app)); 05207 if (appdata) 05208 ast_copy_string(tmp->data, appdata, sizeof(tmp->data)); 05209 tmp->chan = chan; 05210 if (sync > 1) { 05211 if (locked_channel) 05212 ast_mutex_unlock(&chan->lock); 05213 ast_pbx_run_app(tmp); 05214 } else { 05215 pthread_attr_init(&attr); 05216 pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); 05217 if (locked_channel) 05218 ast_mutex_lock(&chan->lock); 05219 if (ast_pthread_create(&tmp->t, &attr, ast_pbx_run_app, tmp)) { 05220 ast_log(LOG_WARNING, "Unable to spawn execute thread on %s: %s\n", chan->name, strerror(errno)); 05221 free(tmp); 05222 if (locked_channel) 05223 ast_mutex_unlock(&chan->lock); 05224 ast_hangup(chan); 05225 res = -1; 05226 } else { 05227 if (locked_channel) 05228 *locked_channel = chan; 05229 } 05230 } 05231 } else { 05232 ast_log(LOG_ERROR, "Out of memory :(\n"); 05233 res = -1; 05234 } 05235 } else { 05236 if (option_verbose > 3) 05237 ast_verbose(VERBOSE_PREFIX_4 "Channel %s was never answered.\n", chan->name); 05238 if (chan->cdr) { /* update the cdr */ 05239 /* here we update the status of the call, which sould be busy. 05240 * if that fails then we set the status to failed */ 05241 if (ast_cdr_disposition(chan->cdr, chan->hangupcause)) 05242 ast_cdr_failed(chan->cdr); 05243 } 05244 ast_hangup(chan); 05245 } 05246 } 05247 05248 if (res < 0) { /* the call failed for some reason */ 05249 if (*reason == 0) { /* if the call failed (not busy or no answer) 05250 * update the cdr with the failed message */ 05251 cdr_res = ast_pbx_outgoing_cdr_failed(); 05252 if (cdr_res != 0) { 05253 res = cdr_res; 05254 goto outgoing_app_cleanup; 05255 } 05256 } 05257 } 05258 05259 } else { 05260 as = malloc(sizeof(struct async_stat)); 05261 if (!as) { 05262 res = -1; 05263 goto outgoing_app_cleanup; 05264 } 05265 memset(as, 0, sizeof(struct async_stat)); 05266 chan = __ast_request_and_dial(type, format, data, timeout, reason, cid_num, cid_name, &oh); 05267 if (!chan) { 05268 free(as); 05269 res = -1; 05270 goto outgoing_app_cleanup; 05271 } 05272 as->chan = chan; 05273 ast_copy_string(as->app, app, sizeof(as->app)); 05274 if (appdata) 05275 ast_copy_string(as->appdata, appdata, sizeof(as->appdata)); 05276 as->timeout = timeout; 05277 ast_set_variables(chan, vars); 05278 if (account) 05279 ast_cdr_setaccount(chan, account); 05280 /* Start a new thread, and get something handling this channel. */ 05281 pthread_attr_init(&attr); 05282 pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); 05283 if (locked_channel) 05284 ast_mutex_lock(&chan->lock); 05285 if (ast_pthread_create(&as->p, &attr, async_wait, as)) { 05286 ast_log(LOG_WARNING, "Failed to start async wait\n"); 05287 free(as); 05288 if (locked_channel) 05289 ast_mutex_unlock(&chan->lock); 05290 ast_hangup(chan); 05291 res = -1; 05292 goto outgoing_app_cleanup; 05293 } else { 05294 if (locked_channel) 05295 *locked_channel = chan; 05296 } 05297 res = 0; 05298 } 05299 outgoing_app_cleanup: 05300 ast_variables_destroy(vars); 05301 return res; 05302 }
|
|
Definition at line 4985 of file pbx.c. References __ast_request_and_dial(), ast_channel::_state, ast_cdr_alloc(), ast_cdr_disposition(), ast_cdr_failed(), ast_cdr_init(), ast_cdr_setaccount(), ast_cdr_start(), ast_channel_alloc(), ast_exists_extension(), ast_hangup(), ast_log(), ast_mutex_lock(), ast_mutex_unlock(), ast_pbx_outgoing_cdr_failed(), ast_pbx_run(), ast_pbx_start(), ast_pthread_create, ast_request_and_dial(), ast_set_variables(), AST_STATE_UP, ast_strlen_zero(), ast_variables_destroy(), ast_verbose(), async_wait(), ast_channel::cdr, async_stat::chan, async_stat::context, ast_channel::context, async_stat::exten, ast_channel::exten, free, ast_channel::hangupcause, LOAD_OH, ast_channel::lock, LOG_ERROR, LOG_WARNING, malloc, ast_channel::name, option_verbose, async_stat::p, ast_channel::pbx, async_stat::priority, ast_channel::priority, async_stat::timeout, outgoing_helper::vars, and VERBOSE_PREFIX_4. Referenced by action_originate(), attempt_thread(), and fast_originate(). 04986 { 04987 struct ast_channel *chan; 04988 struct async_stat *as; 04989 int res = -1, cdr_res = -1; 04990 struct outgoing_helper oh; 04991 pthread_attr_t attr; 04992 04993 if (sync) { 04994 LOAD_OH(oh); 04995 chan = __ast_request_and_dial(type, format, data, timeout, reason, cid_num, cid_name, &oh); 04996 if (channel) { 04997 *channel = chan; 04998 if (chan) 04999 ast_mutex_lock(&chan->lock); 05000 } 05001 if (chan) { 05002 if (chan->cdr) { /* check if the channel already has a cdr record, if not give it one */ 05003 ast_log(LOG_WARNING, "%s already has a call record??\n", chan->name); 05004 } else { 05005 chan->cdr = ast_cdr_alloc(); /* allocate a cdr for the channel */ 05006 if (!chan->cdr) { 05007 /* allocation of the cdr failed */ 05008 ast_log(LOG_WARNING, "Unable to create Call Detail Record\n"); 05009 free(chan->pbx); 05010 res = -1; 05011 goto outgoing_exten_cleanup; 05012 } 05013 /* allocation of the cdr was successful */ 05014 ast_cdr_init(chan->cdr, chan); /* initilize our channel's cdr */ 05015 ast_cdr_start(chan->cdr); 05016 } 05017 if (chan->_state == AST_STATE_UP) { 05018 res = 0; 05019 if (option_verbose > 3) 05020 ast_verbose(VERBOSE_PREFIX_4 "Channel %s was answered.\n", chan->name); 05021 05022 if (sync > 1) { 05023 if (channel) 05024 ast_mutex_unlock(&chan->lock); 05025 if (ast_pbx_run(chan)) { 05026 ast_log(LOG_ERROR, "Unable to run PBX on %s\n", chan->name); 05027 if (channel) 05028 *channel = NULL; 05029 ast_hangup(chan); 05030 res = -1; 05031 } 05032 } else { 05033 if (ast_pbx_start(chan)) { 05034 ast_log(LOG_ERROR, "Unable to start PBX on %s\n", chan->name); 05035 if (channel) { 05036 *channel = NULL; 05037 ast_mutex_unlock(&chan->lock); 05038 } 05039 ast_hangup(chan); 05040 res = -1; 05041 } 05042 } 05043 } else { 05044 if (option_verbose > 3) 05045 ast_verbose(VERBOSE_PREFIX_4 "Channel %s was never answered.\n", chan->name); 05046 05047 if(chan->cdr) { /* update the cdr */ 05048 /* here we update the status of the call, which sould be busy. 05049 * if that fails then we set the status to failed */ 05050 if (ast_cdr_disposition(chan->cdr, chan->hangupcause)) 05051 ast_cdr_failed(chan->cdr); 05052 } 05053 05054 if (channel) { 05055 *channel = NULL; 05056 ast_mutex_unlock(&chan->lock); 05057 } 05058 ast_hangup(chan); 05059 } 05060 } 05061 05062 if (res < 0) { /* the call failed for some reason */ 05063 if (*reason == 0) { /* if the call failed (not busy or no answer) 05064 * update the cdr with the failed message */ 05065 cdr_res = ast_pbx_outgoing_cdr_failed(); 05066 if (cdr_res != 0) { 05067 res = cdr_res; 05068 goto outgoing_exten_cleanup; 05069 } 05070 } 05071 05072 /* create a fake channel and execute the "failed" extension (if it exists) within the requested context */ 05073 /* check if "failed" exists */ 05074 if (ast_exists_extension(chan, context, "failed", 1, NULL)) { 05075 chan = ast_channel_alloc(0); 05076 if (chan) { 05077 ast_copy_string(chan->name, "OutgoingSpoolFailed", sizeof(chan->name)); 05078 if (!ast_strlen_zero(context)) 05079 ast_copy_string(chan->context, context, sizeof(chan->context)); 05080 ast_copy_string(chan->exten, "failed", sizeof(chan->exten)); 05081 chan->priority = 1; 05082 ast_set_variables(chan, vars); 05083 if (account) 05084 ast_cdr_setaccount(chan, account); 05085 ast_pbx_run(chan); 05086 } else 05087 ast_log(LOG_WARNING, "Can't allocate the channel structure, skipping execution of extension 'failed'\n"); 05088 } 05089 } 05090 } else { 05091 as = malloc(sizeof(struct async_stat)); 05092 if (!as) { 05093 res = -1; 05094 goto outgoing_exten_cleanup; 05095 } 05096 memset(as, 0, sizeof(struct async_stat)); 05097 chan = ast_request_and_dial(type, format, data, timeout, reason, cid_num, cid_name); 05098 if (channel) { 05099 *channel = chan; 05100 if (chan) 05101 ast_mutex_lock(&chan->lock); 05102 } 05103 if (!chan) { 05104 free(as); 05105 res = -1; 05106 goto outgoing_exten_cleanup; 05107 } 05108 as->chan = chan; 05109 ast_copy_string(as->context, context, sizeof(as->context)); 05110 ast_copy_string(as->exten, exten, sizeof(as->exten)); 05111 as->priority = priority; 05112 as->timeout = timeout; 05113 ast_set_variables(chan, vars); 05114 if (account) 05115 ast_cdr_setaccount(chan, account); 05116 pthread_attr_init(&attr); 05117 pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); 05118 if (ast_pthread_create(&as->p, &attr, async_wait, as)) { 05119 ast_log(LOG_WARNING, "Failed to start async wait\n"); 05120 free(as); 05121 if (channel) { 05122 *channel = NULL; 05123 ast_mutex_unlock(&chan->lock); 05124 } 05125 ast_hangup(chan); 05126 res = -1; 05127 goto outgoing_exten_cleanup; 05128 } 05129 res = 0; 05130 } 05131 outgoing_exten_cleanup: 05132 ast_variables_destroy(vars); 05133 return res; 05134 }
|
|
Definition at line 2549 of file pbx.c. References __ast_pbx_run(), AST_PBX_CALL_LIMIT, AST_PBX_SUCCESS, decrease_call_count(), and increase_call_count(). Referenced by ast_pbx_outgoing_exten(), async_wait(), mgcp_ss(), skinny_ss(), and ss_thread(). 02550 { 02551 enum ast_pbx_result res = AST_PBX_SUCCESS; 02552 02553 if (increase_call_count(c)) 02554 return AST_PBX_CALL_LIMIT; 02555 02556 res = __ast_pbx_run(c); 02557 decrease_call_count(); 02558 02559 return res; 02560 }
|
|
Definition at line 2525 of file pbx.c. References ast_log(), AST_PBX_CALL_LIMIT, AST_PBX_FAILED, AST_PBX_SUCCESS, ast_pthread_create, increase_call_count(), LOG_WARNING, pbx_thread(), and t. Referenced by __oh323_new(), alsa_new(), ast_async_goto(), ast_iax2_new(), ast_modem_new(), ast_pbx_outgoing_exten(), check_goto_on_transfer(), do_parking_thread(), handle_request_invite(), local_call(), mgcp_new(), nbs_new(), oss_new(), pbx_start_chan(), phone_new(), rpt_call(), sip_new(), skinny_new(), vpb_new(), and zt_new(). 02526 { 02527 pthread_t t; 02528 pthread_attr_t attr; 02529 02530 if (!c) { 02531 ast_log(LOG_WARNING, "Asked to start thread on NULL channel?\n"); 02532 return AST_PBX_FAILED; 02533 } 02534 02535 if (increase_call_count(c)) 02536 return AST_PBX_CALL_LIMIT; 02537 02538 /* Start a new thread, and get something handling this channel. */ 02539 pthread_attr_init(&attr); 02540 pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); 02541 if (ast_pthread_create(&t, &attr, pbx_thread, c)) { 02542 ast_log(LOG_WARNING, "Failed to create new channel thread\n"); 02543 return AST_PBX_FAILED; 02544 } 02545 02546 return AST_PBX_SUCCESS; 02547 }
|
|
Dynamically register a new dial plan application.
Definition at line 2866 of file pbx.c. References apps, ast_log(), ast_mutex_lock(), ast_mutex_unlock(), ast_verbose(), COLOR_BRCYAN, LOG_ERROR, LOG_WARNING, malloc, ast_app::name, ast_app::next, option_verbose, term_color(), and VERBOSE_PREFIX_2. Referenced by load_module(), and load_pbx(). 02867 { 02868 struct ast_app *tmp, *prev, *cur; 02869 char tmps[80]; 02870 int length; 02871 length = sizeof(struct ast_app); 02872 length += strlen(app) + 1; 02873 if (ast_mutex_lock(&applock)) { 02874 ast_log(LOG_ERROR, "Unable to lock application list\n"); 02875 return -1; 02876 } 02877 tmp = apps; 02878 while(tmp) { 02879 if (!strcasecmp(app, tmp->name)) { 02880 ast_log(LOG_WARNING, "Already have an application '%s'\n", app); 02881 ast_mutex_unlock(&applock); 02882 return -1; 02883 } 02884 tmp = tmp->next; 02885 } 02886 tmp = malloc(length); 02887 if (tmp) { 02888 memset(tmp, 0, length); 02889 strcpy(tmp->name, app); 02890 tmp->execute = execute; 02891 tmp->synopsis = synopsis; 02892 tmp->description = description; 02893 /* Store in alphabetical order */ 02894 cur = apps; 02895 prev = NULL; 02896 while(cur) { 02897 if (strcasecmp(tmp->name, cur->name) < 0) 02898 break; 02899 prev = cur; 02900 cur = cur->next; 02901 } 02902 if (prev) { 02903 tmp->next = prev->next; 02904 prev->next = tmp; 02905 } else { 02906 tmp->next = apps; 02907 apps = tmp; 02908 } 02909 } else { 02910 ast_log(LOG_ERROR, "Out of memory\n"); 02911 ast_mutex_unlock(&applock); 02912 return -1; 02913 } 02914 if (option_verbose > 1) 02915 ast_verbose( VERBOSE_PREFIX_2 "Registered application '%s'\n", term_color(tmps, tmp->name, COLOR_BRCYAN, 0, sizeof(tmps))); 02916 ast_mutex_unlock(&applock); 02917 return 0; 02918 }
|
|
Definition at line 2920 of file pbx.c. References ast_log(), ast_mutex_lock(), ast_mutex_unlock(), LOG_ERROR, LOG_WARNING, ast_switch::name, ast_switch::next, and switches. Referenced by load_module(). 02921 { 02922 struct ast_switch *tmp, *prev=NULL; 02923 if (ast_mutex_lock(&switchlock)) { 02924 ast_log(LOG_ERROR, "Unable to lock switch lock\n"); 02925 return -1; 02926 } 02927 tmp = switches; 02928 while(tmp) { 02929 if (!strcasecmp(tmp->name, sw->name)) 02930 break; 02931 prev = tmp; 02932 tmp = tmp->next; 02933 } 02934 if (tmp) { 02935 ast_mutex_unlock(&switchlock); 02936 ast_log(LOG_WARNING, "Switch '%s' already found\n", sw->name); 02937 return -1; 02938 } 02939 sw->next = NULL; 02940 if (prev) 02941 prev->next = sw; 02942 else 02943 switches = sw; 02944 ast_mutex_unlock(&switchlock); 02945 return 0; 02946 }
|
|
Definition at line 2228 of file pbx.c. References HELPER_SPAWN, and pbx_extension_helper(). Referenced by __ast_pbx_run(), loopback_exec(), and macro_exec(). 02229 { 02230 return pbx_extension_helper(c, NULL, context, exten, priority, NULL, callerid, HELPER_SPAWN); 02231 }
|
|
Definition at line 6284 of file pbx.c. References ast_mutex_unlock(), and ast_context::lock. Referenced by complete_context_add_ignorepat(), complete_context_add_include(), complete_context_dont_include(), complete_context_remove_ignorepat(), dundi_precache_full(), find_matching_endwhile(), and handle_save_dialplan(). 06285 { 06286 return ast_mutex_unlock(&con->lock); 06287 }
|
|
Returns 0 on success, -1 on failure Definition at line 6271 of file pbx.c. References ast_mutex_unlock(). Referenced by ast_add_extension(), ast_context_add_ignorepat(), ast_context_add_include(), ast_context_add_switch(), ast_context_remove_extension(), ast_context_remove_ignorepat(), ast_context_remove_include(), ast_context_remove_switch(), complete_context_add_extension(), complete_context_add_ignorepat(), complete_context_add_include(), complete_context_dont_include(), complete_context_remove_extension(), complete_context_remove_ignorepat(), complete_show_dialplan_context(), dundi_precache_full(), and handle_save_dialplan(). 06272 { 06273 return ast_mutex_unlock(&conlock); 06274 }
|
|
Definition at line 3613 of file pbx.c. References apps, ast_log(), ast_mutex_lock(), ast_mutex_unlock(), ast_verbose(), free, LOG_ERROR, ast_app::name, ast_app::next, option_verbose, and VERBOSE_PREFIX_2. Referenced by __unload_module(), and unload_module(). 03614 { 03615 struct ast_app *tmp, *tmpl = NULL; 03616 if (ast_mutex_lock(&applock)) { 03617 ast_log(LOG_ERROR, "Unable to lock application list\n"); 03618 return -1; 03619 } 03620 tmp = apps; 03621 while(tmp) { 03622 if (!strcasecmp(app, tmp->name)) { 03623 if (tmpl) 03624 tmpl->next = tmp->next; 03625 else 03626 apps = tmp->next; 03627 if (option_verbose > 1) 03628 ast_verbose( VERBOSE_PREFIX_2 "Unregistered application '%s'\n", tmp->name); 03629 free(tmp); 03630 ast_mutex_unlock(&applock); 03631 return 0; 03632 } 03633 tmpl = tmp; 03634 tmp = tmp->next; 03635 } 03636 ast_mutex_unlock(&applock); 03637 return -1; 03638 }
|
|
Definition at line 2948 of file pbx.c. References ast_log(), ast_mutex_lock(), ast_mutex_unlock(), LOG_ERROR, ast_switch::next, and switches. Referenced by __unload_module(), and unload_module(). 02949 { 02950 struct ast_switch *tmp, *prev=NULL; 02951 if (ast_mutex_lock(&switchlock)) { 02952 ast_log(LOG_ERROR, "Unable to lock switch lock\n"); 02953 return; 02954 } 02955 tmp = switches; 02956 while(tmp) { 02957 if (tmp == sw) { 02958 if (prev) 02959 prev->next = tmp->next; 02960 else 02961 switches = tmp->next; 02962 tmp->next = NULL; 02963 break; 02964 } 02965 prev = tmp; 02966 tmp = tmp->next; 02967 } 02968 ast_mutex_unlock(&switchlock); 02969 }
|
|
Definition at line 6391 of file pbx.c. References exten, and ast_context::root. Referenced by complete_context_remove_extension(), dundi_precache_full(), find_matching_priority(), handle_save_dialplan(), and show_dialplan_helper(). 06393 { 06394 if (!exten) 06395 return con ? con->root : NULL; 06396 else 06397 return exten->next; 06398 }
|
|
Definition at line 6427 of file pbx.c. References ast_context::ignorepats, and ast_ignorepat::next. Referenced by complete_context_add_ignorepat(), complete_context_remove_ignorepat(), and handle_save_dialplan(). 06429 { 06430 if (!ip) 06431 return con ? con->ignorepats : NULL; 06432 else 06433 return ip->next; 06434 }
|
|
Definition at line 6418 of file pbx.c. References ast_context::includes, and ast_include::next. Referenced by ast_context_verify_includes(), complete_context_add_include(), complete_context_dont_include(), handle_save_dialplan(), and show_dialplan_helper(). 06420 { 06421 if (!inc) 06422 return con ? con->includes : NULL; 06423 else 06424 return inc->next; 06425 }
|
|
Definition at line 6400 of file pbx.c. References ast_context::alts, and ast_sw::next. Referenced by handle_save_dialplan(). 06402 { 06403 if (!sw) 06404 return con ? con->alts : NULL; 06405 else 06406 return sw->next; 06407 }
|
|
Definition at line 6383 of file pbx.c. References contexts, and ast_context::next. Referenced by ast_add_extension(), ast_context_add_ignorepat(), ast_context_add_include(), ast_context_add_switch(), ast_context_remove_extension(), ast_context_remove_ignorepat(), ast_context_remove_include(), ast_context_remove_switch(), complete_context_add_extension(), complete_context_add_ignorepat(), complete_context_add_include(), complete_context_dont_include(), complete_context_remove_extension(), complete_context_remove_ignorepat(), complete_show_dialplan_context(), dundi_precache_full(), find_matching_endwhile(), handle_save_dialplan(), pbx_load_module(), and show_dialplan_helper().
|
|
Definition at line 6409 of file pbx.c. References exten, and ast_exten::priority. Referenced by complete_context_remove_extension(), find_matching_priority(), handle_save_dialplan(), and show_dialplan_helper().
|
|
Definition at line 6128 of file pbx.c. References AST_LIST_REMOVE_HEAD, ast_mutex_lock(), ast_mutex_unlock(), and ast_var_delete(). Referenced by reload(). 06129 { 06130 struct ast_var_t *vardata; 06131 06132 ast_mutex_lock(&globalslock); 06133 while ((vardata = AST_LIST_REMOVE_HEAD(&globals, entries))) 06134 ast_var_delete(vardata); 06135 ast_mutex_unlock(&globalslock); 06136 }
|
|
Definition at line 5923 of file pbx.c. References AST_LIST_TRAVERSE, ast_mutex_lock(), ast_mutex_unlock(), ast_var_name(), ast_var_value(), and ast_channel::varshead. Referenced by __login_exec(), action_getvar(), agentmonitoroutgoing_exec(), ast_app_group_get_count(), ast_app_group_match_get_count(), ast_bridge_call(), ast_feature_interpret(), ast_monitor_stop(), ast_osp_lookup(), builtin_atxfer(), builtin_automonitor(), builtin_blindtransfer(), check_goto_on_transfer(), conf_exec(), conf_run(), dial_exec_full(), do_chanreads(), dundi_exec(), dundi_helper(), get_index(), get_refer_info(), group_check_exec(), group_count_exec(), group_count_function_read(), group_function_read(), iax2_exec(), import_ch(), leave_voicemail(), macro_exec(), misdn_answer(), misdn_hangup(), oh323_hangup(), ospfinished_exec(), ospnext_exec(), queue_exec(), retrydial_exec(), return_exec(), sip_addheader(), try_suggested_sip_codec(), wait_for_answer(), zt_call(), and zt_hangup(). 05924 { 05925 struct ast_var_t *variables; 05926 char *ret = NULL; 05927 int i; 05928 struct varshead *places[2] = { NULL, &globals }; 05929 05930 if (!name) 05931 return NULL; 05932 if (chan) 05933 places[0] = &chan->varshead; 05934 05935 for (i = 0; i < 2; i++) { 05936 if (!places[i]) 05937 continue; 05938 if (places[i] == &globals) 05939 ast_mutex_lock(&globalslock); 05940 AST_LIST_TRAVERSE(places[i], variables, entries) { 05941 if (!strcmp(name, ast_var_name(variables))) { 05942 ret = ast_var_value(variables); 05943 break; 05944 } 05945 } 05946 if (places[i] == &globals) 05947 ast_mutex_unlock(&globalslock); 05948 if (ret) 05949 break; 05950 } 05951 05952 return ret; 05953 }
|
|
Definition at line 5955 of file pbx.c. References ast_func_write(), AST_LIST_INSERT_HEAD, ast_log(), ast_mutex_lock(), ast_mutex_unlock(), ast_var_assign(), ast_verbose(), LOG_WARNING, option_verbose, ast_channel::varshead, and VERBOSE_PREFIX_2. Referenced by gosub_exec(). 05956 { 05957 struct ast_var_t *newvariable; 05958 struct varshead *headp; 05959 05960 if (name[strlen(name)-1] == ')') { 05961 ast_log(LOG_WARNING, "Cannot push a value onto a function\n"); 05962 return ast_func_write(chan, name, value); 05963 } 05964 05965 headp = (chan) ? &chan->varshead : &globals; 05966 05967 if (value) { 05968 if ((option_verbose > 1) && (headp == &globals)) 05969 ast_verbose(VERBOSE_PREFIX_2 "Setting global variable '%s' to '%s'\n", name, value); 05970 newvariable = ast_var_assign(name, value); 05971 if (headp == &globals) 05972 ast_mutex_lock(&globalslock); 05973 AST_LIST_INSERT_HEAD(headp, newvariable, entries); 05974 if (headp == &globals) 05975 ast_mutex_unlock(&globalslock); 05976 } 05977 }
|
|
Definition at line 5898 of file pbx.c. References ast_build_string(), AST_LIST_TRAVERSE, ast_log(), ast_var_name(), ast_var_value(), LOG_ERROR, total, var, and ast_channel::varshead. Referenced by dumpchan_exec(), and handle_showchan(). 05899 { 05900 struct ast_var_t *variables; 05901 char *var, *val; 05902 int total = 0; 05903 05904 if (!chan) 05905 return 0; 05906 05907 memset(buf, 0, size); 05908 05909 AST_LIST_TRAVERSE(&chan->varshead, variables, entries) { 05910 if ((var = ast_var_name(variables)) && (val = ast_var_value(variables))) { 05911 if (ast_build_string(&buf, &size, "%s=%s\n", var, val)) { 05912 ast_log(LOG_ERROR, "Data Buffer Size Exceeded!\n"); 05913 break; 05914 } else 05915 total++; 05916 } else 05917 break; 05918 } 05919 05920 return total; 05921 }
|
|
|
|
Definition at line 5979 of file pbx.c. References ast_func_write(), AST_LIST_INSERT_HEAD, AST_LIST_REMOVE, AST_LIST_TRAVERSE, ast_mutex_lock(), ast_mutex_unlock(), ast_var_assign(), ast_var_delete(), ast_var_name(), ast_verbose(), option_verbose, ast_channel::varshead, and VERBOSE_PREFIX_2. Referenced by action_setvar(), aPGSQL_connect(), aPGSQL_fetch(), aPGSQL_query(), aqm_exec(), ast_app_group_set_channel(), ast_bridge_call(), ast_iax2_new(), ast_monitor_start(), ast_set_variables(), background_detect_exec(), builtin_blindtransfer(), builtin_function_set(), cb_events(), chanavail_exec(), controlplayback_exec(), count_exec(), curl_exec(), cut_exec(), dundi_lookup_exec(), enumlookup_exec(), eval_exec(), export_ch(), function_db_exists(), function_db_read(), get_exec(), get_refer_info(), group_check_exec(), group_count_exec(), group_match_count_exec(), handle_setvariable(), hasvoicemail_exec(), leave_voicemail(), lookupblacklist_exec(), macro_exec(), math_exec(), md5_exec(), md5check_exec(), misdn_call(), mixmonitor_exec(), monitor_handle_owned(), ospfinished_exec(), osplookup_exec(), ospnext_exec(), pbx_builtin_importvar(), pbx_builtin_setglobalvar(), pbx_builtin_setvar(), pbx_extension_helper(), pbx_load_module(), play_message_datetime(), playback_exec(), pop_exec(), pqm_exec(), prep_email_sub_vars(), privacy_exec(), process_ast_dsp(), read_exec(), readfile_exec(), realtime_exec(), return_exec(), rqm_exec(), sendimage_exec(), sendtext_exec(), sendurl_exec(), set_agentbycallerid(), set_queue_result(), sip_addheader(), sip_getheader(), sip_new(), sort_exec(), start_monitor_exec(), system_exec_helper(), transfer_exec(), txtcidname_exec(), upqm_exec(), vm_box_exists(), vm_exec(), vmauthenticate(), zt_new(), and zt_read(). 05980 { 05981 struct ast_var_t *newvariable; 05982 struct varshead *headp; 05983 const char *nametail = name; 05984 05985 if (name[strlen(name)-1] == ')') 05986 return ast_func_write(chan, name, value); 05987 05988 headp = (chan) ? &chan->varshead : &globals; 05989 05990 /* For comparison purposes, we have to strip leading underscores */ 05991 if (*nametail == '_') { 05992 nametail++; 05993 if (*nametail == '_') 05994 nametail++; 05995 } 05996 05997 if (headp == &globals) 05998 ast_mutex_lock(&globalslock); 05999 AST_LIST_TRAVERSE (headp, newvariable, entries) { 06000 if (strcasecmp(ast_var_name(newvariable), nametail) == 0) { 06001 /* there is already such a variable, delete it */ 06002 AST_LIST_REMOVE(headp, newvariable, entries); 06003 ast_var_delete(newvariable); 06004 break; 06005 } 06006 } 06007 06008 if (value) { 06009 if ((option_verbose > 1) && (headp == &globals)) 06010 ast_verbose(VERBOSE_PREFIX_2 "Setting global variable '%s' to '%s'\n", name, value); 06011 newvariable = ast_var_assign(name, value); 06012 AST_LIST_INSERT_HEAD(headp, newvariable, entries); 06013 } 06014 06015 if (headp == &globals) 06016 ast_mutex_unlock(&globalslock); 06017 }
|
|
Definition at line 6138 of file pbx.c. Referenced by builtin_function_if(), execif_exec(), gosubif_exec(), macroif_exec(), and pbx_builtin_gotoif(). 06139 { 06140 if (condition) { 06141 if (*condition == '\0') { 06142 /* Empty strings are false */ 06143 return 0; 06144 } else if (*condition >= '0' && *condition <= '9') { 06145 /* Numbers are evaluated for truth */ 06146 return atoi(condition); 06147 } else { 06148 /* Strings are true */ 06149 return 1; 06150 } 06151 } else { 06152 /* NULL is also false */ 06153 return 0; 06154 } 06155 }
|
|
Definition at line 531 of file pbx.c. References app, ast_channel::appl, ast_cdr_setapp(), ast_log(), ast_channel::cdr, ast_channel::data, and LOG_WARNING. Referenced by ast_bridge_call(), ast_pbx_run_app(), async_wait(), builtin_automonitor(), conf_run(), exec_exec(), execif_exec(), feature_exec_app(), forward_message(), handle_exec(), iax2_exec(), page_exec(), pbx_builtin_execiftime(), pbx_extension_helper(), and realtime_exec(). 00535 { 00536 int res; 00537 00538 char *saved_c_appl; 00539 char *saved_c_data; 00540 00541 int (*execute)(struct ast_channel *chan, void *data) = app->execute; 00542 00543 if (newstack) { 00544 if (c->cdr) 00545 ast_cdr_setapp(c->cdr, app->name, data); 00546 00547 /* save channel values */ 00548 saved_c_appl= c->appl; 00549 saved_c_data= c->data; 00550 00551 c->appl = app->name; 00552 c->data = data; 00553 res = execute(c, data); 00554 /* restore channel values */ 00555 c->appl= saved_c_appl; 00556 c->data= saved_c_data; 00557 return res; 00558 } else 00559 ast_log(LOG_WARNING, "You really didn't want to call this function with newstack set to 0\n"); 00560 return -1; 00561 }
|
|
Find application handle in linked list.
Definition at line 576 of file pbx.c. References apps, ast_log(), ast_mutex_lock(), ast_mutex_unlock(), LOG_WARNING, ast_app::name, and ast_app::next. Referenced by ast_bridge_call(), ast_pbx_run_app(), async_wait(), builtin_automonitor(), conf_run(), exec_exec(), execif_exec(), feature_exec_app(), forward_message(), handle_exec(), iax2_exec(), page_exec(), pbx_builtin_execiftime(), pbx_extension_helper(), and realtime_exec(). 00577 { 00578 struct ast_app *tmp; 00579 00580 if (ast_mutex_lock(&applock)) { 00581 ast_log(LOG_WARNING, "Unable to obtain application lock\n"); 00582 return NULL; 00583 } 00584 tmp = apps; 00585 while(tmp) { 00586 if (!strcasecmp(tmp->name, app)) 00587 break; 00588 tmp = tmp->next; 00589 } 00590 ast_mutex_unlock(&applock); 00591 return tmp; 00592 }
|
|
pbx_retrieve_variable: Support for Asterisk built-in variables and functions in the dialplan ---
Definition at line 979 of file pbx.c. References ast_channel::accountcode, ast_get_hint(), AST_LIST_TRAVERSE, ast_log(), ast_mutex_lock(), ast_mutex_unlock(), ast_var_name(), ast_var_value(), ast_channel::cid, ast_callerid::cid_ani, ast_callerid::cid_ani2, ast_callerid::cid_dnid, ast_callerid::cid_name, ast_callerid::cid_num, ast_callerid::cid_pres, ast_callerid::cid_rdnis, ast_callerid::cid_tns, ast_callerid::cid_ton, ast_channel::context, ast_channel::exten, ast_channel::hangupcause, ast_channel::language, LOG_WARNING, ast_channel::name, offset, parse_variable_name(), pbx_retrieve_variable(), ast_channel::priority, substring(), ast_channel::uniqueid, and ast_channel::varshead. Referenced by function_fieldqty(), handle_getvariable(), pbx_retrieve_variable(), and pbx_substitute_variables_helper_full(). 00980 { 00981 char tmpvar[80]; 00982 time_t thistime; 00983 struct tm brokentime; 00984 int offset, offset2, isfunc; 00985 struct ast_var_t *variables; 00986 00987 if (c) 00988 headp=&c->varshead; 00989 *ret=NULL; 00990 ast_copy_string(tmpvar, var, sizeof(tmpvar)); 00991 if (parse_variable_name(tmpvar, &offset, &offset2, &isfunc)) { 00992 pbx_retrieve_variable(c, tmpvar, ret, workspace, workspacelen, headp); 00993 if (!(*ret)) 00994 return; 00995 *ret = substring(*ret, offset, offset2, workspace, workspacelen); 00996 } else if (c && !strncmp(var, "CALL", 4)) { 00997 if (!strncmp(var + 4, "ER", 2)) { 00998 if (!strncmp(var + 6, "ID", 2)) { 00999 if (!var[8]) { /* CALLERID */ 01000 if (c->cid.cid_num) { 01001 if (c->cid.cid_name) { 01002 snprintf(workspace, workspacelen, "\"%s\" <%s>", c->cid.cid_name, c->cid.cid_num); 01003 } else { 01004 ast_copy_string(workspace, c->cid.cid_num, workspacelen); 01005 } 01006 *ret = workspace; 01007 } else if (c->cid.cid_name) { 01008 ast_copy_string(workspace, c->cid.cid_name, workspacelen); 01009 *ret = workspace; 01010 } else 01011 *ret = NULL; 01012 } else if (!strcmp(var + 8, "NUM")) { 01013 /* CALLERIDNUM */ 01014 if (c->cid.cid_num) { 01015 ast_copy_string(workspace, c->cid.cid_num, workspacelen); 01016 *ret = workspace; 01017 } else 01018 *ret = NULL; 01019 } else if (!strcmp(var + 8, "NAME")) { 01020 /* CALLERIDNAME */ 01021 if (c->cid.cid_name) { 01022 ast_copy_string(workspace, c->cid.cid_name, workspacelen); 01023 *ret = workspace; 01024 } else 01025 *ret = NULL; 01026 } else 01027 goto icky; 01028 } else if (!strcmp(var + 6, "ANI")) { 01029 /* CALLERANI */ 01030 if (c->cid.cid_ani) { 01031 ast_copy_string(workspace, c->cid.cid_ani, workspacelen); 01032 *ret = workspace; 01033 } else 01034 *ret = NULL; 01035 } else 01036 goto icky; 01037 } else if (!strncmp(var + 4, "ING", 3)) { 01038 if (!strcmp(var + 7, "PRES")) { 01039 /* CALLINGPRES */ 01040 snprintf(workspace, workspacelen, "%d", c->cid.cid_pres); 01041 *ret = workspace; 01042 } else if (!strcmp(var + 7, "ANI2")) { 01043 /* CALLINGANI2 */ 01044 snprintf(workspace, workspacelen, "%d", c->cid.cid_ani2); 01045 *ret = workspace; 01046 } else if (!strcmp(var + 7, "TON")) { 01047 /* CALLINGTON */ 01048 snprintf(workspace, workspacelen, "%d", c->cid.cid_ton); 01049 *ret = workspace; 01050 } else if (!strcmp(var + 7, "TNS")) { 01051 /* CALLINGTNS */ 01052 snprintf(workspace, workspacelen, "%d", c->cid.cid_tns); 01053 *ret = workspace; 01054 } else 01055 goto icky; 01056 } else 01057 goto icky; 01058 } else if (c && !strcmp(var, "DNID")) { 01059 if (c->cid.cid_dnid) { 01060 ast_copy_string(workspace, c->cid.cid_dnid, workspacelen); 01061 *ret = workspace; 01062 } else 01063 *ret = NULL; 01064 } else if (c && !strcmp(var, "HINT")) { 01065 if (!ast_get_hint(workspace, workspacelen, NULL, 0, c, c->context, c->exten)) 01066 *ret = NULL; 01067 else 01068 *ret = workspace; 01069 } else if (c && !strcmp(var, "HINTNAME")) { 01070 if (!ast_get_hint(NULL, 0, workspace, workspacelen, c, c->context, c->exten)) 01071 *ret = NULL; 01072 else 01073 *ret = workspace; 01074 } else if (c && !strcmp(var, "EXTEN")) { 01075 ast_copy_string(workspace, c->exten, workspacelen); 01076 *ret = workspace; 01077 } else if (c && !strcmp(var, "RDNIS")) { 01078 if (c->cid.cid_rdnis) { 01079 ast_copy_string(workspace, c->cid.cid_rdnis, workspacelen); 01080 *ret = workspace; 01081 } else 01082 *ret = NULL; 01083 } else if (c && !strcmp(var, "CONTEXT")) { 01084 ast_copy_string(workspace, c->context, workspacelen); 01085 *ret = workspace; 01086 } else if (c && !strcmp(var, "PRIORITY")) { 01087 snprintf(workspace, workspacelen, "%d", c->priority); 01088 *ret = workspace; 01089 } else if (c && !strcmp(var, "CHANNEL")) { 01090 ast_copy_string(workspace, c->name, workspacelen); 01091 *ret = workspace; 01092 } else if (!strcmp(var, "EPOCH")) { 01093 snprintf(workspace, workspacelen, "%u",(int)time(NULL)); 01094 *ret = workspace; 01095 } else if (!strcmp(var, "DATETIME")) { 01096 thistime=time(NULL); 01097 localtime_r(&thistime, &brokentime); 01098 snprintf(workspace, workspacelen, "%02d%02d%04d-%02d:%02d:%02d", 01099 brokentime.tm_mday, 01100 brokentime.tm_mon+1, 01101 brokentime.tm_year+1900, 01102 brokentime.tm_hour, 01103 brokentime.tm_min, 01104 brokentime.tm_sec 01105 ); 01106 *ret = workspace; 01107 } else if (!strcmp(var, "TIMESTAMP")) { 01108 thistime=time(NULL); 01109 localtime_r(&thistime, &brokentime); 01110 /* 20031130-150612 */ 01111 snprintf(workspace, workspacelen, "%04d%02d%02d-%02d%02d%02d", 01112 brokentime.tm_year+1900, 01113 brokentime.tm_mon+1, 01114 brokentime.tm_mday, 01115 brokentime.tm_hour, 01116 brokentime.tm_min, 01117 brokentime.tm_sec 01118 ); 01119 *ret = workspace; 01120 } else if (c && !strcmp(var, "UNIQUEID")) { 01121 snprintf(workspace, workspacelen, "%s", c->uniqueid); 01122 *ret = workspace; 01123 } else if (c && !strcmp(var, "HANGUPCAUSE")) { 01124 snprintf(workspace, workspacelen, "%d", c->hangupcause); 01125 *ret = workspace; 01126 } else if (c && !strcmp(var, "ACCOUNTCODE")) { 01127 ast_copy_string(workspace, c->accountcode, workspacelen); 01128 *ret = workspace; 01129 } else if (c && !strcmp(var, "LANGUAGE")) { 01130 ast_copy_string(workspace, c->language, workspacelen); 01131 *ret = workspace; 01132 } else { 01133 icky: 01134 if (headp) { 01135 AST_LIST_TRAVERSE(headp,variables,entries) { 01136 #if 0 01137 ast_log(LOG_WARNING,"Comparing variable '%s' with '%s'\n",var,ast_var_name(variables)); 01138 #endif 01139 if (strcasecmp(ast_var_name(variables),var)==0) { 01140 *ret=ast_var_value(variables); 01141 if (*ret) { 01142 ast_copy_string(workspace, *ret, workspacelen); 01143 *ret = workspace; 01144 } 01145 break; 01146 } 01147 } 01148 } 01149 if (!(*ret)) { 01150 /* Try globals */ 01151 ast_mutex_lock(&globalslock); 01152 AST_LIST_TRAVERSE(&globals,variables,entries) { 01153 if (strcasecmp(ast_var_name(variables),var)==0) { 01154 *ret = ast_var_value(variables); 01155 if (*ret) { 01156 ast_copy_string(workspace, *ret, workspacelen); 01157 *ret = workspace; 01158 } 01159 } 01160 } 01161 ast_mutex_unlock(&globalslock); 01162 } 01163 } 01164 }
|
|
Definition at line 2567 of file pbx.c. Referenced by pbx_load_module(). 02568 { 02569 int oldval; 02570 oldval = autofallthrough; 02571 if (oldval != newval) 02572 autofallthrough = newval; 02573 return oldval; 02574 }
|
|
Definition at line 1598 of file pbx.c. References pbx_substitute_variables_helper_full(), and ast_channel::varshead. Referenced by custom_log(), cut_internal(), eval_exec(), exec_exec(), function_eval(), handle_getvariablefull(), pbx_builtin_importvar(), pbx_load_module(), pbx_substitute_variables(), realtime_exec(), sendmail(), and sendpage(). 01599 { 01600 pbx_substitute_variables_helper_full(c, (c) ? &c->varshead : NULL, cp1, cp2, count); 01601 }
|
|
Definition at line 1603 of file pbx.c. References pbx_substitute_variables_helper_full(). Referenced by ast_add_extension2(), dundi_lookup_local(), and loopback_helper(). 01604 { 01605 pbx_substitute_variables_helper_full(NULL, headp, cp1, cp2, count); 01606 }
|
|
Referenced by ast_extension_state2str(). |