Thu Apr 28 2011 17:13:27

Asterisk developer's documentation


agi.h

Go to the documentation of this file.
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 
00033 typedef struct agi_state {
00034    int fd;             /*!< FD for general output */
00035    int audio;          /*!< FD for audio output */
00036    int ctrl;      /*!< FD for input control */
00037    unsigned int fast:1;    /*!< flag for fast agi or not */
00038    struct ast_speech *speech; /*!< Speech structure for speech recognition */
00039 } AGI;
00040 
00041 typedef struct agi_command {
00042    char *cmda[AST_MAX_CMD_LEN];     /*!< Null terminated list of the words of the command */
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    /*! AGI command syntax description */
00053    char *syntax;
00054    /*! See also content */
00055    char *seealso;
00056    /*! Where the documentation come from. */
00057    enum ast_doc_src docsrc;
00058    /*! Pointer to module that registered the agi command */
00059    struct ast_module *mod;
00060    /*! Linked list pointer */
00061    AST_LIST_ENTRY(agi_command) list;
00062 } agi_command;
00063 
00064 /*!
00065  * \brief
00066  *
00067  * Registers an AGI command.
00068  *
00069  * \param mod Pointer to the module_info structure for the module that is registering the command
00070  * \param cmd Pointer to the descriptor for the command
00071  * \return 1 on success, 0 if the command is already registered
00072  *
00073  */
00074 int ast_agi_register(struct ast_module *mod, agi_command *cmd) attribute_weak;
00075 
00076 /*!
00077  * \brief
00078  *
00079  * Unregisters an AGI command.
00080  *
00081  * \param mod Pointer to the module_info structure for the module that is unregistering the command
00082  * \param cmd Pointer to the descriptor for the command
00083  * \return 1 on success, 0 if the command was not already registered
00084  *
00085  */
00086 int ast_agi_unregister(struct ast_module *mod, agi_command *cmd) attribute_weak;
00087 
00088 /*!
00089  * \brief
00090  *
00091  * Registers a group of AGI commands, provided as an array of struct agi_command
00092  * entries.
00093  *
00094  * \param mod Pointer to the module_info structure for the module that is registering the commands
00095  * \param cmd Pointer to the first entry in the array of command descriptors
00096  * \param len Length of the array (use the ARRAY_LEN macro to determine this easily)
00097  * \return 0 on success, -1 on failure
00098  *
00099  * \note If any command fails to register, all commands previously registered during the operation
00100  * will be unregistered. In other words, this function registers all the provided commands, or none
00101  * of them.
00102  */
00103 int ast_agi_register_multiple(struct ast_module *mod, struct agi_command *cmd, unsigned int len) attribute_weak;
00104 
00105 /*!
00106  * \brief
00107  *
00108  * Unregisters a group of AGI commands, provided as an array of struct agi_command
00109  * entries.
00110  *
00111  * \param mod Pointer to the module_info structure for the module that is unregistering the commands
00112  * \param cmd Pointer to the first entry in the array of command descriptors
00113  * \param len Length of the array (use the ARRAY_LEN macro to determine this easily)
00114  * \return 0 on success, -1 on failure
00115  *
00116  * \note If any command fails to unregister, this function will continue to unregister the
00117  * remaining commands in the array; it will not reregister the already-unregistered commands.
00118  */
00119 int ast_agi_unregister_multiple(struct ast_module *mod, struct agi_command *cmd, unsigned int len) attribute_weak;
00120 
00121 /*!
00122  * \brief
00123  *
00124  * Sends a string of text to an application connected via AGI.
00125  *
00126  * \param fd The file descriptor for the AGI session (from struct agi_state)
00127  * \param chan Pointer to an associated Asterisk channel, if any
00128  * \param fmt printf-style format string
00129  * \return 0 for success, -1 for failure
00130  *
00131  */
00132 int ast_agi_send(int fd, struct ast_channel *chan, char *fmt, ...) attribute_weak __attribute__((format(printf, 3, 4)));
00133 
00134 #if defined(__cplusplus) || defined(c_plusplus)
00135 }
00136 #endif
00137 
00138 #endif /* _ASTERISK_AGI_H */