00001 /* 00002 * Asterisk -- An open source telephony toolkit. 00003 * 00004 * Copyright (C) 1999 - 2005, Digium, Inc. 00005 * 00006 * Mark Spencer <markster@digium.com> 00007 * 00008 * See http://www.asterisk.org for more information about 00009 * the Asterisk project. Please do not directly contact 00010 * any of the maintainers of this project for assistance; 00011 * the project provides a web site, mailing lists and IRC 00012 * channels for your use. 00013 * 00014 * This program is free software, distributed under the terms of 00015 * the GNU General Public License Version 2. See the LICENSE file 00016 * at the top of the source tree. 00017 */ 00018 00019 /*! \file 00020 * \brief AGI Extension interfaces - Asterisk Gateway Interface 00021 */ 00022 00023 #ifndef _ASTERISK_AGI_H 00024 #define _ASTERISK_AGI_H 00025 00026 #if defined(__cplusplus) || defined(c_plusplus) 00027 extern "C" { 00028 #endif 00029 00030 #include "asterisk/cli.h" 00031 #include "asterisk/xmldoc.h" 00032 #include "asterisk/optional_api.h" 00033 00034 typedef struct agi_state { 00035 int fd; /*!< FD for general output */ 00036 int audio; /*!< FD for audio output */ 00037 int ctrl; /*!< FD for input control */ 00038 unsigned int fast:1; /*!< flag for fast agi or not */ 00039 struct ast_speech *speech; /*!< Speech structure for speech recognition */ 00040 } AGI; 00041 00042 typedef struct agi_command { 00043 const char * const cmda[AST_MAX_CMD_LEN]; /*!< Null terminated list of the words of the command */ 00044 /*! Handler for the command (channel, AGI state, # of arguments, argument list). 00045 Returns RESULT_SHOWUSAGE for improper arguments */ 00046 int (* const handler)(struct ast_channel *chan, AGI *agi, int argc, const char * const argv[]); 00047 /*! Summary of the command (< 60 characters) */ 00048 const char * const summary; 00049 /*! Detailed usage information */ 00050 const char * const usage; 00051 /*! Does this application run dead */ 00052 const int dead; 00053 /*! AGI command syntax description */ 00054 const char * const syntax; 00055 /*! See also content */ 00056 const char * const seealso; 00057 /*! Where the documentation come from. */ 00058 const enum ast_doc_src docsrc; 00059 /*! Pointer to module that registered the agi command */ 00060 struct ast_module *mod; 00061 /*! Linked list pointer */ 00062 AST_LIST_ENTRY(agi_command) list; 00063 } agi_command; 00064 00065 /*! 00066 * \brief 00067 * 00068 * Registers an AGI command. 00069 * 00070 * \param mod Pointer to the module_info structure for the module that is registering the command 00071 * \param cmd Pointer to the descriptor for the command 00072 * \retval 1 on success 00073 * \retval 0 the command is already registered 00074 * \retval AST_OPTIONAL_API_UNAVAILABLE the module is not loaded. 00075 */ 00076 AST_OPTIONAL_API(int, ast_agi_register, 00077 (struct ast_module *mod, agi_command *cmd), 00078 { return AST_OPTIONAL_API_UNAVAILABLE; }); 00079 00080 /*! 00081 * \brief 00082 * 00083 * Unregisters an AGI command. 00084 * 00085 * \param mod Pointer to the module_info structure for the module that is unregistering the command 00086 * \param cmd Pointer to the descriptor for the command 00087 * \return 1 on success, 0 if the command was not already registered 00088 * 00089 */ 00090 AST_OPTIONAL_API(int, ast_agi_unregister, 00091 (struct ast_module *mod, agi_command *cmd), 00092 { return AST_OPTIONAL_API_UNAVAILABLE; }); 00093 00094 /*! 00095 * \brief 00096 * 00097 * Registers a group of AGI commands, provided as an array of struct agi_command 00098 * entries. 00099 * 00100 * \param mod Pointer to the module_info structure for the module that is registering the commands 00101 * \param cmd Pointer to the first entry in the array of command descriptors 00102 * \param len Length of the array (use the ARRAY_LEN macro to determine this easily) 00103 * \return 0 on success, -1 on failure, AST_OPTIONAL_API_UNAVAILABLE if res_agi is not loaded 00104 * 00105 * \note If any command fails to register, all commands previously registered during the operation 00106 * will be unregistered. In other words, this function registers all the provided commands, or none 00107 * of them. 00108 */ 00109 AST_OPTIONAL_API(int, ast_agi_register_multiple, 00110 (struct ast_module *mod, struct agi_command *cmd, unsigned int len), 00111 { return AST_OPTIONAL_API_UNAVAILABLE; }); 00112 00113 /*! 00114 * \brief 00115 * 00116 * Unregisters a group of AGI commands, provided as an array of struct agi_command 00117 * entries. 00118 * 00119 * \param mod Pointer to the module_info structure for the module that is unregistering the commands 00120 * \param cmd Pointer to the first entry in the array of command descriptors 00121 * \param len Length of the array (use the ARRAY_LEN macro to determine this easily) 00122 * \return 0 on success, -1 on failure, AST_OPTIONAL_API_UNAVAILABLE if res_agi is not loaded 00123 * 00124 * \note If any command fails to unregister, this function will continue to unregister the 00125 * remaining commands in the array; it will not reregister the already-unregistered commands. 00126 */ 00127 AST_OPTIONAL_API(int, ast_agi_unregister_multiple, 00128 (struct ast_module *mod, struct agi_command *cmd, unsigned int len), 00129 { return AST_OPTIONAL_API_UNAVAILABLE; }); 00130 00131 /*! 00132 * \brief 00133 * 00134 * Sends a string of text to an application connected via AGI. 00135 * 00136 * \param fd The file descriptor for the AGI session (from struct agi_state) 00137 * \param chan Pointer to an associated Asterisk channel, if any 00138 * \param fmt printf-style format string 00139 * \return 0 for success, -1 for failure, AST_OPTIONAL_API_UNAVAILABLE if res_agi is not loaded 00140 * 00141 */ 00142 AST_OPTIONAL_API_ATTR(int, format(printf, 3, 4), ast_agi_send, 00143 (int fd, struct ast_channel *chan, char *fmt, ...), 00144 { return AST_OPTIONAL_API_UNAVAILABLE; }); 00145 00146 #if defined(__cplusplus) || defined(c_plusplus) 00147 } 00148 #endif 00149 00150 #endif /* _ASTERISK_AGI_H */