mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-02 19:16:15 +00:00
Add CLI configuration documentation
This patch allows a module to define its configuration in XML in source, such that it can be parsed by the XML documentation engine. Documentation is generated in a two-pass approach: 1. The documentation is first generated from the XML pulled from the source 2. The documentation is then enhanced by the registration of configuration options that use the configuration framework This patch include configuration documentation for the following modules: * chan_motif * res_xmpp * app_confbridge * app_skel * udptl Two new CLI commands have been added: * config show help - show configuration help by module, category, and item * xmldoc dump - dump the in-memory representation of the XML documentation to a new XML file. Review: https://reviewboard.asterisk.org/r/2278 Review: https://reviewboard.asterisk.org/r/2058 patches: on review 2058 uploaded by twilson git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@381527 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
39
main/xml.c
39
main/xml.c
@@ -28,6 +28,7 @@
|
||||
#include "asterisk.h"
|
||||
#include "asterisk/xml.h"
|
||||
#include "asterisk/logger.h"
|
||||
#include "asterisk/utils.h"
|
||||
|
||||
ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
|
||||
|
||||
@@ -35,6 +36,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
|
||||
#include <libxml/parser.h>
|
||||
#include <libxml/tree.h>
|
||||
#include <libxml/xinclude.h>
|
||||
#include <libxml/xpath.h>
|
||||
/* libxml2 ast_xml implementation. */
|
||||
|
||||
|
||||
@@ -316,5 +318,42 @@ struct ast_xml_node *ast_xml_node_get_parent(struct ast_xml_node *node)
|
||||
return (struct ast_xml_node *) ((xmlNode *) node)->parent;
|
||||
}
|
||||
|
||||
struct ast_xml_node *ast_xml_xpath_get_first_result(struct ast_xml_xpath_results *results)
|
||||
{
|
||||
return (struct ast_xml_node *) ((xmlXPathObjectPtr) results)->nodesetval->nodeTab[0];
|
||||
}
|
||||
|
||||
void ast_xml_xpath_results_free(struct ast_xml_xpath_results *results)
|
||||
{
|
||||
xmlXPathFreeObject((xmlXPathObjectPtr) results);
|
||||
}
|
||||
|
||||
int ast_xml_xpath_num_results(struct ast_xml_xpath_results *results)
|
||||
{
|
||||
return ((xmlXPathObjectPtr) results)->nodesetval->nodeNr;
|
||||
}
|
||||
|
||||
struct ast_xml_xpath_results *ast_xml_query(struct ast_xml_doc *doc, const char *xpath_str)
|
||||
{
|
||||
xmlXPathContextPtr context;
|
||||
xmlXPathObjectPtr result;
|
||||
if (!(context = xmlXPathNewContext((xmlDoc *) doc))) {
|
||||
ast_log(LOG_ERROR, "Could not create XPath context!\n");
|
||||
return NULL;
|
||||
}
|
||||
result = xmlXPathEvalExpression((xmlChar *) xpath_str, context);
|
||||
xmlXPathFreeContext(context);
|
||||
if (!result) {
|
||||
ast_log(LOG_WARNING, "Error for query: %s\n", xpath_str);
|
||||
return NULL;
|
||||
}
|
||||
if (xmlXPathNodeSetIsEmpty(result->nodesetval)) {
|
||||
xmlXPathFreeObject(result);
|
||||
ast_debug(5, "No results for query: %s\n", xpath_str);
|
||||
return NULL;
|
||||
}
|
||||
return (struct ast_xml_xpath_results *) result;
|
||||
}
|
||||
|
||||
#endif /* defined(HAVE_LIBXML2) */
|
||||
|
||||
|
Reference in New Issue
Block a user