[svn-commits] mmichelson: branch mmichelson/digit_manipulation r195632 - in /team/mmichelso...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Tue May 19 17:44:30 CDT 2009


Author: mmichelson
Date: Tue May 19 17:44:27 2009
New Revision: 195632

URL: http://svn.asterisk.org/svn-view/asterisk?view=rev&rev=195632
Log:
* Doxygenify ast_app_run_macro
* Fill in the external_run_macro function in app_macro.c
* Add macro_args parameter to all necessary functions


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=195632&r1=195631&r2=195632
==============================================================================
--- team/mmichelson/digit_manipulation/apps/app_macro.c (original)
+++ team/mmichelson/digit_manipulation/apps/app_macro.c Tue May 19 17:44:27 2009
@@ -610,10 +610,19 @@
 	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 external_run_macro(struct ast_channel *autoservice_chan, struct ast_channel *macro_chan, const char * const macro_name, const char * const macro_args)
+{
+	int res;
+	char buf[1024];
+	if (autoservice_chan) {
+		ast_autoservice_start(autoservice_chan);
+	}
+	snprintf(buf, sizeof(buf), "%s%s%s", macro_name, ast_strlen_zero(macro_args) ? "" : ",", S_OR(macro_args, ""));
+	res = macro_exec(macro_chan, buf);
+	if (autoservice_chan) {
+		ast_autoservice_stop(autoservice_chan);
+	}
+	return res;
 }
 
 static int unload_module(void)

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=195632&r1=195631&r2=195632
==============================================================================
--- team/mmichelson/digit_manipulation/include/asterisk/app.h (original)
+++ team/mmichelson/digit_manipulation/include/asterisk/app.h Tue May 19 17:44:27 2009
@@ -108,10 +108,25 @@
 /*! \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_install_macro_functions(int (*run_macro_func)(struct ast_channel *, struct ast_channel *, const char * const, const char * const));
 void ast_uninstall_macro_functions(void);
 
-int ast_app_run_macro(struct ast_channel *, struct ast_channel *, const char * const);
+/*!
+ * \brief Run a macro on a channel, placing a second channel into autoservice.
+ *
+ * This is a shorthand method that makes it very easy to run a macro on any given channel. It is perfectly
+ * reasonable to supply a NULL autoservice_chan here in case there is no channel to place into autoservice.
+ * It is very important that the autoservice_chan parameter is not locked prior to calling ast_app_run_macro.
+ * A deadlock could result, otherwise.
+ *
+ * \param autoservice_chan A channel to place into autoservice while the macro is run
+ * \param macro_chan The channel to run the macro on
+ * \param macro_name The name of the macro to run
+ * \param macro_args The arguments to pass to the macro
+ * \retval 0 success
+ * \retval -1 failure
+ */
+int ast_app_run_macro(struct ast_channel *autoservice_chan, struct ast_channel *macro_chan, const char * const macro_name, const char * const macro_args);
 
 /*!
  * \brief Set voicemail function callbacks

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=195632&r1=195631&r2=195632
==============================================================================
--- team/mmichelson/digit_manipulation/main/app.c (original)
+++ team/mmichelson/digit_manipulation/main/app.c Tue May 19 17:44:27 2009
@@ -203,9 +203,9 @@
 	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))
+static int (*ast_run_macro_func)(struct ast_channel *, struct ast_channel *, const char * const, const char * const) = NULL;
+
+void ast_install_macro_functions(int (*run_macro_func)(struct ast_channel *, struct ast_channel *, const char * const, const char * const))
 {
 	ast_run_macro_func = run_macro_func;
 }
@@ -215,10 +215,10 @@
 	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)
+int ast_app_run_macro(struct ast_channel *autoservice_chan, struct ast_channel *macro_chan, const char * const macro_name, const char * const macro_args)
 {
 	if (ast_run_macro_func) {
-		return ast_run_macro_func(autoservice_chan, macro_chan, macro_name);
+		return ast_run_macro_func(autoservice_chan, macro_chan, macro_name, macro_args);
 	}
 	return -1;
 }




More information about the svn-commits mailing list