Asterisk - The Open Source Telephony Project GIT-master-0deac78
Data Structures | Enumerations | Functions
xmldoc.h File Reference

Asterisk XML Documentation API. More...

#include "asterisk/xml.h"
#include "asterisk/stringfields.h"
#include "asterisk/strings.h"
Include dependency graph for xmldoc.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  ast_xml_doc_item
 Struct that contains the XML documentation for a particular item. Note that this is an ao2 ref counted object. More...
 
struct  ast_xml_doc_item_list
 The struct to be used as the head of an ast_xml_doc_item list when being manipulated. More...
 

Enumerations

enum  ast_doc_src { AST_XML_DOC , AST_STATIC_DOC }
 From where the documentation come from, this structure is useful for use it inside application/functions/manager actions structure. More...
 

Functions

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. More...
 
char * ast_xmldoc_build_description (const char *type, const char *name, const char *module)
 Generate description documentation from XML. More...
 
struct ao2_containerast_xmldoc_build_documentation (const char *type)
 Build the documentation for a particular source type. More...
 
struct ast_xml_doc_itemast_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. More...
 
struct ast_xml_doc_itemast_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. More...
 
char * ast_xmldoc_build_seealso (const char *type, const char *name, const char *module)
 Parse the <see-also> node content. More...
 
char * ast_xmldoc_build_since (const char *type, const char *name, const char *module)
 Parse the <since> node content. More...
 
char * ast_xmldoc_build_synopsis (const char *type, const char *name, const char *module)
 Generate synopsis documentation from XML. More...
 
char * ast_xmldoc_build_syntax (const char *type, const char *name, const char *module)
 Get the syntax for a specified application or function. More...
 
char * ast_xmldoc_printable (const char *bwinput, int withcolors)
 Colorize and put delimiters (instead of tags) to the xmldoc output. More...
 
struct ast_xml_xpath_results * ast_xmldoc_query (const char *fmt,...)
 Execute an XPath query on the loaded XML documentation. More...
 
int ast_xmldoc_regenerate_doc_item (struct ast_xml_doc_item *item)
 Regenerate the documentation for a particular item. More...
 

Detailed Description

Asterisk XML Documentation API.

Definition in file xmldoc.h.

Enumeration Type Documentation

◆ ast_doc_src

From where the documentation come from, this structure is useful for use it inside application/functions/manager actions structure.

Enumerator
AST_XML_DOC 

From XML documentation

AST_STATIC_DOC 

From application/function registration

Definition at line 30 of file xmldoc.h.

30 {
31 AST_XML_DOC, /*!< From XML documentation */
32 AST_STATIC_DOC /*!< From application/function registration */
33};
@ AST_XML_DOC
Definition: xmldoc.h:31
@ AST_STATIC_DOC
Definition: xmldoc.h:32

Function Documentation

◆ ast_xmldoc_build_arguments()

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.

Parameters
type'application', 'function' or 'agi' ?
nameName of the application or function to build the 'arguments' tag.
moduleThe module the item is in (optional, can be NULL)
Return values
NULLon error.
Outputbuffer with the [arguments] tag content.

Definition at line 2174 of file xmldoc.c.

2175{
2176 struct ast_xml_node *node;
2177 char *arguments;
2178
2180 return NULL;
2181 }
2182
2185
2188 return NULL;
2189 }
2190
2191 arguments = _ast_xmldoc_build_arguments(node);
2193 return arguments;
2194}
static const char type[]
Definition: chan_ooh323.c:109
static const char name[]
Definition: format_mp3.c:68
#define AST_RWLIST_RDLOCK(head)
Read locks a list.
Definition: linkedlists.h:78
#define AST_RWLIST_UNLOCK(head)
Attempts to unlock a read/write based list.
Definition: linkedlists.h:151
#define NULL
Definition: resample.c:96
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition: strings.h:65
Definition: test_heap.c:38
Container of documentation trees.
Definition: xmldoc.c:74
struct ast_xml_node * ast_xml_node_get_children(struct ast_xml_node *node)
Get the node's children.
Definition: xml.c:395
static char documentation_language[6]
XML documentation language.
Definition: xmldoc.c:51
static char * _ast_xmldoc_build_arguments(struct ast_xml_node *node)
Definition: xmldoc.c:2134
static struct ast_xml_node * xmldoc_get_node(const char *type, const char *name, const char *module, const char *language)
Definition: xmldoc.c:435

References _ast_xmldoc_build_arguments(), AST_RWLIST_RDLOCK, AST_RWLIST_UNLOCK, ast_strlen_zero(), ast_xml_node_get_children(), documentation_language, name, NULL, type, and xmldoc_get_node().

Referenced by acf_retrieve_docs(), ast_agi_register(), ast_manager_register2(), and ast_register_application2().

◆ ast_xmldoc_build_description()

char * ast_xmldoc_build_description ( const char *  type,
const char *  name,
const char *  module 
)

Generate description documentation from XML.

Parameters
typeThe source of documentation (application, function, etc).
nameThe name of the application, function, etc.
moduleThe module the item is in (optional, can be NULL)
Return values
NULLon error.
Amalloc'ed string with the formatted description.

Definition at line 2361 of file xmldoc.c.

2362{
2363 return xmldoc_build_field(type, name, module, "description", 0);
2364}
static char * xmldoc_build_field(const char *type, const char *name, const char *module, const char *var, int raw)
Definition: xmldoc.c:2294

References name, type, and xmldoc_build_field().

Referenced by acf_retrieve_docs(), ast_agi_register(), ast_manager_register2(), and ast_register_application2().

◆ ast_xmldoc_build_documentation()

struct ao2_container * ast_xmldoc_build_documentation ( const char *  type)

Build the documentation for a particular source type.

Parameters
typeThe source of the documentation items (application, function, etc.)
Return values
NULLon error
Anao2_container populated with ast_xml_doc instances for each item that exists for the specified source type
Since
11

Definition at line 2783 of file xmldoc.c.

2784{
2785 struct ao2_container *docs;
2786 struct ast_xml_node *node = NULL, *instance = NULL;
2787 struct documentation_tree *doctree;
2788 const char *name;
2789
2792 if (!docs) {
2793 ast_log(AST_LOG_ERROR, "Failed to create container for xml document item instances\n");
2794 return NULL;
2795 }
2796
2798 AST_LIST_TRAVERSE(&xmldoc_tree, doctree, entry) {
2799 /* the core xml documents have priority over thirdparty document. */
2800 node = ast_xml_get_root(doctree->doc);
2801 if (!node) {
2802 break;
2803 }
2804
2806 struct ast_xml_doc_item *item = NULL;
2807
2808 /* Ignore empty nodes or nodes that aren't of the type requested */
2810 continue;
2811 }
2812 name = ast_xml_get_attribute(node, "name");
2813 if (!name) {
2814 continue;
2815 }
2816
2817 switch (xmldoc_get_syntax_type(type)) {
2819 {
2820 struct ast_xml_doc_item_list root;
2821
2822 AST_LIST_HEAD_INIT(&root);
2823 for (instance = ast_xml_node_get_children(node); instance; instance = ast_xml_node_get_next(instance)) {
2824 struct ast_xml_doc_item *temp;
2825 if (!ast_xml_node_get_children(instance) || strcasecmp(ast_xml_node_get_name(instance), "managerEventInstance")) {
2826 continue;
2827 }
2828 temp = xmldoc_build_documentation_item(instance, name, type);
2829 if (!temp) {
2830 break;
2831 }
2832 AST_LIST_INSERT_TAIL(&root, temp, next);
2833 }
2834 item = AST_LIST_FIRST(&root);
2835 break;
2836 }
2837 case CONFIG_INFO_SYNTAX:
2838 {
2839 RAII_VAR(const char *, name, ast_xml_get_attribute(node, "name"), ast_xml_free_attr);
2840
2841 if (!ast_xml_node_get_children(node) || strcasecmp(ast_xml_node_get_name(node), "configInfo")) {
2842 break;
2843 }
2844
2846 if (item) {
2847 struct ast_xml_doc_item_list root;
2848
2849 AST_LIST_HEAD_INIT(&root);
2850 AST_LIST_INSERT_TAIL(&root, item, next);
2851 build_config_docs(node, &root);
2852 }
2853 break;
2854 }
2855 default:
2857 }
2859
2860 if (item) {
2861 ao2_link(docs, item);
2862 ao2_t_ref(item, -1, "Dispose of creation ref");
2863 }
2864 }
2865 }
2867
2868 return docs;
2869}
#define ast_log
Definition: astobj2.c:42
#define ao2_t_ref(o, delta, tag)
Definition: astobj2.h:460
#define ao2_link(container, obj)
Add an object to a container.
Definition: astobj2.h:1532
@ AO2_ALLOC_OPT_LOCK_MUTEX
Definition: astobj2.h:363
#define ao2_container_alloc_hash(ao2_options, container_options, n_buckets, hash_fn, sort_fn, cmp_fn)
Allocate and initialize a hash container with the desired number of buckets.
Definition: astobj2.h:1303
#define AST_LOG_ERROR
#define AST_LIST_TRAVERSE(head, var, field)
Loops over (traverses) the entries in a list.
Definition: linkedlists.h:491
#define AST_LIST_INSERT_TAIL(head, elm, field)
Appends a list entry to the tail of a list.
Definition: linkedlists.h:731
#define AST_LIST_HEAD_INIT(head)
Initializes a list head structure.
Definition: linkedlists.h:626
#define AST_LIST_FIRST(head)
Returns the first entry contained in a list.
Definition: linkedlists.h:421
Generic container type.
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_xml_doc_item * next
Definition: xmldoc.h:80
XML documentation tree.
Definition: xmldoc.c:54
struct ast_xml_doc * doc
Definition: xmldoc.c:56
static struct aco_type item
Definition: test_config.c:1463
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
Definition: utils.h:978
const char * ast_xml_get_attribute(struct ast_xml_node *node, const char *attrname)
Get a node attribute by name.
Definition: xml.c:267
const char * ast_xml_node_get_name(struct ast_xml_node *node)
Get the name of a node.
Definition: xml.c:390
void ast_xml_free_attr(const char *attribute)
Free an attribute returned by ast_xml_get_attribute()
Definition: xml.c:253
struct ast_xml_node * ast_xml_node_get_next(struct ast_xml_node *node)
Get the next node in the same level.
Definition: xml.c:400
struct ast_xml_node * ast_xml_get_root(struct ast_xml_doc *doc)
Get the document root node.
Definition: xml.c:230
static int ast_xml_doc_item_cmp(void *obj, void *arg, int flags)
Definition: xmldoc.c:2454
static struct ast_xml_doc_item * xmldoc_build_documentation_item(struct ast_xml_node *node, const char *name, const char *type)
Definition: xmldoc.c:2474
static int ast_xml_doc_item_hash(const void *obj, const int flags)
Definition: xmldoc.c:2442
@ CONFIG_INFO_SYNTAX
Definition: xmldoc.c:1157
@ MANAGER_EVENT_SYNTAX
Definition: xmldoc.c:1156
static enum syntaxtype xmldoc_get_syntax_type(const char *type)
Definition: xmldoc.c:1188
static void build_config_docs(struct ast_xml_node *cur, struct ast_xml_doc_item_list *root)
Definition: xmldoc.c:2706

References AO2_ALLOC_OPT_LOCK_MUTEX, ao2_container_alloc_hash, ao2_link, ao2_t_ref, AST_LIST_FIRST, AST_LIST_HEAD_INIT, AST_LIST_INSERT_TAIL, AST_LIST_TRAVERSE, ast_log, AST_LOG_ERROR, AST_RWLIST_RDLOCK, AST_RWLIST_UNLOCK, ast_xml_doc_item_cmp(), ast_xml_doc_item_hash(), ast_xml_free_attr(), ast_xml_get_attribute(), ast_xml_get_root(), ast_xml_node_get_children(), ast_xml_node_get_name(), ast_xml_node_get_next(), build_config_docs(), CONFIG_INFO_SYNTAX, documentation_tree::doc, item, MANAGER_EVENT_SYNTAX, name, ast_xml_doc_item::next, NULL, RAII_VAR, type, xmldoc_build_documentation_item(), and xmldoc_get_syntax_type().

Referenced by __init_manager(), and aco_init().

◆ ast_xmldoc_build_final_response()

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.

Parameters
type'application', 'function' or 'agi'
nameName of the application or function to build the 'responses' tag.
moduleThe module the item is in (optional, can be NULL)
Returns
An XMLDoc item list with the [final response] tag content.
Since
13.0.0

Definition at line 2653 of file xmldoc.c.

2654{
2655 struct ast_xml_node *node;
2656 static struct ast_xml_doc_item *response;
2657
2659 return NULL;
2660 }
2661
2664
2667 return NULL;
2668 }
2669
2672 return response;
2673}
static struct ast_xml_doc_item * xmldoc_build_final_response(struct ast_xml_node *manager_action)
Definition: xmldoc.c:2619

References AST_RWLIST_RDLOCK, AST_RWLIST_UNLOCK, ast_strlen_zero(), ast_xml_node_get_children(), documentation_language, name, NULL, type, xmldoc_build_final_response(), and xmldoc_get_node().

Referenced by ast_manager_register2().

◆ ast_xmldoc_build_list_responses()

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.

Parameters
type'application', 'function' or 'agi'
nameName of the application or function to build the 'responses' tag.
moduleThe module the item is in (optional, can be NULL)
Returns
An XMLDoc item list with the [list responses] tag content.
Since
13.0.0

Definition at line 2583 of file xmldoc.c.

2584{
2585 struct ast_xml_node *node;
2586 struct ast_xml_doc_item *responses;
2587
2589 return NULL;
2590 }
2591
2594
2597 return NULL;
2598 }
2599
2600 responses = xmldoc_build_list_responses(node);
2602 return responses;
2603}
static struct ast_xml_doc_item * xmldoc_build_list_responses(struct ast_xml_node *manager_action)
Definition: xmldoc.c:2539

References AST_RWLIST_RDLOCK, AST_RWLIST_UNLOCK, ast_strlen_zero(), ast_xml_node_get_children(), documentation_language, name, NULL, type, xmldoc_build_list_responses(), and xmldoc_get_node().

Referenced by ast_manager_register2().

◆ ast_xmldoc_build_seealso()

char * ast_xmldoc_build_seealso ( const char *  type,
const char *  name,
const char *  module 
)

Parse the <see-also> node content.

Parameters
type'application', 'function' or 'agi'.
nameApplication or functions name.
moduleThe module the item is in (optional, can be NULL)
Return values
NULLon error.
Contentof the see-also node.

Definition at line 1707 of file xmldoc.c.

1708{
1709 char *output;
1710 struct ast_xml_node *node;
1711
1713 return NULL;
1714 }
1715
1716 /* get the application/function root node. */
1721 return NULL;
1722 }
1723
1726
1727 return output;
1728}
static char * _ast_xmldoc_build_seealso(struct ast_xml_node *node)
Definition: xmldoc.c:1645

References _ast_xmldoc_build_seealso(), AST_RWLIST_RDLOCK, AST_RWLIST_UNLOCK, ast_strlen_zero(), ast_xml_node_get_children(), documentation_language, name, NULL, type, and xmldoc_get_node().

Referenced by acf_retrieve_docs(), ast_agi_register(), ast_manager_register2(), and ast_register_application2().

◆ ast_xmldoc_build_since()

char * ast_xmldoc_build_since ( const char *  type,
const char *  name,
const char *  module 
)

Parse the <since> node content.

Parameters
type'application', 'function' or 'agi'.
nameApplication or functions name.
moduleThe module the item is in (optional, can be NULL)
Return values
NULLon error.
Contentof the since node.

Definition at line 1792 of file xmldoc.c.

1793{
1794 char *output;
1795 struct ast_xml_node *node;
1796
1798 return NULL;
1799 }
1800
1801 /* get the application/function root node. */
1806 return NULL;
1807 }
1808
1809 output = _ast_xmldoc_build_since(node);
1811
1812 return output;
1813}
static char * _ast_xmldoc_build_since(struct ast_xml_node *node)
Definition: xmldoc.c:1744

References _ast_xmldoc_build_since(), AST_RWLIST_RDLOCK, AST_RWLIST_UNLOCK, ast_strlen_zero(), ast_xml_node_get_children(), documentation_language, name, NULL, type, and xmldoc_get_node().

Referenced by acf_retrieve_docs(), ast_agi_register(), ast_manager_register2(), and ast_register_application2().

◆ ast_xmldoc_build_synopsis()

char * ast_xmldoc_build_synopsis ( const char *  type,
const char *  name,
const char *  module 
)

Generate synopsis documentation from XML.

Parameters
typeThe source of documentation (application, function, etc).
nameThe name of the application, function, etc.
moduleThe module the item is in (optional, can be NULL)
Return values
NULLon error.
Amalloc'ed string with the synopsis.

Definition at line 2338 of file xmldoc.c.

2339{
2340 return xmldoc_build_field(type, name, module, "synopsis", 1);
2341}

References name, type, and xmldoc_build_field().

Referenced by acf_retrieve_docs(), ast_agi_register(), ast_manager_register2(), and ast_register_application2().

◆ ast_xmldoc_build_syntax()

char * ast_xmldoc_build_syntax ( const char *  type,
const char *  name,
const char *  module 
)

Get the syntax for a specified application or function.

Parameters
typeApplication, Function or AGI ?
nameName of the application or function.
moduleThe module the item is in (optional, can be NULL)
Return values
NULLon error.
Thegenerated syntax in a ast_malloc'ed string.

Definition at line 1252 of file xmldoc.c.

1253{
1254 struct ast_xml_node *node;
1255 char *syntax;
1256
1259 if (!node) {
1261 return NULL;
1262 }
1263
1266 return syntax;
1267}
static char * _ast_xmldoc_build_syntax(struct ast_xml_node *root_node, const char *type, const char *name)
Definition: xmldoc.c:1215

References _ast_xmldoc_build_syntax(), AST_RWLIST_RDLOCK, AST_RWLIST_UNLOCK, documentation_language, name, NULL, type, and xmldoc_get_node().

Referenced by acf_retrieve_docs(), ast_agi_register(), ast_manager_register2(), and ast_register_application2().

◆ ast_xmldoc_printable()

char * ast_xmldoc_printable ( const char *  bwinput,
int  withcolors 
)

Colorize and put delimiters (instead of tags) to the xmldoc output.

Parameters
bwinputNot colorized input with tags.
withcolorsResult output with colors.
Return values
NULLon error.
Newmalloced buffer colorized and with delimiters.

Definition at line 241 of file xmldoc.c.

242{
243 struct ast_str *colorized;
244 char *wrapped = NULL;
245 int i, c, len, colorsection;
246 char *tmp;
247 size_t bwinputlen;
248 static const int base_fg = COLOR_CYAN;
249
250 if (!bwinput) {
251 return NULL;
252 }
253
254 bwinputlen = strlen(bwinput);
255
256 if (!(colorized = ast_str_create(256))) {
257 return NULL;
258 }
259
260 if (withcolors) {
261 ast_term_color_code(&colorized, base_fg, 0);
262 if (!colorized) {
263 return NULL;
264 }
265 }
266
267 for (i = 0; i < bwinputlen; i++) {
268 colorsection = 0;
269 /* Check if we are at the beginning of a tag to be colorized. */
270 for (c = 0; c < ARRAY_LEN(colorized_tags); c++) {
271 if (strncasecmp(bwinput + i, colorized_tags[c].inittag, strlen(colorized_tags[c].inittag))) {
272 continue;
273 }
274
275 if (!(tmp = strcasestr(bwinput + i + strlen(colorized_tags[c].inittag), colorized_tags[c].endtag))) {
276 continue;
277 }
278
279 len = tmp - (bwinput + i + strlen(colorized_tags[c].inittag));
280
281 /* Setup color */
282 if (withcolors) {
284 /* Turn off *bright* colors */
285 ast_term_color_code(&colorized, colorized_tags[c].colorfg & 0x7f, 0);
286 } else {
287 /* Turn on *bright* colors */
288 ast_term_color_code(&colorized, colorized_tags[c].colorfg | 0x80, 0);
289 }
290 if (!colorized) {
291 return NULL;
292 }
293 }
294
295 /* copy initial string replace */
296 ast_str_append(&colorized, 0, "%s", colorized_tags[c].init);
297 if (!colorized) {
298 return NULL;
299 }
300 {
301 char buf[len + 1];
302 ast_copy_string(buf, bwinput + i + strlen(colorized_tags[c].inittag), sizeof(buf));
303 ast_str_append(&colorized, 0, "%s", buf);
304 }
305 if (!colorized) {
306 return NULL;
307 }
308
309 /* copy the ending string replace */
310 ast_str_append(&colorized, 0, "%s", colorized_tags[c].end);
311 if (!colorized) {
312 return NULL;
313 }
314
315 /* Continue with the last color. */
316 if (withcolors) {
317 ast_term_color_code(&colorized, base_fg, 0);
318 if (!colorized) {
319 return NULL;
320 }
321 }
322
323 i += len + strlen(colorized_tags[c].endtag) + strlen(colorized_tags[c].inittag) - 1;
324 colorsection = 1;
325 break;
326 }
327
328 if (!colorsection) {
329 ast_str_append(&colorized, 0, "%c", bwinput[i]);
330 if (!colorized) {
331 return NULL;
332 }
333 }
334 }
335
336 if (withcolors) {
337 ast_str_append(&colorized, 0, "%s", ast_term_reset());
338 if (!colorized) {
339 return NULL;
340 }
341 }
342
343 /* Wrap the text, notice that string wrap will avoid cutting an ESC sequence. */
345
346 ast_free(colorized);
347
348 return wrapped;
349}
char * strcasestr(const char *, const char *)
#define ast_free(a)
Definition: astmm.h:180
char * end
Definition: eagi_proxy.c:73
char buf[BUFSIZE]
Definition: eagi_proxy.c:66
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
#define ast_opt_light_background
Definition: options.h:140
int ast_str_append(struct ast_str **buf, ssize_t max_len, const char *fmt,...)
Append to a thread local dynamic string.
Definition: strings.h:1139
char * ast_str_buffer(const struct ast_str *buf)
Returns the string buffer within the ast_str buf.
Definition: strings.h:761
#define ast_str_create(init_len)
Create a malloc'ed dynamic length string.
Definition: strings.h:659
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:425
Support for dynamic strings.
Definition: strings.h:623
int ast_term_color_code(struct ast_str **str, int fgcolor, int bgcolor)
Append a color sequence to an ast_str.
Definition: term.c:296
const char * ast_term_reset(void)
Returns the terminal reset code.
Definition: term.c:357
#define COLOR_CYAN
Definition: term.h:62
static struct test_val c
#define ARRAY_LEN(a)
Definition: utils.h:703
static const struct strcolorized_tags colorized_tags[]
static char * xmldoc_string_wrap(const char *text, int columns)
Definition: xmldoc.c:175
static const int xmldoc_text_columns
Number of columns to print when showing the XML documentation with a 'core show application/function ...
Definition: xmldoc.c:48

References ARRAY_LEN, ast_copy_string(), ast_free, ast_opt_light_background, ast_str_append(), ast_str_buffer(), ast_str_create, ast_term_color_code(), ast_term_reset(), buf, c, COLOR_CYAN, colorized_tags, end, len(), NULL, strcasestr(), xmldoc_string_wrap(), and xmldoc_text_columns.

Referenced by cli_show_module_options(), cli_show_module_type(), cli_show_module_types(), handle_cli_agi_show(), handle_show_function(), handle_showmancmd(), print_app_docs(), print_event_instance(), and write_htmldump().

◆ ast_xmldoc_query()

struct ast_xml_xpath_results * ast_xmldoc_query ( const char *  fmt,
  ... 
)

Execute an XPath query on the loaded XML documentation.

Parameters
fmtThe XPath query string to execute
...Variable printf style format arguments
Return values
AnXPath results object on success
NULLif no match found
Since
12

Definition at line 2675 of file xmldoc.c.

2676{
2677 struct ast_xml_xpath_results *results = NULL;
2678 struct documentation_tree *doctree;
2679 RAII_VAR(struct ast_str *, xpath_str, ast_str_create(128), ast_free);
2680 va_list ap;
2681 int res;
2682
2683 if (!xpath_str) {
2684 return NULL;
2685 }
2686
2687 va_start(ap, fmt);
2688 res = ast_str_set_va(&xpath_str, 0, fmt, ap);
2689 va_end(ap);
2690 if (res == AST_DYNSTR_BUILD_FAILED) {
2691 return NULL;
2692 }
2693
2695 AST_LIST_TRAVERSE(&xmldoc_tree, doctree, entry) {
2696 if (!(results = ast_xml_query(doctree->doc, ast_str_buffer(xpath_str)))) {
2697 continue;
2698 }
2699 break;
2700 }
2702
2703 return results;
2704}
int ast_str_set_va(struct ast_str **buf, ssize_t max_len, const char *fmt, va_list ap)
Set a dynamic string from a va_list.
Definition: strings.h:1030
@ AST_DYNSTR_BUILD_FAILED
Definition: strings.h:943
struct ast_xml_xpath_results * ast_xml_query(struct ast_xml_doc *doc, const char *xpath_str)
Execute an XPath query on an XML document.
Definition: xml.c:441

References AST_DYNSTR_BUILD_FAILED, ast_free, AST_LIST_TRAVERSE, AST_RWLIST_RDLOCK, AST_RWLIST_UNLOCK, ast_str_buffer(), ast_str_create, ast_str_set_va(), ast_xml_query(), documentation_tree::doc, NULL, and RAII_VAR.

Referenced by load_modules(), xmldoc_update_config_option(), and xmldoc_update_config_type().

◆ ast_xmldoc_regenerate_doc_item()

int ast_xmldoc_regenerate_doc_item ( struct ast_xml_doc_item item)

Regenerate the documentation for a particular item.

Parameters
itemThe documentation item to regenerate
Return values
-1on error
0on success
Since
12

Definition at line 2734 of file xmldoc.c.

2735{
2736 const char *name;
2737 char *syntax;
2738 char *seealso;
2739 char *arguments;
2740 char *synopsis;
2741 char *description;
2742
2743 if (!item || !item->node) {
2744 return -1;
2745 }
2746
2747 name = ast_xml_get_attribute(item->node, "name");
2748 if (!name) {
2749 return -1;
2750 }
2751
2752 syntax = _ast_xmldoc_build_syntax(item->node, item->type, name);
2753 seealso = _ast_xmldoc_build_seealso(item->node);
2754 arguments = _ast_xmldoc_build_arguments(item->node);
2756 description = _ast_xmldoc_build_description(item->node);
2757
2758 if (syntax) {
2759 ast_str_set(&item->syntax, 0, "%s", syntax);
2760 }
2761 if (seealso) {
2762 ast_str_set(&item->seealso, 0, "%s", seealso);
2763 }
2764 if (arguments) {
2765 ast_str_set(&item->arguments, 0, "%s", arguments);
2766 }
2767 if (synopsis) {
2768 ast_str_set(&item->synopsis, 0, "%s", synopsis);
2769 }
2770 if (description) {
2771 ast_str_set(&item->description, 0, "%s", description);
2772 }
2773
2774 ast_free(syntax);
2775 ast_free(seealso);
2776 ast_free(arguments);
2778 ast_free(description);
2780 return 0;
2781}
static char * synopsis
Definition: func_enum.c:166
int ast_str_set(struct ast_str **buf, ssize_t max_len, const char *fmt,...)
Set a dynamic string using variable arguments.
Definition: strings.h:1113
enum aco_type_t type
static char * _ast_xmldoc_build_synopsis(struct ast_xml_node *node)
Definition: xmldoc.c:2333
static char * _ast_xmldoc_build_description(struct ast_xml_node *node)
Definition: xmldoc.c:2356

References _ast_xmldoc_build_arguments(), _ast_xmldoc_build_description(), _ast_xmldoc_build_seealso(), _ast_xmldoc_build_synopsis(), _ast_xmldoc_build_syntax(), ast_xml_doc_item::arguments, ast_free, ast_str_set(), ast_xml_free_attr(), ast_xml_get_attribute(), ast_xml_doc_item::description, item, name, ast_xml_doc_item::seealso, synopsis, ast_xml_doc_item::syntax, and aco_type::type.

Referenced by xmldoc_update_config_option(), and xmldoc_update_config_type().