#include "asterisk/sched.h"
#include "asterisk/channel.h"
#include "asterisk/linkedlists.h"

Go to the source code of this file.
Data Structures | |
| struct | ast_custom_function |
| Data structure associated with a custom dialplan function. More... | |
| struct | ast_pbx |
| struct | ast_switch |
| struct | ast_timing |
Defines | |
| #define | AST_MAX_APP 32 |
| #define | AST_PBX_KEEP 0 |
| #define | AST_PBX_KEEPALIVE 10 |
| Special return values from applications to the PBX {. | |
| #define | AST_PBX_NO_HANGUP_PEER 11 |
| #define | AST_PBX_NO_HANGUP_PEER_PARKED 12 |
| #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) |
| Typedef for devicestate and hint callbacks. | |
| typedef int( | ast_switch_f )(struct ast_channel *chan, const char *context, const char *exten, int priority, const char *callerid, const char *data) |
| All switch functions have the same interface, so define a type for them. | |
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, AST_EXTENSION_ONHOLD = 1 << 4 } |
| Extension states. More... | |
| enum | ast_pbx_result { AST_PBX_SUCCESS = 0, AST_PBX_FAILED = -1, AST_PBX_CALL_LIMIT = -2 } |
Functions | |
| int | ast_active_calls (void) |
| Retrieve the number of active calls. | |
| 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) |
| Add and extension to an extension context. | |
| 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) |
| Add an extension to an extension context, this time with an ast_context *. | |
| 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, const char *context, const char *exten, int priority) |
| int | ast_build_timing (struct ast_timing *i, const char *info) |
| int | ast_canmatch_extension (struct ast_channel *c, const char *context, const char *exten, int priority, const char *callerid) |
| Looks for a valid matching extension. | |
| int | ast_check_timing (const struct ast_timing *i) |
| int | ast_context_add_ignorepat (const char *context, const char *ignorepat, const char *registrar) |
| Add an ignorepat. | |
| 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) |
| Add a context include. | |
| int | ast_context_add_include2 (struct ast_context *con, const char *include, const char *registrar) |
| Add a context include. | |
| int | ast_context_add_switch (const char *context, const char *sw, const char *data, int eval, const char *registrar) |
| Add a switch. | |
| int | ast_context_add_switch2 (struct ast_context *con, const char *sw, const char *data, int eval, const char *registrar) |
| Adds a switch (first param is a ast_context). | |
| struct ast_context * | ast_context_create (struct ast_context **extcontexts, const char *name, const char *registrar) |
| Register a new context. | |
| void | ast_context_destroy (struct ast_context *con, const char *registrar) |
| Destroy a context (matches the specified context (or ANY context if NULL). | |
| struct ast_context * | ast_context_find (const char *name) |
| Find a context. | |
| struct ast_context * | ast_context_find_or_create (struct ast_context **extcontexts, const char *name, const char *registrar) |
| int | ast_context_lockmacro (const char *macrocontext) |
| locks the macrolock in the given given context | |
| int | ast_context_remove_extension (const char *context, const char *extension, int priority, const char *registrar) |
| Simply remove extension from context. | |
| 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_extension_callerid (const char *context, const char *extension, int priority, const char *callerid, int matchcid, const char *registrar) |
| int | ast_context_remove_extension_callerid2 (struct ast_context *con, const char *extension, int priority, const char *callerid, int matchcid, const char *registrar) |
| 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) |
| Remove a context include. | |
| int | ast_context_remove_include2 (struct ast_context *con, const char *include, const char *registrar) |
| Removes an include by an ast_context structure. | |
| int | ast_context_remove_switch (const char *context, const char *sw, const char *data, const char *registrar) |
| Remove a switch. | |
| 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_unlockmacro (const char *macrocontext) |
| Unlocks the macrolock in the given context. | |
| int | ast_context_verify_includes (struct ast_context *con) |
| Verifies includes in an ast_contect structure. | |
| struct ast_custom_function * | ast_custom_function_find (const char *name) |
| int | ast_custom_function_register (struct ast_custom_function *acf) |
| Reigster a custom function. | |
| int | ast_custom_function_unregister (struct ast_custom_function *acf) |
| Unregister a custom function. | |
| int | ast_exists_extension (struct ast_channel *c, const char *context, const char *exten, int priority, const char *callerid) |
| Determine whether an extension exists. | |
| 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) |
| Determine if a given extension matches a given pattern (in NXX format). | |
| int | ast_extension_patmatch (const char *pattern, const char *data) |
| int | ast_extension_state (struct ast_channel *c, const char *context, const char *exten) |
| Uses hint and devicestate callback to get the state of an extension. | |
| const char * | ast_extension_state2str (int extension_state) |
| Return string representation of the state of an extension. | |
| int | ast_extension_state_add (const char *context, const char *exten, ast_state_cb_type callback, void *data) |
| Registers a state change callback. | |
| int | ast_extension_state_del (int id, ast_state_cb_type callback) |
| Deletes a registered state change callback by ID. | |
| int | ast_findlabel_extension (struct ast_channel *c, const char *context, const char *exten, const char *label, const char *callerid) |
| Find the priority of an extension that has the specified label. | |
| int | ast_findlabel_extension2 (struct ast_channel *c, struct ast_context *con, const char *exten, const char *label, const char *callerid) |
| Find the priority of an extension that has the specified label. | |
| int | ast_func_read (struct ast_channel *chan, char *function, char *workspace, size_t len) |
| executes a read operation on a function | |
| int | ast_func_write (struct ast_channel *chan, char *function, const char *value) |
| executes a write operation on a function | |
| 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) |
| struct ast_context * | ast_get_extension_context (struct ast_exten *exten) |
| 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) |
| If an extension exists, return non-zero. | |
| 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, const char *context, const char *exten, int priority) |
| void | ast_hint_state_changed (const char *device) |
| int | ast_ignore_pattern (const char *context, const char *pattern) |
| Checks to see if a number should be ignored. | |
| int | ast_lock_context (struct ast_context *con) |
| Locks a given context. | |
| int | ast_lock_contexts (void) |
| Locks the context list. | |
| int | ast_matchmore_extension (struct ast_channel *c, const char *context, const char *exten, int priority, const char *callerid) |
| Looks to see if adding anything to this extension might match something. (exists ^ canmatch). | |
| void | ast_merge_contexts_and_delete (struct ast_context **extcontexts, const char *registrar) |
| Merge the temporary contexts into a global contexts list and delete from the global list the ones that are being added. | |
| 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) |
| Execute the PBX in the current thread. | |
| enum ast_pbx_result | ast_pbx_start (struct ast_channel *c) |
| Create a new thread and start the PBX. | |
| int | ast_rdlock_contexts (void) |
| int | ast_register_application (const char *app, int(*execute)(struct ast_channel *, void *), const char *synopsis, const char *description) |
| Register an application. | |
| int | ast_register_switch (struct ast_switch *sw) |
| Register an alternative dialplan switch. | |
| int | ast_spawn_extension (struct ast_channel *c, const char *context, const char *exten, int priority, const char *callerid) |
| Launch a new extension (i.e. new stack). | |
| int | ast_unlock_context (struct ast_context *con) |
| int | ast_unlock_contexts (void) |
| Unlocks contexts. | |
| int | ast_unregister_application (const char *app) |
| Unregister an application. | |
| void | ast_unregister_switch (struct ast_switch *sw) |
| Unregister an alternative switch. | |
| struct ast_exten * | ast_walk_context_extensions (struct ast_context *con, struct ast_exten *priority) |
| struct ast_ignorepat * | ast_walk_context_ignorepats (struct ast_context *con, struct ast_ignorepat *ip) |
| struct ast_include * | ast_walk_context_includes (struct ast_context *con, struct ast_include *inc) |
| struct ast_sw * | ast_walk_context_switches (struct ast_context *con, struct ast_sw *sw) |
| struct ast_context * | ast_walk_contexts (struct ast_context *con) |
| struct ast_exten * | ast_walk_extension_priorities (struct ast_exten *exten, struct ast_exten *priority) |
| int | ast_wrlock_contexts (void) |
| void | pbx_builtin_clear_globals (void) |
| const 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 (const char *condition) |
| Evaluate a condition. | |
| int | pbx_exec (struct ast_channel *c, struct ast_app *app, void *data) |
| Execute an application. | |
| struct ast_app * | pbx_findapp (const char *app) |
| Look up an application. | |
| 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 --- | |
| 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) |
Definition in file pbx.h.
| #define AST_MAX_APP 32 |
Max length of an application
Definition at line 34 of file pbx.h.
Referenced by destroy_station(), handle_show_application(), handle_show_application_deprecated(), handle_show_function(), handle_show_function_deprecated(), and sla_build_station().
| #define AST_PBX_KEEPALIVE 10 |
Special return values from applications to the PBX {.
Destroy the thread, but don't hang up the channel
Definition at line 40 of file pbx.h.
Referenced by __ast_pbx_run(), _macro_exec(), agi_handle_command(), ast_bridge_call(), builtin_parkcall(), feature_exec_app(), park_call_exec(), queue_exec(), rpt_exec(), run_agi(), and try_calling().
| #define AST_PBX_NO_HANGUP_PEER 11 |
The peer has been involved in a transfer
Definition at line 41 of file pbx.h.
Referenced by feature_exec_app(), park_exec(), and try_calling().
| #define AST_PBX_NO_HANGUP_PEER_PARKED 12 |
Don't touch the peer channel - it was sent to the parking lot and might be gone by now
Definition at line 42 of file pbx.h.
Referenced by ast_bridge_call(), builtin_parkcall(), feature_exec_app(), park_exec(), and try_calling().
| #define PRIORITY_HINT -1 |
} Special Priority for a hint
Definition at line 45 of file pbx.h.
Referenced by add_extensions(), add_pri(), ast_add_extension2(), ast_hint_extension(), ast_merge_contexts_and_delete(), destroy_exten(), destroy_station(), handle_context_add_extension(), handle_context_add_extension_deprecated(), handle_context_remove_extension(), handle_context_remove_extension_deprecated(), handle_save_dialplan(), park_add_hints(), pbx_load_config(), print_ext(), and sla_build_station().
| typedef int(* ast_state_cb_type)(char *context, char *id, enum ast_extension_states state, void *data) |
| typedef int( ast_switch_f)(struct ast_channel *chan, const char *context, const char *exten, int priority, const char *callerid, const char *data) |
| enum ast_extension_states |
Extension states.
Definition at line 48 of file pbx.h.
00048 { 00049 AST_EXTENSION_REMOVED = -2, /*!< Extension removed */ 00050 AST_EXTENSION_DEACTIVATED = -1, /*!< Extension hint removed */ 00051 AST_EXTENSION_NOT_INUSE = 0, /*!< No device INUSE or BUSY */ 00052 AST_EXTENSION_INUSE = 1 << 0, /*!< One or more devices INUSE */ 00053 AST_EXTENSION_BUSY = 1 << 1, /*!< All devices BUSY */ 00054 AST_EXTENSION_UNAVAILABLE = 1 << 2, /*!< All devices UNAVAILABLE/UNREGISTERED */ 00055 AST_EXTENSION_RINGING = 1 << 3, /*!< All devices RINGING */ 00056 AST_EXTENSION_ONHOLD = 1 << 4, /*!< All devices ONHOLD */ 00057 };
| enum ast_pbx_result |
Definition at line 215 of file pbx.h.
00215 { 00216 AST_PBX_SUCCESS = 0, 00217 AST_PBX_FAILED = -1, 00218 AST_PBX_CALL_LIMIT = -2, 00219 };
| int ast_active_calls | ( | void | ) |
Retrieve the number of active calls.
Definition at line 2670 of file pbx.c.
References countcalls.
Referenced by handle_chanlist(), and handle_chanlist_deprecated().
02671 { 02672 return countcalls; 02673 }
| 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(*)(void *) | datad, | |||
| const char * | registrar | |||
| ) |
Add and extension to an extension context.
| context | context to add the extension to | |
| replace | ||
| extension | extension to add | |
| priority | priority level of extension addition | |
| label | extension label | |
| callerid | pattern to match CallerID, or NULL to match any CallerID | |
| application | application to run on the extension with that priority level | |
| data | data to pass to the application | |
| datad | ||
| registrar | who registered the extension |
| 0 | success | |
| -1 | failure |
Definition at line 4552 of file pbx.c.
References ast_add_extension2(), ast_unlock_contexts(), and find_context_locked().
Referenced by handle_context_add_extension(), handle_context_add_extension_deprecated(), park_add_hints(), and register_peer_exten().
04555 { 04556 int ret = -1; 04557 struct ast_context *c = find_context_locked(context); 04558 04559 if (c) { 04560 ret = ast_add_extension2(c, replace, extension, priority, label, callerid, 04561 application, data, datad, registrar); 04562 ast_unlock_contexts(); 04563 } 04564 return ret; 04565 }
| 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(*)(void *) | datad, | |||
| const char * | registrar | |||
| ) |
Add an extension to an extension context, this time with an ast_context *.
We sort extensions in order of matching preference, so that we can stop the search as soon as we find a suitable match. This ordering also takes care of wildcards such as '.' (meaning "one or more of any character") and '!' (which is 'earlymatch', meaning "zero or more of any character" but also impacts the return value from CANMATCH and EARLYMATCH.
The extension match rules defined in the devmeeting 2006.05.05 are quite simple: WE SELECT THE LONGEST MATCH. In detail, "longest" means the number of matched characters in the extension. In case of ties (e.g. _XXX and 333) in the length of a pattern, we give priority to entries with the smallest cardinality (e.g, [5-9] comes before [2-8] before the former has only 5 elements, while the latter has 7, etc. In case of same cardinality, the first element in the range counts. If we still have a tie, any final '!' will make this as a possibly less specific pattern.
EBUSY - can't lock EEXIST - extension with the same priority exist and no replace is set
Definition at line 4767 of file pbx.c.
References add_pri(), ast_exten::app, ast_add_hint(), ast_calloc, AST_LIST_FIRST, ast_log(), ast_mutex_lock(), ast_mutex_unlock(), ast_verbose(), ast_exten::cidmatch, ast_exten::data, ast_exten::datad, el, errno, ext_cmp(), ext_strncpy(), ast_exten::exten, globals, globalslock, ast_exten::label, ast_context::lock, LOG_DEBUG, ast_exten::matchcid, ast_context::name, ast_exten::next, option_debug, option_verbose, ast_exten::parent, pbx_substitute_variables_varshead(), ast_exten::priority, PRIORITY_HINT, ast_exten::registrar, ast_context::root, ast_exten::stuff, VAR_BUF_SIZE, and VERBOSE_PREFIX_3.
Referenced by add_extensions(), ast_add_extension(), do_parking_thread(), load_config(), park_call_full(), pbx_load_config(), pbx_load_users(), sla_build_station(), and sla_build_trunk().
04771 { 04772 /* 04773 * Sort extensions (or patterns) according to the rules indicated above. 04774 * These are implemented by the function ext_cmp()). 04775 * All priorities for the same ext/pattern/cid are kept in a list, 04776 * using the 'peer' field as a link field.. 04777 */ 04778 struct ast_exten *tmp, *e, *el = NULL; 04779 int res; 04780 int length; 04781 char *p; 04782 char expand_buf[VAR_BUF_SIZE] = { 0, }; 04783 04784 /* if we are adding a hint, and there are global variables, and the hint 04785 contains variable references, then expand them 04786 */ 04787 ast_mutex_lock(&globalslock); 04788 if (priority == PRIORITY_HINT && AST_LIST_FIRST(&globals) && strstr(application, "${")) { 04789 pbx_substitute_variables_varshead(&globals, application, expand_buf, sizeof(expand_buf)); 04790 application = expand_buf; 04791 } 04792 ast_mutex_unlock(&globalslock); 04793 04794 length = sizeof(struct ast_exten); 04795 length += strlen(extension) + 1; 04796 length += strlen(application) + 1; 04797 if (label) 04798 length += strlen(label) + 1; 04799 if (callerid) 04800 length += strlen(callerid) + 1; 04801 else 04802 length ++; /* just the '\0' */ 04803 04804 /* Be optimistic: Build the extension structure first */ 04805 if (!(tmp = ast_calloc(1, length))) 04806 return -1; 04807 04808 /* use p as dst in assignments, as the fields are const char * */ 04809 p = tmp->stuff; 04810 if (label) { 04811 tmp->label = p; 04812 strcpy(p, label); 04813 p += strlen(label) + 1; 04814 } 04815 tmp->exten = p; 04816 p += ext_strncpy(p, extension, strlen(extension) + 1) + 1; 04817 tmp->priority = priority; 04818 tmp->cidmatch = p; /* but use p for assignments below */ 04819 if (callerid) { 04820 p += ext_strncpy(p, callerid, strlen(callerid) + 1) + 1; 04821 tmp->matchcid = 1; 04822 } else { 04823 *p++ = '\0'; 04824 tmp->matchcid = 0; 04825 } 04826 tmp->app = p; 04827 strcpy(p, application); 04828 tmp->parent = con; 04829 tmp->data = data; 04830 tmp->datad = datad; 04831 tmp->registrar = registrar; 04832 04833 ast_mutex_lock(&con->lock); 04834 res = 0; /* some compilers will think it is uninitialized otherwise */ 04835 for (e = con->root; e; el = e, e = e->next) { /* scan the extension list */ 04836 res = ext_cmp(e->exten, tmp->exten); 04837 if (res == 0) { /* extension match, now look at cidmatch */ 04838 if (!e->matchcid && !tmp->matchcid) 04839 res = 0; 04840 else if (tmp->matchcid && !e->matchcid) 04841 res = 1; 04842 else if (e->matchcid && !tmp->matchcid) 04843 res = -1; 04844 else 04845 res = strcasecmp(e->cidmatch, tmp->cidmatch); 04846 } 04847 if (res >= 0) 04848 break; 04849 } 04850 if (e && res == 0) { /* exact match, insert in the pri chain */ 04851 res = add_pri(con, tmp, el, e, replace); 04852 ast_mutex_unlock(&con->lock); 04853 if (res < 0) { 04854 errno = EEXIST; /* XXX do we care ? */ 04855 return 0; /* XXX should we return -1 maybe ? */ 04856 } 04857 } else { 04858 /* 04859 * not an exact match, this is the first entry with this pattern, 04860 * so insert in the main list right before 'e' (if any) 04861 */ 04862 tmp->next = e; 04863 if (el) 04864 el->next = tmp; 04865 else 04866 con->root = tmp; 04867 ast_mutex_unlock(&con->lock); 04868 if (tmp->priority == PRIORITY_HINT) 04869 ast_add_hint(tmp); 04870 } 04871 if (option_debug) { 04872 if (tmp->matchcid) { 04873 if (option_debug) 04874 ast_log(LOG_DEBUG, "Added extension '%s' priority %d (CID match '%s') to %s\n", 04875 tmp->exten, tmp->priority, tmp->cidmatch, con->name); 04876 } else { 04877 if (option_debug) 04878 ast_log(LOG_DEBUG, "Added extension '%s' priority %d to %s\n", 04879 tmp->exten, tmp->priority, con->name); 04880 } 04881 } 04882 if (option_verbose > 2) { 04883 if (tmp->matchcid) { 04884 ast_verbose( VERBOSE_PREFIX_3 "Added extension '%s' priority %d (CID match '%s')to %s\n", 04885 tmp->exten, tmp->priority, tmp->cidmatch, con->name); 04886 } else { 04887 ast_verbose( VERBOSE_PREFIX_3 "Added extension '%s' priority %d to %s\n", 04888 tmp->exten, tmp->priority, con->name); 04889 } 04890 } 04891 return 0; 04892 }
| int ast_async_goto | ( | struct ast_channel * | chan, | |
| const char * | context, | |||
| const char * | exten, | |||
| int | priority | |||
| ) |
Definition at line 4590 of file pbx.c.
References ast_channel::_state, ast_channel::accountcode, ast_channel::amaflags, ast_cdr_discard(), ast_cdr_dup(), ast_channel_alloc(), ast_channel_lock, ast_channel_masquerade(), ast_channel_unlock, ast_do_masquerade(), ast_explicit_goto(), ast_hangup(), ast_log(), ast_pbx_start(), AST_SOFTHANGUP_ASYNCGOTO, ast_softhangup_nolock(), ast_channel::cdr, ast_channel::context, ast_channel::exten, LOG_WARNING, ast_channel::name, ast_channel::pbx, ast_channel::readformat, S_OR, and ast_channel::writeformat.
Referenced by __ast_goto_if_exists(), action_redirect(), ast_async_goto_by_name(), builtin_blindtransfer(), console_transfer(), console_transfer_deprecated(), dahdi_handle_dtmfup(), handle_request_bye(), handle_request_refer(), process_ast_dsp(), and socket_process().
04591 { 04592 int res = 0; 04593 04594 ast_channel_lock(chan); 04595 04596 if (chan->pbx) { /* This channel is currently in the PBX */ 04597 ast_explicit_goto(chan, context, exten, priority); 04598 ast_softhangup_nolock(chan, AST_SOFTHANGUP_ASYNCGOTO); 04599 } else { 04600 /* In order to do it when the channel doesn't really exist within 04601 the PBX, we have to make a new channel, masquerade, and start the PBX 04602 at the new location */ 04603 struct ast_channel *tmpchan = ast_channel_alloc(0, chan->_state, 0, 0, chan->accountcode, chan->exten, chan->context, chan->amaflags, "AsyncGoto/%s", chan->name); 04604 if (!tmpchan) { 04605 res = -1; 04606 } else { 04607 if (chan->cdr) { 04608 ast_cdr_discard(tmpchan->cdr); 04609 tmpchan->cdr = ast_cdr_dup(chan->cdr); /* share the love */ 04610 } 04611 /* Make formats okay */ 04612 tmpchan->readformat = chan->readformat; 04613 tmpchan->writeformat = chan->writeformat; 04614 /* Setup proper location */ 04615 ast_explicit_goto(tmpchan, 04616 S_OR(context, chan->context), S_OR(exten, chan->exten), priority); 04617 04618 /* Masquerade into temp channel */ 04619 if (ast_channel_masquerade(tmpchan, chan)) { 04620 /* Failed to set up the masquerade. It's probably chan_local 04621 * in the middle of optimizing itself out. Sad. :( */ 04622 ast_hangup(tmpchan); 04623 tmpchan = NULL; 04624 res = -1; 04625 } else { 04626 /* Grab the locks and get going */ 04627 ast_channel_lock(tmpchan); 04628 ast_do_masquerade(tmpchan); 04629 ast_channel_unlock(tmpchan); 04630 /* Start the PBX going on our stolen channel */ 04631 if (ast_pbx_start(tmpchan)) { 04632 ast_log(LOG_WARNING, "Unable to start PBX on %s\n", tmpchan->name); 04633 ast_hangup(tmpchan); 04634 res = -1; 04635 } 04636 } 04637 } 04638 } 04639 ast_channel_unlock(chan); 04640 return res; 04641 }
| int ast_async_goto_by_name | ( | const char * | chan, | |
| const char * | context, | |||
| const char * | exten, | |||
| int | priority | |||
| ) |
Definition at line 4643 of file pbx.c.
References ast_async_goto(), ast_channel_unlock, and ast_get_channel_by_name_locked().
04644 { 04645 struct ast_channel *chan; 04646 int res = -1; 04647 04648 chan = ast_get_channel_by_name_locked(channame); 04649 if (chan) { 04650 res = ast_async_goto(chan, context, exten, priority); 04651 ast_channel_unlock(chan); 04652 } 04653 return res; 04654 }
| int ast_async_goto_if_exists | ( | struct ast_channel * | chan, | |
| const char * | context, | |||
| const char * | exten, | |||
| int | priority | |||
| ) |
Definition at line 6355 of file pbx.c.
References __ast_goto_if_exists().
Referenced by asyncgoto_exec().
06356 { 06357 return __ast_goto_if_exists(chan, context, exten, priority, 1); 06358 }
| int ast_build_timing | ( | struct ast_timing * | i, | |
| const char * | info | |||
| ) |
Definition at line 4230 of file pbx.c.
References ast_copy_string(), ast_strlen_zero(), ast_timing::daymask, days, ast_timing::dowmask, get_range(), get_timerange(), ast_timing::monthmask, and months.
Referenced by ast_context_add_include2(), iftime(), pbx_builtin_execiftime(), and pbx_builtin_gotoiftime().
04231 { 04232 char info_save[256]; 04233 char *info; 04234 04235 /* Check for empty just in case */ 04236 if (ast_strlen_zero(info_in)) 04237 return 0; 04238 /* make a copy just in case we were passed a static string */ 04239 ast_copy_string(info_save, info_in, sizeof(info_save)); 04240 info = info_save; 04241 /* Assume everything except time */ 04242 i->monthmask = 0xfff; /* 12 bits */ 04243 i->daymask = 0x7fffffffU; /* 31 bits */ 04244 i->dowmask = 0x7f; /* 7 bits */ 04245 /* on each call, use strsep() to move info to the next argument */ 04246 get_timerange(i, strsep(&info, "|")); 04247 if (info) 04248 i->dowmask = get_range(strsep(&info, "|"), 7, days, "day of week"); 04249 if (info) 04250 i->daymask = get_range(strsep(&info, "|"), 31, NULL, "day"); 04251 if (info) 04252 i->monthmask = get_range(strsep(&info, "|"), 12, months, "month"); 04253 return 1; 04254 }
| int ast_canmatch_extension | ( | struct ast_channel * | c, | |
| const char * | context, | |||
| const char * | exten, | |||
| int | priority, | |||
| const char * | callerid | |||
| ) |
Looks for a valid matching extension.
| c | not really important | |
| context | context to serach within | |
| exten | extension to check | |
| priority | priority of extension path | |
| callerid | callerid of extension being searched for |
Definition at line 2306 of file pbx.c.
References E_CANMATCH, and pbx_extension_helper().
Referenced by background_detect_exec(), cb_events(), dp_lookup(), dundi_lookup_local(), get_also_info(), get_destination(), handle_link_data(), handle_link_phone_dtmf(), local_dtmf_helper(), loopback_canmatch(), mgcp_ss(), nv_background_detect_exec(), nv_detectfax_exec(), phone_check_exception(), skinny_ss(), ss_thread(), and valid_exit().
02307 { 02308 return pbx_extension_helper(c, NULL, context, exten, priority, NULL, callerid, E_CANMATCH); 02309 }
| int ast_check_timing | ( | const struct ast_timing * | i | ) |
Definition at line 4256 of file pbx.c.
References ast_localtime(), ast_log(), ast_timing::daymask, ast_timing::dowmask, LOG_WARNING, ast_timing::minmask, ast_timing::monthmask, and t.
Referenced by iftime(), include_valid(), pbx_builtin_execiftime(), and pbx_builtin_gotoiftime().
04257 { 04258 struct tm tm; 04259 time_t t = time(NULL); 04260 04261 ast_localtime(&t, &tm, NULL); 04262 04263 /* If it's not the right month, return */ 04264 if (!(i->monthmask & (1 << tm.tm_mon))) 04265 return 0; 04266 04267 /* If it's not that time of the month.... */ 04268 /* Warning, tm_mday has range 1..31! */ 04269 if (!(i->daymask & (1 << (tm.tm_mday-1)))) 04270 return 0; 04271 04272 /* If it's not the right day of the week */ 04273 if (!(i->dowmask & (1 << tm.tm_wday))) 04274 return 0; 04275 04276 /* Sanity check the hour just to be safe */ 04277 if ((tm.tm_hour < 0) || (tm.tm_hour > 23)) { 04278 ast_log(LOG_WARNING, "Insane time...\n"); 04279 return 0; 04280 } 04281 04282 /* Now the tough part, we calculate if it fits 04283 in the right time based on min/hour */ 04284 if (!(i->minmask[tm.tm_hour] & (1 << (tm.tm_min / 2)))) 04285 return 0; 04286 04287 /* If we got this far, then we're good */ 04288 return 1; 04289 }
| int ast_context_add_ignorepat | ( | const char * | context, | |
| const char * | ignorepat, | |||
| const char * | registrar | |||
| ) |
Add an ignorepat.
| context | which context to add the ignorpattern to | |
| ignorepat | ignorepattern to set up for the extension | |
| registrar | registrar of the ignore pattern |
| 0 | on success | |
| -1 | on failure |
Definition at line 4483 of file pbx.c.
References ast_context_add_ignorepat2(), ast_unlock_contexts(), and find_context_locked().
Referenced by handle_context_add_ignorepat(), and handle_context_add_ignorepat_deprecated().
04484 { 04485 int ret = -1; 04486 struct ast_context *c = find_context_locked(context); 04487 04488 if (c) { 04489 ret = ast_context_add_ignorepat2(c, value, registrar); 04490 ast_unlock_contexts(); 04491 } 04492 return ret; 04493 }
| int ast_context_add_ignorepat2 | ( | struct ast_context * | con, | |
| const char * | ignorepat, | |||
| const char * | registrar | |||
| ) |
Definition at line 4495 of file pbx.c.
References ast_calloc, ast_mutex_lock(), ast_mutex_unlock(), errno, ast_context::ignorepats, ast_context::lock, ast_ignorepat::next, ast_ignorepat::pattern, and ast_ignorepat::registrar.
Referenced by ast_compile_ael2(), ast_context_add_ignorepat(), and pbx_load_config().
04496 { 04497 struct ast_ignorepat *ignorepat, *ignorepatc, *ignorepatl = NULL; 04498 int length; 04499 char *pattern; 04500 length = sizeof(struct ast_ignorepat); 04501 length += strlen(value) + 1; 04502 if (!(ignorepat = ast_calloc(1, length))) 04503 return -1; 04504 /* The cast to char * is because we need to write the initial value. 04505 * The field is not supposed to be modified otherwise. Also, gcc 4.2 04506 * sees the cast as dereferencing a type-punned pointer and warns about 04507 * it. This is the workaround (we're telling gcc, yes, that's really 04508 * what we wanted to do). 04509 */ 04510 pattern = (char *) ignorepat->pattern; 04511 strcpy(pattern, value); 04512 ignorepat->next = NULL; 04513 ignorepat->registrar = registrar; 04514 ast_mutex_lock(&con->lock); 04515 for (ignorepatc = con->ignorepats; ignorepatc; ignorepatc = ignorepatc->next) { 04516 ignorepatl = ignorepatc; 04517 if (!strcasecmp(ignorepatc->pattern, value)) { 04518 /* Already there */ 04519 ast_mutex_unlock(&con->lock); 04520 errno = EEXIST; 04521 return -1; 04522 } 04523 } 04524 if (ignorepatl) 04525 ignorepatl->next = ignorepat; 04526 else 04527 con->ignorepats = ignorepat; 04528 ast_mutex_unlock(&con->lock); 04529 return 0; 04530 04531 }
| int ast_context_add_include | ( | const char * | context, | |
| const char * | include, | |||
| const char * | registrar | |||
| ) |
Add a context include.
| context | context to add include to | |
| include | new include to add | |
| registrar | who's registering it |
| 0 | on success | |
| -1 | on error |
Definition at line 4036 of file pbx.c.
References ast_context_add_include2(), ast_unlock_contexts(), and find_context_locked().
Referenced by handle_context_add_include(), and handle_context_add_include_deprecated().
04037 { 04038 int ret = -1; 04039 struct ast_context *c = find_context_locked(context); 04040 04041 if (c) { 04042 ret = ast_context_add_include2(c, include, registrar); 04043 ast_unlock_contexts(); 04044 } 04045 return ret; 04046 }
| int ast_context_add_include2 | ( | struct ast_context * | con, | |
| const char * | include, | |||
| const char * | registrar | |||
| ) |
Add a context include.
| con | context to add the include to | |
| include | include to add | |
| registrar | who registered the context |
| 0 | on success | |
| -1 | on failure |
Definition at line 4298 of file pbx.c.
References ast_build_timing(), ast_calloc, ast_get_context_name(), ast_mutex_lock(), ast_mutex_unlock(), ast_verbose(), errno, free, ast_include::hastime, ast_context::includes, ast_context::lock, 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_compile_ael2(), ast_context_add_include(), and pbx_load_config().
04300 { 04301 struct ast_include *new_include; 04302 char *c; 04303 struct ast_include *i, *il = NULL; /* include, include_last */ 04304 int length; 04305 char *p; 04306 04307 length = sizeof(struct ast_include); 04308 length += 2 * (strlen(value) + 1); 04309 04310 /* allocate new include structure ... */ 04311 if (!(new_include = ast_calloc(1, length))) 04312 return -1; 04313 /* Fill in this structure. Use 'p' for assignments, as the fields 04314 * in the structure are 'const char *' 04315 */ 04316 p = new_include->stuff; 04317 new_include->name = p; 04318 strcpy(p, value); 04319 p += strlen(value) + 1; 04320 new_include->rname = p; 04321 strcpy(p, value); 04322 /* Strip off timing info, and process if it is there */ 04323 if ( (c = strchr(p, '|')) ) { 04324 *c++ = '\0'; 04325 new_include->hastime = ast_build_timing(&(new_include->timing), c); 04326 } 04327 new_include->next = NULL; 04328 new_include->registrar = registrar; 04329 04330 ast_mutex_lock(&con->lock); 04331 04332 /* ... go to last include and check if context is already included too... */ 04333 for (i = con->includes; i; i = i->next) { 04334 if (!strcasecmp(i->name, new_include->name)) { 04335 free(new_include); 04336 ast_mutex_unlock(&con->lock); 04337 errno = EEXIST; 04338 return -1; 04339 } 04340 il = i; 04341 } 04342 04343 /* ... include new context into context list, unlock, return */ 04344 if (il) 04345 il->next = new_include; 04346 else 04347 con->includes = new_include; 04348 if (option_verbose > 2) 04349 ast_verbose(VERBOSE_PREFIX_3 "Including context '%s' in context '%s'\n", new_include->name, ast_get_context_name(con)); 04350 ast_mutex_unlock(&con->lock); 04351 04352 return 0; 04353 }
| int ast_context_add_switch | ( | const char * | context, | |
| const char * | sw, | |||
| const char * | data, | |||
| int | eval, | |||
| const char * | registrar | |||
| ) |
Add a switch.
| context | context to which to add the switch | |
| sw | switch to add | |
| data | data to pass to switch | |
| eval | whether to evaluate variables when running switch | |
| registrar | whoever registered the switch |
| 0 | on success | |
| -1 | on failure |
Definition at line 4360 of file pbx.c.
References ast_context_add_switch2(), ast_unlock_contexts(), and find_context_locked().
04361 { 04362 int ret = -1; 04363 struct ast_context *c = find_context_locked(context); 04364 04365 if (c) { /* found, add switch to this context */ 04366 ret = ast_context_add_switch2(c, sw, data, eval, registrar); 04367 ast_unlock_contexts(); 04368 } 04369 return ret; 04370 }
| int ast_context_add_switch2 | ( | struct ast_context * | con, | |
| const char * | sw, | |||
| const char * | data, | |||
| int | eval, | |||
| const char * | registrar | |||
| ) |
Adds a switch (first param is a ast_context).
Definition at line 4379 of file pbx.c.
References ast_context::alts, ast_calloc, ast_get_context_name(), AST_LIST_INSERT_TAIL, AST_LIST_TRAVERSE, ast_mutex_lock(), ast_mutex_unlock(), ast_verbose(), ast_sw::data, errno, ast_sw::eval, free, ast_sw::list, ast_context::lock, ast_sw::name, option_verbose, ast_sw::registrar, ast_sw::stuff, and VERBOSE_PREFIX_3.
Referenced by ast_compile_ael2(), ast_context_add_switch(), and pbx_load_config().
04381 { 04382 struct ast_sw *new_sw; 04383 struct ast_sw *i; 04384 int length; 04385 char *p; 04386 04387 length = sizeof(struct ast_sw); 04388 length += strlen(value) + 1; 04389 if (data) 04390 length += strlen(data); 04391 length++; 04392 04393 /* allocate new sw structure ... */ 04394 if (!(new_sw = ast_calloc(1, length))) 04395 return -1; 04396 /* ... fill in this structure ... */ 04397 p = new_sw->stuff; 04398 new_sw->name = p; 04399 strcpy(new_sw->name, value); 04400 p += strlen(value) + 1; 04401 new_sw->data = p; 04402 if (data) { 04403 strcpy(new_sw->data, data); 04404 p += strlen(data) + 1; 04405 } else { 04406 strcpy(new_sw->data, ""); 04407 p++; 04408 } 04409 new_sw->eval = eval; 04410 new_sw->registrar = registrar; 04411 04412 /* ... try to lock this context ... */ 04413 ast_mutex_lock(&con->lock); 04414 04415 /* ... go to last sw and check if context is already swd too... */ 04416 AST_LIST_TRAVERSE(&con->alts, i, list) { 04417 if (!strcasecmp(i->name, new_sw->name) && !strcasecmp(i->data, new_sw->data)) { 04418 free(new_sw); 04419 ast_mutex_unlock(&con->lock); 04420 errno = EEXIST; 04421 return -1; 04422 } 04423 } 04424 04425 /* ... sw new context into context list, unlock, return */ 04426 AST_LIST_INSERT_TAIL(&con->alts, new_sw, list); 04427 04428 if (option_verbose > 2) 04429 ast_verbose(VERBOSE_PREFIX_3 "Including switch '%s/%s' in context '%s'\n", new_sw->name, new_sw->data, ast_get_context_name(con)); 04430 04431 ast_mutex_unlock(&con->lock); 04432 04433 return 0; 04434 }
| struct ast_context* ast_context_create | ( | struct ast_context ** | extcontexts, | |
| const char * | name, | |||
| const char * | registrar | |||
| ) | [read] |
Register a new context.
| extcontexts | pointer to the ast_context structure pointer | |
| name | name of the new context | |
| registrar | registrar of the context |
Definition at line 3906 of file pbx.c.
References __ast_context_create().
Referenced by ast_compile_ael2(), do_parking_thread(), load_config(), park_call_full(), reload_config(), and set_config().
03907 { 03908 return __ast_context_create(extcontexts, name, registrar, 0); 03909 }
| void ast_context_destroy | ( | struct ast_context * | con, | |
| const char * | registrar | |||
| ) |
Destroy a context (matches the specified context (or ANY context if NULL).
| con | context to destroy | |
| registrar | who registered it |
Definition at line 5348 of file pbx.c.
References __ast_context_destroy(), ast_unlock_contexts(), and ast_wrlock_contexts().
Referenced by cleanup_stale_contexts(), sla_destroy(), and unload_module().
05349 { 05350 ast_wrlock_contexts(); 05351 __ast_context_destroy(con,registrar); 05352 ast_unlock_contexts(); 05353 }
| struct ast_context* ast_context_find | ( | const char * | name | ) | [read] |
Find a context.
| name | name of the context to find |
Definition at line 896 of file pbx.c.
References ast_rdlock_contexts(), ast_unlock_contexts(), ast_walk_contexts(), and ast_context::name.
Referenced by _macro_exec(), ast_context_verify_includes(), ast_ignore_pattern(), cleanup_stale_contexts(), do_parking_thread(), load_config(), park_call_full(), park_exec(), register_peer_exten(), reload_config(), and set_config().
00897 { 00898 struct ast_context *tmp = NULL; 00899 00900 ast_rdlock_contexts(); 00901 00902 while ( (tmp = ast_walk_contexts(tmp)) ) { 00903 if (!name || !strcasecmp(name, tmp->name)) 00904 break; 00905 } 00906 00907 ast_unlock_contexts(); 00908 00909 return tmp; 00910 }
| struct ast_context* ast_context_find_or_create | ( | struct ast_context ** | extcontexts, | |
| const char * | name, | |||
| const char * | registrar | |||
| ) | [read] |
Definition at line 3911 of file pbx.c.
References __ast_context_create().
Referenced by ast_compile_ael2(), pbx_load_config(), pbx_load_users(), sla_build_station(), and sla_build_trunk().
03912 { 03913 return __ast_context_create(extcontexts, name, registrar, 1); 03914 }
| int ast_context_lockmacro | ( | const char * | context | ) |
locks the macrolock in the given given context
| macrocontext | name of the macro-context to lock |
| 0 | on success | |
| -1 | on failure |
Definition at line 2907 of file pbx.c.
References ast_get_context_name(), ast_mutex_lock(), ast_rdlock_contexts(), ast_unlock_contexts(), ast_walk_contexts(), and ast_context::macrolock.
Referenced by _macro_exec().
02908 { 02909 struct ast_context *c = NULL; 02910 int ret = -1; 02911 02912 ast_rdlock_contexts(); 02913 02914 while ((c = ast_walk_contexts(c))) { 02915 if (!strcmp(ast_get_context_name(c), context)) { 02916 ret = 0; 02917 break; 02918 } 02919 } 02920 02921 ast_unlock_contexts(); 02922 02923 /* if we found context, lock macrolock */ 02924 if (ret == 0) 02925 ret = ast_mutex_lock(&c->macrolock); 02926 02927 return ret; 02928 }
| int ast_context_remove_extension | ( | const char * | context, | |
| const char * | extension, | |||
| int | priority, | |||
| const char * | registrar | |||
| ) |
Simply remove extension from context.
| context | context to remove extension from | |
| extension | which extension to remove | |
| priority | priority of extension to remove (0 to remove all) | |
| callerid | NULL to remove all; non-NULL to match a single record per priority | |
| matchcid | non-zero to match callerid element (if non-NULL); 0 to match default case | |
| registrar | registrar of the extension |
| 0 | on success | |
| -1 | on failure |
Definition at line 2808 of file pbx.c.
References ast_context_remove_extension_callerid().
Referenced by destroy_station(), destroy_trunk(), and register_peer_exten().
02809 { 02810 return ast_context_remove_extension_callerid(context, extension, priority, NULL, 0, registrar); 02811 }
| 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.
Definition at line 2835 of file pbx.c.
References ast_context_remove_extension_callerid2().
Referenced by do_parking_thread(), load_config(), and park_exec().
02836 { 02837 return ast_context_remove_extension_callerid2(con, extension, priority, NULL, 0, registrar); 02838 }
| int ast_context_remove_extension_callerid | ( | const char * | context, | |
| const char * | extension, | |||
| int | priority, | |||
| const char * | callerid, | |||
| int | matchcid, | |||
| const char * | registrar | |||
| ) |
Definition at line 2813 of file pbx.c.
References ast_context_remove_extension_callerid2(), ast_unlock_contexts(), and find_context_locked().
Referenced by ast_context_remove_extension(), handle_context_remove_extension(), and handle_context_remove_extension_deprecated().
02814 { 02815 int ret = -1; /* default error return */ 02816 struct ast_context *c = find_context_locked(context); 02817 02818 if (c) { /* ... remove extension ... */ 02819 ret = ast_context_remove_extension_callerid2(c, extension, priority, callerid, matchcid, registrar); 02820 ast_unlock_contexts(); 02821 } 02822 return ret; 02823 }
| int ast_context_remove_extension_callerid2 | ( | struct ast_context * | con, | |
| const char * | extension, | |||
| int | priority, | |||
| const char * | callerid, | |||
| int | matchcid, | |||
| const char * | registrar | |||
| ) |
Definition at line 2840 of file pbx.c.
References ast_mutex_lock(), ast_mutex_unlock(), ast_exten::cidmatch, destroy_exten(), ast_exten::exten, exten, ast_context::lock, ast_exten::next, ast_exten::peer, ast_exten::priority, ast_exten::registrar, and ast_context::root.
Referenced by ast_context_remove_extension2(), and ast_context_remove_extension_callerid().
02841 { 02842 struct ast_exten *exten, *prev_exten = NULL; 02843 struct ast_exten *peer; 02844 struct ast_exten *previous_peer = NULL; 02845 struct ast_exten *next_peer = NULL; 02846 int found = 0; 02847 02848 ast_mutex_lock(&con->lock); 02849 02850 /* scan the extension list to find first matching extension-registrar */ 02851 for (exten = con->root; exten; prev_exten = exten, exten = exten->next) { 02852 if (!strcmp(exten->exten, extension) && 02853 (!registrar || !strcmp(exten->registrar, registrar))) 02854 break; 02855 } 02856 if (!exten) { 02857 /* we can't find right extension */ 02858 ast_mutex_unlock(&con->lock); 02859 return -1; 02860 } 02861 02862 /* scan the priority list to remove extension with exten->priority == priority */ 02863 for (peer = exten, next_peer = exten->peer ? exten->peer : exten->next; 02864 peer && !strcmp(peer->exten, extension); 02865 peer = next_peer, next_peer = next_peer ? (next_peer->peer ? next_peer->peer : next_peer->next) : NULL) { 02866 if ((priority == 0 || peer->priority == priority) && 02867 (!callerid || !matchcid || (matchcid && !strcmp(peer->cidmatch, callerid))) && 02868 (!registrar || !strcmp(peer->registrar, registrar) )) { 02869 found = 1; 02870 02871 /* we are first priority extension? */ 02872 if (!previous_peer) { 02873 /* 02874 * We are first in the priority chain, so must update the extension chain. 02875 * The next node is either the next priority or the next extension 02876 */ 02877 struct ast_exten *next_node = peer->peer ? peer->peer : peer->next; 02878 02879 if (!prev_exten) { /* change the root... */ 02880 con->root = next_node; 02881 } else { 02882 prev_exten->next = next_node; /* unlink */ 02883 } 02884 if (peer->peer) { /* update the new head of the pri list */ 02885 peer->peer->next = peer->next; 02886 } 02887 } else { /* easy, we are not first priority in extension */ 02888 previous_peer->peer = peer->peer; 02889 } 02890 02891 /* now, free whole priority extension */ 02892 destroy_exten(peer); 02893 } else { 02894 previous_peer = peer; 02895 } 02896 } 02897 ast_mutex_unlock(&con->lock); 02898 return found ? 0 : -1; 02899 }
| int ast_context_remove_ignorepat | ( | const char * | context, | |
| const char * | ignorepat, | |||
| const char * | registrar | |||
| ) |
Definition at line 4440 of file pbx.c.
References ast_context_remove_ignorepat2(), ast_unlock_contexts(), and find_context_locked().
Referenced by handle_context_remove_ignorepat(), and handle_context_remove_ignorepat_deprecated().
04441 { 04442 int ret = -1; 04443 struct ast_context *c = find_context_locked(context); 04444 04445 if (c) { 04446 ret = ast_context_remove_ignorepat2(c, ignorepat, registrar); 04447 ast_unlock_contexts(); 04448 } 04449 return ret; 04450 }
| int ast_context_remove_ignorepat2 | ( | struct ast_context * | con, | |
| const char * | ignorepat, | |||
| const char * | registrar | |||
| ) |
Definition at line 4452 of file pbx.c.
References ast_mutex_lock(), ast_mutex_unlock(), errno, free, ast_context::ignorepats, ast_context::lock, ast_ignorepat::next, ast_ignorepat::pattern, and ast_ignorepat::registrar.
Referenced by ast_context_remove_ignorepat().
04453 { 04454 struct ast_ignorepat *ip, *ipl = NULL; 04455 04456 ast_mutex_lock(&con->lock); 04457 04458 for (ip = con->ignorepats; ip; ip = ip->next) { 04459 if (!strcmp(ip->pattern, ignorepat) && 04460 (!registrar || (registrar == ip->registrar))) { 04461 if (ipl) { 04462 ipl->next = ip->next; 04463 free(ip); 04464 } else { 04465 con->ignorepats = ip->next; 04466 free(ip); 04467 } 04468 ast_mutex_unlock(&con->lock); 04469 return 0; 04470 } 04471 ipl = ip; 04472 } 04473 04474 ast_mutex_unlock(&con->lock); 04475 errno = EINVAL; 04476 return -1; 04477 }
| int ast_context_remove_include | ( | const char * | context, | |
| const char * | include, | |||
| const char * | registrar | |||
| ) |
Remove a context include.
| 0 | on success | |
| -1 | on failure |
Definition at line 2704 of file pbx.c.
References ast_context_remove_include2(), ast_unlock_contexts(), and find_context_locked().
Referenced by handle_context_dont_include_deprecated(), and handle_context_remove_include().
02705 { 02706 int ret = -1; 02707 struct ast_context *c = find_context_locked(context); 02708 02709 if (c) { 02710 /* found, remove include from this context ... */ 02711 ret = ast_context_remove_include2(c, include, registrar); 02712 ast_unlock_contexts(); 02713 } 02714 return ret; 02715 }
| int ast_context_remove_include2 | ( | struct ast_context * | con, | |
| const char * | include, | |||
| const char * | registrar | |||
| ) |
Removes an include by an ast_context structure.
| 0 | on success | |
| -1 | on success |
Definition at line 2725 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().
02726 { 02727 struct ast_include *i, *pi = NULL; 02728 int ret = -1; 02729 02730 ast_mutex_lock(&con->lock); 02731 02732 /* find our include */ 02733 for (i = con->includes; i; pi = i, i = i->next) { 02734 if (!strcmp(i->name, include) && 02735 (!registrar || !strcmp(i->registrar, registrar))) { 02736 /* remove from list */ 02737 if (pi) 02738 pi->next = i->next; 02739 else 02740 con->includes = i->next; 02741 /* free include and return */ 02742 free(i); 02743 ret = 0; 02744 break; 02745 } 02746 } 02747 02748 ast_mutex_unlock(&con->lock); 02749 return ret; 02750 }
| int ast_context_remove_switch | ( | const char * | context, | |
| const char * | sw, | |||
| const char * | data, | |||
| const char * | registrar | |||
| ) |
Remove a switch.
Removes a switch with the given parameters
| 0 | on success | |
| -1 | on failure |
Definition at line 2757 of file pbx.c.
References ast_context_remove_switch2(), ast_unlock_contexts(), and find_context_locked().
02758 { 02759 int ret = -1; /* default error return */ 02760 struct ast_context *c = find_context_locked(context); 02761 02762 if (c) { 02763 /* remove switch from this context ... */ 02764 ret = ast_context_remove_switch2(c, sw, data, registrar); 02765 ast_unlock_contexts(); 02766 } 02767 return ret; 02768 }
| 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.
Definition at line 2778 of file pbx.c.
References ast_context::alts, AST_LIST_REMOVE_CURRENT, AST_LIST_TRAVERSE_SAFE_BEGIN, AST_LIST_TRAVERSE_SAFE_END, ast_mutex_lock(), ast_mutex_unlock(), ast_sw::data, free, ast_sw::list, ast_context::lock, ast_sw::name, and ast_sw::registrar.
Referenced by ast_context_remove_switch().
02779 { 02780 struct ast_sw *i; 02781 int ret = -1; 02782 02783 ast_mutex_lock(&con->lock); 02784 02785 /* walk switches */ 02786 AST_LIST_TRAVERSE_SAFE_BEGIN(&con->alts, i, list) { 02787 if (!strcmp(i->name, sw) && !strcmp(i->data, data) && 02788 (!registrar || !strcmp(i->registrar, registrar))) { 02789 /* found, remove from list */ 02790 AST_LIST_REMOVE_CURRENT(&con->alts, list); 02791 free(i); /* free switch and return */ 02792 ret = 0; 02793 break; 02794 } 02795 } 02796 AST_LIST_TRAVERSE_SAFE_END 02797 02798 ast_mutex_unlock(&con->lock); 02799 02800 return ret; 02801 }
| int ast_context_unlockmacro | ( | const char * | context | ) |
Unlocks the macrolock in the given context.
| macrocontext | name of the macro-context to unlock |
| 0 | on success | |
| -1 | on failure |
Definition at line 2935 of file pbx.c.
References ast_get_context_name(), ast_mutex_unlock(), ast_rdlock_contexts(), ast_unlock_contexts(), ast_walk_contexts(), and ast_context::macrolock.
Referenced by _macro_exec().
02936 { 02937 struct ast_context *c = NULL; 02938 int ret = -1; 02939 02940 ast_rdlock_contexts(); 02941 02942 while ((c = ast_walk_contexts(c))) { 02943 if (!strcmp(ast_get_context_name(c), context)) { 02944 ret = 0; 02945 break; 02946 } 02947 } 02948 02949 ast_unlock_contexts(); 02950 02951 /* if we found context, unlock macrolock */ 02952 if (ret == 0) 02953 ret = ast_mutex_unlock(&c->macrolock); 02954 02955 return ret; 02956 }
| int ast_context_verify_includes | ( | struct ast_context * | con | ) |
Verifies includes in an ast_contect structure.
| con | context in which to verify the includes |
| 0 | if no problems found | |
| -1 | if there were any missing context |
Definition at line 6312 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().
06313 { 06314 struct ast_include *inc = NULL; 06315 int res = 0; 06316 06317 while ( (inc = ast_walk_context_includes(con, inc)) ) { 06318 if (ast_context_find(inc->rname)) 06319 continue; 06320 06321 res = -1; 06322 ast_log(LOG_WARNING, "Context '%s' tries to include nonexistent context '%s'\n", 06323 ast_get_context_name(con), inc->rname); 06324 break; 06325 } 06326 06327 return res; 06328 }
| struct ast_custom_function* ast_custom_function_find | ( | const char * | name | ) | [read] |
Definition at line 1455 of file pbx.c.
References ast_custom_function::acflist, AST_LIST_LOCK, AST_LIST_TRAVERSE, AST_LIST_UNLOCK, and ast_custom_function::name.
Referenced by ast_custom_function_register(), ast_func_read(), ast_func_write(), handle_show_function(), and handle_show_function_deprecated().
01456 { 01457 struct ast_custom_function *acf = NULL; 01458 01459 AST_LIST_LOCK(&acf_root); 01460 AST_LIST_TRAVERSE(&acf_root, acf, acflist) { 01461 if (!strcmp(name, acf->name)) 01462 break; 01463 } 01464 AST_LIST_UNLOCK(&acf_root); 01465 01466 return acf; 01467 }
| int ast_custom_function_register | ( | struct ast_custom_function * | acf | ) |
Reigster a custom function.
Definition at line 1491 of file pbx.c.
References ast_custom_function::acflist, ast_custom_function_find(), AST_LIST_INSERT_BEFORE_CURRENT, AST_LIST_INSERT_TAIL, AST_LIST_LOCK, AST_LIST_TRAVERSE_SAFE_BEGIN, AST_LIST_TRAVERSE_SAFE_END, AST_LIST_UNLOCK, ast_log(), ast_verbose(), LOG_ERROR, ast_custom_function::name, option_verbose, and VERBOSE_PREFIX_2.
Referenced by load_module(), odbc_load_module(), and reload().
01492 { 01493 struct ast_custom_function *cur; 01494 01495 if (!acf) 01496 return -1; 01497 01498 AST_LIST_LOCK(&acf_root); 01499 01500 if (ast_custom_function_find(acf->name)) { 01501 ast_log(LOG_ERROR, "Function %s already registered.\n", acf->name); 01502 AST_LIST_UNLOCK(&acf_root); 01503 return -1; 01504 } 01505 01506 /* Store in alphabetical order */ 01507 AST_LIST_TRAVERSE_SAFE_BEGIN(&acf_root, cur, acflist) { 01508 if (strcasecmp(acf->name, cur->name) < 0) { 01509 AST_LIST_INSERT_BEFORE_CURRENT(&acf_root, acf, acflist); 01510 break; 01511 } 01512 } 01513 AST_LIST_TRAVERSE_SAFE_END 01514 if (!cur) 01515 AST_LIST_INSERT_TAIL(&acf_root, acf, acflist); 01516 01517 AST_LIST_UNLOCK(&acf_root); 01518 01519 if (option_verbose > 1) 01520 ast_verbose(VERBOSE_PREFIX_2 "Registered custom function %s\n", acf->name); 01521 01522 return 0; 01523 }
| int ast_custom_function_unregister | ( | struct ast_custom_function * | acf | ) |
Unregister a custom function.
Definition at line 1469 of file pbx.c.
References ast_custom_function::acflist, AST_LIST_LOCK, AST_LIST_REMOVE_CURRENT, AST_LIST_TRAVERSE_SAFE_BEGIN, AST_LIST_TRAVERSE_SAFE_END, AST_LIST_UNLOCK, ast_verbose(), ast_custom_function::name, option_verbose, and VERBOSE_PREFIX_2.
Referenced by odbc_unload_module(), reload(), and unload_module().
01470 { 01471 struct ast_custom_function *cur; 01472 01473 if (!acf) 01474 return -1; 01475 01476 AST_LIST_LOCK(&acf_root); 01477 AST_LIST_TRAVERSE_SAFE_BEGIN(&acf_root, cur, acflist) { 01478 if (cur == acf) { 01479 AST_LIST_REMOVE_CURRENT(&acf_root, acflist); 01480 if (option_verbose > 1) 01481 ast_verbose(VERBOSE_PREFIX_2 "Unregistered custom function %s\n", acf->name); 01482 break; 01483 } 01484 } 01485 AST_LIST_TRAVERSE_SAFE_END 01486 AST_LIST_UNLOCK(&acf_root); 01487 01488 return acf ? 0 : -1; 01489 }
| int ast_exists_extension | ( | struct ast_channel * | c, | |
| const char * | context, | |||
| const char * | exten, | |||
| int | priority, | |||
| const char * | callerid | |||
| ) |
Determine whether an extension exists.
| c | this is not important | |
| context | which context to look in | |
| exten | which extension to search for | |
| priority | priority of the action within the extension | |
| callerid | callerid to search for |
Definition at line 2291 of file pbx.c.
References E_MATCH, and pbx_extension_helper().
Referenced by __ast_goto_if_exists(), __ast_pbx_run(), __login_exec(), _macro_exec(), agentmonitoroutgoing_exec(), answer_call(), ast_app_dtget(), ast_bridge_call(), ast_pbx_outgoing_exten(), builtin_atxfer(), builtin_blindtransfer(), cb_events(), conf_run(), console_dial(), console_dial_deprecated(), console_transfer(), console_transfer_deprecated(), dahdi_handle_dtmfup(), disa_exec(), dp_lookup(), dundi_lookup_local(), get_also_info(), get_destination(), get_refer_info(), handle_link_data(), handle_link_phone_dtmf(), handle_stimulus_message(), leave_voicemail(), local_alloc(), local_call(), local_devicestate(), local_dtmf_helper(), loopback_exists(), metermaidstate(), mgcp_ss(), misdn_overlap_dial_task(), nv_background_detect_exec(), nv_detectfax_exec(), park_call_full(), parkandannounce_exec(), pbx_builtin_waitexten(), phone_check_exception(), process_ast_dsp(), register_peer_exten(), rpt_exec(), skinny_ss(), socket_process(), ss_thread(), and waitstream_core().
02292 { 02293 return pbx_extension_helper(c, NULL, context, exten, priority, NULL, callerid, E_MATCH); 02294 }
| int ast_explicit_goto | ( | struct ast_channel * | chan, | |
| const char * | context, | |||
| const char * | exten, | |||
| int | priority | |||
| ) |
Definition at line 4567 of file pbx.c.
References ast_channel_lock, ast_channel_unlock, ast_copy_string(), 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(), disa_exec(), do_bridge_masquerade(), and handle_setpriority().
04568 { 04569 if (!chan) 04570 return -1; 04571 04572 ast_channel_lock(chan); 04573 04574 if (!ast_strlen_zero(context)) 04575 ast_copy_string(chan->context, context, sizeof(chan->context)); 04576 if (!ast_strlen_zero(exten)) 04577 ast_copy_string(chan->exten, exten, sizeof(chan->exten)); 04578 if (priority > -1) { 04579 chan->priority = priority; 04580 /* see flag description in channel.h for explanation */ 04581 if (ast_test_flag(chan, AST_FLAG_IN_AUTOLOOP)) 04582 chan->priority--; 04583 } 04584 04585 ast_channel_unlock(chan); 04586 04587 return 0; 04588 }
| int ast_extension_close | ( | const char * | pattern, | |
| const char * | data, | |||
| int | needmore | |||
| ) |
Definition at line 889 of file pbx.c.
References ast_log(), E_CANMATCH, E_MATCHMORE, extension_match_core(), and LOG_WARNING.
Referenced by realtime_switch_common().
00890 { 00891 if (needmore != E_MATCHMORE && needmore != E_CANMATCH) 00892 ast_log(LOG_WARNING, "invalid argument %d\n", needmore); 00893 return extension_match_core(pattern, data, needmore); 00894 }
| int ast_extension_match | ( | const char * | pattern, | |
| const char * | extension | |||
| ) |
Determine if a given extension matches a given pattern (in NXX format).
| pattern | pattern to match | |
| extension | extension to check against the pattern. |
| 1 | on match | |
| 0 | on failure |
Definition at line 884 of file pbx.c.
References E_MATCH, and extension_match_core().
Referenced by ast_ignore_pattern(), do_say(), find_matching_priority(), loopback_canmatch(), loopback_exists(), loopback_matchmore(), matchcid(), misdn_cfg_is_msn_valid(), realtime_switch_common(), and show_dialplan_helper().
00885 { 00886 return extension_match_core(pattern, data, E_MATCH); 00887 }
| int ast_extension_patmatch | ( | const char * | pattern, | |
| const char * | data | |||
| ) |
| int ast_extension_state | ( | struct ast_channel * | c, | |
| const char * | context, | |||
| const char * | exten | |||
| ) |
Uses hint and devicestate callback to get the state of an extension.
| c | this is not important | |
| context | which context to look in | |
| exten | which extension to get state |
Definition at line 2015 of file pbx.c.
References ast_extension_state2(), and ast_hint_extension().
Referenced by action_extensionstate(), and handle_request_subscribe().
02016 { 02017 struct ast_exten *e; 02018 02019 e = ast_hint_extension(c, context, exten); /* Do we have a hint for this extension ? */ 02020 if (!e) 02021 return -1; /* No hint, return -1 */ 02022 02023 return ast_extension_state2(e); /* Check all devices in the hint */ 02024 }
| const char* ast_extension_state2str | ( | int | extension_state | ) |
Return string representation of the state of an extension.
| extension_state | is the numerical state delivered by ast_extension_state |
Definition at line 2003 of file pbx.c.
References extension_states, and cfextension_states::text.
Referenced by __sip_show_channels(), cb_extensionstate(), handle_request_subscribe(), and handle_show_hints().
02004 { 02005 int i; 02006 02007 for (i = 0; (i < (sizeof(extension_states) / sizeof(extension_states[0]))); i++) { 02008 if (extension_states[i].extension_state == extension_state) 02009 return extension_states[i].text; 02010 } 02011 return "Unknown"; 02012 }
| int ast_extension_state_add | ( | const char * | context, | |
| const char * | exten, | |||
| ast_state_cb_type | callback, | |||
| void * | data | |||
| ) |
Registers a state change callback.
| context | which context to look in | |
| exten | which extension to get state | |
| callback | callback to call if state changed | |
| data | to pass to callback |
| -1 | on failure | |
| ID | on success |
Definition at line 2070 of file pbx.c.
References ast_calloc, ast_hint_extension(), AST_LIST_LOCK, AST_LIST_TRAVERSE, AST_LIST_UNLOCK, ast_state_cb::callback, ast_hint::callbacks, ast_state_cb::data, ast_hint::exten, ast_state_cb::id, ast_sw::list, ast_state_cb::next, statecbs, and stateid.
Referenced by handle_request_subscribe(), and init_manager().
02072 { 02073 struct ast_hint *hint; 02074 struct ast_state_cb *cblist; 02075 struct ast_exten *e; 02076 02077 /* If there's no context and extension: add callback to statecbs list */ 02078 if (!context && !exten) { 02079 AST_LIST_LOCK(&hints); 02080 02081 for (cblist = statecbs; cblist; cblist = cblist->next) { 02082 if (cblist->callback == callback) { 02083 cblist->data = data; 02084 AST_LIST_UNLOCK(&hints); 02085 return 0; 02086 } 02087 } 02088 02089 /* Now insert the callback */ 02090 if (!(cblist = ast_calloc(1, sizeof(*cblist)))) { 02091 AST_LIST_UNLOCK(&hints); 02092 return -1; 02093 } 02094 cblist->id = 0; 02095 cblist->callback = callback; 02096 cblist->data = data; 02097 02098 cblist->next = statecbs; 02099 statecbs = cblist; 02100 02101 AST_LIST_UNLOCK(&hints); 02102 return 0; 02103 } 02104 02105 if (!context || !exten) 02106 return -1; 02107 02108 /* This callback type is for only one hint, so get the hint */ 02109 e = ast_hint_extension(NULL, context, exten); 02110 if (!e) { 02111 return -1; 02112 } 02113 02114 /* Find the hint in the list of hints */ 02115 AST_LIST_LOCK(&hints); 02116 02117 AST_LIST_TRAVERSE(&hints, hint, list) { 02118 if (hint->exten == e) 02119 break; 02120 } 02121 02122 if (!hint) { 02123 /* We have no hint, sorry */ 02124 AST_LIST_UNLOCK(&hints); 02125 return -1; 02126 } 02127 02128 /* Now insert the callback in the callback list */ 02129 if (!(cblist = ast_calloc(1, sizeof(*cblist)))) { 02130 AST_LIST_UNLOCK(&hints); 02131 return -1; 02132 } 02133 cblist->id = stateid++; /* Unique ID for this callback */ 02134 cblist->callback = callback; /* Pointer to callback routine */ 02135 cblist->data = data; /* Data for the callback */ 02136 02137 cblist->next = hint->callbacks; 02138 hint->callbacks = cblist; 02139 02140 AST_LIST_UNLOCK(&hints); 02141 return cblist->id; 02142 }
| int ast_extension_state_del | ( | int | id, | |
| ast_state_cb_type | callback | |||
| ) |
Deletes a registered state change callback by ID.
| id | of the callback to delete | |
| callback | callback |
| 0 | success | |
| -1 | failure |
Definition at line 2145 of file pbx.c.
References AST_LIST_LOCK, AST_LIST_TRAVERSE, AST_LIST_UNLOCK, ast_hint::callbacks, free, ast_sw::list, ast_state_cb::next, and statecbs.
Referenced by __sip_destroy(), and handle_request_subscribe().
02146 { 02147 struct ast_state_cb **p_cur = NULL; /* address of pointer to us */ 02148 int ret = -1; 02149 02150 if (!id && !callback) 02151 return -1; 02152 02153 AST_LIST_LOCK(&hints); 02154 02155 if (!id) { /* id == 0 is a callback without extension */ 02156 for (p_cur = &statecbs; *p_cur; p_cur = &(*p_cur)->next) { 02157 if ((*p_cur)->callback == callback) 02158 break; 02159 } 02160 } else { /* callback with extension, find the callback based on ID */ 02161 struct ast_hint *hint; 02162 AST_LIST_TRAVERSE(&hints, hint, list) { 02163 for (p_cur = &hint->callbacks; *p_cur; p_cur = &(*p_cur)->next) { 02164 if ((*p_cur)->id == id) 02165 break; 02166 } 02167 if (*p_cur) /* found in the inner loop */ 02168 break; 02169 } 02170 } 02171 if (p_cur && *p_cur) { 02172 struct ast_state_cb *cur = *p_cur; 02173 *p_cur = cur->next; 02174 free(cur); 02175 ret = 0; 02176 } 02177 AST_LIST_UNLOCK(&hints); 02178 return ret; 02179 }
| int ast_findlabel_extension | ( | struct ast_channel * | c, | |
| const char * | context, | |||
| const char * | exten, | |||
| const char * | label, | |||
| const char * | callerid | |||
| ) |
Find the priority of an extension that has the specified label.
| c | this is not important | |
| context | which context to look in | |
| exten | which extension to search for | |
| label | label of the action within the extension to match to priority | |
| callerid | callerid to search for |
Definition at line 2296 of file pbx.c.
References E_FINDLABEL, and pbx_extension_helper().
Referenced by action_originate(), action_redirect(), ast_parseable_goto(), asyncgoto_exec(), and handle_setpriority().
02297 { 02298 return pbx_extension_helper(c, NULL, context, exten, 0, label, callerid, E_FINDLABEL); 02299 }
| int ast_findlabel_extension2 | ( | struct ast_channel * | c, | |
| struct ast_context * | con, | |||
| const char * | exten, | |||
| const char * | label, | |||
| const char * | callerid | |||
| ) |
Find the priority of an extension that has the specified label.
This function is the same as ast_findlabel_extension, except that it accepts a pointer to an ast_context structure to specify the context instead of the name of the context. Otherwise, the functions behave the same.
Definition at line 2301 of file pbx.c.
References E_FINDLABEL, and pbx_extension_helper().
Referenced by pbx_load_config().
02302 { 02303 return pbx_extension_helper(c, con, NULL, exten, 0, label, callerid, E_FINDLABEL); 02304 }
| int ast_func_read | ( | struct ast_channel * | chan, | |
| char * | function, | |||
| char * | workspace, | |||
| size_t | len | |||
| ) |
executes a read operation on a function
| chan | Channel to execute on | |
| function | Data containing the function call string (will be modified) | |
| workspace | A pointer to safe memory to use for a return value | |
| len | the number of bytes in workspace |
Definition at line 1545 of file pbx.c.
References ast_custom_function_find(), ast_log(), func_args(), LOG_ERROR, and ast_custom_function::read.
Referenced by action_getvar(), handle_getvariable(), and pbx_substitute_variables_helper_full().
01546 { 01547 char *args = func_args(function); 01548 struct ast_custom_function *acfptr = ast_custom_function_find(function); 01549 01550 if (acfptr == NULL) 01551 ast_log(LOG_ERROR, "Function %s not registered\n", function); 01552 else if (!acfptr->read) 01553 ast_log(LOG_ERROR, "Function %s cannot be read\n", function); 01554 else 01555 return acfptr->read(chan, function, args, workspace, len); 01556 return -1; 01557 }
| int ast_func_write | ( | struct ast_channel * | chan, | |
| char * | function, | |||
| const char * | value | |||
| ) |
executes a write operation on a function
| chan | Channel to execute on | |
| function | Data containing the function call string (will be modified) | |
| value | A value parameter to pass for writing |
Definition at line 1559 of file pbx.c.
References ast_custom_function_find(), ast_log(), func_args(), LOG_ERROR, and ast_custom_function::write.
Referenced by pbx_builtin_pushvar_helper(), and pbx_builtin_setvar_helper().
01560 { 01561 char *args = func_args(function); 01562 struct ast_custom_function *acfptr = ast_custom_function_find(function); 01563 01564 if (acfptr == NULL) 01565 ast_log(LOG_ERROR, "Function %s not registered\n", function); 01566 else if (!acfptr->write) 01567 ast_log(LOG_ERROR, "Function %s cannot be written to\n", function); 01568 else 01569 return acfptr->write(chan, function, args, value); 01570 01571 return -1; 01572 }
| const char* ast_get_context_name | ( | struct ast_context * | con | ) |
Definition at line 6169 of file pbx.c.
References ast_context::name.
Referenced by _macro_exec(), ast_context_add_include2(), ast_context_add_switch2(), ast_context_lockmacro(), ast_context_unlockmacro(), ast_context_verify_includes(), complete_context_add_extension(), complete_context_add_extension_deprecated(), complete_context_add_ignorepat(), complete_context_add_ignorepat_deprecated(), complete_context_add_include(), complete_context_add_include_deprecated(), complete_context_dont_include_deprecated(), complete_context_remove_extension(), complete_context_remove_extension_deprecated(), complete_context_remove_ignorepat(), complete_context_remove_ignorepat_deprecated(), complete_context_remove_include(), complete_show_dialplan_context(), dundi_precache_full(), find_context_locked(), find_matching_endwhile(), find_matching_priority(), handle_save_dialplan(), handle_show_hints(), and show_dialplan_helper().
06170 { 06171 return con ? con->name : NULL; 06172 }
| const char* ast_get_context_registrar | ( | struct ast_context * | c | ) |
Definition at line 6207 of file pbx.c.
References ast_context::registrar.
Referenced by handle_save_dialplan(), and show_dialplan_helper().
06208 { 06209 return c ? c->registrar : NULL; 06210 }
| const char* ast_get_extension_app | ( | struct ast_exten * | e | ) |
Definition at line 6237 of file pbx.c.
References ast_exten::app.
Referenced by _macro_exec(), ast_add_hint(), ast_extension_state2(), ast_get_hint(), ast_hint_state_changed(), find_matching_endwhile(), handle_save_dialplan(), handle_show_hints(), and print_ext().
06238 { 06239 return e ? e->app : NULL; 06240 }
| void* ast_get_extension_app_data | ( | struct ast_exten * | e | ) |
Definition at line 6242 of file pbx.c.
References ast_exten::data.
Referenced by _macro_exec(), ast_get_hint(), handle_save_dialplan(), and print_ext().
06243 { 06244 return e ? e->data : NULL; 06245 }
| const char* ast_get_extension_cidmatch | ( | struct ast_exten * | e | ) |
Definition at line 6232 of file pbx.c.
References ast_exten::cidmatch.
Referenced by complete_context_remove_extension(), complete_context_remove_extension_deprecated(), find_matching_priority(), and handle_save_dialplan().
06233 { 06234 return e ? e->cidmatch : NULL; 06235 }
| struct ast_context* ast_get_extension_context | ( | struct ast_exten * | exten | ) | [read] |
Definition at line 6174 of file pbx.c.
References ast_exten::parent.
Referenced by handle_show_hints().
06175 { 06176 return exten ? exten->parent : NULL; 06177 }
| const char* ast_get_extension_label | ( | struct ast_exten * | e | ) |
Definition at line 6184 of file pbx.c.
References ast_exten::label.
Referenced by handle_save_dialplan(), and show_dialplan_helper().
| int ast_get_extension_matchcid | ( | struct ast_exten * | e | ) |
Definition at line 6227 of file pbx.c.
References ast_exten::matchcid.
Referenced by complete_context_remove_extension(), complete_context_remove_extension_deprecated(), find_matching_priority(), and handle_save_dialplan().
06228 { 06229 return e ? e->matchcid : 0; 06230 }
| const char* ast_get_extension_name | ( | struct ast_exten * | exten | ) |
Definition at line 6179 of file pbx.c.
References ast_exten::exten.
Referenced by ast_add_hint(), complete_context_remove_extension(), complete_context_remove_extension_deprecated(), dundi_precache_full(), find_matching_priority(), handle_save_dialplan(), handle_show_hints(), and show_dialplan_helper().
06180 { 06181 return exten ? exten->exten : NULL; 06182 }
| int ast_get_extension_priority | ( | struct ast_exten * | exten | ) |
Definition at line 6199 of file pbx.c.
References ast_exten::priority.
Referenced by complete_context_remove_extension(), complete_context_remove_extension_deprecated(), find_matching_priority(), handle_save_dialplan(), and print_ext().
06200 { 06201 return exten ? exten->priority : -1; 06202 }
| const char* ast_get_extension_registrar | ( | struct ast_exten * | e | ) |
Definition at line 6212 of file pbx.c.
References ast_exten::registrar.
Referenced by handle_save_dialplan(), and show_dialplan_helper().
06213 { 06214 return e ? e->registrar : NULL; 06215 }
| int ast_get_hint | ( | char * | hint, | |
| int | hintsize, | |||
| char * | name, | |||
| int | namesize, | |||
| struct ast_channel * | c, | |||
| const char * | context, | |||
| const char * | exten | |||
| ) |
If an extension exists, return non-zero.
| hint | buffer for hint | |
| maxlen | size of hint buffer | |
| name | buffer for name portion of hint | |
| maxnamelen | size of name buffer | |
| c | this is not important | |
| context | which context to look in | |
| exten | which extension to search for |
Definition at line 2274 of file pbx.c.
References ast_copy_string(), ast_get_extension_app(), ast_get_extension_app_data(), and ast_hint_extension().
Referenced by action_extensionstate(), get_cid_name(), get_destination(), pbx_retrieve_variable(), and transmit_state_notify().
02275 { 02276 struct ast_exten *e = ast_hint_extension(c, context, exten); 02277 02278 if (e) { 02279 if (hint) 02280 ast_copy_string(hint, ast_get_extension_app(e), hintsize); 02281 if (name) { 02282 const char *tmp = ast_get_extension_app_data(e); 02283 if (tmp) 02284 ast_copy_string(name, tmp, namesize); 02285 } 02286 return -1; 02287 } 02288 return 0; 02289 }
| const char* ast_get_ignorepat_name | ( | struct ast_ignorepat * | ip | ) |
Definition at line 6194 of file pbx.c.
References ast_ignorepat::pattern.
Referenced by complete_context_remove_ignorepat(), complete_context_remove_ignorepat_deprecated(), handle_save_dialplan(), lookup_c_ip(), and show_dialplan_helper().
06195 { 06196 return ip ? ip->pattern : NULL; 06197 }
| const char* ast_get_ignorepat_registrar | ( | struct ast_ignorepat * | ip | ) |
Definition at line 6222 of file pbx.c.
References ast_ignorepat::registrar.
Referenced by handle_save_dialplan(), and show_dialplan_helper().
06223 { 06224 return ip ? ip->registrar : NULL; 06225 }
| const char* ast_get_include_name | ( | struct ast_include * | include | ) |
Definition at line 6189 of file pbx.c.
References ast_include::name.
Referenced by complete_context_dont_include_deprecated(), complete_context_remove_include(), find_matching_priority(), handle_save_dialplan(), lookup_ci(), and show_dialplan_helper().
| const char* ast_get_include_registrar | ( | struct ast_include * | i | ) |
Definition at line 6217 of file pbx.c.
References ast_include::registrar.
Referenced by handle_save_dialplan(), and show_dialplan_helper().
06218 { 06219 return i ? i->registrar : NULL; 06220 }
| const char* ast_get_switch_data | ( | struct ast_sw * | sw | ) |
Definition at line 6252 of file pbx.c.
References ast_sw::data.
Referenced by handle_save_dialplan(), and show_dialplan_helper().
06253 { 06254 return sw ? sw->data : NULL; 06255 }
| const char* ast_get_switch_name | ( | struct ast_sw * | sw | ) |
Definition at line 6247 of file pbx.c.
References ast_sw::name.
Referenced by handle_save_dialplan(), and show_dialplan_helper().
06248 { 06249 return sw ? sw->name : NULL; 06250 }
| const char* ast_get_switch_registrar | ( | struct ast_sw * | sw | ) |
Definition at line 6257 of file pbx.c.
References ast_sw::registrar.
Referenced by handle_save_dialplan(), and show_dialplan_helper().
06258 { 06259 return sw ? sw->registrar : NULL; 06260 }
| int ast_goto_if_exists | ( | struct ast_channel * | chan, | |
| const char * | context, | |||
| const char * | exten, | |||
| int | priority | |||
| ) |
Definition at line 6350 of file pbx.c.
References __ast_goto_if_exists().
Referenced by aqm_exec(), auth_exec(), background_detect_exec(), chanavail_exec(), conf_run(), controlplayback_exec(), do_directory(), hasvoicemail_exec(), leave_voicemail(), lookupblacklist_exec(), onedigit_goto(), ospauth_exec(), ospfinished_exec(), osplookup_exec(), ospnext_exec(), play_mailbox_owner(), playback_exec(), pqm_exec(), privacy_exec(), rqm_exec(), sendimage_exec(), sendtext_exec(), sendurl_exec(), system_exec_helper(), transfer_exec(), upqm_exec(), valid_exit(), vm_box_exists(), vm_exec(), and wait_for_answer().
06351 { 06352 return __ast_goto_if_exists(chan, context, exten, priority, 0); 06353 }
| void ast_hint_state_changed | ( | const char * | device | ) |
Definition at line 2026 of file pbx.c.
References ast_copy_string(), ast_extension_state2(), ast_get_extension_app(), AST_LIST_LOCK, AST_LIST_TRAVERSE, AST_LIST_UNLOCK, AST_MAX_EXTENSION, ast_state_cb::callback, ast_hint::callbacks, ast_state_cb::data, ast_exten::exten, ast_hint::exten, ast_hint::laststate, ast_sw::list, ast_context::name, ast_state_cb::next, ast_exten::parent, parse(), and statecbs.
Referenced by do_state_change().
02027 { 02028 struct ast_hint *hint; 02029 02030 AST_LIST_LOCK(&hints); 02031 02032 AST_LIST_TRAVERSE(&hints, hint, list) { 02033 struct ast_state_cb *cblist; 02034 char buf[AST_MAX_EXTENSION]; 02035 char *parse = buf; 02036 char *cur; 02037 int state; 02038 02039 ast_copy_string(buf, ast_get_extension_app(hint->exten), sizeof(buf)); 02040 while ( (cur = strsep(&parse, "&")) ) { 02041 if (!strcasecmp(cur, device)) 02042 break; 02043 } 02044 if (!cur) 02045 continue; 02046 02047 /* Get device state for this hint */ 02048 state = ast_extension_state2(hint->exten); 02049 02050 if ((state == -1) || (state == hint->laststate)) 02051 continue; 02052 02053 /* Device state changed since last check - notify the watchers */ 02054 02055 /* For general callbacks */ 02056 for (cblist = statecbs; cblist; cblist = cblist->next) 02057 cblist->callback(hint->exten->parent->name, hint->exten->exten, state, cblist->data); 02058 02059 /* For extension callbacks */ 02060 for (cblist = hint->callbacks; cblist; cblist = cblist->next) 02061 cblist->callback(hint->exten->parent->name, hint->exten->exten, state, cblist->data); 02062 02063 hint->laststate = state; /* record we saw the change */ 02064 } 02065 02066 AST_LIST_UNLOCK(&hints); 02067 }
| int ast_ignore_pattern | ( | const char * | context, | |
| const char * | pattern | |||
| ) |
Checks to see if a number should be ignored.
| context | context to search within | |
| pattern | to check whether it should be ignored or not |
| 0 | if the pattern should not be ignored | |
| non-zero | if the pattern should be ignored |
Definition at line 4533 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(), disa_exec(), dp_lookup(), dundi_lookup_local(), handle_enbloc_call_message(), handle_soft_key_event_message(), handle_stimulus_message(), mgcp_ss(), skinny_ss(), and ss_thread().
04534 { 04535 struct ast_context *con = ast_context_find(context); 04536 if (con) { 04537 struct ast_ignorepat *pat; 04538 for (pat = con->ignorepats; pat; pat = pat->next) { 04539 if (ast_extension_match(pat->pattern, pattern)) 04540 return 1; 04541 } 04542 } 04543 04544 return 0; 04545 }
| int ast_lock_context | ( | struct ast_context * | con | ) |
Locks a given context.
| con | context to lock |
| 0 | on success | |
| -1 | on failure |
Definition at line 6156 of file pbx.c.
References ast_mutex_lock(), and ast_context::lock.
Referenced by _macro_exec(), complete_context_dont_include_deprecated(), complete_context_remove_ignorepat(), complete_context_remove_ignorepat_deprecated(), complete_context_remove_include(), dundi_precache_full(), find_matching_endwhile(), handle_save_dialplan(), lookup_c_ip(), lookup_ci(), and show_dialplan_helper().
06157 { 06158 return ast_mutex_lock(&con->lock); 06159 }
| int ast_lock_contexts | ( | void | ) |
Locks the context list.
| 0 | on success | |
| -1 | on error |
Definition at line 6133 of file pbx.c.
References ast_rwlock_wrlock(), and conlock.
Referenced by find_matching_endwhile().
06134 { 06135 return ast_rwlock_wrlock(&conlock); 06136 }
| int ast_matchmore_extension | ( | struct ast_channel * | c, | |
| const char * | context, | |||
| const char * | exten, | |||
| int | priority, | |||
| const char * | callerid | |||
| ) |
Looks to see if adding anything to this extension might match something. (exists ^ canmatch).
| c | not really important XXX | |
| context | context to serach within | |
| exten | extension to check | |
| priority | priority of extension path | |
| callerid | callerid of extension being searched for |
Definition at line 2311 of file pbx.c.
References E_MATCHMORE, and pbx_extension_helper().
Referenced by ast_app_dtget(), collect_digits(), disa_exec(), dp_lookup(), dundi_lookup_local(), handle_stimulus_message(), loopback_matchmore(), mgcp_ss(), skinny_ss(), and ss_thread().
02312 { 02313 return pbx_extension_helper(c, NULL, context, exten, priority, NULL, callerid, E_MATCHMORE); 02314 }
| void ast_merge_contexts_and_delete | ( | struct ast_context ** | extcontexts, | |
| const char * | registrar | |||
| ) |
Merge the temporary contexts into a global contexts list and delete from the global list the ones that are being added.
| extcontexts | pointer to the ast_context structure pointer | |
| registrar | of the context; if it's set the routine will delete all contexts that belong to that registrar; if NULL only the contexts that are specified in extcontexts |
Definition at line 3929 of file pbx.c.
References __ast_context_destroy(), ast_calloc, AST_EXTENSION_REMOVED, AST_LIST_HEAD_INIT_VALUE, AST_LIST_INSERT_HEAD, AST_LIST_LOCK, AST_LIST_REMOVE_HEAD, AST_LIST_TRAVERSE, AST_LIST_UNLOCK, ast_log(), ast_unlock_contexts(), ast_wrlock_contexts(), ast_state_cb::callback, ast_hint::callbacks, context, contexts, ast_state_cb::data, E_MATCH, ast_exten::exten, ast_hint::exten, exten, free, ast_hint::laststate, LOG_DEBUG, LOG_WARNING, ast_context::name, ast_state_cb::next, ast_context::next, option_debug, ast_exten::parent, pbx_find_extension(), PRIORITY_HINT, ast_context::registrar, and pbx_find_info::stacklen.
Referenced by pbx_load_module().
03930 { 03931 struct ast_context *tmp, *lasttmp = NULL; 03932 struct store_hints store = AST_LIST_HEAD_INIT_VALUE; 03933 struct store_hint *this; 03934 struct ast_hint *hint; 03935 struct ast_exten *exten; 03936 int length; 03937 struct ast_state_cb *thiscb, *prevcb; 03938 03939 /* it is very important that this function hold the hint list lock _and_ the conlock 03940 during its operation; not only do we need to ensure that the list of contexts 03941 and extensions does not change, but also that no hint callbacks (watchers) are 03942 added or removed during the merge/delete process 03943 03944 in addition, the locks _must_ be taken in this order, because there are already 03945 other code paths that use this order 03946 */ 03947 ast_wrlock_contexts(); 03948 AST_LIST_LOCK(&hints); 03949 03950 /* preserve all watchers for hints associated with this registrar */ 03951 AST_LIST_TRAVERSE(&hints, hint, list) { 03952 if (hint->callbacks && !strcmp(registrar, hint->exten->parent->registrar)) { 03953 length = strlen(hint->exten->exten) + strlen(hint->exten->parent->name) + 2 + sizeof(*this); 03954 if (!(this = ast_calloc(1, length))) 03955 continue; 03956 this->callbacks = hint->callbacks; 03957 hint->callbacks = NULL; 03958 this->laststate = hint->laststate; 03959 this->context = this->data; 03960 strcpy(this->data, hint->exten->parent->name); 03961 this->exten = this->data + strlen(this->context) + 1; 03962 strcpy(this->exten, hint->exten->exten); 03963 AST_LIST_INSERT_HEAD(&store, this, list); 03964 } 03965 } 03966 03967 tmp = *extcontexts; 03968 if (registrar) { 03969 /* XXX remove previous contexts from same registrar */ 03970 if (option_debug) 03971 ast_log(LOG_DEBUG, "must remove any reg %s\n", registrar); 03972 __ast_context_destroy(NULL,registrar); 03973 while (tmp) { 03974 lasttmp = tmp; 03975 tmp = tmp->next; 03976 } 03977 } else { 03978 /* XXX remove contexts with the same name */ 03979 while (tmp) { 03980 ast_log(LOG_WARNING, "must remove %s reg %s\n", tmp->name, tmp->registrar); 03981 __ast_context_destroy(tmp,tmp->registrar); 03982 lasttmp = tmp; 03983 tmp = tmp->next; 03984 } 03985 } 03986 if (lasttmp) { 03987 lasttmp->next = contexts; 03988 contexts = *extcontexts; 03989 *extcontexts = NULL; 03990 } else 03991 ast_log(LOG_WARNING, "Requested contexts didn't get merged\n"); 03992 03993 /* restore the watchers for hints that can be found; notify those that 03994 cannot be restored 03995 */ 03996 while ((this = AST_LIST_REMOVE_HEAD(&store, list))) { 03997 struct pbx_find_info q = { .stacklen = 0 }; 03998 exten = pbx_find_extension(NULL, NULL, &q, this->context, this->exten, PRIORITY_HINT, NULL, "", E_MATCH); 03999 /* Find the hint in the list of hints */ 04000 AST_LIST_TRAVERSE(&hints, hint, list) { 04001 if (hint->exten == exten) 04002 break; 04003 } 04004 if (!exten || !hint) { 04005 /* this hint has been removed, notify the watchers */ 04006 prevcb = NULL; 04007 thiscb = this->callbacks; 04008 while (thiscb) { 04009 prevcb = thiscb; 04010 thiscb = thiscb->next; 04011 prevcb->callback(this->context, this->exten, AST_EXTENSION_REMOVED, prevcb->data); 04012 free(prevcb); 04013 } 04014 } else { 04015 thiscb = this->callbacks; 04016 while (thiscb->next) 04017 thiscb = thiscb->next; 04018 thiscb->next = hint->callbacks; 04019 hint->callbacks = this->callbacks; 04020 hint->laststate = this->laststate; 04021 } 04022 free(this); 04023 } 04024 04025 AST_LIST_UNLOCK(&hints); 04026 ast_unlock_contexts(); 04027 04028 return; 04029 }
| int ast_parseable_goto | ( | struct ast_channel * | chan, | |
| const char * | goto_string | |||
| ) |
This function will handle locking the channel as needed.
Definition at line 6360 of file pbx.c.
References 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, and ast_channel::priority.
Referenced by _while_exec(), check_goto_on_transfer(), gosub_exec(), ivr_dispatch(), pbx_builtin_goto(), random_exec(), return_exec(), and while_continue_exec().
06361 { 06362 char *exten, *pri, *context; 06363 char *stringp; 06364 int ipri; 06365 int mode = 0; 06366 06367 if (ast_strlen_zero(goto_string)) { 06368 ast_log(LOG_WARNING, "Goto requires an argument (optional context|optional extension|priority)\n"); 06369 return -1; 06370 } 06371 stringp = ast_strdupa(goto_string); 06372 context = strsep(&stringp, "|"); /* guaranteed non-null */ 06373 exten = strsep(&stringp, "|"); 06374 pri = strsep(&stringp, "|"); 06375 if (!exten) { /* Only a priority in this one */ 06376 pri = context; 06377 exten = NULL; 06378 context = NULL; 06379 } else if (!pri) { /* Only an extension and priority in this one */ 06380 pri = exten; 06381 exten = context; 06382 context = NULL; 06383 } 06384 if (*pri == '+') { 06385 mode = 1; 06386 pri++; 06387 } else if (*pri == '-') { 06388 mode = -1; 06389 pri++; 06390 } 06391 if (sscanf(pri, "%d", &ipri) != 1) { 06392 if ((ipri = ast_findlabel_extension(chan, context ? context : chan->context, exten ? exten : chan->exten, 06393 pri, chan->cid.cid_num)) < 1) { 06394 ast_log(LOG_WARNING, "Priority '%s' must be a number > 0, or valid label\n", pri); 06395 return -1; 06396 } else 06397 mode = 0; 06398 } 06399 /* At this point we have a priority and maybe an extension and a context */ 06400 06401 if (mode) 06402 ipri = chan->priority + (ipri * mode); 06403 06404 ast_explicit_goto(chan, context, exten, ipri); 06405 return 0; 06406 06407 }
| 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 | |||
| ) |
Synchronously or asynchronously make an outbound call and send it to a particular application with given extension
Definition at line 5160 of file pbx.c.
References __ast_request_and_dial(), ast_channel::_state, outgoing_helper::account, async_stat::app, app_tmp::app, async_stat::appdata, ast_calloc, ast_cdr_disposition(), ast_cdr_failed(), ast_cdr_setaccount(), ast_channel_lock, ast_channel_unlock, ast_copy_string(), ast_hangup(), ast_log(), 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, app_tmp::chan, app_tmp::data, errno, free, ast_channel::hangupcause, LOG_WARNING, ast_channel::name, option_verbose, async_stat::p, app_tmp::t, async_stat::timeout, outgoing_helper::vars, and VERBOSE_PREFIX_4.
Referenced by action_originate(), attempt_thread(), fast_originate(), and orig_app().
05161 { 05162 struct ast_channel *chan; 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 ast_set_variables(chan, vars); 05182 if (account) 05183 ast_cdr_setaccount(chan, account); 05184 if (chan->_state == AST_STATE_UP) { 05185 res = 0; 05186 if (option_verbose > 3) 05187 ast_verbose(VERBOSE_PREFIX_4 "Channel %s was answered.\n", chan->name); 05188 tmp = ast_calloc(1, sizeof(*tmp)); 05189 if (!tmp) 05190 res = -1; 05191 else { 05192 ast_copy_string(tmp->app, app, sizeof(tmp->app)); 05193 if (appdata) 05194 ast_copy_string(tmp->data, appdata, sizeof(tmp->data)); 05195 tmp->chan = chan; 05196 if (sync > 1) { 05197 if (locked_channel) 05198 ast_channel_unlock(chan); 05199 ast_pbx_run_app(tmp); 05200 } else { 05201 pthread_attr_init(&attr); 05202 pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); 05203 if (locked_channel) 05204 ast_channel_lock(chan); 05205 if (ast_pthread_create(&tmp->t, &attr, ast_pbx_run_app, tmp)) { 05206 ast_log(LOG_WARNING, "Unable to spawn execute thread on %s: %s\n", chan->name, strerror(errno)); 05207 free(tmp); 05208 if (locked_channel) 05209 ast_channel_unlock(chan); 05210 ast_hangup(chan); 05211 res = -1; 05212 } else { 05213 if (locked_channel) 05214 *locked_channel = chan; 05215 } 05216 pthread_attr_destroy(&attr); 05217 } 05218 } 05219 } else { 05220 if (option_verbose > 3) 05221 ast_verbose(VERBOSE_PREFIX_4 "Channel %s was never answered.\n", chan->name); 05222 if (chan->cdr) { /* update the cdr */ 05223 /* here we update the status of the call, which sould be busy. 05224 * if that fails then we set the status to failed */ 05225 if (ast_cdr_disposition(chan->cdr, chan->hangupcause)) 05226 ast_cdr_failed(chan->cdr); 05227 } 05228 ast_hangup(chan); 05229 } 05230 } 05231 05232 if (res < 0) { /* the call failed for some reason */ 05233 if (*reason == 0) { /* if the call failed (not busy or no answer) 05234 * update the cdr with the failed message */ 05235 cdr_res = ast_pbx_outgoing_cdr_failed(); 05236 if (cdr_res != 0) { 05237 res = cdr_res; 05238 goto outgoing_app_cleanup; 05239 } 05240 } 05241 } 05242 05243 } else { 05244 struct async_stat *as; 05245 if (!(as = ast_calloc(1, sizeof(*as)))) { 05246 res = -1; 05247 goto outgoing_app_cleanup; 05248 } 05249 chan = __ast_request_and_dial(type, format, data, timeout, reason, cid_num, cid_name, &oh); 05250 if (!chan) { 05251 free(as); 05252 res = -1; 05253 goto outgoing_app_cleanup; 05254 } 05255 as->chan = chan; 05256 ast_copy_string(as->app, app, sizeof(as->app)); 05257 if (appdata) 05258 ast_copy_string(as->appdata, appdata, sizeof(as->appdata)); 05259 as->timeout = timeout; 05260 ast_set_variables(chan, vars); 05261 if (account) 05262 ast_cdr_setaccount(chan, account); 05263 /* Start a new thread, and get something handling this channel. */ 05264 pthread_attr_init(&attr); 05265 pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); 05266 if (locked_channel) 05267 ast_channel_lock(chan); 05268 if (ast_pthread_create(&as->p, &attr, async_wait, as)) { 05269 ast_log(LOG_WARNING, "Failed to start async wait\n"); 05270 free(as); 05271 if (locked_channel) 05272 ast_channel_unlock(chan); 05273 ast_hangup(chan); 05274 res = -1; 05275 pthread_attr_destroy(&attr); 05276 goto outgoing_app_cleanup; 05277 } else { 05278 if (locked_channel) 05279 *locked_channel = chan; 05280 } 05281 pthread_attr_destroy(&attr); 05282 res = 0; 05283 } 05284 outgoing_app_cleanup: 05285 ast_variables_destroy(vars); 05286 return res; 05287 }
| 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 | |||
| ) |
Synchronously or asynchronously make an outbound call and send it to a particular extension
Definition at line 4994 of file pbx.c.
References __ast_request_and_dial(), ast_channel::_state, ast_calloc, ast_cdr_disposition(), ast_cdr_failed(), ast_cdr_setaccount(), ast_channel_alloc(), ast_channel_lock, ast_channel_unlock, ast_copy_string(), ast_exists_extension(), ast_hangup(), ast_log(), ast_pbx_outgoing_cdr_failed(), ast_pbx_run(), ast_pbx_start(), ast_pthread_create, ast_request_and_dial(), ast_set_variables(), AST_STATE_DOWN, 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, free, ast_channel::hangupcause, LOAD_OH, LOG_ERROR, LOG_WARNING, ast_channel::name, option_verbose, async_stat::p, pbx_builtin_setvar_helper(), set_ext_pri(), async_stat::timeout, and VERBOSE_PREFIX_4.
Referenced by action_originate(), attempt_thread(), fast_originate(), and orig_exten().
04995 { 04996 struct ast_channel *chan; 04997 struct async_stat *as; 04998 int res = -1, cdr_res = -1; 04999 struct outgoing_helper oh; 05000 pthread_attr_t attr; 05001 05002 if (sync) { 05003 LOAD_OH(oh); 05004 chan = __ast_request_and_dial(type, format, data, timeout, reason, cid_num, cid_name, &oh); 05005 if (channel) { 05006 *channel = chan; 05007 if (chan) 05008 ast_channel_lock(chan); 05009 } 05010 if (chan) { 05011 if (chan->_state == AST_STATE_UP) { 05012 res = 0; 05013 if (option_verbose > 3) 05014 ast_verbose(VERBOSE_PREFIX_4 "Channel %s was answered.\n", chan->name); 05015 05016 if (sync > 1) { 05017 if (channel) 05018 ast_channel_unlock(chan); 05019 if (ast_pbx_run(chan)) { 05020 ast_log(LOG_ERROR, "Unable to run PBX on %s\n", chan->name); 05021 if (channel) 05022 *channel = NULL; 05023 ast_hangup(chan); 05024 chan = NULL; 05025 res = -1; 05026 } 05027 } else { 05028 if (ast_pbx_start(chan)) { 05029 ast_log(LOG_ERROR, "Unable to start PBX on %s\n", chan->name); 05030 if (channel) { 05031 *channel = NULL; 05032 ast_channel_unlock(chan); 05033 } 05034 ast_hangup(chan); 05035 res = -1; 05036 } 05037 chan = NULL; 05038 } 05039 } else { 05040 if (option_verbose > 3) 05041 ast_verbose(VERBOSE_PREFIX_4 "Channel %s was never answered.\n", chan->name); 05042 05043 if (chan->cdr) { /* update the cdr */ 05044 /* here we update the status of the call, which sould be busy. 05045 * if that fails then we set the status to failed */ 05046 if (ast_cdr_disposition(chan->cdr, chan->hangupcause)) 05047 ast_cdr_failed(chan->cdr); 05048 } 05049 05050 if (channel) { 05051 *channel = NULL; 05052 ast_channel_unlock(chan); 05053 } 05054 ast_hangup(chan); 05055 chan = NULL; 05056 } 05057 } 05058 05059 if (res < 0) { /* the call failed for some reason */ 05060 if (*reason == 0) { /* if the call failed (not busy or no answer) 05061 * update the cdr with the failed message */ 05062 cdr_res = ast_pbx_outgoing_cdr_failed(); 05063 if (cdr_res != 0) { 05064 res = cdr_res; 05065 goto outgoing_exten_cleanup; 05066 } 05067 } 05068 05069 /* create a fake channel and execute the "failed" extension (if it exists) within the requested context */ 05070 /* check if "failed" exists */ 05071 if (ast_exists_extension(chan, context, "failed", 1, NULL)) { 05072 chan = ast_channel_alloc(0, AST_STATE_DOWN, 0, 0, "", "", "", 0, "OutgoingSpoolFailed"); 05073 if (chan) { 05074 char failed_reason[4] = ""; 05075 if (!ast_strlen_zero(context)) 05076 ast_copy_string(chan->context, context, sizeof(chan->context)); 05077 set_ext_pri(chan, "failed", 1); 05078 ast_set_variables(chan, vars); 05079 snprintf(failed_reason, sizeof(failed_reason), "%d", *reason); 05080 pbx_builtin_setvar_helper(chan, "REASON", failed_reason); 05081 if (account) 05082 ast_cdr_setaccount(chan, account); 05083 if (ast_pbx_run(chan)) { 05084 ast_log(LOG_ERROR, "Unable to run PBX on %s\n", chan->name); 05085 ast_hangup(chan); 05086 } 05087 chan = NULL; 05088 } 05089 } 05090 } 05091 } else { 05092 if (!(as = ast_calloc(1, sizeof(*as)))) { 05093 res = -1; 05094 goto outgoing_exten_cleanup; 05095 } 05096 chan = ast_request_and_dial(type, format, data, timeout, reason, cid_num, cid_name); 05097 if (channel) { 05098 *channel = chan; 05099 if (chan) 05100 ast_channel_lock(chan); 05101 } 05102 if (!chan) { 05103 free(as); 05104 res = -1; 05105 goto outgoing_exten_cleanup; 05106 } 05107 as->chan = chan; 05108 ast_copy_string(as->context, context, sizeof(as->context)); 05109 set_ext_pri(as->chan, exten, priority); 05110 as->timeout = timeout; 05111 ast_set_variables(chan, vars); 05112 if (account) 05113 ast_cdr_setaccount(chan, account); 05114 pthread_attr_init(&attr); 05115 pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); 05116 if (ast_pthread_create(&as->p, &attr, async_wait, as)) { 05117 ast_log(LOG_WARNING, "Failed to start async wait\n"); 05118 free(as); 05119 if (channel) { 05120 *channel = NULL; 05121 ast_channel_unlock(chan); 05122 } 05123 ast_hangup(chan); 05124 res = -1; 05125 pthread_attr_destroy(&attr); 05126 goto outgoing_exten_cleanup; 05127 } 05128 pthread_attr_destroy(&attr); 05129 res = 0; 05130 } 05131 outgoing_exten_cleanup: 05132 ast_variables_destroy(vars); 05133 return res; 05134 }
| enum ast_pbx_result ast_pbx_run | ( | struct ast_channel * | c | ) |
Execute the PBX in the current thread.
| c | channel to run the pbx on |
Definition at line 2657 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_newcall(), and ss_thread().
02658 { 02659 enum ast_pbx_result res = AST_PBX_SUCCESS; 02660 02661 if (increase_call_count(c)) 02662 return AST_PBX_CALL_LIMIT; 02663 02664 res = __ast_pbx_run(c); 02665 decrease_call_count(); 02666 02667 return res; 02668 }
| enum ast_pbx_result ast_pbx_start | ( | struct ast_channel * | c | ) |
Create a new thread and start the PBX.
| c | channel to start the pbx on |
Definition at line 2630 of file pbx.c.
References ast_log(), AST_PBX_CALL_LIMIT, AST_PBX_FAILED, AST_PBX_SUCCESS, ast_pthread_create, decrease_call_count(), increase_call_count(), LOG_WARNING, pbx_thread(), and t.
Referenced by __oh323_new(), alsa_new(), ast_async_goto(), ast_bridge_call_thread(), ast_iax2_new(), ast_pbx_outgoing_exten(), bridge_exec(), check_goto_on_transfer(), dahdi_new(), do_parking_thread(), gtalk_new(), gtalk_newcall(), handle_request_invite(), local_call(), mgcp_new(), nbs_new(), ooh323_new(), oss_new(), pbx_start_chan(), phone_new(), rpt_call(), sip_new(), and skinny_new().
02631 { 02632 pthread_t t; 02633 pthread_attr_t attr; 02634 02635 if (!c) { 02636 ast_log(LOG_WARNING, "Asked to start thread on NULL channel?\n"); 02637 return AST_PBX_FAILED; 02638 } 02639 02640 if (increase_call_count(c)) 02641 return AST_PBX_CALL_LIMIT; 02642 02643 /* Start a new thread, and get something handling this channel. */ 02644 pthread_attr_init(&attr); 02645 pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); 02646 if (ast_pthread_create(&t, &attr, pbx_thread, c)) { 02647 ast_log(LOG_WARNING, "Failed to create new channel thread\n"); 02648 pthread_attr_destroy(&attr); 02649 decrease_call_count(); 02650 return AST_PBX_FAILED; 02651 } 02652 pthread_attr_destroy(&attr); 02653 02654 return AST_PBX_SUCCESS; 02655 }
| int ast_rdlock_contexts | ( | void | ) |
Definition at line 6138 of file pbx.c.
References ast_rwlock_rdlock(), and conlock.
Referenced by __ast_context_create(), _macro_exec(), ast_context_find(), ast_context_lockmacro(), ast_context_unlockmacro(), ast_hint_extension(), complete_context_add_extension(), complete_context_add_extension_deprecated(), complete_context_add_ignorepat(), complete_context_add_ignorepat_deprecated(), complete_context_add_include(), complete_context_add_include_deprecated(), complete_context_dont_include_deprecated(), complete_context_remove_extension(), complete_context_remove_extension_deprecated(), complete_context_remove_ignorepat(), complete_context_remove_ignorepat_deprecated(), complete_context_remove_include(), complete_show_dialplan_context(), dundi_precache_full(), find_context_locked(), handle_save_dialplan(), pbx_extension_helper(), and show_dialplan_helper().
06139 { 06140 return ast_rwlock_rdlock(&conlock); 06141 }
| int ast_register_application | ( | const char * | app, | |
| int(*)(struct ast_channel *, void *) | execute, | |||
| const char * | synopsis, | |||
| const char * | description | |||
| ) |
Register an application.
| app | Short name of the application | |
| execute | a function callback to execute the application. It should return non-zero if the channel needs to be hung up. | |
| synopsis | a short description (one line synopsis) of the application | |
| description | long description with all of the details about the use of the application |
| 0 | success | |
| -1 | failure. |
Definition at line 2959 of file pbx.c.
References ast_calloc, AST_LIST_INSERT_BEFORE_CURRENT, AST_LIST_INSERT_TAIL, AST_LIST_LOCK, AST_LIST_TRAVERSE, AST_LIST_TRAVERSE_SAFE_BEGIN, AST_LIST_TRAVERSE_SAFE_END, AST_LIST_UNLOCK, ast_log(), ast_verbose(), COLOR_BRCYAN, ast_app::description, ast_app::execute, ast_sw::list, LOG_WARNING, ast_app::name, option_verbose, ast_app::synopsis, term_color(), and VERBOSE_PREFIX_2.
Referenced by load_module(), and load_pbx().
02960 { 02961 struct ast_app *tmp, *cur = NULL; 02962 char tmps[80]; 02963 int length; 02964 02965 AST_LIST_LOCK(&apps); 02966 AST_LIST_TRAVERSE(&apps, tmp, list) { 02967 if (!strcasecmp(app, tmp->name)) { 02968 ast_log(LOG_WARNING, "Already have an application '%s'\n", app); 02969 AST_LIST_UNLOCK(&apps); 02970 return -1; 02971 } 02972 } 02973 02974 length = sizeof(*tmp) + strlen(app) + 1; 02975 02976 if (!(tmp = ast_calloc(1, length))) { 02977 AST_LIST_UNLOCK(&apps); 02978 return -1; 02979 } 02980 02981 strcpy(tmp->name, app); 02982 tmp->execute = execute; 02983 tmp->synopsis = synopsis; 02984 tmp->description = description; 02985 02986 /* Store in alphabetical order */ 02987 AST_LIST_TRAVERSE_SAFE_BEGIN(&apps, cur, list) { 02988 if (strcasecmp(tmp->name, cur->name) < 0) { 02989 AST_LIST_INSERT_BEFORE_CURRENT(&apps, tmp, list); 02990 break; 02991 } 02992 } 02993 AST_LIST_TRAVERSE_SAFE_END 02994 if (!cur) 02995 AST_LIST_INSERT_TAIL(&apps, tmp, list); 02996 02997 if (option_verbose > 1) 02998 ast_verbose( VERBOSE_PREFIX_2 "Registered application '%s'\n", term_color(tmps, tmp->name, COLOR_BRCYAN, 0, sizeof(tmps))); 02999 03000 AST_LIST_UNLOCK(&apps); 03001 03002 return 0; 03003 }
| int ast_register_switch | ( | struct ast_switch * | sw | ) |
Register an alternative dialplan switch.
| sw | switch to register |
Definition at line 3009 of file pbx.c.
References AST_LIST_INSERT_TAIL, AST_LIST_LOCK, AST_LIST_TRAVERSE, AST_LIST_UNLOCK, ast_log(), ast_sw::list, LOG_WARNING, and ast_switch::name.
Referenced by load_module().
03010 { 03011 struct ast_switch *tmp; 03012 03013 AST_LIST_LOCK(&switches); 03014 AST_LIST_TRAVERSE(&switches, tmp, list) { 03015 if (!strcasecmp(tmp->name, sw->name)) { 03016 AST_LIST_UNLOCK(&switches); 03017 ast_log(LOG_WARNING, "Switch '%s' already found\n", sw->name); 03018 return -1; 03019 } 03020 } 03021 AST_LIST_INSERT_TAIL(&switches, sw, list); 03022 AST_LIST_UNLOCK(&switches); 03023 03024 return 0; 03025 }
| int ast_spawn_extension | ( | struct ast_channel * | c, | |
| const char * | context, | |||
| const char * | exten, | |||
| int | priority, | |||
| const char * | callerid | |||
| ) |
Launch a new extension (i.e. new stack).
| c | not important | |
| context | which context to generate the extension within | |
| exten | new extension to add | |
| priority | priority of new extension | |
| callerid | callerid of extension |
| 0 | on success | |
| -1 | on failure. |
Definition at line 2316 of file pbx.c.
References E_SPAWN, and pbx_extension_helper().
Referenced by __ast_pbx_run(), _macro_exec(), ast_bridge_call(), and loopback_exec().
02317 { 02318 return pbx_extension_helper(c, NULL, context, exten, priority, NULL, callerid, E_SPAWN); 02319 }
| int ast_unlock_context | ( | struct ast_context * | con | ) |
| Unlocks | the given context |
| con | context to unlock |
| 0 | on success | |
| -1 | on failure |
Definition at line 6161 of file pbx.c.
References ast_mutex_unlock(), and ast_context::lock.
Referenced by _macro_exec(), complete_context_dont_include_deprecated(), complete_context_remove_ignorepat(), complete_context_remove_ignorepat_deprecated(), complete_context_remove_include(), dundi_precache_full(), find_matching_endwhile(), handle_save_dialplan(), lookup_c_ip(), lookup_ci(), and show_dialplan_helper().
06162 { 06163 return ast_mutex_unlock(&con->lock); 06164 }
| int ast_unlock_contexts | ( | void | ) |
Unlocks contexts.
| 0 | on success | |
| -1 | on failure |
Definition at line 6148 of file pbx.c.
References ast_rwlock_unlock(), and conlock.
Referenced by __ast_context_create(), _macro_exec(), ast_add_extension(), ast_context_add_ignorepat(), ast_context_add_include(), ast_context_add_switch(), ast_context_destroy(), ast_context_find(), ast_context_lockmacro(), ast_context_remove_extension_callerid(), ast_context_remove_ignorepat(), ast_context_remove_include(), ast_context_remove_switch(), ast_context_unlockmacro(), ast_hint_extension(), ast_merge_contexts_and_delete(), complete_context_add_extension(), complete_context_add_extension_deprecated(), complete_context_add_ignorepat(), complete_context_add_ignorepat_deprecated(), complete_context_add_include(), complete_context_add_include_deprecated(), complete_context_dont_include_deprecated(), complete_context_remove_extension(), complete_context_remove_extension_deprecated(), complete_context_remove_ignorepat(), complete_context_remove_ignorepat_deprecated(), complete_context_remove_include(), complete_show_dialplan_context(), dundi_precache_full(), find_context_locked(), find_matching_endwhile(), handle_save_dialplan(), pbx_extension_helper(), and show_dialplan_helper().
06149 { 06150 return ast_rwlock_unlock(&conlock); 06151 }
| int ast_unregister_application | ( | const char * | app | ) |
Unregister an application.
| app | name of the application (does not have to be the same string as the one that was registered) |
| 0 | success | |
| -1 | failure |
Definition at line 3840 of file pbx.c.
References AST_LIST_LOCK, AST_LIST_REMOVE_CURRENT, AST_LIST_TRAVERSE_SAFE_BEGIN, AST_LIST_TRAVERSE_SAFE_END, AST_LIST_UNLOCK, ast_verbose(), free, ast_sw::list, ast_app::name, option_verbose, and VERBOSE_PREFIX_2.
Referenced by __unload_module(), and unload_module().
03841 { 03842 struct ast_app *tmp; 03843 03844 AST_LIST_LOCK(&apps); 03845 AST_LIST_TRAVERSE_SAFE_BEGIN(&apps, tmp, list) { 03846 if (!strcasecmp(app, tmp->name)) { 03847 AST_LIST_REMOVE_CURRENT(&apps, list); 03848 if (option_verbose > 1) 03849 ast_verbose( VERBOSE_PREFIX_2 "Unregistered application '%s'\n", tmp->name); 03850 free(tmp); 03851 break; 03852 } 03853 } 03854 AST_LIST_TRAVERSE_SAFE_END 03855 AST_LIST_UNLOCK(&apps); 03856 03857 return tmp ? 0 : -1; 03858 }
| void ast_unregister_switch | ( | struct ast_switch * | sw | ) |
Unregister an alternative switch.
| sw | switch to unregister |
Definition at line 3027 of file pbx.c.
References AST_LIST_LOCK, AST_LIST_REMOVE, AST_LIST_UNLOCK, and ast_sw::list.
Referenced by __unload_module(), and unload_module().
03028 { 03029 AST_LIST_LOCK(&switches); 03030 AST_LIST_REMOVE(&switches, sw, list); 03031 AST_LIST_UNLOCK(&switches); 03032 }
| struct ast_exten* ast_walk_context_extensions | ( | struct ast_context * | con, | |
| struct ast_exten * | priority | |||
| ) | [read] |
Definition at line 6270 of file pbx.c.
References ast_exten::next, and ast_context::root.
Referenced by complete_context_remove_extension(), complete_context_remove_extension_deprecated(), dundi_precache_full(), find_matching_priority(), handle_save_dialplan(), pbx_find_extension(), and show_dialplan_helper().
06272 { 06273 if (!exten) 06274 return con ? con->root : NULL; 06275 else 06276 return exten->next; 06277 }
| struct ast_ignorepat* ast_walk_context_ignorepats | ( | struct ast_context * | con, | |
| struct ast_ignorepat * | ip | |||
| ) | [read] |
Definition at line 6303 of file pbx.c.
References ast_context::ignorepats, and ast_ignorepat::next.
Referenced by complete_context_remove_ignorepat(), complete_context_remove_ignorepat_deprecated(), handle_save_dialplan(), lookup_c_ip(), and show_dialplan_helper().
06305 { 06306 if (!ip) 06307 return con ? con->ignorepats : NULL; 06308 else 06309 return ip->next; 06310 }
| struct ast_include* ast_walk_context_includes | ( | struct ast_context * | con, | |
| struct ast_include * | inc | |||
| ) | [read] |
Definition at line 6294 of file pbx.c.
References ast_context::includes, and ast_include::next.
Referenced by ast_context_verify_includes(), complete_context_dont_include_deprecated(), complete_context_remove_include(), find_matching_priority(), handle_save_dialplan(), lookup_ci(), and show_dialplan_helper().
06296 { 06297 if (!inc) 06298 return con ? con->includes : NULL; 06299 else 06300 return inc->next; 06301 }
| struct ast_sw* ast_walk_context_switches | ( | struct ast_context * | con, | |
| struct ast_sw * | sw | |||
| ) | [read] |
Definition at line 6279 of file pbx.c.
References ast_context::alts, AST_LIST_FIRST, AST_LIST_NEXT, and ast_sw::list.
Referenced by handle_save_dialplan(), and show_dialplan_helper().
06281 { 06282 if (!sw) 06283 return con ? AST_LIST_FIRST(&con->alts) : NULL; 06284 else 06285 return AST_LIST_NEXT(sw, list); 06286 }
| struct ast_context* ast_walk_contexts | ( | struct ast_context * | con | ) | [read] |
Definition at line 6265 of file pbx.c.
References contexts, and ast_context::next.
Referenced by _macro_exec(), ast_context_find(), ast_context_lockmacro(), ast_context_unlockmacro(), complete_context_add_extension(), complete_context_add_extension_deprecated(), complete_context_add_ignorepat(), complete_context_add_ignorepat_deprecated(), complete_context_add_include(), complete_context_add_include_deprecated(), complete_context_dont_include_deprecated(), complete_context_remove_extension(), complete_context_remove_extension_deprecated(), complete_context_remove_ignorepat(), complete_context_remove_ignorepat_deprecated(), complete_context_remove_include(), complete_show_dialplan_context(), dundi_precache_full(), find_context_locked(), find_matching_endwhile(), find_matching_priority(), handle_save_dialplan(), pbx_find_extension(), pbx_load_module(), and show_dialplan_helper().
| struct ast_exten* ast_walk_extension_priorities | ( | struct ast_exten * | exten, | |
| struct ast_exten * | priority | |||
| ) | [read] |
Definition at line 6288 of file pbx.c.
References ast_exten::peer.
Referenced by complete_context_remove_extension(), complete_context_remove_extension_deprecated(), find_matching_priority(), handle_save_dialplan(), pbx_find_extension(), and show_dialplan_helper().
06290 { 06291 return priority ? priority->peer : exten; 06292 }
| int ast_wrlock_contexts | ( | void | ) |
Definition at line 6143 of file pbx.c.
References ast_rwlock_wrlock(), and conlock.
Referenced by __ast_context_create(), ast_context_destroy(), ast_merge_contexts_and_delete(), and complete_context_dont_include_deprecated().
06144 { 06145 return ast_rwlock_wrlock(&conlock); 06146 }
| void pbx_builtin_clear_globals | ( | void | ) |
Definition at line 6004 of file pbx.c.
References AST_LIST_REMOVE_HEAD, ast_mutex_lock(), ast_mutex_unlock(), ast_var_delete(), ast_var_t::entries, globals, and globalslock.
Referenced by handle_reload_extensions(), and reload().
06005 { 06006 struct ast_var_t *vardata; 06007 06008 ast_mutex_lock(&globalslock); 06009 while ((vardata = AST_LIST_REMOVE_HEAD(&globals, entries))) 06010 ast_var_delete(vardata); 06011 ast_mutex_unlock(&globalslock); 06012 }
| const char* pbx_builtin_getvar_helper | ( | struct ast_channel * | chan, | |
| const char * | name | |||
| ) |
Definition at line 5781 of file pbx.c.
References ast_channel_lock, ast_channel_unlock, AST_LIST_TRAVERSE, ast_mutex_lock(), ast_mutex_unlock(), ast_var_name(), ast_var_value(), globals, globalslock, and ast_channel::varshead.
Referenced by __ast_pbx_run(), __login_exec(), _macro_exec(), _while_exec(), agent_hangup(), agent_read(), agentmonitoroutgoing_exec(), ast_bridge_call(), ast_channel_bridge(), ast_feature_interpret(), ast_monitor_stop(), builtin_automonitor(), check_goto_on_transfer(), common_exec(), conf_exec(), conf_run(), dahdi_call(), dahdi_hangup(), dundi_exec(), dundi_helper(), get_also_info(), get_index(), get_refer_info(), global_read(), iax2_exec(), import_ch(), leave_voicemail(), local_hangup(), macro_fixup(), misdn_answer(), misdn_hangup(), morsecode_exec(), notify_new_message(), oh323_call(), oh323_hangup(), ooh323_call(), park_call_full(), pickup_by_mark(), pop_exec(), queue_exec(), real_ctx(), retrydial_exec(), return_exec(), ring_entry(), run_agi(), set_config_flags(), set_local_info(), sip_addheader(), sla_trunk_exec(), speech_background(), try_calling(), try_suggested_sip_codec(), and wait_for_answer().
05782 { 05783 struct ast_var_t *variables; 05784 const char *ret = NULL; 05785 int i; 05786 struct varshead *places[2] = { NULL, &globals }; 05787 05788 if (!name) 05789 return NULL; 05790 05791 if (chan) { 05792 ast_channel_lock(chan); 05793 places[0] = &chan->varshead; 05794 } 05795 05796 for (i = 0; i < 2; i++) { 05797 if (!places[i]) 05798 continue; 05799 if (places[i] == &globals) 05800 ast_mutex_lock(&globalslock); 05801 AST_LIST_TRAVERSE(places[i], variables, entries) { 05802 if (!strcmp(name, ast_var_name(variables))) { 05803 ret = ast_var_value(variables); 05804 break; 05805 } 05806 } 05807 if (places[i] == &globals) 05808 ast_mutex_unlock(&globalslock); 05809 if (ret) 05810 break; 05811 } 05812 05813 if (chan) 05814 ast_channel_unlock(chan); 05815 05816 return ret; 05817 }
| void pbx_builtin_pushvar_helper | ( | struct ast_channel * | chan, | |
| const char * | name, | |||
| const char * | value | |||
| ) |
Definition at line 5819 of file pbx.c.
References ast_channel_lock, ast_channel_unlock, ast_func_write(), AST_LIST_INSERT_HEAD, ast_log(), ast_mutex_lock(), ast_mutex_unlock(), ast_strdupa, ast_var_assign(), ast_verbose(), globals, globalslock, LOG_WARNING, option_verbose, ast_channel::varshead, and VERBOSE_PREFIX_2.
Referenced by acf_odbc_read(), acf_odbc_write(), and gosub_exec().
05820 { 05821 struct ast_var_t *newvariable; 05822 struct varshead *headp; 05823 05824 if (name[strlen(name)-1] == ')') { 05825 char *function = ast_strdupa(name); 05826 05827 ast_log(LOG_WARNING, "Cannot push a value onto a function\n"); 05828 ast_func_write(chan, function, value); 05829 return; 05830 } 05831 05832 if (chan) { 05833 ast_channel_lock(chan); 05834 headp = &chan->varshead; 05835 } else { 05836 ast_mutex_lock(&globalslock); 05837 headp = &globals; 05838 } 05839 05840 if (value) { 05841 if ((option_verbose > 1) && (headp == &globals)) 05842 ast_verbose(VERBOSE_PREFIX_2 "Setting global variable '%s' to '%s'\n", name, value); 05843 newvariable = ast_var_assign(name, value); 05844 AST_LIST_INSERT_HEAD(headp, newvariable, entries); 05845 } 05846 05847 if (chan) 05848 ast_channel_unlock(chan); 05849 else 05850 ast_mutex_unlock(&globalslock); 05851 }
| int pbx_builtin_serialize_variables | ( | struct ast_channel * | chan, | |
| char * | buf, | |||
| size_t | size | |||
| ) |
Definition at line 5750 of file pbx.c.
References ast_build_string(), ast_channel_lock, ast_channel_unlock, AST_LIST_TRAVERSE, ast_log(), ast_var_name(), ast_var_value(), ast_var_t::entries, LOG_ERROR, total, var, and ast_channel::varshead.
Referenced by dumpchan_exec(), handle_showchan(), handle_showchan_deprecated(), and vars2manager().
05751 { 05752 struct ast_var_t *variables; 05753 const char *var, *val; 05754 int total = 0; 05755 05756 if (!chan) 05757 return 0; 05758 05759 memset(buf, 0, size); 05760 05761 ast_channel_lock(chan); 05762 05763 AST_LIST_TRAVERSE(&chan->varshead, variables, entries) { 05764 if ((var=ast_var_name(variables)) && (val=ast_var_value(variables)) 05765 /* && !ast_strlen_zero(var) && !ast_strlen_zero(val) */ 05766 ) { 05767 if (ast_build_string(&buf, &size, "%s=%s\n", var, val)) { 05768 ast_log(LOG_ERROR, "Data Buffer Size Exceeded!\n"); 05769 break; 05770 } else 05771 total++; 05772 } else 05773 break; 05774 } 05775 05776 ast_channel_unlock(chan); 05777 05778 return total; 05779 }
| 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 | |||
| ) |
Definition at line 5853 of file pbx.c.
References ast_channel_lock, ast_channel_unlock, ast_func_write(), AST_LIST_INSERT_HEAD, AST_LIST_REMOVE, AST_LIST_TRAVERSE, ast_mutex_lock(), ast_mutex_unlock(), ast_strdupa, ast_var_assign(), ast_var_delete(), ast_var_name(), ast_verbose(), globals, globalslock, option_verbose, ast_channel::varshead, and VERBOSE_PREFIX_2.
Referenced by __ast_pbx_run(), __login_exec(), __oh323_new(), _macro_exec(), _while_exec(), acf_odbc_read(), acf_odbc_write(), action_setvar(), agi_exec_full(), aji_status_exec(), aMYSQL_fetch(), aPGSQL_connect(), aPGSQL_fetch(), aPGSQL_query(), aqm_exec(), array(), ast_bridge_call(), ast_channel_bridge(), ast_feature_request_and_dial(), ast_iax2_new(), ast_monitor_start(), ast_pbx_outgoing_exten(), ast_set_variables(), background_detect_exec(), bridge_exec(), builtin_automonitor(), builtin_blindtransfer(), cb_events(), chanavail_exec(), conf_run(), controlplayback_exec(), count_exec(), dahdi_handle_dtmfup(), dahdi_new(), disa_exec(), do_waiting(), end_bridge_callback(), export_aoc_vars(), export_ch(), function_db_delete(), function_db_exists(), function_db_read(), global_write(), handle_request_bye(), handle_request_refer(), handle_set_global(), handle_set_global_deprecated(), handle_setvariable(), hasvoicemail_exec(), isAnsweringMachine(), leave_voicemail(), local_hangup(), lookupblacklist_exec(), macro_fixup(), misdn_call(), mixmonitor_exec(), mwanalyze_exec(), MYSQL_exec(), nv_background_detect_exec(), nv_detectfax_exec(), ooh323_new(), ospauth_exec(), ospfinished_exec(), osplookup_exec(), ospnext_exec(), park_exec(), parse_moved_contact(), pbx_builtin_importvar(), pbx_builtin_setglobalvar(), pbx_builtin_setvar(), pbx_load_config(), PGSQL_exec(), phase_e_handler(), pickdown_channel(), pickup_channel(), play_message_datetime(), playback_exec(), pop_exec(), pqm_exec(), prep_email_sub_vars(), privacy_exec(), process_ast_dsp(), read_exec(), readfile_exec(), realtime_exec(), realtime_update_exec(), record_exec(), return_exec(), rqm_exec(), sendimage_exec(), sendtext_exec(), sendurl_exec(), set(), set_agentbycallerid(), set_asterisk_int(), set_queue_result(), sip_addheader(), sip_hangup(), sip_new(), sla_calc_trunk_timeouts(), sla_station_exec(), sla_trunk_exec(), socket_process(), speech_create(), ss_thread(), start_monitor_exec(), steal_channel(), system_exec_helper(), transfer_exec(), transmit(), try_calling(), tryexec_exec(), upqm_exec(), vm_box_exists(), vm_exec(), and vmauthenticate().
05854 { 05855 struct ast_var_t *newvariable; 05856 struct varshead *headp; 05857 const char *nametail = name; 05858 05859 if (name[strlen(name)-1] == ')') { 05860 char *function = ast_strdupa(name); 05861 05862 ast_func_write(chan, function, value); 05863 return; 05864 } 05865 05866 if (chan) { 05867 ast_channel_lock(chan); 05868 headp = &chan->varshead; 05869 } else { 05870 ast_mutex_lock(&globalslock); 05871 headp = &globals; 05872 } 05873 05874 /* For comparison purposes, we have to strip leading underscores */ 05875 if (*nametail == '_') { 05876 nametail++; 05877 if (*nametail == '_') 05878 nametail++; 05879 } 05880 05881 AST_LIST_TRAVERSE (headp, newvariable, entries) { 05882 if (strcasecmp(ast_var_name(newvariable), nametail) == 0) { 05883 /* there is already such a variable, delete it */ 05884 AST_LIST_REMOVE(headp, newvariable, entries); 05885 ast_var_delete(newvariable); 05886 break; 05887 } 05888 } 05889 05890 if (value) { 05891 if ((option_verbose > 1) && (headp == &globals)) 05892 ast_verbose(VERBOSE_PREFIX_2 "Setting global variable '%s' to '%s'\n", name, value); 05893 newvariable = ast_var_assign(name, value); 05894 AST_LIST_INSERT_HEAD(headp, newvariable, entries); 05895 } 05896 05897 if (chan) 05898 ast_channel_unlock(chan); 05899 else 05900 ast_mutex_unlock(&globalslock); 05901 }
| int pbx_checkcondition | ( | const char * | condition | ) |
Evaluate a condition.
| 0 | if the condition is NULL or of zero length | |
| int | If the string is an integer, the integer representation of the integer is returned | |
| 1 | Any other non-empty string |
Definition at line 6014 of file pbx.c.
References ast_strlen_zero().
Referenced by _macro_exec(), _while_exec(), acf_if(), execif_exec(), gosubif_exec(), macroif_exec(), and pbx_builtin_gotoif().
06015 { 06016 if (ast_strlen_zero(condition)) /* NULL or empty strings are false */ 06017 return 0; 06018 else if (*condition >= '0' && *condition <= '9') /* Numbers are evaluated for truth */ 06019 return atoi(condition); 06020 else /* Strings are true */ 06021 return 1; 06022 }
| int pbx_exec | ( | struct ast_channel * | c, | |
| struct ast_app * | app, | |||
| void * | data | |||
| ) |
Execute an application.
| c | channel to execute on | |
| app | which app to execute | |
| data | the data passed into the app |
| c | Channel | |
| app | Application | |
| data | Data for execution |
Definition at line 515 of file pbx.c.
References ast_channel::appl, ast_cdr_setapp(), ast_check_hangup(), ast_channel::cdr, ast_channel::data, ast_app::execute, ast_app::module, ast_app::name, and S_OR.
Referenced by answer_exec_run(), ast_bridge_call(), ast_pbx_run_app(), async_wait(), builtin_automonitor(), conf_run(), dundi_exec(), exec_exec(), execif_exec(), feature_exec_app(), forward_message(), handle_exec(), iax2_exec(), milliwatt_exec(), page_exec(), pbx_builtin_execiftime(), pbx_extension_helper(), realtime_exec(), try_calling(), and tryexec_exec().
00518 { 00519 int res; 00520 00521 const char *saved_c_appl; 00522 const char *saved_c_data; 00523 00524 if (c->cdr && !ast_check_hangup(c)) 00525 ast_cdr_setapp(c->cdr, app->name, data); 00526 00527 /* save channel values */ 00528 saved_c_appl= c->appl; 00529 saved_c_data= c->data; 00530 00531 c->appl = app->name; 00532 c->data = data; 00533 /* XXX remember what to to when we have linked apps to modules */ 00534 if (app->module) { 00535 /* XXX LOCAL_USER_ADD(app->module) */ 00536 } 00537 res = app->execute(c, S_OR(data, "")); 00538 if (app->module) { 00539 /* XXX LOCAL_USER_REMOVE(app->module) */ 00540 } 00541 /* restore channel values */ 00542 c->appl = saved_c_appl; 00543 c->data = saved_c_data; 00544 return res; 00545 }
| struct ast_app* pbx_findapp | ( | const char * | app | ) | [read] |
Look up an application.
| app | name of the app |
Definition at line 553 of file pbx.c.
References AST_LIST_LOCK, AST_LIST_TRAVERSE, AST_LIST_UNLOCK, ast_sw::list, and ast_app::name.
Referenced by answer_exec_run(), ast_bridge_call(), ast_pbx_run_app(), async_wait(), builtin_automonitor(), conf_run(), dundi_exec(), exec_exec(), execif_exec(), feature_exec_app(), forward_message(), handle_exec(), iax2_exec(), milliwatt_exec(), page_exec(), pbx_builtin_execiftime(), pbx_extension_helper(), realtime_exec(), try_calling(), and tryexec_exec().
00554 { 00555 struct ast_app *tmp; 00556 00557 AST_LIST_LOCK(&apps); 00558 AST_LIST_TRAVERSE(&apps, tmp, list) { 00559 if (!strcasecmp(tmp->name, app)) 00560 break; 00561 } 00562 AST_LIST_UNLOCK(&apps); 00563 00564 return tmp; 00565 }
| 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 ---
Definition at line 1152 of file pbx.c.
References ast_channel_lock, ast_channel_unlock, ast_config_AST_SYSTEM_NAME, ast_copy_string(), ast_get_hint(), AST_LIST_TRAVERSE, ast_mutex_lock(), ast_mutex_unlock(), ast_strdupa, ast_var_name(), ast_var_value(), ast_channel::cid, ast_callerid::cid_ani2, ast_callerid::cid_pres, ast_callerid::cid_tns, ast_callerid::cid_ton, ast_channel::context, ast_var_t::entries, ast_channel::exten, globals, globalslock, ast_channel::hangupcause, ast_channel::name, offset, parse_variable_name(), ast_channel::priority, s, substring(), ast_channel::uniqueid, and ast_channel::varshead.
Referenced by action_getvar(), function_fieldqty(), handle_getvariable(), and pbx_substitute_variables_helper_full().
01153 { 01154 const char not_found = '\0'; 01155 char *tmpvar; 01156 const char *s; /* the result */ 01157 int offset, length; 01158 int i, need_substring; 01159 struct varshead *places[2] = { headp, &globals }; /* list of places where we may look */ 01160 01161 if (c) { 01162 ast_channel_lock(c); 01163 places[0] = &c->varshead; 01164 } 01165 /* 01166 * Make a copy of var because parse_variable_name() modifies the string. 01167 * Then if called directly, we might need to run substring() on the result; 01168 * remember this for later in 'need_substring', 'offset' and 'length' 01169 */ 01170 tmpvar = ast_strdupa(var); /* parse_variable_name modifies the string */ 01171 need_substring = parse_variable_name(tmpvar, &offset, &length, &i /* ignored */); 01172 01173 /* 01174 * Look first into predefined variables, then into variable lists. 01175 * Variable 's' points to the result, according to the following rules: 01176 * s == ¬_found (set at the beginning) means that we did not find a 01177 * matching variable and need to look into more places. 01178 * If s != ¬_found, s is a valid result string as follows: 01179 * s = NULL if the variable does not have a value; 01180 * you typically do this when looking for an unset predefined variable. 01181 * s = workspace if the result has been assembled there; 01182 * typically done when the result is built e.g. with an snprintf(), 01183 * so we don't need to do an additional copy. 01184 * s != workspace in case we have a string, that needs to be copied 01185 * (the ast_copy_string is done once for all at the end). 01186 * Typically done when the result is already available in some string. 01187 */ 01188 s = ¬_found; /* default value */ 01189 if (c) { /* This group requires a valid channel */ 01190 /* Names with common parts are looked up a piece at a time using strncmp. */ 01191 if (!strncmp(var, "CALL", 4)) { 01192 if (!strncmp(var + 4, "ING", 3)) { 01193 if (!strcmp(var + 7, "PRES")) { /* CALLINGPRES */ 01194 snprintf(workspace, workspacelen, "%d", c->cid.cid_pres); 01195 s = workspace; 01196 } else if (!strcmp(var + 7, "ANI2")) { /* CALLINGANI2 */ 01197 snprintf(workspace, workspacelen, "%d", c->cid.cid_ani2); 01198 s = workspace; 01199 } else if (!strcmp(var + 7, "TON")) { /* CALLINGTON */ 01200 snprintf(workspace, workspacelen, "%d", c->cid.cid_ton); 01201 s = workspace; 01202 } else if (!strcmp(var + 7, "TNS")) { /* CALLINGTNS */ 01203 snprintf(workspace, workspacelen, "%d", c->cid.cid_tns); 01204 s = workspace; 01205 } 01206 } 01207 } else if (!strcmp(var, "HINT")) { 01208 s = ast_get_hint(workspace, workspacelen, NULL, 0, c, c->context, c->exten) ? workspace : NULL; 01209 } else if (!strcmp(var, "HINTNAME")) { 01210 s = ast_get_hint(NULL, 0, workspace, workspacelen, c, c->context, c->exten) ? workspace : NULL; 01211 } else if (!strcmp(var, "EXTEN")) { 01212 s = c->exten; 01213 } else if (!strcmp(var, "CONTEXT")) { 01214 s = c->context; 01215 } else if (!strcmp(var, "PRIORITY")) { 01216 snprintf(workspace, workspacelen, "%d", c->priority); 01217 s = workspace; 01218 } else if (!strcmp(var, "CHANNEL")) { 01219 s = c->name; 01220 } else if (!strcmp(var, "UNIQUEID")) { 01221 s = c->uniqueid; 01222 } else if (!strcmp(var, "HANGUPCAUSE")) { 01223 snprintf(workspace, workspacelen, "%d", c->hangupcause); 01224 s = workspace; 01225 } 01226 } 01227 if (s == ¬_found) { /* look for more */ 01228 if (!strcmp(var, "EPOCH")) { 01229 snprintf(workspace, workspacelen, "%u",(int)time(NULL)); 01230 s = workspace; 01231 } else if (!strcmp(var, "SYSTEMNAME")) { 01232 s = ast_config_AST_SYSTEM_NAME; 01233 } 01234 } 01235 /* if not found, look into chanvars or global vars */ 01236 for (i = 0; s == ¬_found && i < (sizeof(places) / sizeof(places[0])); i++) { 01237 struct ast_var_t *variables; 01238 if (!places[i]) 01239 continue; 01240 if (places[i] == &globals) 01241 ast_mutex_lock(&globalslock); 01242 AST_LIST_TRAVERSE(places[i], variables, entries) { 01243 if (strcasecmp(ast_var_name(variables), var)==0) { 01244 s = ast_var_value(variables); 01245 break; 01246 } 01247 } 01248 if (places[i] == &globals) 01249 ast_mutex_unlock(&globalslock); 01250 } 01251 if (s == ¬_found || s == NULL) 01252 *ret = NULL; 01253 else { 01254 if (s != workspace) 01255 ast_copy_string(workspace, s, workspacelen); 01256 *ret = workspace; 01257 if (need_substring) 01258 *ret = substring(*ret, offset, length, workspace, workspacelen); 01259 } 01260 01261 if (c) 01262 ast_channel_unlock(c); 01263 }
| int pbx_set_autofallthrough | ( | int | newval | ) |
Set "autofallthrough" flag, if newval is <0, does not acutally set. If set to 1, sets to auto fall through. If newval set to 0, sets to no auto fall through (reads extension instead). Returns previous value.
Definition at line 2675 of file pbx.c.
References autofallthrough.
Referenced by pbx_load_module().
02676 { 02677 int oldval = autofallthrough; 02678 autofallthrough = newval; 02679 return oldval; 02680 }
| void pbx_substitute_variables_helper | ( | struct ast_channel * | c, | |
| const char * | cp1, | |||
| char * | cp2, | |||
| int | count | |||
| ) |
Definition at line 1768 of file pbx.c.
References pbx_substitute_variables_helper_full(), and ast_channel::varshead.
Referenced by _macro_exec(), acf_odbc_read(), acf_odbc_write(), add_extensions(), custom_log(), cut_internal(), exec_exec(), function_eval(), handle_getvariablefull(), launch_monitor_thread(), make_email_file(), pbx_builtin_importvar(), pbx_find_extension(), pbx_load_config(), pbx_substitute_variables(), realtime_exec(), rpt_do_lstats(), rpt_exec(), sendpage(), try_calling(), and tryexec_exec().
01769 { 01770 pbx_substitute_variables_helper_full(c, (c) ? &c->varshead : NULL, cp1, cp2, count); 01771 }
| void pbx_substitute_variables_varshead | ( | struct varshead * | headp, | |
| const char * | cp1, | |||
| char * | cp2, | |||
| int | count | |||
| ) |
Definition at line 1773 of file pbx.c.
References pbx_substitute_variables_helper_full().
Referenced by ast_add_extension2(), do_say(), dundi_lookup_local(), and loopback_subst().
01774 { 01775 pbx_substitute_variables_helper_full(NULL, headp, cp1, cp2, count); 01776 }
1.5.9