[asterisk-commits] kpfleming: branch kpfleming/optional_api r159472 - in /team/kpfleming/optiona...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Nov 26 11:02:30 CST 2008


Author: kpfleming
Date: Wed Nov 26 11:02:29 2008
New Revision: 159472

URL: http://svn.digium.com/view/asterisk?view=rev&rev=159472
Log:
add doxygen docs for the rest of the functions in agi.h

make ast_agi_unregister and the 'multiple' variants optional as well (consumers of the API don't need to 'remember' whether the registration was successful this way)


Modified:
    team/kpfleming/optional_api/apps/app_stack.c
    team/kpfleming/optional_api/include/asterisk/agi.h

Modified: team/kpfleming/optional_api/apps/app_stack.c
URL: http://svn.digium.com/view/asterisk/team/kpfleming/optional_api/apps/app_stack.c?view=diff&rev=159472&r1=159471&r2=159472
==============================================================================
--- team/kpfleming/optional_api/apps/app_stack.c (original)
+++ team/kpfleming/optional_api/apps/app_stack.c Wed Nov 26 11:02:29 2008
@@ -149,8 +149,6 @@
 static const char *app_return = "Return";
 static const char *app_pop = "StackPop";
 
-static int agi_registered;
-
 static void gosub_free(void *data);
 
 static struct ast_datastore_info stack_info = {
@@ -575,12 +573,10 @@
 {
 	struct ast_context *con;
 
-	if (agi_registered) {
-		if (ast_agi_unregister(ast_module_info->self, &gosub_agi_command)) {
-			if ((con = ast_context_find("app_stack_gosub_virtual_context"))) {
-				ast_context_remove_extension2(con, "s", 1, NULL, 0);
-				ast_context_destroy(con, "app_stack"); /* leave nothing behind */
-			}
+	if (ast_agi_unregister(ast_module_info->self, &gosub_agi_command) == 1) {
+		if ((con = ast_context_find("app_stack_gosub_virtual_context"))) {
+			ast_context_remove_extension2(con, "s", 1, NULL, 0);
+			ast_context_destroy(con, "app_stack"); /* leave nothing behind */
 		}
 	}
 
@@ -604,8 +600,6 @@
 		} else {
 			ast_add_extension2(con, 1, "s", 1, NULL, NULL, "KeepAlive", ast_strdup(""), ast_free_ptr, "app_stack");
 		}
-
-		agi_registered = 1;
 	}
 
 	ast_register_application_xml(app_pop, pop_exec);

Modified: team/kpfleming/optional_api/include/asterisk/agi.h
URL: http://svn.digium.com/view/asterisk/team/kpfleming/optional_api/include/asterisk/agi.h?view=diff&rev=159472&r1=159471&r2=159472
==============================================================================
--- team/kpfleming/optional_api/include/asterisk/agi.h (original)
+++ team/kpfleming/optional_api/include/asterisk/agi.h Wed Nov 26 11:02:29 2008
@@ -61,9 +61,66 @@
 	AST_LIST_ENTRY(agi_command) list;
 } agi_command;
 
+/*!
+ * \brief
+ *
+ * Registers an AGI command.
+ *
+ * \param mod Pointer to the module_info structure for the module that is registering the command
+ * \param cmd Pointer to the descriptor for the command
+ * \return 1 on success, 0 if the command is already registered
+ *
+ */
 AST_OPTIONAL_API(int, ast_agi_register, (struct ast_module *mod, agi_command *cmd),
 		 { return AST_OPTIONAL_API_UNAVAILABLE; });
-int ast_agi_unregister(struct ast_module *mod, agi_command *cmd);
+
+/*!
+ * \brief
+ *
+ * Unregisters an AGI command.
+ *
+ * \param mod Pointer to the module_info structure for the module that is unregistering the command
+ * \param cmd Pointer to the descriptor for the command
+ * \return 1 on success, 0 if the command was not already registered
+ *
+ */
+AST_OPTIONAL_API(int, ast_agi_unregister, (struct ast_module *mod, agi_command *cmd),
+		 { return AST_OPTIONAL_API_UNAVAILABLE; });
+
+/*!
+ * \brief
+ *
+ * Registers a group of AGI commands, provided as an array of struct agi_command
+ * entries.
+ *
+ * \param mod Pointer to the module_info structure for the module that is registering the commands
+ * \param cmd Pointer to the first entry in the array of command descriptors
+ * \param len Length of the array (use the ARRAY_LEN macro to determine this easily)
+ * \return 0 on success, -1 on failure, AST_OPTIONAL_API_UNAVAILABLE if res_agi is not loaded
+ *
+ * \note If any command fails to register, all commands previously registered during the operation
+ * will be unregistered. In other words, this function registers all the provided commands, or none
+ * of them.
+ */
+AST_OPTIONAL_API(int, ast_agi_register_multiple, (struct ast_module *mod, struct agi_command *cmd, unsigned int len),
+		 { return AST_OPTIONAL_API_UNAVAILABLE; });
+
+/*!
+ * \brief
+ *
+ * Unregisters a group of AGI commands, provided as an array of struct agi_command
+ * entries.
+ *
+ * \param mod Pointer to the module_info structure for the module that is unregistering the commands
+ * \param cmd Pointer to the first entry in the array of command descriptors
+ * \param len Length of the array (use the ARRAY_LEN macro to determine this easily)
+ * \return 0 on success, -1 on failure, AST_OPTIONAL_API_UNAVAILABLE if res_agi is not loaded
+ *
+ * \note If any command fails to unregister, this function will continue to unregister the
+ * remaining commands in the array; it will not reregister the already-unregistered commands.
+ */
+AST_OPTIONAL_API(int, ast_agi_unregister_multiple, (struct ast_module *mod, struct agi_command *cmd, unsigned int len),
+		 { return AST_OPTIONAL_API_UNAVAILABLE; });
 
 /*!
  * \brief
@@ -77,38 +134,6 @@
  *
  */
 int ast_agi_send(int fd, struct ast_channel *chan, char *fmt, ...) __attribute__((format(printf, 3, 4)));
-/*!
- * \brief
- *
- * Registers a group of AGI commands, provided as an array of struct agi_command
- * entries.
- *
- * \param mod Pointer to the module_info structure for the module that is registering the commands
- * \param cmd Pointer to the first entry in the array of commands
- * \param len Length of the array (use the ARRAY_LEN macro to determine this easily)
- * \return 0 on success, -1 on failure
- *
- * \note If any command fails to register, all commands previously registered during the operation
- * will be unregistered. In other words, this function registers all the provided commands, or none
- * of them.
- */
-int ast_agi_register_multiple(struct ast_module *mod, struct agi_command *cmd, unsigned int len);
-
-/*!
- * \brief
- *
- * Unregisters a group of AGI commands, provided as an array of struct agi_command
- * entries.
- *
- * \param mod Pointer to the module_info structure for the module that is unregistering the commands
- * \param cmd Pointer to the first entry in the array of commands
- * \param len Length of the array (use the ARRAY_LEN macro to determine this easily)
- * \return 0 on success, -1 on failure
- *
- * \note If any command fails to unregister, this function will continue to unregister the
- * remaining commands in the array; it will not reregister the already-unregistered commands.
- */
-int ast_agi_unregister_multiple(struct ast_module *mod, struct agi_command *cmd, unsigned int len);
 
 #if defined(__cplusplus) || defined(c_plusplus)
 }




More information about the asterisk-commits mailing list