[asterisk-commits] mmichelson: branch mmichelson/digit_manipulation r195631 - in /team/mmichelso...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue May 19 17:24:01 CDT 2009


Author: mmichelson
Date: Tue May 19 17:23:58 2009
New Revision: 195631

URL: http://svn.asterisk.org/svn-view/asterisk?view=rev&rev=195631
Log:
Add easy ability to run a macro from outside of app_macro.

Yeah, I know you can already do it, but hey, why not make it easier, right?


Modified:
    team/mmichelson/digit_manipulation/apps/app_macro.c
    team/mmichelson/digit_manipulation/include/asterisk/app.h
    team/mmichelson/digit_manipulation/main/app.c

Modified: team/mmichelson/digit_manipulation/apps/app_macro.c
URL: http://svn.asterisk.org/svn-view/asterisk/team/mmichelson/digit_manipulation/apps/app_macro.c?view=diff&rev=195631&r1=195630&r2=195631
==============================================================================
--- team/mmichelson/digit_manipulation/apps/app_macro.c (original)
+++ team/mmichelson/digit_manipulation/apps/app_macro.c Tue May 19 17:23:58 2009
@@ -36,6 +36,7 @@
 #include "asterisk/config.h"
 #include "asterisk/utils.h"
 #include "asterisk/lock.h"
+#include "asterisk/app.h"
 
 /*** DOCUMENTATION
 	<application name="Macro" language="en_US">
@@ -609,6 +610,12 @@
 	return MACRO_EXIT_RESULT;
 }
 
+static int external_run_macro(struct ast_channel *autoservice_chan, struct ast_channel *macro_chan, const char * const macro_name)
+{
+	/*stub*/
+	return 0;
+}
+
 static int unload_module(void)
 {
 	int res;
@@ -617,6 +624,7 @@
 	res |= ast_unregister_application(exit_app);
 	res |= ast_unregister_application(app);
 	res |= ast_unregister_application(exclusive_app);
+	ast_uninstall_macro_functions();
 
 	return res;
 }
@@ -629,6 +637,7 @@
 	res |= ast_register_application_xml(if_app, macroif_exec);
 	res |= ast_register_application_xml(exclusive_app, macroexclusive_exec);
 	res |= ast_register_application_xml(app, macro_exec);
+	ast_install_macro_functions(external_run_macro);
 
 	return res;
 }

Modified: team/mmichelson/digit_manipulation/include/asterisk/app.h
URL: http://svn.asterisk.org/svn-view/asterisk/team/mmichelson/digit_manipulation/include/asterisk/app.h?view=diff&rev=195631&r1=195630&r2=195631
==============================================================================
--- team/mmichelson/digit_manipulation/include/asterisk/app.h (original)
+++ team/mmichelson/digit_manipulation/include/asterisk/app.h Tue May 19 17:23:58 2009
@@ -108,6 +108,11 @@
 /*! \brief Full version with audiofd and controlfd.  NOTE: returns '2' on ctrlfd available, not '1' like other full functions */
 int ast_app_getdata_full(struct ast_channel *c, char *prompt, char *s, int maxlen, int timeout, int audiofd, int ctrlfd);
 
+void ast_install_macro_functions(int (*run_macro_func)(struct ast_channel *, struct ast_channel *, const char * const));
+void ast_uninstall_macro_functions(void);
+
+int ast_app_run_macro(struct ast_channel *, struct ast_channel *, const char * const);
+
 /*!
  * \brief Set voicemail function callbacks
  * \param[in] inboxcount2_func set function pointer

Modified: team/mmichelson/digit_manipulation/main/app.c
URL: http://svn.asterisk.org/svn-view/asterisk/team/mmichelson/digit_manipulation/main/app.c?view=diff&rev=195631&r1=195630&r2=195631
==============================================================================
--- team/mmichelson/digit_manipulation/main/app.c (original)
+++ team/mmichelson/digit_manipulation/main/app.c Tue May 19 17:23:58 2009
@@ -201,6 +201,26 @@
 	res = ast_readstring_full(c, s, maxlen, to, fto, "#", audiofd, ctrlfd);
 
 	return res;
+}
+
+static int (*ast_run_macro_func)(struct ast_channel *, struct ast_channel *, const char * const) = NULL;
+
+void ast_install_macro_functions(int (*run_macro_func)(struct ast_channel *, struct ast_channel *, const char * const))
+{
+	ast_run_macro_func = run_macro_func;
+}
+
+void ast_uninstall_macro_functions(void)
+{
+	ast_run_macro_func = NULL;
+}
+
+int ast_app_run_macro(struct ast_channel *autoservice_chan, struct ast_channel *macro_chan, const char * const macro_name)
+{
+	if (ast_run_macro_func) {
+		return ast_run_macro_func(autoservice_chan, macro_chan, macro_name);
+	}
+	return -1;
 }
 
 static int (*ast_has_voicemail_func)(const char *mailbox, const char *folder) = NULL;




More information about the asterisk-commits mailing list