Asterisk - The Open Source Telephony Project GIT-master-8924258
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Macros Modules Pages
agi.h
Go to the documentation of this file.
1/*
2 * Asterisk -- An open source telephony toolkit.
3 *
4 * Copyright (C) 1999 - 2005, Digium, Inc.
5 *
6 * Mark Spencer <markster@digium.com>
7 *
8 * See http://www.asterisk.org for more information about
9 * the Asterisk project. Please do not directly contact
10 * any of the maintainers of this project for assistance;
11 * the project provides a web site, mailing lists and IRC
12 * channels for your use.
13 *
14 * This program is free software, distributed under the terms of
15 * the GNU General Public License Version 2. See the LICENSE file
16 * at the top of the source tree.
17 */
18
19/*! \file
20 * \brief AGI Extension interfaces - Asterisk Gateway Interface
21 */
22
23#ifndef _ASTERISK_AGI_H
24#define _ASTERISK_AGI_H
25
26#if defined(__cplusplus) || defined(c_plusplus)
27extern "C" {
28#endif
29
30#include "asterisk/cli.h"
31#include "asterisk/xmldoc.h"
33
34typedef struct agi_state {
35 int fd; /*!< FD for general output */
36 int audio; /*!< FD for audio output */
37 int ctrl; /*!< FD for input control */
38 unsigned int fast:1; /*!< flag for fast agi or not */
39 struct ast_speech *speech; /*!< Speech structure for speech recognition */
41
42typedef struct agi_command {
43 const char * const cmda[AST_MAX_CMD_LEN]; /*!< Null terminated list of the words of the command */
44 /*! Handler for the command (channel, AGI state, # of arguments, argument list).
45 Returns RESULT_SHOWUSAGE for improper arguments */
46 int (* const handler)(struct ast_channel *chan, AGI *agi, int argc, const char * const argv[]);
47 /*! Summary of the command (< 60 characters) */
48 const char * const summary;
49 /*! Detailed usage information */
50 const char * const usage;
51 /*! Does this application run dead */
52 const int dead;
53 /*! AGI command syntax description */
54 const char * const syntax;
55 /*! See also content */
56 const char * const seealso;
57 /*! Where the documentation come from. */
58 const enum ast_doc_src docsrc;
59 /*! Pointer to module that registered the agi command */
60 struct ast_module *mod;
61 /*! Linked list pointer */
63 /*! Since content */
64 const char * const since;
65 /*! Syntax arguments content */
66 const char * const arguments;
68
69/*!
70 * \brief
71 *
72 * Registers an AGI command.
73 *
74 * \param mod Pointer to the module_info structure for the module that is registering the command
75 * \param cmd Pointer to the descriptor for the command
76 * \retval 1 on success
77 * \retval 0 the command is already registered
78 * \retval AST_OPTIONAL_API_UNAVAILABLE the module is not loaded.
79 */
81 (struct ast_module *mod, agi_command *cmd),
83
84/*!
85 * \brief
86 *
87 * Unregisters an AGI command.
88 *
89 * \param cmd Pointer to the descriptor for the command
90 * \return 1 on success, 0 if the command was not already registered
91 *
92 */
94 (agi_command *cmd),
96
97/*!
98 * \brief
99 *
100 * Registers a group of AGI commands, provided as an array of struct agi_command
101 * entries.
102 *
103 * \param mod Pointer to the module_info structure for the module that is registering the commands
104 * \param cmd Pointer to the first entry in the array of command descriptors
105 * \param len Length of the array (use the ARRAY_LEN macro to determine this easily)
106 * \return 0 on success, -1 on failure, AST_OPTIONAL_API_UNAVAILABLE if res_agi is not loaded
107 *
108 * \note If any command fails to register, all commands previously registered during the operation
109 * will be unregistered. In other words, this function registers all the provided commands, or none
110 * of them.
111 */
113 (struct ast_module *mod, struct agi_command *cmd, unsigned int len),
114 { return AST_OPTIONAL_API_UNAVAILABLE; });
115
116/*!
117 * \brief
118 *
119 * Unregisters a group of AGI commands, provided as an array of struct agi_command
120 * entries.
121 *
122 * \param cmd Pointer to the first entry in the array of command descriptors
123 * \param len Length of the array (use the ARRAY_LEN macro to determine this easily)
124 * \return 0 on success, -1 on failure, AST_OPTIONAL_API_UNAVAILABLE if res_agi is not loaded
125 *
126 * \note If any command fails to unregister, this function will continue to unregister the
127 * remaining commands in the array; it will not reregister the already-unregistered commands.
128 */
130 (struct agi_command *cmd, unsigned int len),
131 { return AST_OPTIONAL_API_UNAVAILABLE; });
132
133/*!
134 * \brief
135 *
136 * Sends a string of text to an application connected via AGI.
137 *
138 * \param fd The file descriptor for the AGI session (from struct agi_state)
139 * \param chan Pointer to an associated Asterisk channel, if any
140 * \param fmt printf-style format string
141 * \return 0 for success, -1 for failure, AST_OPTIONAL_API_UNAVAILABLE if res_agi is not loaded
142 *
143 */
144AST_OPTIONAL_API_ATTR(int, format(printf, 3, 4), ast_agi_send,
145 (int fd, struct ast_channel *chan, char *fmt, ...),
146 { return AST_OPTIONAL_API_UNAVAILABLE; });
147
148#if defined(__cplusplus) || defined(c_plusplus)
149}
150#endif
151
152#endif /* _ASTERISK_AGI_H */
int ast_agi_send(int fd, struct ast_channel *chan, char *fmt,...)
Sends a string of text to an application connected via AGI.
Definition: res_agi.c:1646
int ast_agi_register(struct ast_module *mod, agi_command *cmd)
Registers an AGI command.
Definition: res_agi.c:3988
int ast_agi_unregister_multiple(struct agi_command *cmd, unsigned int len)
Unregisters a group of AGI commands, provided as an array of struct agi_command entries.
Definition: res_agi.c:4104
int ast_agi_unregister(agi_command *cmd)
Unregisters an AGI command.
Definition: res_agi.c:4034
struct agi_state AGI
struct agi_command agi_command
int ast_agi_register_multiple(struct ast_module *mod, struct agi_command *cmd, unsigned int len)
Registers a group of AGI commands, provided as an array of struct agi_command entries.
Definition: res_agi.c:4074
Standard Command Line Interface.
#define AST_MAX_CMD_LEN
Definition: cli.h:48
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
#define AST_LIST_ENTRY(type)
Declare a forward link structure inside a list entry.
Definition: linkedlists.h:410
Optional API function macros.
#define AST_OPTIONAL_API_UNAVAILABLE
A common value for optional API stub functions to return.
Definition: optional_api.h:74
#define AST_OPTIONAL_API_ATTR(result, attr, name, proto, stub)
Declare an optional API function with compiler attributes.
Definition: optional_api.h:233
#define AST_OPTIONAL_API(result, name, proto, stub)
Declare an optional API function.
Definition: optional_api.h:230
struct agi_command::@181 list
int(*const handler)(struct ast_channel *chan, AGI *agi, int argc, const char *const argv[])
Definition: agi.h:46
const char *const since
Definition: agi.h:64
const char *const summary
Definition: agi.h:48
const char *const arguments
Definition: agi.h:66
struct ast_module * mod
Definition: agi.h:60
enum ast_doc_src docsrc
Definition: agi.h:58
const char *const usage
Definition: agi.h:50
const int dead
Definition: agi.h:52
const char *const seealso
Definition: agi.h:56
const char *const syntax
Definition: agi.h:54
const char *const cmda[AST_MAX_CMD_LEN]
Definition: agi.h:43
Definition: agi.h:34
int ctrl
Definition: agi.h:37
int audio
Definition: agi.h:36
int fd
Definition: agi.h:35
unsigned int fast
Definition: agi.h:38
struct ast_speech * speech
Definition: agi.h:39
Main Channel structure associated with a channel.
Asterisk XML Documentation API.
ast_doc_src
From where the documentation come from, this structure is useful for use it inside application/functi...
Definition: xmldoc.h:30