Asterisk - The Open Source Telephony Project GIT-master-8924258
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Macros Modules Pages
xmldoc.h
Go to the documentation of this file.
1/*
2 * Asterisk -- An open source telephony toolkit.
3 *
4 * Copyright (C) 2008, Eliel C. Sardanons (LU1ALY) <eliels@gmail.com>
5 *
6 * See http://www.asterisk.org for more information about
7 * the Asterisk project. Please do not directly contact
8 * any of the maintainers of this project for assistance;
9 * the project provides a web site, mailing lists and IRC
10 * channels for your use.
11 *
12 * This program is free software, distributed under the terms of
13 * the GNU General Public License Version 2. See the LICENSE file
14 * at the top of the source tree.
15 */
16
17#ifndef _ASTERISK_XMLDOC_H
18#define _ASTERISK_XMLDOC_H
19
20/*! \file
21 * \brief Asterisk XML Documentation API
22 */
23
24#include "asterisk/xml.h"
26#include "asterisk/strings.h"
27
28/*! \brief From where the documentation come from, this structure is useful for
29 * use it inside application/functions/manager actions structure. */
31 AST_XML_DOC, /*!< From XML documentation */
32 AST_STATIC_DOC /*!< From application/function registration */
33};
34
35#ifdef AST_XML_DOCS
36
37struct ao2_container;
38struct ast_xml_node;
39
40/*!
41 * \brief The struct to be used as the head of an ast_xml_doc_item list
42 * when being manipulated
43 * \since 13.0.0
44 */
46
47/*! \brief Struct that contains the XML documentation for a particular item. Note
48 * that this is an ao2 ref counted object.
49 *
50 * \note
51 * Each of the ast_str objects are built from the corresponding ast_xmldoc_build_*
52 * calls
53 *
54 * \since 11
55 */
57 /*! The syntax of the item */
58 struct ast_str *syntax;
59 /*! Seealso tagged information, if it exists */
61 /*! The arguments to the item */
63 /*! A synopsis of the item */
65 /*! A description of the item */
68 /*! The name of the item */
70 /*! The type of the item */
72 /*! Reference to another field */
74 );
75 /*! The node that this item was created from. Note that the life time of
76 * the node is not tied to the lifetime of this object.
77 */
78 struct ast_xml_node *node;
79 /*! The next XML documentation item that matches the same name/item type */
81 /*! Since tagged information, if it exists */
82 struct ast_str *since;
83};
84
85/*! \brief Execute an XPath query on the loaded XML documentation
86 * \param fmt The XPath query string to execute
87 * \param ... Variable printf style format arguments
88 * \retval An XPath results object on success
89 * \retval NULL if no match found
90 *
91 * \since 12
92 */
93struct ast_xml_xpath_results *__attribute__((format(printf, 1, 2))) ast_xmldoc_query(const char *fmt, ...);
94
95/*!
96 * \brief Get the syntax for a specified application or function.
97 * \param type Application, Function or AGI ?
98 * \param name Name of the application or function.
99 * \param module The module the item is in (optional, can be NULL)
100 * \retval NULL on error.
101 * \retval The generated syntax in a ast_malloc'ed string.
102 */
103char *ast_xmldoc_build_syntax(const char *type, const char *name, const char *module);
104
105/*!
106 * \brief Parse the <see-also> node content.
107 * \param type 'application', 'function' or 'agi'.
108 * \param name Application or functions name.
109 * \param module The module the item is in (optional, can be NULL)
110 * \retval NULL on error.
111 * \retval Content of the see-also node.
112 */
113char *ast_xmldoc_build_seealso(const char *type, const char *name, const char *module);
114
115/*!
116 * \brief Parse the <since> node content.
117 * \param type 'application', 'function' or 'agi'.
118 * \param name Application or functions name.
119 * \param module The module the item is in (optional, can be NULL)
120 * \retval NULL on error.
121 * \retval Content of the since node.
122 */
123char *ast_xmldoc_build_since(const char *type, const char *name, const char *module);
124
125/*!
126 * \brief Generate the [arguments] tag based on type of node ('application',
127 * 'function' or 'agi') and name.
128 * \param type 'application', 'function' or 'agi' ?
129 * \param name Name of the application or function to build the 'arguments' tag.
130 * \param module The module the item is in (optional, can be NULL)
131 * \retval NULL on error.
132 * \retval Output buffer with the [arguments] tag content.
133 */
134char *ast_xmldoc_build_arguments(const char *type, const char *name, const char *module);
135
136/*!
137 * \brief Generate the [final response] tag based on type of node ('application',
138 * 'function' or 'agi') and name.
139 *
140 * \param type 'application', 'function' or 'agi'
141 * \param name Name of the application or function to build the 'responses' tag.
142 * \param module The module the item is in (optional, can be NULL)
143 *
144 * \return An XMLDoc item list with the [final response] tag content.
145 *
146 * \since 13.0.0
147 */
148struct ast_xml_doc_item *ast_xmldoc_build_final_response(const char *type, const char *name, const char *module);
149
150/*!
151 * \brief Generate the [list responses] tag based on type of node ('application',
152 * 'function' or 'agi') and name.
153 *
154 * \param type 'application', 'function' or 'agi'
155 * \param name Name of the application or function to build the 'responses' tag.
156 * \param module The module the item is in (optional, can be NULL)
157 *
158 * \return An XMLDoc item list with the [list responses] tag content.
159 *
160 * \since 13.0.0
161 */
162struct ast_xml_doc_item *ast_xmldoc_build_list_responses(const char *type, const char *name, const char *module);
163
164/*!
165 * \brief Colorize and put delimiters (instead of tags) to the xmldoc output.
166 * \param bwinput Not colorized input with tags.
167 * \param withcolors Result output with colors.
168 * \retval NULL on error.
169 * \retval New malloced buffer colorized and with delimiters.
170 */
171char *ast_xmldoc_printable(const char *bwinput, int withcolors);
172
173/*!
174 * \brief Generate synopsis documentation from XML.
175 * \param type The source of documentation (application, function, etc).
176 * \param name The name of the application, function, etc.
177 * \param module The module the item is in (optional, can be NULL)
178 * \retval NULL on error.
179 * \retval A malloc'ed string with the synopsis.
180 */
181char *ast_xmldoc_build_synopsis(const char *type, const char *name, const char *module);
182
183/*!
184 * \brief Generate description documentation from XML.
185 * \param type The source of documentation (application, function, etc).
186 * \param name The name of the application, function, etc.
187 * \param module The module the item is in (optional, can be NULL)
188 * \retval NULL on error.
189 * \retval A malloc'ed string with the formatted description.
190 */
191char *ast_xmldoc_build_description(const char *type, const char *name, const char *module);
192
193/*!
194 * \brief Build the documentation for a particular source type
195 * \param type The source of the documentation items (application, function, etc.)
196 *
197 * \retval NULL on error
198 * \retval An ao2_container populated with ast_xml_doc instances for each item
199 * that exists for the specified source type
200 *
201 * \since 11
202 */
204
205/*!
206 * \brief Regenerate the documentation for a particular item
207 * \param item The documentation item to regenerate
208 *
209 * \retval -1 on error
210 * \retval 0 on success
211 *
212 * \since 12
213 */
215
216#endif /* AST_XML_DOCS */
217
218#endif /* _ASTERISK_XMLDOC_H */
static const char type[]
Definition: chan_ooh323.c:109
static const char name[]
Definition: format_mp3.c:68
#define AST_LIST_ENTRY(type)
Declare a forward link structure inside a list entry.
Definition: linkedlists.h:410
#define AST_LIST_HEAD(name, type)
Defines a structure to be used to hold a list of specified type.
Definition: linkedlists.h:173
#define AST_DECLARE_STRING_FIELDS(field_list)
Declare the fields needed in a structure.
Definition: stringfields.h:341
#define AST_STRING_FIELD(name)
Declare a string field.
Definition: stringfields.h:303
String manipulation functions.
Generic container type.
Support for dynamic strings.
Definition: strings.h:623
The struct to be used as the head of an ast_xml_doc_item list when being manipulated.
Definition: xmldoc.h:45
Struct that contains the XML documentation for a particular item. Note that this is an ao2 ref counte...
Definition: xmldoc.h:56
struct ast_str * syntax
Definition: xmldoc.h:58
struct ast_xml_node * node
Definition: xmldoc.h:78
const ast_string_field ref
Definition: xmldoc.h:74
struct ast_xml_doc_item * next
Definition: xmldoc.h:80
struct ast_str * arguments
Definition: xmldoc.h:62
struct ast_str * since
Definition: xmldoc.h:82
const ast_string_field type
Definition: xmldoc.h:74
struct ast_str * description
Definition: xmldoc.h:66
const ast_string_field name
Definition: xmldoc.h:74
struct ast_str * seealso
Definition: xmldoc.h:60
struct ast_str * synopsis
Definition: xmldoc.h:64
static struct aco_type item
Definition: test_config.c:1463
Asterisk XML abstraction layer.
struct ast_xml_xpath_results * ast_xmldoc_query(const char *fmt,...)
Execute an XPath query on the loaded XML documentation.
Definition: xmldoc.c:2670
struct ast_xml_doc_item * ast_xmldoc_build_list_responses(const char *type, const char *name, const char *module)
Generate the [list responses] tag based on type of node ('application', 'function' or 'agi') and name...
Definition: xmldoc.c:2578
char * ast_xmldoc_build_description(const char *type, const char *name, const char *module)
Generate description documentation from XML.
Definition: xmldoc.c:2356
char * ast_xmldoc_build_syntax(const char *type, const char *name, const char *module)
Get the syntax for a specified application or function.
Definition: xmldoc.c:1252
char * ast_xmldoc_build_arguments(const char *type, const char *name, const char *module)
Generate the [arguments] tag based on type of node ('application', 'function' or 'agi') and name.
Definition: xmldoc.c:2169
char * ast_xmldoc_build_synopsis(const char *type, const char *name, const char *module)
Generate synopsis documentation from XML.
Definition: xmldoc.c:2333
char * ast_xmldoc_build_since(const char *type, const char *name, const char *module)
Parse the <since> node content.
Definition: xmldoc.c:1787
struct ao2_container * ast_xmldoc_build_documentation(const char *type)
Build the documentation for a particular source type.
Definition: xmldoc.c:2778
ast_doc_src
From where the documentation come from, this structure is useful for use it inside application/functi...
Definition: xmldoc.h:30
@ AST_XML_DOC
Definition: xmldoc.h:31
@ AST_STATIC_DOC
Definition: xmldoc.h:32
char * ast_xmldoc_build_seealso(const char *type, const char *name, const char *module)
Parse the <see-also> node content.
Definition: xmldoc.c:1702
char * ast_xmldoc_printable(const char *bwinput, int withcolors)
Colorize and put delimiters (instead of tags) to the xmldoc output.
Definition: xmldoc.c:241
struct ast_xml_doc_item * ast_xmldoc_build_final_response(const char *type, const char *name, const char *module)
Generate the [final response] tag based on type of node ('application', 'function' or 'agi') and name...
Definition: xmldoc.c:2648
int ast_xmldoc_regenerate_doc_item(struct ast_xml_doc_item *item)
Regenerate the documentation for a particular item.
Definition: xmldoc.c:2729