summaryrefslogtreecommitdiff
path: root/include/asterisk/agi.h
diff options
context:
space:
mode:
authorKevin P. Fleming <kpfleming@digium.com>2008-11-26 21:20:50 +0000
committerKevin P. Fleming <kpfleming@digium.com>2008-11-26 21:20:50 +0000
commite14dfcbedc84a426e751c440cd051660368bb8b2 (patch)
tree7b208b24111d20e17d362d1a3bdab092a075a995 /include/asterisk/agi.h
parentaa0e8886290c1964bbfc9635ac83d477a179d02c (diff)
improve handling of API calls provided by loaded modules through use of some GCC features; this makes app_stack's usage of AGI APIs even cleaner, and will allow it to work 'as expected' either with or without res_agi being loaded
reviewed at http://reviewboard.digium.com/r/62 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@159631 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'include/asterisk/agi.h')
-rw-r--r--include/asterisk/agi.h60
1 files changed, 41 insertions, 19 deletions
diff --git a/include/asterisk/agi.h b/include/asterisk/agi.h
index c92ab3c66..9c7759576 100644
--- a/include/asterisk/agi.h
+++ b/include/asterisk/agi.h
@@ -28,6 +28,7 @@ extern "C" {
#endif
#include "asterisk/cli.h"
+#include "asterisk/optional_api.h"
typedef struct agi_state {
int fd; /*!< FD for general output */
@@ -60,26 +61,31 @@ typedef struct agi_command {
AST_LIST_ENTRY(agi_command) list;
} agi_command;
-#if defined(ASTERISK_AGI_OPTIONAL)
-#define AGI_WEAK attribute_weak
-#else
-#define AGI_WEAK
-#endif
+/*!
+ * \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; });
/*!
* \brief
*
- * Sends a string of text to an application connected via AGI.
+ * Unregisters an AGI command.
*
- * \param fd The file descriptor for the AGI session (from struct agi_state)
- * \param chan Pointer to an associated Asterisk channel, if any
- * \param fmt printf-style format string
- * \return 0 for success, -1 for failure
+ * \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
*
*/
-int AGI_WEAK ast_agi_send(int fd, struct ast_channel *chan, char *fmt, ...) __attribute__((format(printf, 3, 4)));
-int AGI_WEAK ast_agi_register(struct ast_module *mod, agi_command *cmd);
-int AGI_WEAK ast_agi_unregister(struct ast_module *mod, agi_command *cmd);
+AST_OPTIONAL_API(int, ast_agi_unregister, (struct ast_module *mod, agi_command *cmd),
+ { return AST_OPTIONAL_API_UNAVAILABLE; });
/*!
* \brief
@@ -88,15 +94,16 @@ int AGI_WEAK ast_agi_unregister(struct ast_module *mod, agi_command *cmd);
* 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 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
+ * \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.
*/
-int AGI_WEAK ast_agi_register_multiple(struct ast_module *mod, struct agi_command *cmd, unsigned int len);
+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
@@ -105,14 +112,29 @@ int AGI_WEAK ast_agi_register_multiple(struct ast_module *mod, struct agi_comman
* 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 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
+ * \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.
*/
-int AGI_WEAK ast_agi_unregister_multiple(struct ast_module *mod, struct agi_command *cmd, unsigned int len);
+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
+ *
+ * Sends a string of text to an application connected via AGI.
+ *
+ * \param fd The file descriptor for the AGI session (from struct agi_state)
+ * \param chan Pointer to an associated Asterisk channel, if any
+ * \param fmt printf-style format string
+ * \return 0 for success, -1 for failure, AST_OPTIONAL_API_UNAVAILABLE if res_agi is not loaded
+ *
+ */
+AST_OPTIONAL_API_ATTR(int, format(printf, 3, 4), ast_agi_send, (int fd, struct ast_channel *chan, char *fmt, ...),
+ { return AST_OPTIONAL_API_UNAVAILABLE; });
#if defined(__cplusplus) || defined(c_plusplus)
}