summaryrefslogtreecommitdiff
path: root/include/asterisk/app.h
diff options
context:
space:
mode:
authorRichard Mudgett <rmudgett@digium.com>2012-06-14 23:22:53 +0000
committerRichard Mudgett <rmudgett@digium.com>2012-06-14 23:22:53 +0000
commitf8746d0009d7f54eb55fe804d320b30e628ad9bb (patch)
tree207388fca29fa5a75d0a6c6651d3b19f694480f1 /include/asterisk/app.h
parentaaa591447d908ef41404e75b7ed350eef56f905f (diff)
Allow non-normal execution routines to be able to run on hungup channels.
* Make non-normal dialplan execution routines be able to run on a hung up channel. This is preparation work for hangup handler routines. * Fixed ability to support relative non-normal dialplan execution routines. (i.e., The context and exten are optional for the specified dialplan location.) Predial routines are the only non-normal routines that it makes sense to optionally omit the context and exten. Setting a hangup handler also needs this ability. * Fix Return application being able to restore a dialplan location exactly. Channels without a PBX may not have context or exten set. * Fixes non-normal execution routines like connected line interception and predial leaving the dialplan execution stack unbalanced. Errors like missing Return statements, popping too many stack frames using StackPop, or an application returning non-zero could leave the dialplan stack unbalanced. * Fixed the AGI gosub application so it cleans up the dialplan execution stack and handles the autoloop priority increments correctly. * Eliminated the need for the gosub_virtual_context return location. Review: https://reviewboard.asterisk.org/r/1984/ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@368985 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'include/asterisk/app.h')
-rw-r--r--include/asterisk/app.h80
1 files changed, 70 insertions, 10 deletions
diff --git a/include/asterisk/app.h b/include/asterisk/app.h
index 50f667446..d10a0a667 100644
--- a/include/asterisk/app.h
+++ b/include/asterisk/app.h
@@ -148,8 +148,7 @@ int ast_app_getdata_full(struct ast_channel *c, const char *prompt, char *s, int
* supply a NULL autoservice_chan here in case there is no
* channel to place into autoservice.
*
- * \note It is very important that the autoservice_chan is not
- * locked prior to calling. Otherwise, a deadlock could result.
+ * \note Absolutely _NO_ channel locks should be held before calling this function.
*
* \param autoservice_chan A channel to place into autoservice while the macro is run
* \param macro_chan Channel to execute macro on.
@@ -170,8 +169,7 @@ int ast_app_exec_macro(struct ast_channel *autoservice_chan, struct ast_channel
* supply a NULL autoservice_chan here in case there is no
* channel to place into autoservice.
*
- * \note It is very important that the autoservice_chan is not
- * locked prior to calling. Otherwise, a deadlock could result.
+ * \note Absolutely _NO_ channel locks should be held before calling this function.
*
* \param autoservice_chan A channel to place into autoservice while the macro is run
* \param macro_chan Channel to execute macro on.
@@ -185,6 +183,68 @@ int ast_app_run_macro(struct ast_channel *autoservice_chan,
struct ast_channel *macro_chan, const char *macro_name, const char *macro_args);
/*!
+ * \brief Stack applications callback functions.
+ */
+struct ast_app_stack_funcs {
+ /*!
+ * Module reference pointer so the module will stick around
+ * while a callback is active.
+ */
+ void *module;
+
+ /*!
+ * \brief Callback for the routine to run a subroutine on a channel.
+ *
+ * \note Absolutely _NO_ channel locks should be held before calling this function.
+ *
+ * \param chan Channel to execute subroutine on.
+ * \param args Gosub application argument string.
+ * \param ignore_hangup TRUE if a hangup does not stop execution of the routine.
+ *
+ * \retval 0 success
+ * \retval -1 on error
+ */
+ int (*run_sub)(struct ast_channel *chan, const char *args, int ignore_hangup);
+
+ /*!
+ * \brief Add missing context/exten to Gosub application argument string.
+ *
+ * \param chan Channel to obtain context/exten.
+ * \param args Gosub application argument string.
+ *
+ * \details
+ * Fills in the optional context and exten from the given channel.
+ *
+ * \retval New-args Gosub argument string on success. Must be freed.
+ * \retval NULL on error.
+ */
+ const char *(*expand_sub_args)(struct ast_channel *chan, const char *args);
+
+ /* Add new API calls to the end here. */
+};
+
+/*!
+ * \since 11
+ * \brief Set stack application function callbacks
+ * \param funcs Stack applications callback functions.
+ */
+void ast_install_stack_functions(const struct ast_app_stack_funcs *funcs);
+
+/*!
+ * \brief Add missing context/exten to subroutine argument string.
+ *
+ * \param chan Channel to obtain context/exten.
+ * \param args Gosub application argument string.
+ *
+ * \details
+ * Fills in the optional context and exten from the given channel.
+ *
+ * \retval New-args Gosub argument string on success. Must be freed.
+ * \retval NULL on error.
+ */
+const char *ast_app_expand_sub_args(struct ast_channel *chan, const char *args);
+
+/*!
* \since 11
* \brief Run a subroutine on a channel, placing an optional second channel into autoservice.
*
@@ -194,17 +254,17 @@ int ast_app_run_macro(struct ast_channel *autoservice_chan,
* to supply a NULL autoservice_chan here in case there is no
* channel to place into autoservice.
*
- * \note It is very important that the autoservice_chan is not
- * locked prior to calling. Otherwise, a deadlock could result.
+ * \note Absolutely _NO_ channel locks should be held before calling this function.
*
* \param autoservice_chan A channel to place into autoservice while the subroutine is run
* \param sub_chan Channel to execute subroutine on.
* \param sub_args Gosub application argument string.
+ * \param ignore_hangup TRUE if a hangup does not stop execution of the routine.
*
* \retval 0 success
* \retval -1 on error
*/
-int ast_app_exec_sub(struct ast_channel *autoservice_chan, struct ast_channel *sub_chan, const char *sub_args);
+int ast_app_exec_sub(struct ast_channel *autoservice_chan, struct ast_channel *sub_chan, const char *sub_args, int ignore_hangup);
/*!
* \since 11
@@ -216,19 +276,19 @@ int ast_app_exec_sub(struct ast_channel *autoservice_chan, struct ast_channel *s
* to supply a NULL autoservice_chan here in case there is no
* channel to place into autoservice.
*
- * \note It is very important that the autoservice_chan is not
- * locked prior to calling. Otherwise, a deadlock could result.
+ * \note Absolutely _NO_ channel locks should be held before calling this function.
*
* \param autoservice_chan A channel to place into autoservice while the subroutine is run
* \param sub_chan Channel to execute subroutine on.
* \param sub_location The location of the subroutine to run.
* \param sub_args The arguments to pass to the subroutine.
+ * \param ignore_hangup TRUE if a hangup does not stop execution of the routine.
*
* \retval 0 success
* \retval -1 on error
*/
int ast_app_run_sub(struct ast_channel *autoservice_chan,
- struct ast_channel *sub_chan, const char *sub_location, const char *sub_args);
+ struct ast_channel *sub_chan, const char *sub_location, const char *sub_args, int ignore_hangup);
enum ast_vm_snapshot_sort_val {
AST_VM_SNAPSHOT_SORT_BY_ID = 0,