Asterisk - The Open Source Telephony Project GIT-master-80b953f
Loading...
Searching...
No Matches
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 /*! The provided-by of the item */
85};
86
87/*! \brief Execute an XPath query on the loaded XML documentation
88 * \param fmt The XPath query string to execute
89 * \param ... Variable printf style format arguments
90 * \retval An XPath results object on success
91 * \retval NULL if no match found
92 *
93 * \since 12
94 */
95struct ast_xml_xpath_results *__attribute__((format(printf, 1, 2))) ast_xmldoc_query(const char *fmt, ...);
96
97/*!
98 * \brief Get the syntax for a specified application or function.
99 * \param type Application, Function or AGI ?
100 * \param name Name of the application or function.
101 * \param module The module the item is in (optional, can be NULL)
102 * \retval NULL on error.
103 * \retval The generated syntax in a ast_malloc'ed string.
104 */
105char *ast_xmldoc_build_syntax(const char *type, const char *name, const char *module);
106
107/*!
108 * \brief Parse the <see-also> node content.
109 * \param type 'application', 'function' or 'agi'.
110 * \param name Application or functions name.
111 * \param module The module the item is in (optional, can be NULL)
112 * \retval NULL on error.
113 * \retval Content of the see-also node.
114 */
115char *ast_xmldoc_build_seealso(const char *type, const char *name, const char *module);
116
117/*!
118 * \brief Parse the <since> node content.
119 * \param type 'application', 'function' or 'agi'.
120 * \param name Application or functions name.
121 * \param module The module the item is in (optional, can be NULL)
122 * \retval NULL on error.
123 * \retval Content of the since node.
124 */
125char *ast_xmldoc_build_since(const char *type, const char *name, const char *module);
126
127/*!
128 * \brief Generate the [arguments] tag based on type of node ('application',
129 * 'function' or 'agi') and name.
130 * \param type 'application', 'function' or 'agi' ?
131 * \param name Name of the application or function to build the 'arguments' tag.
132 * \param module The module the item is in (optional, can be NULL)
133 * \retval NULL on error.
134 * \retval Output buffer with the [arguments] tag content.
135 */
136char *ast_xmldoc_build_arguments(const char *type, const char *name, const char *module);
137
138/*!
139 * \brief Generate the [final response] tag based on type of node ('application',
140 * 'function' or 'agi') and name.
141 *
142 * \param type 'application', 'function' or 'agi'
143 * \param name Name of the application or function to build the 'responses' tag.
144 * \param module The module the item is in (optional, can be NULL)
145 *
146 * \return An XMLDoc item list with the [final response] tag content.
147 *
148 * \since 13.0.0
149 */
150struct ast_xml_doc_item *ast_xmldoc_build_final_response(const char *type, const char *name, const char *module);
151
152/*!
153 * \brief Generate the [list responses] tag based on type of node ('application',
154 * 'function' or 'agi') and name.
155 *
156 * \param type 'application', 'function' or 'agi'
157 * \param name Name of the application or function to build the 'responses' tag.
158 * \param module The module the item is in (optional, can be NULL)
159 *
160 * \return An XMLDoc item list with the [list responses] tag content.
161 *
162 * \since 13.0.0
163 */
164struct ast_xml_doc_item *ast_xmldoc_build_list_responses(const char *type, const char *name, const char *module);
165
166/*!
167 * \brief Colorize and put delimiters (instead of tags) to the xmldoc output.
168 * \param bwinput Not colorized input with tags.
169 * \param withcolors Result output with colors.
170 * \retval NULL on error.
171 * \retval New malloced buffer colorized and with delimiters.
172 */
173char *ast_xmldoc_printable(const char *bwinput, int withcolors);
174
175/*!
176 * \brief Generate synopsis documentation from XML.
177 * \param type The source of documentation (application, function, etc).
178 * \param name The name of the application, function, etc.
179 * \param module The module the item is in (optional, can be NULL)
180 * \retval NULL on error.
181 * \retval A malloc'ed string with the synopsis.
182 */
183char *ast_xmldoc_build_synopsis(const char *type, const char *name, const char *module);
184
185/*!
186 * \brief Generate provided-by documentation from XML.
187 * \param type The source of documentation (application, function, etc).
188 * \param name The name of the application, function, etc.
189 * \param module The module the item is in (optional, can be NULL)
190 * \retval NULL on error.
191 * \retval A malloc'ed string with the provided-by.
192 *
193 * \note The value actually comes from the "module" attribute.
194 */
195char *ast_xmldoc_build_provided_by(const char *type, const char *name, const char *module);
196
197/*!
198 * \brief Generate description documentation from XML.
199 * \param type The source of documentation (application, function, etc).
200 * \param name The name of the application, function, etc.
201 * \param module The module the item is in (optional, can be NULL)
202 * \retval NULL on error.
203 * \retval A malloc'ed string with the formatted description.
204 */
205char *ast_xmldoc_build_description(const char *type, const char *name, const char *module);
206
207/*!
208 * \brief Build the documentation for a particular source type
209 * \param type The source of the documentation items (application, function, etc.)
210 *
211 * \retval NULL on error
212 * \retval An ao2_container populated with ast_xml_doc instances for each item
213 * that exists for the specified source type
214 *
215 * \since 11
216 */
218
219/*!
220 * \brief Regenerate the documentation for a particular item
221 * \param item The documentation item to regenerate
222 *
223 * \retval -1 on error
224 * \retval 0 on success
225 *
226 * \since 12
227 */
229
230#endif /* AST_XML_DOCS */
231
232#endif /* _ASTERISK_XMLDOC_H */
static const char type[]
static const char name[]
Definition format_mp3.c:68
#define AST_LIST_ENTRY(type)
Declare a forward link structure inside a list entry.
#define AST_LIST_HEAD(name, type)
Defines a structure to be used to hold a list of specified type.
#define AST_DECLARE_STRING_FIELDS(field_list)
Declare the fields needed in a structure.
#define AST_STRING_FIELD(name)
Declare a string field.
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
struct ast_str * provided_by
Definition xmldoc.h:84
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
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:2740
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:2648
char * ast_xmldoc_build_description(const char *type, const char *name, const char *module)
Generate description documentation from XML.
Definition xmldoc.c:2418
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:2231
char * ast_xmldoc_build_synopsis(const char *type, const char *name, const char *module)
Generate synopsis documentation from XML.
Definition xmldoc.c:2395
char * ast_xmldoc_build_since(const char *type, const char *name, const char *module)
Parse the <since> node content.
Definition xmldoc.c:1792
struct ao2_container * ast_xmldoc_build_documentation(const char *type)
Build the documentation for a particular source type.
Definition xmldoc.c:2851
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:1707
char * ast_xmldoc_build_provided_by(const char *type, const char *name, const char *module)
Generate provided-by documentation from XML.
Definition xmldoc.c:1844
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:2718
int ast_xmldoc_regenerate_doc_item(struct ast_xml_doc_item *item)
Regenerate the documentation for a particular item.
Definition xmldoc.c:2799