#include "asterisk.h"
#include "asterisk/_private.h"
#include "asterisk/paths.h"
#include "asterisk/linkedlists.h"
#include "asterisk/strings.h"
#include "asterisk/config.h"
#include "asterisk/term.h"
#include "asterisk/xmldoc.h"
Go to the source code of this file.
Data Structures | |
struct | documentation_tree |
XML documentation tree. More... | |
struct | strcolorized_tags |
struct | strspecial_tags |
struct | strsyntaxtype |
Mapping between type of node and type of syntax to generate. More... | |
struct | xmldoc_tree |
Container of documentation trees. More... | |
Defines | |
#define | GOTONEXT(__rev, __a) (__rev ? ast_xml_node_get_prev(__a) : ast_xml_node_get_next(__a)) |
#define | ISLAST(__rev, __a) (__rev == 1 ? (ast_xml_node_get_prev(__a) ? 0 : 1) : (ast_xml_node_get_next(__a) ? 0 : 1)) |
#define | MP(__a) ((multiple ? __a : "")) |
Enumerations | |
enum | syntaxtype { FUNCTION_SYNTAX, MANAGER_SYNTAX, COMMAND_SYNTAX } |
Types of syntax that we are able to generate. More... | |
Functions | |
char * | ast_xmldoc_build_arguments (const char *type, const char *name, const char *module) |
char * | ast_xmldoc_build_description (const char *type, const char *name, const char *module) |
char * | ast_xmldoc_build_seealso (const char *type, const char *name, const char *module) |
char * | ast_xmldoc_build_synopsis (const char *type, const char *name, const char *module) |
char * | ast_xmldoc_build_syntax (const char *type, const char *name, const char *module) |
char * | ast_xmldoc_printable (const char *bwinput, int withcolors) |
static int | xmldoc_attribute_match (struct ast_xml_node *node, const char *attr, const char *value) |
static char * | xmldoc_build_field (const char *type, const char *name, const char *module, const char *var, int raw) |
Get the content of a field (synopsis, description, etc) from an asterisk document tree. | |
static int | xmldoc_foundspace_backward (const char *text, int currentpos, int maxdiff) |
static struct ast_str * | xmldoc_get_formatted (struct ast_xml_node *node, int raw_output, int raw_wrap) |
static struct ast_xml_node * | xmldoc_get_node (const char *type, const char *name, const char *module, const char *language) |
static char * | xmldoc_get_syntax_cmd (struct ast_xml_node *fixnode, const char *name, int printname) |
static char * | xmldoc_get_syntax_fun (struct ast_xml_node *rootnode, const char *rootname, const char *childname, int printparenthesis, int printrootname) |
static char * | xmldoc_get_syntax_manager (struct ast_xml_node *fixnode, const char *name) |
static enum syntaxtype | xmldoc_get_syntax_type (const char *type) |
static int | xmldoc_has_inside (struct ast_xml_node *fixnode, const char *what) |
static int | xmldoc_has_nodes (struct ast_xml_node *fixnode) |
static int | xmldoc_has_specialtags (struct ast_xml_node *fixnode) |
static int | xmldoc_parse_argument (struct ast_xml_node *fixnode, int insideparameter, const char *paramtabs, const char *tabs, struct ast_str **buffer) |
static char * | xmldoc_parse_cmd_enumlist (struct ast_xml_node *fixnode) |
static int | xmldoc_parse_enum (struct ast_xml_node *fixnode, const char *tabs, struct ast_str **buffer) |
static int | xmldoc_parse_enumlist (struct ast_xml_node *fixnode, const char *tabs, struct ast_str **buffer) |
static int | xmldoc_parse_option (struct ast_xml_node *fixnode, const char *tabs, struct ast_str **buffer) |
static void | xmldoc_parse_optionlist (struct ast_xml_node *fixnode, const char *tabs, struct ast_str **buffer) |
static int | xmldoc_parse_para (struct ast_xml_node *node, const char *tabs, const char *posttabs, struct ast_str **buffer) |
static void | xmldoc_parse_parameter (struct ast_xml_node *fixnode, const char *tabs, struct ast_str **buffer) |
static int | xmldoc_parse_specialtags (struct ast_xml_node *fixnode, const char *tabs, const char *posttabs, struct ast_str **buffer) |
static int | xmldoc_parse_variable (struct ast_xml_node *node, const char *tabs, struct ast_str **buffer) |
static int | xmldoc_parse_variablelist (struct ast_xml_node *node, const char *tabs, struct ast_str **buffer) |
static int | xmldoc_postbrlen (const char *postbr) |
static void | xmldoc_reverse_helper (int reverse, int *len, char **syntax, const char *fmt,...) |
static void | xmldoc_setpostbr (char *postbr, size_t len, const char *text) |
static void | xmldoc_string_cleanup (const char *text, struct ast_str **output, int lastspaces) |
static char * | xmldoc_string_wrap (const char *text, int columns, int maxdiff) |
static int | xmldoc_wait_nextspace (const char *text, int currentpos, int maxdiff) |
Variables | |
static struct strcolorized_tags | colorized_tags [] |
static const char | default_documentation_language [] = "en_US" |
Default documentation language. | |
static char | documentation_language [6] |
XML documentation language. | |
static struct strspecial_tags | special_tags [] |
static struct strsyntaxtype | stxtype [] |
Mapping between type of node and type of syntax to generate. | |
static const int | xmldoc_max_diff = 5 |
This is a value that we will use to let the wrapping mechanism move the cursor backward and forward xmldoc_max_diff positions before cutting the middle of a word, trying to find a space or a . | |
static const int | xmldoc_text_columns = 74 |
Number of columns to print when showing the XML documentation with a 'core show application/function *' CLI command. Used in text wrapping. |
Definition in file xmldoc.c.
#define GOTONEXT | ( | __rev, | |||
__a | ) | (__rev ? ast_xml_node_get_prev(__a) : ast_xml_node_get_next(__a)) |
Referenced by xmldoc_get_syntax_fun().
#define ISLAST | ( | __rev, | |||
__a | ) | (__rev == 1 ? (ast_xml_node_get_prev(__a) ? 0 : 1) : (ast_xml_node_get_next(__a) ? 0 : 1)) |
Referenced by xmldoc_get_syntax_fun().
#define MP | ( | __a | ) | ((multiple ? __a : "")) |
Referenced by xmldoc_get_syntax_fun().
enum syntaxtype |
Types of syntax that we are able to generate.
Definition at line 1102 of file xmldoc.c.
01102 { 01103 FUNCTION_SYNTAX, 01104 MANAGER_SYNTAX, 01105 COMMAND_SYNTAX 01106 };
char* ast_xmldoc_build_arguments | ( | const char * | type, | |
const char * | name, | |||
const char * | module | |||
) |
Definition at line 1741 of file xmldoc.c.
References ast_free, ast_str_buffer(), ast_str_create(), ast_str_strlen(), ast_str_truncate(), ast_strdup, ast_strlen_zero(), ast_xml_node_get_children(), ast_xml_node_get_name(), ast_xml_node_get_next(), xmldoc_get_node(), and xmldoc_parse_parameter().
Referenced by acf_retrieve_docs(), ast_manager_register2(), and ast_register_application2().
01742 { 01743 struct ast_xml_node *node; 01744 struct ast_str *ret = ast_str_create(128); 01745 char *retstr = NULL; 01746 01747 if (ast_strlen_zero(type) || ast_strlen_zero(name)) { 01748 ast_free(ret); 01749 return NULL; 01750 } 01751 01752 node = xmldoc_get_node(type, name, module, documentation_language); 01753 01754 if (!node || !ast_xml_node_get_children(node)) { 01755 ast_free(ret); 01756 return NULL; 01757 } 01758 01759 /* Find the syntax field. */ 01760 for (node = ast_xml_node_get_children(node); node; node = ast_xml_node_get_next(node)) { 01761 if (!strcasecmp(ast_xml_node_get_name(node), "syntax")) { 01762 break; 01763 } 01764 } 01765 01766 if (!node || !ast_xml_node_get_children(node)) { 01767 /* We couldn't find the syntax node. */ 01768 ast_free(ret); 01769 return NULL; 01770 } 01771 01772 for (node = ast_xml_node_get_children(node); node; node = ast_xml_node_get_next(node)) { 01773 xmldoc_parse_parameter(node, "", &ret); 01774 } 01775 01776 if (ast_str_strlen(ret) > 0) { 01777 /* remove last '\n' */ 01778 char *buf = ast_str_buffer(ret); 01779 if (buf[ast_str_strlen(ret) - 1] == '\n') { 01780 ast_str_truncate(ret, -1); 01781 } 01782 retstr = ast_strdup(ast_str_buffer(ret)); 01783 } 01784 ast_free(ret); 01785 01786 return retstr; 01787 }
char* ast_xmldoc_build_description | ( | const char * | type, | |
const char * | name, | |||
const char * | module | |||
) |
Definition at line 1878 of file xmldoc.c.
References xmldoc_build_field().
Referenced by acf_retrieve_docs(), ast_agi_register(), ast_manager_register2(), and ast_register_application2().
01879 { 01880 return xmldoc_build_field(type, name, module, "description", 0); 01881 }
char* ast_xmldoc_build_seealso | ( | const char * | type, | |
const char * | name, | |||
const char * | module | |||
) |
Definition at line 1442 of file xmldoc.c.
References ast_free, ast_str_append(), ast_str_buffer(), ast_str_create(), ast_strdup, ast_strlen_zero(), ast_xml_free_attr(), ast_xml_free_text(), ast_xml_get_attribute(), ast_xml_get_text(), ast_xml_node_get_children(), ast_xml_node_get_name(), ast_xml_node_get_next(), first, and xmldoc_get_node().
Referenced by acf_retrieve_docs(), ast_agi_register(), ast_manager_register2(), and ast_register_application2().
01443 { 01444 struct ast_str *outputstr; 01445 char *output; 01446 struct ast_xml_node *node; 01447 const char *typename; 01448 const char *content; 01449 int first = 1; 01450 01451 if (ast_strlen_zero(type) || ast_strlen_zero(name)) { 01452 return NULL; 01453 } 01454 01455 /* get the application/function root node. */ 01456 node = xmldoc_get_node(type, name, module, documentation_language); 01457 if (!node || !ast_xml_node_get_children(node)) { 01458 return NULL; 01459 } 01460 01461 /* Find the <see-also> node. */ 01462 for (node = ast_xml_node_get_children(node); node; node = ast_xml_node_get_next(node)) { 01463 if (!strcasecmp(ast_xml_node_get_name(node), "see-also")) { 01464 break; 01465 } 01466 } 01467 01468 if (!node || !ast_xml_node_get_children(node)) { 01469 /* we couldnt find a <see-also> node. */ 01470 return NULL; 01471 } 01472 01473 /* prepare the output string. */ 01474 outputstr = ast_str_create(128); 01475 if (!outputstr) { 01476 return NULL; 01477 } 01478 01479 /* get into the <see-also> node. */ 01480 for (node = ast_xml_node_get_children(node); node; node = ast_xml_node_get_next(node)) { 01481 if (strcasecmp(ast_xml_node_get_name(node), "ref")) { 01482 continue; 01483 } 01484 01485 /* parse the <ref> node. 'type' attribute is required. */ 01486 typename = ast_xml_get_attribute(node, "type"); 01487 if (!typename) { 01488 continue; 01489 } 01490 content = ast_xml_get_text(node); 01491 if (!content) { 01492 ast_xml_free_attr(typename); 01493 continue; 01494 } 01495 if (!strcasecmp(typename, "application")) { 01496 ast_str_append(&outputstr, 0, "%s%s()", (first ? "" : ", "), content); 01497 } else if (!strcasecmp(typename, "function")) { 01498 ast_str_append(&outputstr, 0, "%s%s", (first ? "" : ", "), content); 01499 } else if (!strcasecmp(typename, "astcli")) { 01500 ast_str_append(&outputstr, 0, "%s<astcli>%s</astcli>", (first ? "" : ", "), content); 01501 } else { 01502 ast_str_append(&outputstr, 0, "%s%s", (first ? "" : ", "), content); 01503 } 01504 first = 0; 01505 ast_xml_free_text(content); 01506 ast_xml_free_attr(typename); 01507 } 01508 01509 output = ast_strdup(ast_str_buffer(outputstr)); 01510 ast_free(outputstr); 01511 01512 return output; 01513 }
char* ast_xmldoc_build_synopsis | ( | const char * | type, | |
const char * | name, | |||
const char * | module | |||
) |
Definition at line 1873 of file xmldoc.c.
References xmldoc_build_field().
Referenced by acf_retrieve_docs(), ast_agi_register(), ast_manager_register2(), and ast_register_application2().
01874 { 01875 return xmldoc_build_field(type, name, module, "synopsis", 1); 01876 }
char* ast_xmldoc_build_syntax | ( | const char * | type, | |
const char * | name, | |||
const char * | module | |||
) |
Definition at line 1136 of file xmldoc.c.
References ast_xml_node_get_children(), ast_xml_node_get_name(), ast_xml_node_get_next(), COMMAND_SYNTAX, FUNCTION_SYNTAX, MANAGER_SYNTAX, xmldoc_get_node(), xmldoc_get_syntax_cmd(), xmldoc_get_syntax_fun(), xmldoc_get_syntax_manager(), and xmldoc_get_syntax_type().
Referenced by acf_retrieve_docs(), ast_agi_register(), ast_manager_register2(), and ast_register_application2().
01137 { 01138 struct ast_xml_node *node; 01139 char *syntax = NULL; 01140 01141 node = xmldoc_get_node(type, name, module, documentation_language); 01142 if (!node) { 01143 return NULL; 01144 } 01145 01146 for (node = ast_xml_node_get_children(node); node; node = ast_xml_node_get_next(node)) { 01147 if (!strcasecmp(ast_xml_node_get_name(node), "syntax")) { 01148 break; 01149 } 01150 } 01151 01152 if (node) { 01153 switch (xmldoc_get_syntax_type(type)) { 01154 case FUNCTION_SYNTAX: 01155 syntax = xmldoc_get_syntax_fun(node, name, "parameter", 1, 1); 01156 break; 01157 case COMMAND_SYNTAX: 01158 syntax = xmldoc_get_syntax_cmd(node, name, 1); 01159 break; 01160 case MANAGER_SYNTAX: 01161 syntax = xmldoc_get_syntax_manager(node, name); 01162 break; 01163 default: 01164 syntax = xmldoc_get_syntax_fun(node, name, "parameter", 1, 1); 01165 } 01166 } 01167 return syntax; 01168 }
char* ast_xmldoc_printable | ( | const char * | bwinput, | |
int | withcolors | |||
) |
Definition at line 315 of file xmldoc.c.
References ARRAY_LEN, ast_copy_string(), ast_free, ast_str_append(), ast_str_buffer(), ast_str_create(), ast_term_color_code(), COLOR_CYAN, colorized_tags, len(), strcasestr(), term_end(), and xmldoc_string_wrap().
Referenced by handle_cli_agi_show(), handle_show_function(), handle_showmancmd(), print_app_docs(), and write_htmldump().
00316 { 00317 struct ast_str *colorized; 00318 char *wrapped = NULL; 00319 int i, c, len, colorsection; 00320 char *tmp; 00321 size_t bwinputlen; 00322 static const int base_fg = COLOR_CYAN; 00323 00324 if (!bwinput) { 00325 return NULL; 00326 } 00327 00328 bwinputlen = strlen(bwinput); 00329 00330 if (!(colorized = ast_str_create(256))) { 00331 return NULL; 00332 } 00333 00334 if (withcolors) { 00335 ast_term_color_code(&colorized, base_fg, 0); 00336 if (!colorized) { 00337 return NULL; 00338 } 00339 } 00340 00341 for (i = 0; i < bwinputlen; i++) { 00342 colorsection = 0; 00343 /* Check if we are at the beginning of a tag to be colorized. */ 00344 for (c = 0; c < ARRAY_LEN(colorized_tags); c++) { 00345 if (strncasecmp(bwinput + i, colorized_tags[c].inittag, strlen(colorized_tags[c].inittag))) { 00346 continue; 00347 } 00348 00349 if (!(tmp = strcasestr(bwinput + i + strlen(colorized_tags[c].inittag), colorized_tags[c].endtag))) { 00350 continue; 00351 } 00352 00353 len = tmp - (bwinput + i + strlen(colorized_tags[c].inittag)); 00354 00355 /* Setup color */ 00356 if (withcolors) { 00357 ast_term_color_code(&colorized, colorized_tags[c].colorfg, 0); 00358 if (!colorized) { 00359 return NULL; 00360 } 00361 } 00362 00363 /* copy initial string replace */ 00364 ast_str_append(&colorized, 0, "%s", colorized_tags[c].init); 00365 if (!colorized) { 00366 return NULL; 00367 } 00368 { 00369 char buf[len + 1]; 00370 ast_copy_string(buf, bwinput + i + strlen(colorized_tags[c].inittag), sizeof(buf)); 00371 ast_str_append(&colorized, 0, "%s", buf); 00372 } 00373 if (!colorized) { 00374 return NULL; 00375 } 00376 00377 /* copy the ending string replace */ 00378 ast_str_append(&colorized, 0, "%s", colorized_tags[c].end); 00379 if (!colorized) { 00380 return NULL; 00381 } 00382 00383 /* Continue with the last color. */ 00384 if (withcolors) { 00385 ast_term_color_code(&colorized, base_fg, 0); 00386 if (!colorized) { 00387 return NULL; 00388 } 00389 } 00390 00391 i += len + strlen(colorized_tags[c].endtag) + strlen(colorized_tags[c].inittag) - 1; 00392 colorsection = 1; 00393 break; 00394 } 00395 00396 if (!colorsection) { 00397 ast_str_append(&colorized, 0, "%c", bwinput[i]); 00398 if (!colorized) { 00399 return NULL; 00400 } 00401 } 00402 } 00403 00404 if (withcolors) { 00405 ast_str_append(&colorized, 0, "%s", term_end()); 00406 if (!colorized) { 00407 return NULL; 00408 } 00409 } 00410 00411 /* Wrap the text, notice that string wrap will avoid cutting an ESC sequence. */ 00412 wrapped = xmldoc_string_wrap(ast_str_buffer(colorized), xmldoc_text_columns, xmldoc_max_diff); 00413 00414 ast_free(colorized); 00415 00416 return wrapped; 00417 }
static int xmldoc_attribute_match | ( | struct ast_xml_node * | node, | |
const char * | attr, | |||
const char * | value | |||
) | [static] |
Definition at line 470 of file xmldoc.c.
References ast_xml_free_attr(), ast_xml_get_attribute(), and match().
Referenced by xmldoc_get_node().
00471 { 00472 const char *attr_value = ast_xml_get_attribute(node, attr); 00473 int match = attr_value && !strcmp(attr_value, value); 00474 ast_xml_free_attr(attr_value); 00475 return match; 00476 }
static char* xmldoc_build_field | ( | const char * | type, | |
const char * | name, | |||
const char * | module, | |||
const char * | var, | |||
int | raw | |||
) | [static] |
Get the content of a field (synopsis, description, etc) from an asterisk document tree.
type | Type of element (application, function, ...). | |
name | Name of element (Dial, Echo, Playback, ...). | |
var | Name of field to return (synopsis, description, etc). | |
raw | Field only contains text, no other elements inside it. |
NULL | On error. | |
Field | text content on success. |
Definition at line 1839 of file xmldoc.c.
References ast_free, ast_log(), ast_str_buffer(), ast_str_strlen(), ast_strdup, ast_strlen_zero(), ast_xml_find_element(), ast_xml_node_get_children(), LOG_DEBUG, LOG_ERROR, LOG_WARNING, xmldoc_get_formatted(), and xmldoc_get_node().
Referenced by ast_xmldoc_build_description(), and ast_xmldoc_build_synopsis().
01840 { 01841 struct ast_xml_node *node; 01842 char *ret = NULL; 01843 struct ast_str *formatted; 01844 01845 if (ast_strlen_zero(type) || ast_strlen_zero(name)) { 01846 ast_log(LOG_ERROR, "Tried to look in XML tree with faulty values.\n"); 01847 return ret; 01848 } 01849 01850 node = xmldoc_get_node(type, name, module, documentation_language); 01851 01852 if (!node) { 01853 ast_log(LOG_WARNING, "Couldn't find %s %s in XML documentation\n", type, name); 01854 return ret; 01855 } 01856 01857 node = ast_xml_find_element(ast_xml_node_get_children(node), var, NULL, NULL); 01858 01859 if (!node || !ast_xml_node_get_children(node)) { 01860 ast_log(LOG_DEBUG, "Cannot find variable '%s' in tree '%s'\n", var, name); 01861 return ret; 01862 } 01863 01864 formatted = xmldoc_get_formatted(node, raw, raw); 01865 if (ast_str_strlen(formatted) > 0) { 01866 ret = ast_strdup(ast_str_buffer(formatted)); 01867 } 01868 ast_free(formatted); 01869 01870 return ret; 01871 }
static int xmldoc_foundspace_backward | ( | const char * | text, | |
int | currentpos, | |||
int | maxdiff | |||
) | [static] |
Definition at line 209 of file xmldoc.c.
Referenced by xmldoc_string_wrap().
00210 { 00211 int i; 00212 00213 for (i = currentpos; i > 0; i--) { 00214 if (text[i] == ' ' || text[i] == '\n') { 00215 return (currentpos - i); 00216 } else if (text[i] == 'm' && (text[i - 1] >= '0' || text[i - 1] <= '9')) { 00217 /* give up, we found the end of a possible ESC sequence. */ 00218 return 0; 00219 } else if (currentpos - i > maxdiff) { 00220 /* give up, we can't move anymore. */ 00221 return 0; 00222 } 00223 } 00224 00225 /* we found the beginning of the text */ 00226 00227 return 0; 00228 }
static struct ast_str* xmldoc_get_formatted | ( | struct ast_xml_node * | node, | |
int | raw_output, | |||
int | raw_wrap | |||
) | [static] |
Definition at line 1797 of file xmldoc.c.
References ast_skip_blanks(), ast_str_buffer(), ast_str_create(), ast_str_strlen(), ast_str_truncate(), ast_xml_free_text(), ast_xml_get_text(), ast_xml_node_get_children(), ast_xml_node_get_next(), xmldoc_parse_enumlist(), xmldoc_parse_para(), xmldoc_parse_specialtags(), xmldoc_parse_variablelist(), and xmldoc_string_cleanup().
Referenced by xmldoc_build_field().
01798 { 01799 struct ast_xml_node *tmp; 01800 const char *notcleanret, *tmpstr; 01801 struct ast_str *ret = ast_str_create(128); 01802 01803 if (raw_output) { 01804 notcleanret = ast_xml_get_text(node); 01805 tmpstr = notcleanret; 01806 xmldoc_string_cleanup(ast_skip_blanks(notcleanret), &ret, 0); 01807 ast_xml_free_text(tmpstr); 01808 } else { 01809 for (tmp = ast_xml_node_get_children(node); tmp; tmp = ast_xml_node_get_next(tmp)) { 01810 /* if found, parse a <para> element. */ 01811 if (xmldoc_parse_para(tmp, "", "\n", &ret)) { 01812 continue; 01813 } else if (xmldoc_parse_specialtags(tmp, "", "\n", &ret)) { 01814 continue; 01815 } 01816 /* if found, parse a <variablelist> element. */ 01817 xmldoc_parse_variablelist(tmp, "", &ret); 01818 xmldoc_parse_enumlist(tmp, " ", &ret); 01819 } 01820 /* remove last '\n' */ 01821 /* XXX Don't modify ast_str internals manually */ 01822 tmpstr = ast_str_buffer(ret); 01823 if (tmpstr[ast_str_strlen(ret) - 1] == '\n') { 01824 ast_str_truncate(ret, -1); 01825 } 01826 } 01827 return ret; 01828 }
static struct ast_xml_node* xmldoc_get_node | ( | const char * | type, | |
const char * | name, | |||
const char * | module, | |||
const char * | language | |||
) | [static] |
Definition at line 489 of file xmldoc.c.
References AST_LIST_TRAVERSE, AST_RWLIST_RDLOCK, AST_RWLIST_UNLOCK, ast_strlen_zero(), ast_xml_find_element(), ast_xml_get_root(), ast_xml_node_get_children(), ast_xml_node_get_next(), documentation_tree::doc, documentation_tree::entry, and xmldoc_attribute_match().
Referenced by ast_xmldoc_build_arguments(), ast_xmldoc_build_seealso(), ast_xmldoc_build_syntax(), and xmldoc_build_field().
00490 { 00491 struct ast_xml_node *node = NULL; 00492 struct ast_xml_node *first_match = NULL; 00493 struct ast_xml_node *lang_match = NULL; 00494 struct documentation_tree *doctree; 00495 00496 AST_RWLIST_RDLOCK(&xmldoc_tree); 00497 AST_LIST_TRAVERSE(&xmldoc_tree, doctree, entry) { 00498 /* the core xml documents have priority over thirdparty document. */ 00499 node = ast_xml_get_root(doctree->doc); 00500 if (!node) { 00501 break; 00502 } 00503 00504 node = ast_xml_node_get_children(node); 00505 while ((node = ast_xml_find_element(node, type, "name", name))) { 00506 if (!ast_xml_node_get_children(node)) { 00507 /* ignore empty nodes */ 00508 node = ast_xml_node_get_next(node); 00509 continue; 00510 } 00511 00512 if (!first_match) { 00513 first_match = node; 00514 } 00515 00516 /* Check language */ 00517 if (xmldoc_attribute_match(node, "language", language)) { 00518 if (!lang_match) { 00519 lang_match = node; 00520 } 00521 00522 /* if module is empty we have a match */ 00523 if (ast_strlen_zero(module)) { 00524 break; 00525 } 00526 00527 /* Check module */ 00528 if (xmldoc_attribute_match(node, "module", module)) { 00529 break; 00530 } 00531 } 00532 00533 node = ast_xml_node_get_next(node); 00534 } 00535 00536 /* if we matched lang and module return this match */ 00537 if (node) { 00538 break; 00539 } 00540 00541 /* we didn't match lang and module, just return the first 00542 * result with a matching language if we have one */ 00543 if (lang_match) { 00544 node = lang_match; 00545 break; 00546 } 00547 00548 /* we didn't match with only the language, just return the 00549 * first match */ 00550 if (first_match) { 00551 node = first_match; 00552 break; 00553 } 00554 } 00555 AST_RWLIST_UNLOCK(&xmldoc_tree); 00556 00557 return node; 00558 }
static char * xmldoc_get_syntax_cmd | ( | struct ast_xml_node * | fixnode, | |
const char * | name, | |||
int | printname | |||
) | [static] |
Definition at line 954 of file xmldoc.c.
References ast_free, ast_str_append(), ast_str_buffer(), ast_str_create(), ast_strdup, ast_true(), ast_xml_free_attr(), ast_xml_get_attribute(), ast_xml_node_get_children(), ast_xml_node_get_name(), ast_xml_node_get_next(), first, xmldoc_has_inside(), and xmldoc_parse_cmd_enumlist().
Referenced by ast_xmldoc_build_syntax(), and xmldoc_parse_cmd_enumlist().
00955 { 00956 struct ast_str *syntax; 00957 struct ast_xml_node *tmpnode, *node = fixnode; 00958 char *ret, *paramname; 00959 const char *paramtype, *attrname, *literal; 00960 int required, isenum, first = 1, isliteral; 00961 00962 syntax = ast_str_create(128); 00963 if (!syntax) { 00964 /* at least try to return something... */ 00965 return ast_strdup(name); 00966 } 00967 00968 /* append name to output string. */ 00969 if (printname) { 00970 ast_str_append(&syntax, 0, "%s", name); 00971 first = 0; 00972 } 00973 00974 for (node = ast_xml_node_get_children(node); node; node = ast_xml_node_get_next(node)) { 00975 if (strcasecmp(ast_xml_node_get_name(node), "parameter")) { 00976 continue; 00977 } 00978 00979 if (xmldoc_has_inside(node, "parameter")) { 00980 /* is this a recursive parameter. */ 00981 paramname = xmldoc_get_syntax_cmd(node, "", 0); 00982 isenum = 1; 00983 } else { 00984 for (tmpnode = ast_xml_node_get_children(node); tmpnode; tmpnode = ast_xml_node_get_next(tmpnode)) { 00985 if (!strcasecmp(ast_xml_node_get_name(tmpnode), "enumlist")) { 00986 break; 00987 } 00988 } 00989 if (tmpnode) { 00990 /* parse enumlist (note that this is a special enumlist 00991 that is used to describe a syntax like {<param1>|<param2>|...} */ 00992 paramname = xmldoc_parse_cmd_enumlist(tmpnode); 00993 isenum = 1; 00994 } else { 00995 /* this is a simple parameter. */ 00996 attrname = ast_xml_get_attribute(node, "name"); 00997 if (!attrname) { 00998 /* ignore this bogus parameter and continue. */ 00999 continue; 01000 } 01001 paramname = ast_strdup(attrname); 01002 ast_xml_free_attr(attrname); 01003 isenum = 0; 01004 } 01005 } 01006 01007 /* Is this parameter required? */ 01008 required = 0; 01009 paramtype = ast_xml_get_attribute(node, "required"); 01010 if (paramtype) { 01011 required = ast_true(paramtype); 01012 ast_xml_free_attr(paramtype); 01013 } 01014 01015 /* Is this a replaceable value or a fixed parameter value? */ 01016 isliteral = 0; 01017 literal = ast_xml_get_attribute(node, "literal"); 01018 if (literal) { 01019 isliteral = ast_true(literal); 01020 ast_xml_free_attr(literal); 01021 } 01022 01023 /* if required="false" print with [...]. 01024 * if literal="true" or is enum print without <..>. 01025 * if not first print a space at the beginning. 01026 */ 01027 ast_str_append(&syntax, 0, "%s%s%s%s%s%s", 01028 (first ? "" : " "), 01029 (required ? "" : "["), 01030 (isenum || isliteral ? "" : "<"), 01031 paramname, 01032 (isenum || isliteral ? "" : ">"), 01033 (required ? "" : "]")); 01034 first = 0; 01035 ast_free(paramname); 01036 } 01037 01038 /* return a common string. */ 01039 ret = ast_strdup(ast_str_buffer(syntax)); 01040 ast_free(syntax); 01041 01042 return ret; 01043 }
static char* xmldoc_get_syntax_fun | ( | struct ast_xml_node * | rootnode, | |
const char * | rootname, | |||
const char * | childname, | |||
int | printparenthesis, | |||
int | printrootname | |||
) | [static] |
Definition at line 676 of file xmldoc.c.
References ast_asprintf, ast_free, ast_log(), ast_strdup, ast_strdupa, ast_strlen_zero(), ast_true(), ast_xml_free_attr(), ast_xml_get_attribute(), ast_xml_node_get_children(), ast_xml_node_get_name(), ast_xml_node_get_next(), GOTONEXT, ISLAST, len(), LOG_WARNING, MP, xmldoc_has_inside(), and xmldoc_reverse_helper().
Referenced by ast_xmldoc_build_syntax(), and xmldoc_parse_optionlist().
00677 { 00678 #define GOTONEXT(__rev, __a) (__rev ? ast_xml_node_get_prev(__a) : ast_xml_node_get_next(__a)) 00679 #define ISLAST(__rev, __a) (__rev == 1 ? (ast_xml_node_get_prev(__a) ? 0 : 1) : (ast_xml_node_get_next(__a) ? 0 : 1)) 00680 #define MP(__a) ((multiple ? __a : "")) 00681 struct ast_xml_node *node = NULL, *firstparam = NULL, *lastparam = NULL; 00682 const char *paramtype, *multipletype, *paramnameattr, *attrargsep, *parenthesis, *argname; 00683 int reverse, required, paramcount = 0, openbrackets = 0, len = 0, hasparams=0; 00684 int reqfinode = 0, reqlanode = 0, optmidnode = 0, prnparenthesis, multiple; 00685 char *syntax = NULL, *argsep, *paramname; 00686 00687 if (ast_strlen_zero(rootname) || ast_strlen_zero(childname)) { 00688 ast_log(LOG_WARNING, "Tried to look in XML tree with faulty rootname or childname while creating a syntax.\n"); 00689 return NULL; 00690 } 00691 00692 if (!rootnode || !ast_xml_node_get_children(rootnode)) { 00693 /* If the rootnode field is not found, at least print name. */ 00694 ast_asprintf(&syntax, "%s%s", (printrootname ? rootname : ""), (printparenthesis ? "()" : "")); 00695 return syntax; 00696 } 00697 00698 /* Get the argument separator from the root node attribute name 'argsep', if not found 00699 defaults to ','. */ 00700 attrargsep = ast_xml_get_attribute(rootnode, "argsep"); 00701 if (attrargsep) { 00702 argsep = ast_strdupa(attrargsep); 00703 ast_xml_free_attr(attrargsep); 00704 } else { 00705 argsep = ast_strdupa(","); 00706 } 00707 00708 /* Get order of evaluation. */ 00709 for (node = ast_xml_node_get_children(rootnode); node; node = ast_xml_node_get_next(node)) { 00710 if (strcasecmp(ast_xml_node_get_name(node), childname)) { 00711 continue; 00712 } 00713 required = 0; 00714 hasparams = 1; 00715 if ((paramtype = ast_xml_get_attribute(node, "required"))) { 00716 if (ast_true(paramtype)) { 00717 required = 1; 00718 } 00719 ast_xml_free_attr(paramtype); 00720 } 00721 00722 lastparam = node; 00723 reqlanode = required; 00724 00725 if (!firstparam) { 00726 /* first parameter node */ 00727 firstparam = node; 00728 reqfinode = required; 00729 } 00730 } 00731 00732 if (!hasparams) { 00733 /* This application, function, option, etc, doesn't have any params. */ 00734 ast_asprintf(&syntax, "%s%s", (printrootname ? rootname : ""), (printparenthesis ? "()" : "")); 00735 return syntax; 00736 } 00737 00738 if (reqfinode && reqlanode) { 00739 /* check midnode */ 00740 for (node = ast_xml_node_get_children(rootnode); node; node = ast_xml_node_get_next(node)) { 00741 if (strcasecmp(ast_xml_node_get_name(node), childname)) { 00742 continue; 00743 } 00744 if (node != firstparam && node != lastparam) { 00745 if ((paramtype = ast_xml_get_attribute(node, "required"))) { 00746 if (!ast_true(paramtype)) { 00747 optmidnode = 1; 00748 break; 00749 } 00750 ast_xml_free_attr(paramtype); 00751 } 00752 } 00753 } 00754 } 00755 00756 if ((!reqfinode && reqlanode) || (reqfinode && reqlanode && optmidnode)) { 00757 reverse = 1; 00758 node = lastparam; 00759 } else { 00760 reverse = 0; 00761 node = firstparam; 00762 } 00763 00764 /* init syntax string. */ 00765 if (reverse) { 00766 xmldoc_reverse_helper(reverse, &len, &syntax, 00767 (printrootname ? (printrootname == 2 ? ")]" : ")"): "")); 00768 } else { 00769 xmldoc_reverse_helper(reverse, &len, &syntax, "%s%s", (printrootname ? rootname : ""), 00770 (printrootname ? (printrootname == 2 ? "[(" : "(") : "")); 00771 } 00772 00773 for (; node; node = GOTONEXT(reverse, node)) { 00774 if (strcasecmp(ast_xml_node_get_name(node), childname)) { 00775 continue; 00776 } 00777 00778 /* Get the argument name, if it is not the leaf, go inside that parameter. */ 00779 if (xmldoc_has_inside(node, "argument")) { 00780 parenthesis = ast_xml_get_attribute(node, "hasparams"); 00781 prnparenthesis = 0; 00782 if (parenthesis) { 00783 prnparenthesis = ast_true(parenthesis); 00784 if (!strcasecmp(parenthesis, "optional")) { 00785 prnparenthesis = 2; 00786 } 00787 ast_xml_free_attr(parenthesis); 00788 } 00789 argname = ast_xml_get_attribute(node, "name"); 00790 if (argname) { 00791 paramname = xmldoc_get_syntax_fun(node, argname, "argument", prnparenthesis, prnparenthesis); 00792 ast_xml_free_attr(argname); 00793 } else { 00794 /* Malformed XML, print **UNKOWN** */ 00795 paramname = ast_strdup("**unknown**"); 00796 } 00797 } else { 00798 paramnameattr = ast_xml_get_attribute(node, "name"); 00799 if (!paramnameattr) { 00800 ast_log(LOG_WARNING, "Malformed XML %s: no %s name\n", rootname, childname); 00801 if (syntax) { 00802 /* Free already allocated syntax */ 00803 ast_free(syntax); 00804 } 00805 /* to give up is ok? */ 00806 ast_asprintf(&syntax, "%s%s", (printrootname ? rootname : ""), (printparenthesis ? "()" : "")); 00807 return syntax; 00808 } 00809 paramname = ast_strdup(paramnameattr); 00810 ast_xml_free_attr(paramnameattr); 00811 } 00812 00813 /* Defaults to 'false'. */ 00814 multiple = 0; 00815 if ((multipletype = ast_xml_get_attribute(node, "multiple"))) { 00816 if (ast_true(multipletype)) { 00817 multiple = 1; 00818 } 00819 ast_xml_free_attr(multipletype); 00820 } 00821 00822 required = 0; /* Defaults to 'false'. */ 00823 if ((paramtype = ast_xml_get_attribute(node, "required"))) { 00824 if (ast_true(paramtype)) { 00825 required = 1; 00826 } 00827 ast_xml_free_attr(paramtype); 00828 } 00829 00830 /* build syntax core. */ 00831 00832 if (required) { 00833 /* First parameter */ 00834 if (!paramcount) { 00835 xmldoc_reverse_helper(reverse, &len, &syntax, "%s%s%s%s", paramname, MP("["), MP(argsep), MP("...]")); 00836 } else { 00837 /* Time to close open brackets. */ 00838 while (openbrackets > 0) { 00839 xmldoc_reverse_helper(reverse, &len, &syntax, (reverse ? "[" : "]")); 00840 openbrackets--; 00841 } 00842 if (reverse) { 00843 xmldoc_reverse_helper(reverse, &len, &syntax, "%s%s", paramname, argsep); 00844 } else { 00845 xmldoc_reverse_helper(reverse, &len, &syntax, "%s%s", argsep, paramname); 00846 } 00847 xmldoc_reverse_helper(reverse, &len, &syntax, "%s%s%s", MP("["), MP(argsep), MP("...]")); 00848 } 00849 } else { 00850 /* First parameter */ 00851 if (!paramcount) { 00852 xmldoc_reverse_helper(reverse, &len, &syntax, "[%s%s%s%s]", paramname, MP("["), MP(argsep), MP("...]")); 00853 } else { 00854 if (ISLAST(reverse, node)) { 00855 /* This is the last parameter. */ 00856 if (reverse) { 00857 xmldoc_reverse_helper(reverse, &len, &syntax, "[%s%s%s%s]%s", paramname, 00858 MP("["), MP(argsep), MP("...]"), argsep); 00859 } else { 00860 xmldoc_reverse_helper(reverse, &len, &syntax, "%s[%s%s%s%s]", argsep, paramname, 00861 MP("["), MP(argsep), MP("...]")); 00862 } 00863 } else { 00864 if (reverse) { 00865 xmldoc_reverse_helper(reverse, &len, &syntax, "%s%s%s%s%s]", paramname, argsep, 00866 MP("["), MP(argsep), MP("...]")); 00867 } else { 00868 xmldoc_reverse_helper(reverse, &len, &syntax, "[%s%s%s%s%s", argsep, paramname, 00869 MP("["), MP(argsep), MP("...]")); 00870 } 00871 openbrackets++; 00872 } 00873 } 00874 } 00875 ast_free(paramname); 00876 00877 paramcount++; 00878 } 00879 00880 /* Time to close open brackets. */ 00881 while (openbrackets > 0) { 00882 xmldoc_reverse_helper(reverse, &len, &syntax, (reverse ? "[" : "]")); 00883 openbrackets--; 00884 } 00885 00886 /* close syntax string. */ 00887 if (reverse) { 00888 xmldoc_reverse_helper(reverse, &len, &syntax, "%s%s", (printrootname ? rootname : ""), 00889 (printrootname ? (printrootname == 2 ? "[(" : "(") : "")); 00890 } else { 00891 xmldoc_reverse_helper(reverse, &len, &syntax, (printrootname ? (printrootname == 2 ? ")]" : ")") : "")); 00892 } 00893 00894 return syntax; 00895 #undef ISLAST 00896 #undef GOTONEXT 00897 #undef MP 00898 }
static char* xmldoc_get_syntax_manager | ( | struct ast_xml_node * | fixnode, | |
const char * | name | |||
) | [static] |
Definition at line 1052 of file xmldoc.c.
References ast_free, ast_str_append(), ast_str_buffer(), ast_str_create(), ast_strdup, ast_true(), ast_xml_free_attr(), ast_xml_get_attribute(), ast_xml_node_get_children(), ast_xml_node_get_name(), and ast_xml_node_get_next().
Referenced by ast_xmldoc_build_syntax().
01053 { 01054 struct ast_str *syntax; 01055 struct ast_xml_node *node = fixnode; 01056 const char *paramtype, *attrname; 01057 int required; 01058 char *ret; 01059 01060 syntax = ast_str_create(128); 01061 if (!syntax) { 01062 return ast_strdup(name); 01063 } 01064 01065 ast_str_append(&syntax, 0, "Action: %s", name); 01066 01067 for (node = ast_xml_node_get_children(node); node; node = ast_xml_node_get_next(node)) { 01068 if (strcasecmp(ast_xml_node_get_name(node), "parameter")) { 01069 continue; 01070 } 01071 01072 /* Is this parameter required? */ 01073 required = 0; 01074 paramtype = ast_xml_get_attribute(node, "required"); 01075 if (paramtype) { 01076 required = ast_true(paramtype); 01077 ast_xml_free_attr(paramtype); 01078 } 01079 01080 attrname = ast_xml_get_attribute(node, "name"); 01081 if (!attrname) { 01082 /* ignore this bogus parameter and continue. */ 01083 continue; 01084 } 01085 01086 ast_str_append(&syntax, 0, "\n%s%s:%s <value>", 01087 (required ? "" : "["), 01088 attrname, 01089 (required ? "" : "]")); 01090 01091 ast_xml_free_attr(attrname); 01092 } 01093 01094 /* return a common string. */ 01095 ret = ast_strdup(ast_str_buffer(syntax)); 01096 ast_free(syntax); 01097 01098 return ret; 01099 }
static enum syntaxtype xmldoc_get_syntax_type | ( | const char * | type | ) | [static] |
Definition at line 1124 of file xmldoc.c.
References ARRAY_LEN, FUNCTION_SYNTAX, strsyntaxtype::stxtype, and stxtype.
Referenced by ast_xmldoc_build_syntax().
01125 { 01126 int i; 01127 for (i=0; i < ARRAY_LEN(stxtype); i++) { 01128 if (!strcasecmp(stxtype[i].type, type)) { 01129 return stxtype[i].stxtype; 01130 } 01131 } 01132 01133 return FUNCTION_SYNTAX; 01134 }
static int xmldoc_has_inside | ( | struct ast_xml_node * | fixnode, | |
const char * | what | |||
) | [static] |
Definition at line 615 of file xmldoc.c.
References ast_xml_node_get_children(), ast_xml_node_get_name(), and ast_xml_node_get_next().
Referenced by xmldoc_get_syntax_cmd(), xmldoc_get_syntax_fun(), xmldoc_parse_argument(), and xmldoc_parse_parameter().
00616 { 00617 struct ast_xml_node *node = fixnode; 00618 00619 for (node = ast_xml_node_get_children(fixnode); node; node = ast_xml_node_get_next(node)) { 00620 if (!strcasecmp(ast_xml_node_get_name(node), what)) { 00621 return 1; 00622 } 00623 } 00624 return 0; 00625 }
static int xmldoc_has_nodes | ( | struct ast_xml_node * | fixnode | ) | [static] |
Definition at line 633 of file xmldoc.c.
References ast_xml_node_get_children(), ast_xml_node_get_name(), and ast_xml_node_get_next().
Referenced by xmldoc_parse_parameter().
00634 { 00635 struct ast_xml_node *node = fixnode; 00636 00637 for (node = ast_xml_node_get_children(fixnode); node; node = ast_xml_node_get_next(node)) { 00638 if (strcasecmp(ast_xml_node_get_name(node), "text")) { 00639 return 1; 00640 } 00641 } 00642 return 0; 00643 }
static int xmldoc_has_specialtags | ( | struct ast_xml_node * | fixnode | ) | [static] |
Definition at line 651 of file xmldoc.c.
References ARRAY_LEN, ast_xml_node_get_children(), ast_xml_node_get_name(), ast_xml_node_get_next(), and special_tags.
Referenced by xmldoc_parse_argument().
00652 { 00653 struct ast_xml_node *node = fixnode; 00654 int i; 00655 00656 for (node = ast_xml_node_get_children(fixnode); node; node = ast_xml_node_get_next(node)) { 00657 for (i = 0; i < ARRAY_LEN(special_tags); i++) { 00658 if (!strcasecmp(ast_xml_node_get_name(node), special_tags[i].tagname)) { 00659 return 1; 00660 } 00661 } 00662 } 00663 return 0; 00664 }
static int xmldoc_parse_argument | ( | struct ast_xml_node * | fixnode, | |
int | insideparameter, | |||
const char * | paramtabs, | |||
const char * | tabs, | |||
struct ast_str ** | buffer | |||
) | [static] |
Definition at line 1286 of file xmldoc.c.
References ast_str_append(), ast_xml_free_attr(), ast_xml_get_attribute(), ast_xml_node_get_children(), ast_xml_node_get_next(), xmldoc_has_inside(), xmldoc_has_specialtags(), xmldoc_parse_para(), and xmldoc_parse_specialtags().
Referenced by xmldoc_parse_option(), and xmldoc_parse_parameter().
01287 { 01288 struct ast_xml_node *node = fixnode; 01289 const char *argname; 01290 int count = 0, ret = 0; 01291 01292 if (!node || !ast_xml_node_get_children(node)) { 01293 return ret; 01294 } 01295 01296 /* Print the argument names */ 01297 argname = ast_xml_get_attribute(node, "name"); 01298 if (!argname) { 01299 return 0; 01300 } 01301 if (xmldoc_has_inside(node, "para") || xmldoc_has_specialtags(node)) { 01302 ast_str_append(buffer, 0, "%s%s%s", tabs, argname, (insideparameter ? "\n" : "")); 01303 ast_xml_free_attr(argname); 01304 } else { 01305 ast_xml_free_attr(argname); 01306 return 0; 01307 } 01308 01309 for (node = ast_xml_node_get_children(node); node; node = ast_xml_node_get_next(node)) { 01310 if (xmldoc_parse_para(node, (insideparameter ? paramtabs : (!count ? " - " : tabs)), "\n", buffer) == 2) { 01311 count++; 01312 ret = 1; 01313 } else if (xmldoc_parse_specialtags(node, (insideparameter ? paramtabs : (!count ? " - " : tabs)), "\n", buffer) == 2) { 01314 count++; 01315 ret = 1; 01316 } 01317 } 01318 01319 return ret; 01320 }
static char* xmldoc_parse_cmd_enumlist | ( | struct ast_xml_node * | fixnode | ) | [static] |
Definition at line 907 of file xmldoc.c.
References ast_free, ast_str_append(), ast_str_buffer(), ast_str_create(), ast_strdup, ast_xml_node_get_children(), ast_xml_node_get_name(), ast_xml_node_get_next(), first, and xmldoc_get_syntax_cmd().
Referenced by xmldoc_get_syntax_cmd().
00908 { 00909 struct ast_xml_node *node = fixnode; 00910 struct ast_str *paramname; 00911 char *enumname, *ret; 00912 int first = 1; 00913 00914 paramname = ast_str_create(128); 00915 if (!paramname) { 00916 return ast_strdup("{<unkown>}"); 00917 } 00918 00919 ast_str_append(¶mname, 0, "{"); 00920 00921 for (node = ast_xml_node_get_children(node); node; node = ast_xml_node_get_next(node)) { 00922 if (strcasecmp(ast_xml_node_get_name(node), "enum")) { 00923 continue; 00924 } 00925 00926 enumname = xmldoc_get_syntax_cmd(node, "", 0); 00927 if (!enumname) { 00928 continue; 00929 } 00930 if (!first) { 00931 ast_str_append(¶mname, 0, "|"); 00932 } 00933 ast_str_append(¶mname, 0, "%s", enumname); 00934 first = 0; 00935 ast_free(enumname); 00936 } 00937 00938 ast_str_append(¶mname, 0, "}"); 00939 00940 ret = ast_strdup(ast_str_buffer(paramname)); 00941 ast_free(paramname); 00942 00943 return ret; 00944 }
static int xmldoc_parse_enum | ( | struct ast_xml_node * | fixnode, | |
const char * | tabs, | |||
struct ast_str ** | buffer | |||
) | [static] |
Definition at line 1522 of file xmldoc.c.
References ast_asprintf, ast_free, ast_xml_node_get_children(), ast_xml_node_get_next(), xmldoc_parse_enumlist(), xmldoc_parse_para(), and xmldoc_parse_specialtags().
Referenced by xmldoc_parse_enumlist().
01523 { 01524 struct ast_xml_node *node = fixnode; 01525 int ret = 0; 01526 char *optiontabs; 01527 01528 ast_asprintf(&optiontabs, "%s ", tabs); 01529 01530 for (node = ast_xml_node_get_children(node); node; node = ast_xml_node_get_next(node)) { 01531 if ((xmldoc_parse_para(node, (ret ? tabs : " - "), "\n", buffer))) { 01532 ret = 1; 01533 } else if ((xmldoc_parse_specialtags(node, (ret ? tabs : " - "), "\n", buffer))) { 01534 ret = 1; 01535 } 01536 01537 xmldoc_parse_enumlist(node, optiontabs, buffer); 01538 } 01539 01540 ast_free(optiontabs); 01541 01542 return ret; 01543 }
static int xmldoc_parse_enumlist | ( | struct ast_xml_node * | fixnode, | |
const char * | tabs, | |||
struct ast_str ** | buffer | |||
) | [static] |
Definition at line 1552 of file xmldoc.c.
References ast_str_append(), ast_xml_free_attr(), ast_xml_get_attribute(), ast_xml_node_get_children(), ast_xml_node_get_name(), ast_xml_node_get_next(), and xmldoc_parse_enum().
Referenced by xmldoc_get_formatted(), xmldoc_parse_enum(), xmldoc_parse_option(), and xmldoc_parse_parameter().
01553 { 01554 struct ast_xml_node *node = fixnode; 01555 const char *enumname; 01556 int ret = 0; 01557 01558 for (node = ast_xml_node_get_children(node); node; node = ast_xml_node_get_next(node)) { 01559 if (strcasecmp(ast_xml_node_get_name(node), "enum")) { 01560 continue; 01561 } 01562 01563 enumname = ast_xml_get_attribute(node, "name"); 01564 if (enumname) { 01565 ast_str_append(buffer, 0, "%s<enum>%s</enum>", tabs, enumname); 01566 ast_xml_free_attr(enumname); 01567 01568 /* parse only enum elements inside a enumlist node. */ 01569 if ((xmldoc_parse_enum(node, tabs, buffer))) { 01570 ret = 1; 01571 } else { 01572 ast_str_append(buffer, 0, "\n"); 01573 } 01574 } 01575 } 01576 return ret; 01577 }
static int xmldoc_parse_option | ( | struct ast_xml_node * | fixnode, | |
const char * | tabs, | |||
struct ast_str ** | buffer | |||
) | [static] |
Definition at line 1588 of file xmldoc.c.
References ast_asprintf, ast_free, ast_str_append(), ast_xml_node_get_children(), ast_xml_node_get_name(), ast_xml_node_get_next(), xmldoc_parse_argument(), xmldoc_parse_enumlist(), xmldoc_parse_para(), xmldoc_parse_specialtags(), and xmldoc_parse_variablelist().
Referenced by xmldoc_parse_optionlist().
01589 { 01590 struct ast_xml_node *node; 01591 int ret = 0; 01592 char *optiontabs; 01593 01594 ast_asprintf(&optiontabs, "%s ", tabs); 01595 if (!optiontabs) { 01596 return ret; 01597 } 01598 for (node = ast_xml_node_get_children(fixnode); node; node = ast_xml_node_get_next(node)) { 01599 if (!strcasecmp(ast_xml_node_get_name(node), "argument")) { 01600 /* if this is the first data appended to buffer, print a \n*/ 01601 if (!ret && ast_xml_node_get_children(node)) { 01602 /* print \n */ 01603 ast_str_append(buffer, 0, "\n"); 01604 } 01605 if (xmldoc_parse_argument(node, 0, NULL, optiontabs, buffer)) { 01606 ret = 1; 01607 } 01608 continue; 01609 } 01610 01611 if (xmldoc_parse_para(node, (ret ? tabs : ""), "\n", buffer)) { 01612 ret = 1; 01613 } else if (xmldoc_parse_specialtags(node, (ret ? tabs : ""), "\n", buffer)) { 01614 ret = 1; 01615 } 01616 01617 xmldoc_parse_variablelist(node, optiontabs, buffer); 01618 01619 xmldoc_parse_enumlist(node, optiontabs, buffer); 01620 } 01621 ast_free(optiontabs); 01622 01623 return ret; 01624 }
static void xmldoc_parse_optionlist | ( | struct ast_xml_node * | fixnode, | |
const char * | tabs, | |||
struct ast_str ** | buffer | |||
) | [static] |
Definition at line 1633 of file xmldoc.c.
References ast_free, ast_str_append(), ast_xml_free_attr(), ast_xml_get_attribute(), ast_xml_node_get_children(), ast_xml_node_get_name(), ast_xml_node_get_next(), xmldoc_get_syntax_fun(), and xmldoc_parse_option().
Referenced by xmldoc_parse_parameter().
01634 { 01635 struct ast_xml_node *node; 01636 const char *optname, *hasparams; 01637 char *optionsyntax; 01638 int optparams; 01639 01640 for (node = ast_xml_node_get_children(fixnode); node; node = ast_xml_node_get_next(node)) { 01641 /* Start appending every option tag. */ 01642 if (strcasecmp(ast_xml_node_get_name(node), "option")) { 01643 continue; 01644 } 01645 01646 /* Get the option name. */ 01647 optname = ast_xml_get_attribute(node, "name"); 01648 if (!optname) { 01649 continue; 01650 } 01651 01652 optparams = 1; 01653 hasparams = ast_xml_get_attribute(node, "hasparams"); 01654 if (hasparams && !strcasecmp(hasparams, "optional")) { 01655 optparams = 2; 01656 } 01657 01658 optionsyntax = xmldoc_get_syntax_fun(node, optname, "argument", 0, optparams); 01659 if (!optionsyntax) { 01660 ast_xml_free_attr(optname); 01661 ast_xml_free_attr(hasparams); 01662 continue; 01663 } 01664 01665 ast_str_append(buffer, 0, "%s%s: ", tabs, optionsyntax); 01666 01667 if (!xmldoc_parse_option(node, tabs, buffer)) { 01668 ast_str_append(buffer, 0, "\n"); 01669 } 01670 ast_str_append(buffer, 0, "\n"); 01671 ast_xml_free_attr(optname); 01672 ast_xml_free_attr(hasparams); 01673 ast_free(optionsyntax); 01674 } 01675 }
static int xmldoc_parse_para | ( | struct ast_xml_node * | node, | |
const char * | tabs, | |||
const char * | posttabs, | |||
struct ast_str ** | buffer | |||
) | [static] |
Definition at line 1182 of file xmldoc.c.
References ast_free, ast_str_append(), ast_str_buffer(), ast_xml_free_text(), ast_xml_get_text(), ast_xml_node_get_children(), ast_xml_node_get_name(), ast_xml_node_get_next(), and xmldoc_string_cleanup().
Referenced by xmldoc_get_formatted(), xmldoc_parse_argument(), xmldoc_parse_enum(), xmldoc_parse_option(), xmldoc_parse_parameter(), xmldoc_parse_specialtags(), xmldoc_parse_variable(), and xmldoc_parse_variablelist().
01183 { 01184 const char *tmptext; 01185 struct ast_xml_node *tmp; 01186 int ret = 0; 01187 struct ast_str *tmpstr; 01188 01189 if (!node || !ast_xml_node_get_children(node)) { 01190 return ret; 01191 } 01192 01193 if (strcasecmp(ast_xml_node_get_name(node), "para")) { 01194 return ret; 01195 } 01196 01197 ast_str_append(buffer, 0, "%s", tabs); 01198 01199 ret = 1; 01200 01201 for (tmp = ast_xml_node_get_children(node); tmp; tmp = ast_xml_node_get_next(tmp)) { 01202 /* Get the text inside the <para> element and append it to buffer. */ 01203 tmptext = ast_xml_get_text(tmp); 01204 if (tmptext) { 01205 /* Strip \n etc. */ 01206 xmldoc_string_cleanup(tmptext, &tmpstr, 0); 01207 ast_xml_free_text(tmptext); 01208 if (tmpstr) { 01209 if (strcasecmp(ast_xml_node_get_name(tmp), "text")) { 01210 ast_str_append(buffer, 0, "<%s>%s</%s>", ast_xml_node_get_name(tmp), 01211 ast_str_buffer(tmpstr), ast_xml_node_get_name(tmp)); 01212 } else { 01213 ast_str_append(buffer, 0, "%s", ast_str_buffer(tmpstr)); 01214 } 01215 ast_free(tmpstr); 01216 ret = 2; 01217 } 01218 } 01219 } 01220 01221 ast_str_append(buffer, 0, "%s", posttabs); 01222 01223 return ret; 01224 }
static void xmldoc_parse_parameter | ( | struct ast_xml_node * | fixnode, | |
const char * | tabs, | |||
struct ast_str ** | buffer | |||
) | [static] |
Definition at line 1684 of file xmldoc.c.
References ast_asprintf, ast_free, ast_str_append(), ast_xml_free_attr(), ast_xml_get_attribute(), ast_xml_node_get_children(), ast_xml_node_get_name(), ast_xml_node_get_next(), xmldoc_has_inside(), xmldoc_has_nodes(), xmldoc_parse_argument(), xmldoc_parse_enumlist(), xmldoc_parse_optionlist(), xmldoc_parse_para(), and xmldoc_parse_specialtags().
Referenced by ast_xmldoc_build_arguments().
01685 { 01686 const char *paramname; 01687 struct ast_xml_node *node = fixnode; 01688 int hasarguments, printed = 0; 01689 char *internaltabs; 01690 01691 if (strcasecmp(ast_xml_node_get_name(node), "parameter")) { 01692 return; 01693 } 01694 01695 hasarguments = xmldoc_has_inside(node, "argument"); 01696 if (!(paramname = ast_xml_get_attribute(node, "name"))) { 01697 /* parameter MUST have an attribute name. */ 01698 return; 01699 } 01700 01701 ast_asprintf(&internaltabs, "%s ", tabs); 01702 if (!internaltabs) { 01703 return; 01704 } 01705 01706 if (!hasarguments && xmldoc_has_nodes(node)) { 01707 ast_str_append(buffer, 0, "%s\n", paramname); 01708 ast_xml_free_attr(paramname); 01709 printed = 1; 01710 } 01711 01712 for (node = ast_xml_node_get_children(node); node; node = ast_xml_node_get_next(node)) { 01713 if (!strcasecmp(ast_xml_node_get_name(node), "optionlist")) { 01714 xmldoc_parse_optionlist(node, internaltabs, buffer); 01715 } else if (!strcasecmp(ast_xml_node_get_name(node), "enumlist")) { 01716 xmldoc_parse_enumlist(node, internaltabs, buffer); 01717 } else if (!strcasecmp(ast_xml_node_get_name(node), "argument")) { 01718 xmldoc_parse_argument(node, 1, internaltabs, (!hasarguments ? " " : ""), buffer); 01719 } else if (!strcasecmp(ast_xml_node_get_name(node), "para")) { 01720 if (!printed) { 01721 ast_str_append(buffer, 0, "%s\n", paramname); 01722 ast_xml_free_attr(paramname); 01723 printed = 1; 01724 } 01725 if (xmldoc_parse_para(node, internaltabs, "\n", buffer)) { 01726 /* If anything ever goes in below this condition before the continue below, 01727 * we should probably continue immediately. */ 01728 continue; 01729 } 01730 continue; 01731 } else if ((xmldoc_parse_specialtags(node, internaltabs, "\n", buffer))) { 01732 continue; 01733 } 01734 } 01735 if (!printed) { 01736 ast_xml_free_attr(paramname); 01737 } 01738 ast_free(internaltabs); 01739 }
static int xmldoc_parse_specialtags | ( | struct ast_xml_node * | fixnode, | |
const char * | tabs, | |||
const char * | posttabs, | |||
struct ast_str ** | buffer | |||
) | [static] |
Definition at line 1236 of file xmldoc.c.
References ARRAY_LEN, ast_str_append(), ast_strlen_zero(), ast_xml_node_get_children(), ast_xml_node_get_name(), ast_xml_node_get_next(), special_tags, and xmldoc_parse_para().
Referenced by xmldoc_get_formatted(), xmldoc_parse_argument(), xmldoc_parse_enum(), xmldoc_parse_option(), xmldoc_parse_parameter(), xmldoc_parse_variable(), and xmldoc_parse_variablelist().
01237 { 01238 struct ast_xml_node *node = fixnode; 01239 int ret = 0, i, count = 0; 01240 01241 if (!node || !ast_xml_node_get_children(node)) { 01242 return ret; 01243 } 01244 01245 for (i = 0; i < ARRAY_LEN(special_tags); i++) { 01246 if (strcasecmp(ast_xml_node_get_name(node), special_tags[i].tagname)) { 01247 continue; 01248 } 01249 01250 ret = 1; 01251 /* This is a special tag. */ 01252 01253 /* concat data */ 01254 if (!ast_strlen_zero(special_tags[i].init)) { 01255 ast_str_append(buffer, 0, "%s%s", tabs, special_tags[i].init); 01256 } 01257 01258 /* parse <para> elements inside special tags. */ 01259 for (node = ast_xml_node_get_children(node); node; node = ast_xml_node_get_next(node)) { 01260 /* first <para> just print it without tabs at the begining. */ 01261 if (xmldoc_parse_para(node, (!count ? "" : tabs), posttabs, buffer) == 2) { 01262 ret = 2; 01263 } 01264 } 01265 01266 if (!ast_strlen_zero(special_tags[i].end)) { 01267 ast_str_append(buffer, 0, "%s%s", special_tags[i].end, posttabs); 01268 } 01269 01270 break; 01271 } 01272 01273 return ret; 01274 }
static int xmldoc_parse_variable | ( | struct ast_xml_node * | node, | |
const char * | tabs, | |||
struct ast_str ** | buffer | |||
) | [static] |
Definition at line 1333 of file xmldoc.c.
References ast_free, ast_str_append(), ast_str_buffer(), ast_str_strlen(), ast_xml_free_attr(), ast_xml_free_text(), ast_xml_get_attribute(), ast_xml_get_text(), ast_xml_node_get_children(), ast_xml_node_get_name(), ast_xml_node_get_next(), xmldoc_parse_para(), xmldoc_parse_specialtags(), and xmldoc_string_cleanup().
Referenced by xmldoc_parse_variablelist().
01334 { 01335 struct ast_xml_node *tmp; 01336 const char *valname; 01337 const char *tmptext; 01338 struct ast_str *cleanstr; 01339 int ret = 0, printedpara=0; 01340 01341 for (tmp = ast_xml_node_get_children(node); tmp; tmp = ast_xml_node_get_next(tmp)) { 01342 if (xmldoc_parse_para(tmp, (ret ? tabs : ""), "\n", buffer)) { 01343 printedpara = 1; 01344 continue; 01345 } else if (xmldoc_parse_specialtags(tmp, (ret ? tabs : ""), "\n", buffer)) { 01346 printedpara = 1; 01347 continue; 01348 } 01349 01350 if (strcasecmp(ast_xml_node_get_name(tmp), "value")) { 01351 continue; 01352 } 01353 01354 /* Parse a <value> tag only. */ 01355 if (!printedpara) { 01356 ast_str_append(buffer, 0, "\n"); 01357 printedpara = 1; 01358 } 01359 /* Parse each <value name='valuename'>desciption</value> */ 01360 valname = ast_xml_get_attribute(tmp, "name"); 01361 if (valname) { 01362 ret = 1; 01363 ast_str_append(buffer, 0, "%s<value>%s</value>", tabs, valname); 01364 ast_xml_free_attr(valname); 01365 } 01366 tmptext = ast_xml_get_text(tmp); 01367 /* Check inside this node for any explanation about its meaning. */ 01368 if (tmptext) { 01369 /* Cleanup text. */ 01370 xmldoc_string_cleanup(tmptext, &cleanstr, 1); 01371 ast_xml_free_text(tmptext); 01372 if (cleanstr && ast_str_strlen(cleanstr) > 0) { 01373 ast_str_append(buffer, 0, ":%s", ast_str_buffer(cleanstr)); 01374 } 01375 ast_free(cleanstr); 01376 } 01377 ast_str_append(buffer, 0, "\n"); 01378 } 01379 01380 return ret; 01381 }
static int xmldoc_parse_variablelist | ( | struct ast_xml_node * | node, | |
const char * | tabs, | |||
struct ast_str ** | buffer | |||
) | [static] |
Definition at line 1394 of file xmldoc.c.
References ast_asprintf, ast_free, ast_str_append(), ast_xml_free_attr(), ast_xml_get_attribute(), ast_xml_node_get_children(), ast_xml_node_get_name(), ast_xml_node_get_next(), xmldoc_parse_para(), xmldoc_parse_specialtags(), and xmldoc_parse_variable().
Referenced by xmldoc_get_formatted(), and xmldoc_parse_option().
01395 { 01396 struct ast_xml_node *tmp; 01397 const char *varname; 01398 char *vartabs; 01399 int ret = 0; 01400 01401 if (!node || !ast_xml_node_get_children(node)) { 01402 return ret; 01403 } 01404 01405 if (strcasecmp(ast_xml_node_get_name(node), "variablelist")) { 01406 return ret; 01407 } 01408 01409 /* use this spacing (add 4 spaces) inside a variablelist node. */ 01410 ast_asprintf(&vartabs, "%s ", tabs); 01411 if (!vartabs) { 01412 return ret; 01413 } 01414 for (tmp = ast_xml_node_get_children(node); tmp; tmp = ast_xml_node_get_next(tmp)) { 01415 /* We can have a <para> element inside the variable list */ 01416 if ((xmldoc_parse_para(tmp, (ret ? tabs : ""), "\n", buffer))) { 01417 ret = 1; 01418 continue; 01419 } else if ((xmldoc_parse_specialtags(tmp, (ret ? tabs : ""), "\n", buffer))) { 01420 ret = 1; 01421 continue; 01422 } 01423 01424 if (!strcasecmp(ast_xml_node_get_name(tmp), "variable")) { 01425 /* Store the variable name in buffer. */ 01426 varname = ast_xml_get_attribute(tmp, "name"); 01427 if (varname) { 01428 ast_str_append(buffer, 0, "%s<variable>%s</variable>: ", tabs, varname); 01429 ast_xml_free_attr(varname); 01430 /* Parse the <variable> possible values. */ 01431 xmldoc_parse_variable(tmp, vartabs, buffer); 01432 ret = 1; 01433 } 01434 } 01435 } 01436 01437 ast_free(vartabs); 01438 01439 return ret; 01440 }
static int xmldoc_postbrlen | ( | const char * | postbr | ) | [static] |
Definition at line 115 of file xmldoc.c.
Referenced by xmldoc_string_wrap().
00116 { 00117 int postbrreallen = 0, i; 00118 size_t postbrlen; 00119 00120 if (!postbr) { 00121 return 0; 00122 } 00123 postbrlen = strlen(postbr); 00124 for (i = 0; i < postbrlen; i++) { 00125 if (postbr[i] == '\t') { 00126 postbrreallen += 8 - (postbrreallen % 8); 00127 } else { 00128 postbrreallen++; 00129 } 00130 } 00131 return postbrreallen; 00132 }
static void xmldoc_reverse_helper | ( | int | reverse, | |
int * | len, | |||
char ** | syntax, | |||
const char * | fmt, | |||
... | ||||
) | [static] |
Definition at line 569 of file xmldoc.c.
References ast_free, ast_realloc, and ast_vasprintf.
Referenced by xmldoc_get_syntax_fun().
00570 { 00571 int totlen, tmpfmtlen; 00572 char *tmpfmt, tmp; 00573 va_list ap; 00574 00575 va_start(ap, fmt); 00576 if (ast_vasprintf(&tmpfmt, fmt, ap) < 0) { 00577 va_end(ap); 00578 return; 00579 } 00580 va_end(ap); 00581 00582 tmpfmtlen = strlen(tmpfmt); 00583 totlen = *len + tmpfmtlen + 1; 00584 00585 *syntax = ast_realloc(*syntax, totlen); 00586 00587 if (!*syntax) { 00588 ast_free(tmpfmt); 00589 return; 00590 } 00591 00592 if (reverse) { 00593 memmove(*syntax + tmpfmtlen, *syntax, *len); 00594 /* Save this char, it will be overwritten by the \0 of strcpy. */ 00595 tmp = (*syntax)[0]; 00596 strcpy(*syntax, tmpfmt); 00597 /* Restore the already saved char. */ 00598 (*syntax)[tmpfmtlen] = tmp; 00599 (*syntax)[totlen - 1] = '\0'; 00600 } else { 00601 strcpy(*syntax + *len, tmpfmt); 00602 } 00603 00604 *len = totlen - 1; 00605 ast_free(tmpfmt); 00606 }
static void xmldoc_setpostbr | ( | char * | postbr, | |
size_t | len, | |||
const char * | text | |||
) | [static] |
Definition at line 141 of file xmldoc.c.
Referenced by xmldoc_string_wrap().
00142 { 00143 int c, postbrlen = 0; 00144 00145 if (!text) { 00146 return; 00147 } 00148 00149 for (c = 0; c < len; c++) { 00150 if (text[c] == '\t' || text[c] == ' ') { 00151 postbr[postbrlen++] = text[c]; 00152 } else { 00153 break; 00154 } 00155 } 00156 postbr[postbrlen] = '\0'; 00157 }
static void xmldoc_string_cleanup | ( | const char * | text, | |
struct ast_str ** | output, | |||
int | lastspaces | |||
) | [static] |
Definition at line 425 of file xmldoc.c.
References ast_log(), ast_str_append(), ast_str_create(), ast_str_trim_blanks(), and LOG_ERROR.
Referenced by xmldoc_get_formatted(), xmldoc_parse_para(), and xmldoc_parse_variable().
00426 { 00427 int i; 00428 size_t textlen; 00429 00430 if (!text) { 00431 *output = NULL; 00432 return; 00433 } 00434 00435 textlen = strlen(text); 00436 00437 *output = ast_str_create(textlen); 00438 if (!(*output)) { 00439 ast_log(LOG_ERROR, "Problem allocating output buffer\n"); 00440 return; 00441 } 00442 00443 for (i = 0; i < textlen; i++) { 00444 if (text[i] == '\n' || text[i] == '\r') { 00445 /* remove spaces/tabs/\n after a \n. */ 00446 while (text[i + 1] == '\t' || text[i + 1] == '\r' || text[i + 1] == '\n') { 00447 i++; 00448 } 00449 ast_str_append(output, 0, " "); 00450 continue; 00451 } else { 00452 ast_str_append(output, 0, "%c", text[i]); 00453 } 00454 } 00455 00456 /* remove last spaces (we don't want always to remove the trailing spaces). */ 00457 if (lastspaces) { 00458 ast_str_trim_blanks(*output); 00459 } 00460 }
static char* xmldoc_string_wrap | ( | const char * | text, | |
int | columns, | |||
int | maxdiff | |||
) | [static] |
Definition at line 238 of file xmldoc.c.
References ast_free, ast_log(), ast_str_append(), ast_str_buffer(), ast_str_create(), ast_str_truncate(), ast_strdup, ESC, LOG_WARNING, xmldoc_foundspace_backward(), xmldoc_postbrlen(), xmldoc_setpostbr(), and xmldoc_wait_nextspace().
Referenced by ast_xmldoc_printable().
00239 { 00240 struct ast_str *tmp; 00241 char *ret, postbr[160]; 00242 int count = 1, i, backspace, needtobreak = 0, colmax, textlen; 00243 00244 /* sanity check */ 00245 if (!text || columns <= 0 || maxdiff < 0) { 00246 ast_log(LOG_WARNING, "Passing wrong arguments while trying to wrap the text\n"); 00247 return NULL; 00248 } 00249 00250 tmp = ast_str_create(strlen(text) * 3); 00251 00252 if (!tmp) { 00253 return NULL; 00254 } 00255 00256 /* Check for blanks and tabs and put them in postbr. */ 00257 xmldoc_setpostbr(postbr, sizeof(postbr), text); 00258 colmax = columns - xmldoc_postbrlen(postbr); 00259 00260 textlen = strlen(text); 00261 for (i = 0; i < textlen; i++) { 00262 if (needtobreak || !(count % colmax)) { 00263 if (text[i] == ' ') { 00264 ast_str_append(&tmp, 0, "\n%s", postbr); 00265 needtobreak = 0; 00266 count = 1; 00267 } else if (text[i] != '\n') { 00268 needtobreak = 1; 00269 if (xmldoc_wait_nextspace(text, i, maxdiff)) { 00270 /* wait for the next space */ 00271 ast_str_append(&tmp, 0, "%c", text[i]); 00272 continue; 00273 } 00274 /* Try to look backwards */ 00275 backspace = xmldoc_foundspace_backward(text, i, maxdiff); 00276 if (backspace) { 00277 needtobreak = 1; 00278 ast_str_truncate(tmp, -backspace); 00279 i -= backspace + 1; 00280 continue; 00281 } 00282 ast_str_append(&tmp, 0, "\n%s", postbr); 00283 needtobreak = 0; 00284 count = 1; 00285 } 00286 /* skip blanks after a \n */ 00287 while (text[i] == ' ') { 00288 i++; 00289 } 00290 } 00291 if (text[i] == '\n') { 00292 xmldoc_setpostbr(postbr, sizeof(postbr), &text[i] + 1); 00293 colmax = columns - xmldoc_postbrlen(postbr); 00294 needtobreak = 0; 00295 count = 1; 00296 } 00297 if (text[i] == ESC) { 00298 /* Ignore Escape sequences. */ 00299 do { 00300 ast_str_append(&tmp, 0, "%c", text[i]); 00301 i++; 00302 } while (i < textlen && text[i] != 'm'); 00303 } else { 00304 count++; 00305 } 00306 ast_str_append(&tmp, 0, "%c", text[i]); 00307 } 00308 00309 ret = ast_strdup(ast_str_buffer(tmp)); 00310 ast_free(tmp); 00311 00312 return ret; 00313 }
static int xmldoc_wait_nextspace | ( | const char * | text, | |
int | currentpos, | |||
int | maxdiff | |||
) | [static] |
Definition at line 169 of file xmldoc.c.
References ESC.
Referenced by xmldoc_string_wrap().
00170 { 00171 int i, textlen; 00172 00173 if (!text) { 00174 return 0; 00175 } 00176 00177 textlen = strlen(text); 00178 for (i = currentpos; i < textlen; i++) { 00179 if (text[i] == ESC) { 00180 /* Move to the end of the escape sequence */ 00181 while (i < textlen && text[i] != 'm') { 00182 i++; 00183 } 00184 } else if (text[i] == ' ' || text[i] == '\n') { 00185 /* Found the next space or linefeed */ 00186 return 1; 00187 } else if (i - currentpos > maxdiff) { 00188 /* We have looked the max distance and didn't find it */ 00189 return 0; 00190 } 00191 } 00192 00193 /* Reached the end and did not find it */ 00194 00195 return 0; 00196 }
struct strcolorized_tags colorized_tags[] [static] |
Referenced by ast_xmldoc_printable().
const char default_documentation_language[] = "en_US" [static] |
char documentation_language[6] [static] |
struct strspecial_tags special_tags[] [static] |
Referenced by xmldoc_has_specialtags(), and xmldoc_parse_specialtags().
struct strsyntaxtype stxtype[] [static] |
Mapping between type of node and type of syntax to generate.
Referenced by xmldoc_get_syntax_type().
const int xmldoc_max_diff = 5 [static] |
const int xmldoc_text_columns = 74 [static] |