agi.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  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. /*! \file
  19. * \brief AGI Extension interfaces - Asterisk Gateway Interface
  20. */
  21. #ifndef _ASTERISK_AGI_H
  22. #define _ASTERISK_AGI_H
  23. #if defined(__cplusplus) || defined(c_plusplus)
  24. extern "C" {
  25. #endif
  26. #include "asterisk/cli.h"
  27. #include "asterisk/xmldoc.h"
  28. #include "asterisk/optional_api.h"
  29. typedef struct agi_state {
  30. int fd; /*!< FD for general output */
  31. int audio; /*!< FD for audio output */
  32. int ctrl; /*!< FD for input control */
  33. unsigned int fast:1; /*!< flag for fast agi or not */
  34. struct ast_speech *speech; /*!< Speech structure for speech recognition */
  35. } AGI;
  36. typedef struct agi_command {
  37. const char * const cmda[AST_MAX_CMD_LEN]; /*!< Null terminated list of the words of the command */
  38. /*! Handler for the command (channel, AGI state, # of arguments, argument list).
  39. Returns RESULT_SHOWUSAGE for improper arguments */
  40. int (* const handler)(struct ast_channel *chan, AGI *agi, int argc, const char * const argv[]);
  41. /*! Summary of the command (< 60 characters) */
  42. const char * const summary;
  43. /*! Detailed usage information */
  44. const char * const usage;
  45. /*! Does this application run dead */
  46. const int dead;
  47. /*! AGI command syntax description */
  48. const char * const syntax;
  49. /*! See also content */
  50. const char * const seealso;
  51. /*! Where the documentation come from. */
  52. const enum ast_doc_src docsrc;
  53. /*! Pointer to module that registered the agi command */
  54. struct ast_module *mod;
  55. /*! Linked list pointer */
  56. AST_LIST_ENTRY(agi_command) list;
  57. } agi_command;
  58. /*!
  59. * \brief
  60. *
  61. * Registers an AGI command.
  62. *
  63. * \param mod Pointer to the module_info structure for the module that is registering the command
  64. * \param cmd Pointer to the descriptor for the command
  65. * \retval 1 on success
  66. * \retval 0 the command is already registered
  67. * \retval AST_OPTIONAL_API_UNAVAILABLE the module is not loaded.
  68. */
  69. AST_OPTIONAL_API(int, ast_agi_register,
  70. (struct ast_module *mod, agi_command *cmd),
  71. { return AST_OPTIONAL_API_UNAVAILABLE; });
  72. /*!
  73. * \brief
  74. *
  75. * Unregisters an AGI command.
  76. *
  77. * \param mod Pointer to the module_info structure for the module that is unregistering the command
  78. * \param cmd Pointer to the descriptor for the command
  79. * \return 1 on success, 0 if the command was not already registered
  80. *
  81. */
  82. AST_OPTIONAL_API(int, ast_agi_unregister,
  83. (struct ast_module *mod, agi_command *cmd),
  84. { return AST_OPTIONAL_API_UNAVAILABLE; });
  85. /*!
  86. * \brief
  87. *
  88. * Registers a group of AGI commands, provided as an array of struct agi_command
  89. * entries.
  90. *
  91. * \param mod Pointer to the module_info structure for the module that is registering the commands
  92. * \param cmd Pointer to the first entry in the array of command descriptors
  93. * \param len Length of the array (use the ARRAY_LEN macro to determine this easily)
  94. * \return 0 on success, -1 on failure, AST_OPTIONAL_API_UNAVAILABLE if res_agi is not loaded
  95. *
  96. * \note If any command fails to register, all commands previously registered during the operation
  97. * will be unregistered. In other words, this function registers all the provided commands, or none
  98. * of them.
  99. */
  100. AST_OPTIONAL_API(int, ast_agi_register_multiple,
  101. (struct ast_module *mod, struct agi_command *cmd, unsigned int len),
  102. { return AST_OPTIONAL_API_UNAVAILABLE; });
  103. /*!
  104. * \brief
  105. *
  106. * Unregisters a group of AGI commands, provided as an array of struct agi_command
  107. * entries.
  108. *
  109. * \param mod Pointer to the module_info structure for the module that is unregistering the commands
  110. * \param cmd Pointer to the first entry in the array of command descriptors
  111. * \param len Length of the array (use the ARRAY_LEN macro to determine this easily)
  112. * \return 0 on success, -1 on failure, AST_OPTIONAL_API_UNAVAILABLE if res_agi is not loaded
  113. *
  114. * \note If any command fails to unregister, this function will continue to unregister the
  115. * remaining commands in the array; it will not reregister the already-unregistered commands.
  116. */
  117. AST_OPTIONAL_API(int, ast_agi_unregister_multiple,
  118. (struct ast_module *mod, struct agi_command *cmd, unsigned int len),
  119. { return AST_OPTIONAL_API_UNAVAILABLE; });
  120. /*!
  121. * \brief
  122. *
  123. * Sends a string of text to an application connected via AGI.
  124. *
  125. * \param fd The file descriptor for the AGI session (from struct agi_state)
  126. * \param chan Pointer to an associated Asterisk channel, if any
  127. * \param fmt printf-style format string
  128. * \return 0 for success, -1 for failure, AST_OPTIONAL_API_UNAVAILABLE if res_agi is not loaded
  129. *
  130. */
  131. AST_OPTIONAL_API_ATTR(int, format(printf, 3, 4), ast_agi_send,
  132. (int fd, struct ast_channel *chan, char *fmt, ...),
  133. { return AST_OPTIONAL_API_UNAVAILABLE; });
  134. #if defined(__cplusplus) || defined(c_plusplus)
  135. }
  136. #endif
  137. #endif /* _ASTERISK_AGI_H */