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 00032 typedef struct agi_state { 00033 int fd; /*!< FD for general output */ 00034 int audio; /*!< FD for audio output */ 00035 int ctrl; /*!< FD for input control */ 00036 unsigned int fast:1; /*!< flag for fast agi or not */ 00037 struct ast_speech *speech; /*!< Speech structure for speech recognition */ 00038 } AGI; 00039 00040 typedef struct agi_command { 00041 /* Null terminated list of the words of the command */ 00042 char *cmda[AST_MAX_CMD_LEN]; 00043 /* Handler for the command (channel, AGI state, # of arguments, argument list). 00044 Returns RESULT_SHOWUSAGE for improper arguments */ 00045 int (*handler)(struct ast_channel *chan, AGI *agi, int argc, char *argv[]); 00046 /* Summary of the command (< 60 characters) */ 00047 char *summary; 00048 /* Detailed usage information */ 00049 char *usage; 00050 /* Does this application run dead */ 00051 int dead; 00052 /* Pointer to module that registered the agi command */ 00053 struct ast_module *mod; 00054 /* Linked list pointer */ 00055 AST_LIST_ENTRY(agi_command) list; 00056 } agi_command; 00057 00058 #if defined(ASTERISK_AGI_OPTIONAL) 00059 #define AGI_WEAK attribute_weak 00060 #else 00061 #define AGI_WEAK 00062 #endif 00063 00064 /*! 00065 * \brief 00066 * 00067 * Sends a string of text to an application connected via AGI. 00068 * 00069 * \param fd The file descriptor for the AGI session (from struct agi_state) 00070 * \param chan Pointer to an associated Asterisk channel, if any 00071 * \param fmt printf-style format string 00072 * \return 0 for success, -1 for failure 00073 * 00074 */ 00075 int AGI_WEAK ast_agi_send(int fd, struct ast_channel *chan, char *fmt, ...) __attribute__((format(printf, 3, 4))); 00076 int AGI_WEAK ast_agi_register(struct ast_module *mod, agi_command *cmd); 00077 int AGI_WEAK ast_agi_unregister(struct ast_module *mod, agi_command *cmd); 00078 00079 /*! 00080 * \brief 00081 * 00082 * Registers a group of AGI commands, provided as an array of struct agi_command 00083 * entries. 00084 * 00085 * \param mod Pointer to the module_info structure for the module that is registering the commands 00086 * \param cmd Pointer to the first entry in the array of commands 00087 * \param len Length of the array (use the ARRAY_LEN macro to determine this easily) 00088 * \return 0 on success, -1 on failure 00089 * 00090 * \note If any command fails to register, all commands previously registered during the operation 00091 * will be unregistered. In other words, this function registers all the provided commands, or none 00092 * of them. 00093 */ 00094 int AGI_WEAK ast_agi_register_multiple(struct ast_module *mod, struct agi_command *cmd, unsigned int len); 00095 00096 /*! 00097 * \brief 00098 * 00099 * Unregisters a group of AGI commands, provided as an array of struct agi_command 00100 * entries. 00101 * 00102 * \param mod Pointer to the module_info structure for the module that is unregistering the commands 00103 * \param cmd Pointer to the first entry in the array of commands 00104 * \param len Length of the array (use the ARRAY_LEN macro to determine this easily) 00105 * \return 0 on success, -1 on failure 00106 * 00107 * \note If any command fails to unregister, this function will continue to unregister the 00108 * remaining commands in the array; it will not reregister the already-unregistered commands. 00109 */ 00110 int AGI_WEAK ast_agi_unregister_multiple(struct ast_module *mod, struct agi_command *cmd, unsigned int len); 00111 00112 #if defined(__cplusplus) || defined(c_plusplus) 00113 } 00114 #endif 00115 00116 #endif /* _ASTERISK_AGI_H */