From 7b6a016c07f49b782cccc27cc6bcfa9f582e35f0 Mon Sep 17 00:00:00 2001 From: Russell Bryant Date: Mon, 24 Apr 2006 18:41:44 +0000 Subject: remove some files we don't need git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@22302 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- mxml/mxml.spec | 99 -- mxml/mxmldoc.c | 2782 ------------------------------------------------------ mxml/temp1.xmlfd | 29 - mxml/test.xml | 29 - mxml/testmxml.c | 653 ------------- 5 files changed, 3592 deletions(-) delete mode 100644 mxml/mxml.spec delete mode 100644 mxml/mxmldoc.c delete mode 100644 mxml/temp1.xmlfd delete mode 100644 mxml/test.xml delete mode 100644 mxml/testmxml.c (limited to 'mxml') diff --git a/mxml/mxml.spec b/mxml/mxml.spec deleted file mode 100644 index 9050952ba..000000000 --- a/mxml/mxml.spec +++ /dev/null @@ -1,99 +0,0 @@ -# -# "$Id$" -# -# RPM "spec" file for Mini-XML, a small XML library. -# -# Copyright 2003-2005 by Michael Sweet. -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU Library General Public -# License as published by the Free Software Foundation; either -# version 2, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# - -Summary: Miniature XML development library -Name: mxml -Version: 2.2.2 -Release: 1 -Copyright: GPL -Group: Development/Libraries -Source: http://www.easysw.com/~mike/mxml/mxml-%{version}.tar.gz -Url: http://www.easysw.com/~mike/mxml/ -Packager: Michael Sweet -Vendor: Michael Sweet - -# Use buildroot so as not to disturb the version already installed -BuildRoot: /var/tmp/%{name}-root - -%description -Mini-XML is a small XML parsing library that you can use to read -XML and XML-like data files in your application without -requiring large non-standard libraries. Mini-XML provides the -following functionality: - - - Reading of UTF-8 and UTF-16 and writing of UTF-8 encoded - XML files and strings. - - Data is stored in a linked-list tree structure, preserving - the XML data hierarchy. - - Supports arbitrary element names, attributes, and - attribute values with no preset limits, just available - memory. - - Supports integer, real, opaque ("cdata"), and text data - types in "leaf" nodes. - - Functions for creating and managing trees of data. - - "Find" and "walk" functions for easily locating and - navigating trees of data. - -Mini-XML doesn't do validation or other types of processing on -the data based upon schema files or other sources of definition -information, nor does it support character entities other than -those required by the XML specification. - -%prep -%setup - -%build -CFLAGS="$RPM_OPT_FLAGS" CXXFLAGS="$RPM_OPT_FLAGS" LDFLAGS="$RPM_OPT_FLAGS" ./configure --enable-shared --prefix=/usr - -# If we got this far, all prerequisite libraries must be here. -make - -%install -# Make sure the RPM_BUILD_ROOT directory exists. -rm -rf $RPM_BUILD_ROOT - -make BUILDROOT=$RPM_BUILD_ROOT install - -%clean -rm -rf $RPM_BUILD_ROOT - -%files -%defattr(-,root,root) - -%dir /usr/bin -/usr/bin/* -%dir /usr/include -/usr/include/mxml.h -%dir /usr/lib -/usr/lib/* -%dir /usr/lib/pkgconfig -/usr/lib/pkgconfig/mxml.pc -%dir /usr/share/doc/mxml -/usr/share/doc/mxml/* -%dir /usr/share/man/cat1 -/usr/share/man/cat1/* -%dir /usr/share/man/cat3 -/usr/share/man/cat3/* -%dir /usr/share/man/man1 -/usr/share/man/man1/* -%dir /usr/share/man/man3 -/usr/share/man/man3/* - -# -# End of "$Id$". -# diff --git a/mxml/mxmldoc.c b/mxml/mxmldoc.c deleted file mode 100644 index 3fbd896fb..000000000 --- a/mxml/mxmldoc.c +++ /dev/null @@ -1,2782 +0,0 @@ -/* - * "$Id$" - * - * Documentation generator using Mini-XML, a small XML-like file parsing - * library. - * - * Copyright 2003-2005 by Michael Sweet. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * Contents: - * - * main() - Main entry for test program. - * add_variable() - Add a variable or argument. - * safe_strcpy() - Copy a string allowing for overlapping strings. - * scan_file() - Scan a source file. - * sort_node() - Insert a node sorted into a tree. - * update_comment() - Update a comment node. - * write_documentation() - Write HTML documentation. - * write_element() - Write an elements text nodes. - * write_string() - Write a string, quoting XHTML special chars - * as needed... - * ws_cb() - Whitespace callback for saving. - */ - -/* - * Include necessary headers... - */ - -#include "config.h" -#include "mxml.h" - - -/* - * This program scans source and header files and produces public API - * documentation for code that conforms to the CUPS Configuration - * Management Plan (CMP) coding standards. Please see the following web - * page for details: - * - * http://www.cups.org/cmp.html - * - * Using Mini-XML, this program creates and maintains an XML representation - * of the public API code documentation which can then be converted to HTML - * as desired. The following is a poor-man's schema: - * - * - * - * - * [optional...] - * - * descriptive text - * - * - * - * descriptive text - * ... - * - * - * - * descriptive text - * type string - * - * - * - * descriptive text - * - * descriptive text - * type string - * - * - * descriptive text - * type string - * - * function names separated by spaces - * - * - * - * descriptive text - * type string - * - * - * - * descriptive text - * ... - * ... - * - * - * - * descriptive text - * ... - * - * - * - * descriptive text - * ... - * ... - * ... - * ... - * ... - * - * - * - */ - - -/* - * Basic states for file parser... - */ - -#define STATE_NONE 0 /* No state - whitespace, etc. */ -#define STATE_PREPROCESSOR 1 /* Preprocessor directive */ -#define STATE_C_COMMENT 2 /* Inside a C comment */ -#define STATE_CXX_COMMENT 3 /* Inside a C++ comment */ -#define STATE_STRING 4 /* Inside a string constant */ -#define STATE_CHARACTER 5 /* Inside a character constant */ -#define STATE_IDENTIFIER 6 /* Inside a keyword/identifier */ - - -/* - * Local functions... - */ - -static mxml_node_t *add_variable(mxml_node_t *parent, const char *name, - mxml_node_t *type); -static void safe_strcpy(char *dst, const char *src); -static int scan_file(const char *filename, FILE *fp, - mxml_node_t *doc); -static void sort_node(mxml_node_t *tree, mxml_node_t *func); -static void update_comment(mxml_node_t *parent, - mxml_node_t *comment); -static void write_documentation(mxml_node_t *doc); -static void write_element(mxml_node_t *doc, mxml_node_t *element); -static void write_string(const char *s); -static const char *ws_cb(mxml_node_t *node, int where); - - -/* - * 'main()' - Main entry for test program. - */ - -int /* O - Exit status */ -main(int argc, /* I - Number of command-line args */ - char *argv[]) /* I - Command-line args */ -{ - int i; /* Looping var */ - FILE *fp; /* File to read */ - mxml_node_t *doc; /* XML documentation tree */ - mxml_node_t *mxmldoc; /* mxmldoc node */ - - - /* - * Check arguments... - */ - - if (argc < 2) - { - fputs("Usage: mxmldoc filename.xml [source files] >filename.html\n", stderr); - return (1); - } - - /* - * Read the XML documentation file, if it exists... - */ - - if ((fp = fopen(argv[1], "r")) != NULL) - { - /* - * Read the existing XML file... - */ - - doc = mxmlLoadFile(NULL, fp, MXML_NO_CALLBACK); - - fclose(fp); - - if (!doc) - { - mxmldoc = NULL; - - fprintf(stderr, "mxmldoc: Unable to read the XML documentation file \"%s\"!\n", - argv[1]); - } - else if ((mxmldoc = mxmlFindElement(doc, doc, "mxmldoc", NULL, - NULL, MXML_DESCEND)) == NULL) - { - fprintf(stderr, "mxmldoc: XML documentation file \"%s\" is missing node!!\n", - argv[1]); - - mxmlDelete(doc); - doc = NULL; - } - } - else - { - doc = NULL; - mxmldoc = NULL; - } - - if (!doc) - { - /* - * Create an empty XML documentation file... - */ - - doc = mxmlNewElement(NULL, "?xml version=\"1.0\"?"); - - mxmldoc = mxmlNewElement(doc, "mxmldoc"); - -#ifdef MXML_INCLUDE_SCHEMA - /* - * Currently we don't include the schema/namespace stuff with the - * XML output since some validators don't seem to like it... - */ - - mxmlElementSetAttr(mxmldoc, "xmlns", "http://www.easysw.com"); - mxmlElementSetAttr(mxmldoc, "xmlns:xsi", - "http://www.w3.org/2001/XMLSchema-instance"); - mxmlElementSetAttr(mxmldoc, "xsi:schemaLocation", - "http://www.easysw.com/~mike/mxml/mxmldoc.xsd"); -#endif /* MXML_INCLUDE_SCHEMA */ - } - - /* - * Loop through all of the source files... - */ - - for (i = 2; i < argc; i ++) - if ((fp = fopen(argv[i], "r")) == NULL) - { - fprintf(stderr, "Unable to open source file \"%s\": %s\n", argv[i], - strerror(errno)); - mxmlDelete(doc); - return (1); - } - else if (scan_file(argv[i], fp, mxmldoc)) - { - fclose(fp); - mxmlDelete(doc); - return (1); - } - else - fclose(fp); - - if (argc > 2) - { - /* - * Save the updated XML documentation file... - */ - - if ((fp = fopen(argv[1], "w")) != NULL) - { - /* - * Write over the existing XML file... - */ - - if (mxmlSaveFile(doc, fp, ws_cb)) - { - fprintf(stderr, "Unable to write the XML documentation file \"%s\": %s!\n", - argv[1], strerror(errno)); - fclose(fp); - mxmlDelete(doc); - return (1); - } - - fclose(fp); - } - else - { - fprintf(stderr, "Unable to create the XML documentation file \"%s\": %s!\n", - argv[1], strerror(errno)); - mxmlDelete(doc); - return (1); - } - } - - /* - * Write HTML documentation... - */ - - write_documentation(mxmldoc); - - /* - * Delete the tree and return... - */ - - mxmlDelete(doc); - - return (0); -} - - -/* - * 'add_variable()' - Add a variable or argument. - */ - -static mxml_node_t * /* O - New variable/argument */ -add_variable(mxml_node_t *parent, /* I - Parent node */ - const char *name, /* I - "argument" or "variable" */ - mxml_node_t *type) /* I - Type nodes */ -{ - mxml_node_t *variable, /* New variable */ - *node, /* Current node */ - *next; /* Next node */ - char buffer[16384], /* String buffer */ - *bufptr; /* Pointer into buffer */ - - - /* - * Range check input... - */ - - if (!type || !type->child) - return (NULL); - - /* - * Create the variable/argument node... - */ - - variable = mxmlNewElement(parent, name); - - /* - * Check for a default value... - */ - - for (node = type->child; node; node = node->next) - if (!strcmp(node->value.text.string, "=")) - break; - - if (node) - { - /* - * Default value found, copy it and add as a "default" attribute... - */ - - for (bufptr = buffer; node; bufptr += strlen(bufptr)) - { - if (node->value.text.whitespace && bufptr > buffer) - *bufptr++ = ' '; - - strcpy(bufptr, node->value.text.string); - - next = node->next; - mxmlDelete(node); - node = next; - } - - mxmlElementSetAttr(variable, "default", buffer); - } - - /* - * Extract the argument/variable name... - */ - - if (type->last_child->value.text.string[0] == ')') - { - /* - * Handle "type (*name)(args)"... - */ - - for (node = type->child; node; node = node->next) - if (node->value.text.string[0] == '(') - break; - - for (bufptr = buffer; node; bufptr += strlen(bufptr)) - { - if (node->value.text.whitespace && bufptr > buffer) - *bufptr++ = ' '; - - strcpy(bufptr, node->value.text.string); - - next = node->next; - mxmlDelete(node); - node = next; - } - } - else - { - /* - * Handle "type name"... - */ - - strcpy(buffer, type->last_child->value.text.string); - mxmlDelete(type->last_child); - } - - /* - * Set the name... - */ - - mxmlElementSetAttr(variable, "name", buffer); - - /* - * Add the remaining type information to the variable node... - */ - - mxmlAdd(variable, MXML_ADD_AFTER, MXML_ADD_TO_PARENT, type); - - /* - * Add new new variable node... - */ - - return (variable); -} - - -/* - * 'safe_strcpy()' - Copy a string allowing for overlapping strings. - */ - -static void -safe_strcpy(char *dst, /* I - Destination string */ - const char *src) /* I - Source string */ -{ - while (*src) - *dst++ = *src++; - - *dst = '\0'; -} - - -/* - * 'scan_file()' - Scan a source file. - */ - -static int /* O - 0 on success, -1 on error */ -scan_file(const char *filename, /* I - Filename */ - FILE *fp, /* I - File to scan */ - mxml_node_t *tree) /* I - Function tree */ -{ - int state, /* Current parser state */ - braces, /* Number of braces active */ - parens; /* Number of active parenthesis */ - int ch; /* Current character */ - char buffer[65536], /* String buffer */ - *bufptr; /* Pointer into buffer */ - const char *scope; /* Current variable/function scope */ - mxml_node_t *comment, /* node */ - *constant, /* node */ - *enumeration, /* node */ - *function, /* node */ - *fstructclass, /* function struct/class node */ - *structclass, /* or node */ - *typedefnode, /* node */ - *variable, /* or node */ - *returnvalue, /* node */ - *type, /* node */ - *description, /* node */ - *node, /* Current node */ - *next; /* Next node */ -#if DEBUG > 1 - mxml_node_t *temp; /* Temporary node */ - int oldstate, /* Previous state */ - oldch; /* Old character */ - static const char *states[] = /* State strings */ - { - "STATE_NONE", - "STATE_PREPROCESSOR", - "STATE_C_COMMENT", - "STATE_CXX_COMMENT", - "STATE_STRING", - "STATE_CHARACTER", - "STATE_IDENTIFIER" - }; -#endif /* DEBUG > 1 */ - - -#ifdef DEBUG - fprintf(stderr, "scan_file(filename=\"%s\", fp=%p, tree=%p)\n", filename, - fp, tree); -#endif // DEBUG - - /* - * Initialize the finite state machine... - */ - - state = STATE_NONE; - braces = 0; - parens = 0; - bufptr = buffer; - - comment = mxmlNewElement(MXML_NO_PARENT, "temp"); - constant = NULL; - enumeration = NULL; - function = NULL; - variable = NULL; - returnvalue = NULL; - type = NULL; - description = NULL; - typedefnode = NULL; - structclass = NULL; - fstructclass = NULL; - - if (!strcmp(tree->value.element.name, "class")) - scope = "private"; - else - scope = NULL; - - /* - * Read until end-of-file... - */ - - while ((ch = getc(fp)) != EOF) - { -#if DEBUG > 1 - oldstate = state; - oldch = ch; -#endif /* DEBUG > 1 */ - - switch (state) - { - case STATE_NONE : /* No state - whitespace, etc. */ - switch (ch) - { - case '/' : /* Possible C/C++ comment */ - ch = getc(fp); - bufptr = buffer; - - if (ch == '*') - state = STATE_C_COMMENT; - else if (ch == '/') - state = STATE_CXX_COMMENT; - else - { - ungetc(ch, fp); - - if (type) - { -#ifdef DEBUG - fputs("Identifier: <<<< / >>>\n", stderr); -#endif /* DEBUG */ - ch = type->last_child->value.text.string[0]; - mxmlNewText(type, isalnum(ch) || ch == '_', "/"); - } - } - break; - - case '#' : /* Preprocessor */ -#ifdef DEBUG - fputs(" #preprocessor...\n", stderr); -#endif /* DEBUG */ - state = STATE_PREPROCESSOR; - break; - - case '\'' : /* Character constant */ - state = STATE_CHARACTER; - bufptr = buffer; - *bufptr++ = ch; - break; - - case '\"' : /* String constant */ - state = STATE_STRING; - bufptr = buffer; - *bufptr++ = ch; - break; - - case '{' : -#ifdef DEBUG - fprintf(stderr, " open brace, function=%p, type=%p...\n", - function, type); - if (type) - fprintf(stderr, " type->child=\"%s\"...\n", - type->child->value.text.string); -#endif /* DEBUG */ - - if (function) - { - if (fstructclass) - { - sort_node(fstructclass, function); - fstructclass = NULL; - } - else - sort_node(tree, function); - - function = NULL; - } - else if (type && type->child && - ((!strcmp(type->child->value.text.string, "typedef") && - type->child->next && - (!strcmp(type->child->next->value.text.string, "struct") || - !strcmp(type->child->next->value.text.string, "union") || - !strcmp(type->child->next->value.text.string, "class"))) || - !strcmp(type->child->value.text.string, "union") || - !strcmp(type->child->value.text.string, "struct") || - !strcmp(type->child->value.text.string, "class"))) - { - /* - * Start of a class or structure... - */ - - if (!strcmp(type->child->value.text.string, "typedef")) - { -#ifdef DEBUG - fputs(" starting typedef...\n", stderr); -#endif /* DEBUG */ - - typedefnode = mxmlNewElement(MXML_NO_PARENT, "typedef"); - mxmlDelete(type->child); - } - else - typedefnode = NULL; - - structclass = mxmlNewElement(MXML_NO_PARENT, - type->child->value.text.string); - -#ifdef DEBUG - fprintf(stderr, "%c%s: <<<< %s >>>\n", - toupper(type->child->value.text.string[0]), - type->child->value.text.string + 1, - type->child->next ? - type->child->next->value.text.string : "(noname)"); - - fputs(" type =", stderr); - for (node = type->child; node; node = node->next) - fprintf(stderr, " \"%s\"", node->value.text.string); - putc('\n', stderr); - - fprintf(stderr, " scope = %s\n", scope ? scope : "(null)"); -#endif /* DEBUG */ - - if (comment->last_child && - strstr(comment->last_child->value.text.string, "@private")) - { - mxmlDelete(type); - type = NULL; - - if (typedefnode) - { - mxmlDelete(typedefnode); - typedefnode = NULL; - } - - mxmlDelete(structclass); - structclass = NULL; - - braces ++; - function = NULL; - variable = NULL; - break; - } - - if (type->child->next) - { - mxmlElementSetAttr(structclass, "name", - type->child->next->value.text.string); - sort_node(tree, structclass); - } - - if (typedefnode && type->child) - type->child->value.text.whitespace = 0; - else if (structclass && type->child && - type->child->next && type->child->next->next) - { - for (bufptr = buffer, node = type->child->next->next; - node; - bufptr += strlen(bufptr)) - { - if (node->value.text.whitespace && bufptr > buffer) - *bufptr++ = ' '; - - strcpy(bufptr, node->value.text.string); - - next = node->next; - mxmlDelete(node); - node = next; - } - - mxmlElementSetAttr(structclass, "parent", buffer); - - mxmlDelete(type); - type = NULL; - } - else - { - mxmlDelete(type); - type = NULL; - } - - if (typedefnode && comment->last_child) - { - /* - * Copy comment for typedef as well as class/struct/union... - */ - - mxmlNewText(comment, 0, - comment->last_child->value.text.string); - description = mxmlNewElement(typedefnode, "description"); -#ifdef DEBUG - fputs(" duplicating comment for typedef...\n", stderr); -#endif /* DEBUG */ - update_comment(typedefnode, comment->last_child); - mxmlAdd(description, MXML_ADD_AFTER, MXML_ADD_TO_PARENT, - comment->last_child); - } - - description = mxmlNewElement(structclass, "description"); -#ifdef DEBUG - fprintf(stderr, " adding comment to %s...\n", - structclass->value.element.name); -#endif /* DEBUG */ - update_comment(structclass, comment->last_child); - mxmlAdd(description, MXML_ADD_AFTER, MXML_ADD_TO_PARENT, - comment->last_child); - - if (scan_file(filename, fp, structclass)) - { - mxmlDelete(comment); - return (-1); - } - -#ifdef DEBUG - fputs(" ended typedef...\n", stderr); -#endif /* DEBUG */ - structclass = NULL; - break; - } - else if (type && type->child && type->child->next && - (!strcmp(type->child->value.text.string, "enum") || - (!strcmp(type->child->value.text.string, "typedef") && - !strcmp(type->child->next->value.text.string, "enum")))) - { - /* - * Enumeration type... - */ - - if (!strcmp(type->child->value.text.string, "typedef")) - { -#ifdef DEBUG - fputs(" starting typedef...\n", stderr); -#endif /* DEBUG */ - - typedefnode = mxmlNewElement(MXML_NO_PARENT, "typedef"); - mxmlDelete(type->child); - } - else - typedefnode = NULL; - - enumeration = mxmlNewElement(MXML_NO_PARENT, "enumeration"); - -#ifdef DEBUG - fprintf(stderr, "Enumeration: <<<< %s >>>\n", - type->child->next ? - type->child->next->value.text.string : "(noname)"); -#endif /* DEBUG */ - - if (type->child->next) - { - mxmlElementSetAttr(enumeration, "name", - type->child->next->value.text.string); - sort_node(tree, enumeration); - } - - if (typedefnode && type->child) - type->child->value.text.whitespace = 0; - else - { - mxmlDelete(type); - type = NULL; - } - - if (typedefnode && comment->last_child) - { - /* - * Copy comment for typedef as well as class/struct/union... - */ - - mxmlNewText(comment, 0, - comment->last_child->value.text.string); - description = mxmlNewElement(typedefnode, "description"); -#ifdef DEBUG - fputs(" duplicating comment for typedef...\n", stderr); -#endif /* DEBUG */ - update_comment(typedefnode, comment->last_child); - mxmlAdd(description, MXML_ADD_AFTER, MXML_ADD_TO_PARENT, - comment->last_child); - } - - description = mxmlNewElement(enumeration, "description"); -#ifdef DEBUG - fputs(" adding comment to enumeration...\n", stderr); -#endif /* DEBUG */ - update_comment(enumeration, comment->last_child); - mxmlAdd(description, MXML_ADD_AFTER, MXML_ADD_TO_PARENT, - comment->last_child); - } - else if (type && type->child && - !strcmp(type->child->value.text.string, "extern")) - { - if (scan_file(filename, fp, tree)) - { - mxmlDelete(comment); - return (-1); - } - } - else if (type) - { - mxmlDelete(type); - type = NULL; - } - - braces ++; - function = NULL; - variable = NULL; - break; - - case '}' : -#ifdef DEBUG - fputs(" close brace...\n", stderr); -#endif /* DEBUG */ - - if (structclass) - scope = NULL; - - enumeration = NULL; - constant = NULL; - structclass = NULL; - - if (braces > 0) - braces --; - else - { - mxmlDelete(comment); - return (0); - } - break; - - case '(' : - if (type) - { -#ifdef DEBUG - fputs("Identifier: <<<< ( >>>\n", stderr); -#endif /* DEBUG */ - mxmlNewText(type, 0, "("); - } - - parens ++; - break; - - case ')' : - if (parens > 0) - parens --; - - if (type && parens) - { -#ifdef DEBUG - fputs("Identifier: <<<< ) >>>\n", stderr); -#endif /* DEBUG */ - mxmlNewText(type, 0, ")"); - } - - if (function && type && !parens) - { - variable = add_variable(function, "argument", type); - type = NULL; - } - break; - - case ';' : -#ifdef DEBUG - fputs("Identifier: <<<< ; >>>\n", stderr); - fprintf(stderr, " function=%p, type=%p\n", function, type); -#endif /* DEBUG */ - - if (function) - { - if (!strcmp(tree->value.element.name, "class")) - { -#ifdef DEBUG - fputs(" ADDING FUNCTION TO CLASS\n", stderr); -#endif /* DEBUG */ - sort_node(tree, function); - } - else - mxmlDelete(function); - - function = NULL; - variable = NULL; - } - - if (type) - { - mxmlDelete(type); - type = NULL; - } - break; - - case ':' : - if (type) - { -#ifdef DEBUG - fputs("Identifier: <<<< : >>>\n", stderr); -#endif /* DEBUG */ - mxmlNewText(type, 1, ":"); - } - break; - - case '*' : - if (type) - { -#ifdef DEBUG - fputs("Identifier: <<<< * >>>\n", stderr); -#endif /* DEBUG */ - ch = type->last_child->value.text.string[0]; - mxmlNewText(type, isalnum(ch) || ch == '_', "*"); - } - break; - - case '&' : - if (type) - { -#ifdef DEBUG - fputs("Identifier: <<<< & >>>\n", stderr); -#endif /* DEBUG */ - mxmlNewText(type, 1, "&"); - } - break; - - case '+' : - if (type) - { -#ifdef DEBUG - fputs("Identifier: <<<< + >>>\n", stderr); -#endif /* DEBUG */ - ch = type->last_child->value.text.string[0]; - mxmlNewText(type, isalnum(ch) || ch == '_', "+"); - } - break; - - case '-' : - if (type) - { -#ifdef DEBUG - fputs("Identifier: <<<< - >>>\n", stderr); -#endif /* DEBUG */ - ch = type->last_child->value.text.string[0]; - mxmlNewText(type, isalnum(ch) || ch == '_', "-"); - } - break; - - case '=' : - if (type) - { -#ifdef DEBUG - fputs("Identifier: <<<< = >>>\n", stderr); -#endif /* DEBUG */ - ch = type->last_child->value.text.string[0]; - mxmlNewText(type, isalnum(ch) || ch == '_', "="); - } - break; - - default : /* Other */ - if (isalnum(ch) || ch == '_' || ch == '.' || ch == ':' || ch == '~') - { - state = STATE_IDENTIFIER; - bufptr = buffer; - *bufptr++ = ch; - } - break; - } - break; - - case STATE_PREPROCESSOR : /* Preprocessor directive */ - if (ch == '\n') - state = STATE_NONE; - else if (ch == '\\') - getc(fp); - break; - - case STATE_C_COMMENT : /* Inside a C comment */ - switch (ch) - { - case '\n' : - while ((ch = getc(fp)) != EOF) - if (ch == '*') - { - ch = getc(fp); - - if (ch == '/') - { - *bufptr = '\0'; - - if (comment->child != comment->last_child) - { -#ifdef DEBUG - fprintf(stderr, " removing comment %p, last comment %p...\n", - comment->child, comment->last_child); -#endif /* DEBUG */ - mxmlDelete(comment->child); -#ifdef DEBUG - fprintf(stderr, " new comment %p, last comment %p...\n", - comment->child, comment->last_child); -#endif /* DEBUG */ - } - -#ifdef DEBUG - fprintf(stderr, " processing comment, variable=%p, constant=%p, tree=\"%s\"\n", - variable, constant, tree->value.element.name); -#endif /* DEBUG */ - - if (variable) - { - description = mxmlNewElement(variable, "description"); -#ifdef DEBUG - fputs(" adding comment to variable...\n", stderr); -#endif /* DEBUG */ - update_comment(variable, - mxmlNewText(description, 0, buffer)); - variable = NULL; - } - else if (constant) - { - description = mxmlNewElement(constant, "description"); -#ifdef DEBUG - fputs(" adding comment to constant...\n", stderr); -#endif /* DEBUG */ - update_comment(constant, - mxmlNewText(description, 0, buffer)); - constant = NULL; - } - else if (typedefnode) - { - description = mxmlNewElement(typedefnode, "description"); -#ifdef DEBUG - fprintf(stderr, " adding comment to typedef %s...\n", - mxmlElementGetAttr(typedefnode, "name")); -#endif /* DEBUG */ - update_comment(typedefnode, - mxmlNewText(description, 0, buffer)); - } - else if (strcmp(tree->value.element.name, "mxmldoc") && - !mxmlFindElement(tree, tree, "description", - NULL, NULL, MXML_DESCEND_FIRST)) - { - description = mxmlNewElement(tree, "description"); -#ifdef DEBUG - fputs(" adding comment to parent...\n", stderr); -#endif /* DEBUG */ - update_comment(tree, - mxmlNewText(description, 0, buffer)); - } - else - { -#ifdef DEBUG - fprintf(stderr, " before adding comment, child=%p, last_child=%p\n", - comment->child, comment->last_child); -#endif /* DEBUG */ - mxmlNewText(comment, 0, buffer); -#ifdef DEBUG - fprintf(stderr, " after adding comment, child=%p, last_child=%p\n", - comment->child, comment->last_child); -#endif /* DEBUG */ - } -#ifdef DEBUG - fprintf(stderr, "C comment: <<<< %s >>>\n", buffer); -#endif /* DEBUG */ - - state = STATE_NONE; - break; - } - else - ungetc(ch, fp); - } - else if (ch == '\n' && bufptr > buffer && - bufptr < (buffer + sizeof(buffer) - 1)) - *bufptr++ = ch; - else if (!isspace(ch)) - break; - - if (ch != EOF) - ungetc(ch, fp); - - if (bufptr > buffer && bufptr < (buffer + sizeof(buffer) - 1)) - *bufptr++ = '\n'; - break; - - case '/' : - if (ch == '/' && bufptr > buffer && bufptr[-1] == '*') - { - while (bufptr > buffer && - (bufptr[-1] == '*' || isspace(bufptr[-1] & 255))) - bufptr --; - *bufptr = '\0'; - - if (comment->child != comment->last_child) - { -#ifdef DEBUG - fprintf(stderr, " removing comment %p, last comment %p...\n", - comment->child, comment->last_child); -#endif /* DEBUG */ - mxmlDelete(comment->child); -#ifdef DEBUG - fprintf(stderr, " new comment %p, last comment %p...\n", - comment->child, comment->last_child); -#endif /* DEBUG */ - } - - if (variable) - { - description = mxmlNewElement(variable, "description"); -#ifdef DEBUG - fputs(" adding comment to variable...\n", stderr); -#endif /* DEBUG */ - update_comment(variable, - mxmlNewText(description, 0, buffer)); - variable = NULL; - } - else if (constant) - { - description = mxmlNewElement(constant, "description"); -#ifdef DEBUG - fputs(" adding comment to constant...\n", stderr); -#endif /* DEBUG */ - update_comment(constant, - mxmlNewText(description, 0, buffer)); - constant = NULL; - } - else if (typedefnode) - { - description = mxmlNewElement(typedefnode, "description"); -#ifdef DEBUG - fprintf(stderr, " adding comment to typedef %s...\n", - mxmlElementGetAttr(typedefnode, "name")); -#endif /* DEBUG */ - update_comment(typedefnode, - mxmlNewText(description, 0, buffer)); - } - else if (strcmp(tree->value.element.name, "mxmldoc") && - !mxmlFindElement(tree, tree, "description", - NULL, NULL, MXML_DESCEND_FIRST)) - { - description = mxmlNewElement(tree, "description"); -#ifdef DEBUG - fputs(" adding comment to parent...\n", stderr); -#endif /* DEBUG */ - update_comment(tree, - mxmlNewText(description, 0, buffer)); - } - else - mxmlNewText(comment, 0, buffer); - -#ifdef DEBUG - fprintf(stderr, "C comment: <<<< %s >>>\n", buffer); -#endif /* DEBUG */ - - state = STATE_NONE; - break; - } - - default : - if (ch == ' ' && bufptr == buffer) - break; - - if (bufptr < (buffer + sizeof(buffer) - 1)) - *bufptr++ = ch; - break; - } - break; - - case STATE_CXX_COMMENT : /* Inside a C++ comment */ - if (ch == '\n') - { - state = STATE_NONE; - *bufptr = '\0'; - - if (comment->child != comment->last_child) - { -#ifdef DEBUG - fprintf(stderr, " removing comment %p, last comment %p...\n", - comment->child, comment->last_child); -#endif /* DEBUG */ - mxmlDelete(comment->child); -#ifdef DEBUG - fprintf(stderr, " new comment %p, last comment %p...\n", - comment->child, comment->last_child); -#endif /* DEBUG */ - } - - if (variable) - { - description = mxmlNewElement(variable, "description"); -#ifdef DEBUG - fputs(" adding comment to variable...\n", stderr); -#endif /* DEBUG */ - update_comment(variable, - mxmlNewText(description, 0, buffer)); - variable = NULL; - } - else if (constant) - { - description = mxmlNewElement(constant, "description"); -#ifdef DEBUG - fputs(" adding comment to constant...\n", stderr); -#endif /* DEBUG */ - update_comment(constant, - mxmlNewText(description, 0, buffer)); - constant = NULL; - } - else if (typedefnode) - { - description = mxmlNewElement(typedefnode, "description"); -#ifdef DEBUG - fprintf(stderr, " adding comment to typedef %s...\n", - mxmlElementGetAttr(typedefnode, "name")); -#endif /* DEBUG */ - update_comment(typedefnode, - mxmlNewText(description, 0, buffer)); - } - else if (strcmp(tree->value.element.name, "mxmldoc") && - !mxmlFindElement(tree, tree, "description", - NULL, NULL, MXML_DESCEND_FIRST)) - { - description = mxmlNewElement(tree, "description"); -#ifdef DEBUG - fputs(" adding comment to parent...\n", stderr); -#endif /* DEBUG */ - update_comment(tree, - mxmlNewText(description, 0, buffer)); - } - else - mxmlNewText(comment, 0, buffer); - -#ifdef DEBUG - fprintf(stderr, "C++ comment: <<<< %s >>>\n", buffer); -#endif /* DEBUG */ - } - else if (ch == ' ' && bufptr == buffer) - break; - else if (bufptr < (buffer + sizeof(buffer) - 1)) - *bufptr++ = ch; - break; - - case STATE_STRING : /* Inside a string constant */ - *bufptr++ = ch; - - if (ch == '\\') - *bufptr++ = getc(fp); - else if (ch == '\"') - { - *bufptr = '\0'; - - if (type) - mxmlNewText(type, type->child != NULL, buffer); - - state = STATE_NONE; - } - break; - - case STATE_CHARACTER : /* Inside a character constant */ - *bufptr++ = ch; - - if (ch == '\\') - *bufptr++ = getc(fp); - else if (ch == '\'') - { - *bufptr = '\0'; - - if (type) - mxmlNewText(type, type->child != NULL, buffer); - - state = STATE_NONE; - } - break; - - case STATE_IDENTIFIER : /* Inside a keyword or identifier */ - if (isalnum(ch) || ch == '_' || ch == '[' || ch == ']' || - (ch == ',' && parens > 1) || ch == ':' || ch == '.' || ch == '~') - { - if (bufptr < (buffer + sizeof(buffer) - 1)) - *bufptr++ = ch; - } - else - { - ungetc(ch, fp); - *bufptr = '\0'; - state = STATE_NONE; - -#ifdef DEBUG - fprintf(stderr, " braces=%d, type=%p, type->child=%p, buffer=\"%s\"\n", - braces, type, type ? type->child : NULL, buffer); -#endif /* DEBUG */ - - if (!braces) - { - if (!type || !type->child) - { - if (!strcmp(tree->value.element.name, "class")) - { - if (!strcmp(buffer, "public") || - !strcmp(buffer, "public:")) - { - scope = "public"; -#ifdef DEBUG - fputs(" scope = public\n", stderr); -#endif /* DEBUG */ - break; - } - else if (!strcmp(buffer, "private") || - !strcmp(buffer, "private:")) - { - scope = "private"; -#ifdef DEBUG - fputs(" scope = private\n", stderr); -#endif /* DEBUG */ - break; - } - else if (!strcmp(buffer, "protected") || - !strcmp(buffer, "protected:")) - { - scope = "protected"; -#ifdef DEBUG - fputs(" scope = protected\n", stderr); -#endif /* DEBUG */ - break; - } - } - } - - if (!type) - type = mxmlNewElement(MXML_NO_PARENT, "type"); - -#ifdef DEBUG - fprintf(stderr, " function=%p (%s), type->child=%p, ch='%c', parens=%d\n", - function, - function ? mxmlElementGetAttr(function, "name") : "null", - type->child, ch, parens); -#endif /* DEBUG */ - - if (!function && ch == '(') - { - if (type->child && - !strcmp(type->child->value.text.string, "extern")) - { - /* - * Remove external declarations... - */ - - mxmlDelete(type); - type = NULL; - break; - } - - if (type->child && - !strcmp(type->child->value.text.string, "static") && - !strcmp(tree->value.element.name, "mxmldoc")) - { - /* - * Remove static functions... - */ - - mxmlDelete(type); - type = NULL; - break; - } - - function = mxmlNewElement(MXML_NO_PARENT, "function"); - if ((bufptr = strchr(buffer, ':')) != NULL && bufptr[1] == ':') - { - *bufptr = '\0'; - bufptr += 2; - - if ((fstructclass = - mxmlFindElement(tree, tree, "class", "name", buffer, - MXML_DESCEND_FIRST)) == NULL) - fstructclass = - mxmlFindElement(tree, tree, "struct", "name", buffer, - MXML_DESCEND_FIRST); - } - else - bufptr = buffer; - - mxmlElementSetAttr(function, "name", bufptr); - - if (scope) - mxmlElementSetAttr(function, "scope", scope); - -#ifdef DEBUG - fprintf(stderr, "function: %s\n", buffer); - fprintf(stderr, " scope = %s\n", scope ? scope : "(null)"); - fprintf(stderr, " comment = %p\n", comment); - fprintf(stderr, " child = (%p) %s\n", - comment->child, - comment->child ? - comment->child->value.text.string : "(null)"); - fprintf(stderr, " last_child = (%p) %s\n", - comment->last_child, - comment->last_child ? - comment->last_child->value.text.string : "(null)"); -#endif /* DEBUG */ - - if (type->last_child && - strcmp(type->last_child->value.text.string, "void")) - { - returnvalue = mxmlNewElement(function, "returnvalue"); - - mxmlAdd(returnvalue, MXML_ADD_AFTER, MXML_ADD_TO_PARENT, type); - - description = mxmlNewElement(returnvalue, "description"); -#ifdef DEBUG - fputs(" adding comment to returnvalue...\n", stderr); -#endif /* DEBUG */ - update_comment(returnvalue, comment->last_child); - mxmlAdd(description, MXML_ADD_AFTER, MXML_ADD_TO_PARENT, - comment->last_child); - } - else - mxmlDelete(type); - - description = mxmlNewElement(function, "description"); -#ifdef DEBUG - fputs(" adding comment to function...\n", stderr); -#endif /* DEBUG */ - update_comment(function, comment->last_child); - mxmlAdd(description, MXML_ADD_AFTER, MXML_ADD_TO_PARENT, - comment->last_child); - - type = NULL; - } - else if (function && ((ch == ')' && parens == 1) || ch == ',')) - { - /* - * Argument definition... - */ - - mxmlNewText(type, type->child != NULL && - type->last_child->value.text.string[0] != '(' && - type->last_child->value.text.string[0] != '*', - buffer); - -#ifdef DEBUG - fprintf(stderr, "Argument: <<<< %s >>>\n", buffer); -#endif /* DEBUG */ - - variable = add_variable(function, "argument", type); - type = NULL; - } - else if (type->child && !function && (ch == ';' || ch == ',')) - { -#ifdef DEBUG - fprintf(stderr, " got semicolon, typedefnode=%p, structclass=%p\n", - typedefnode, structclass); -#endif /* DEBUG */ - - if (typedefnode || structclass) - { -#ifdef DEBUG - fprintf(stderr, "Typedef/struct/class: <<<< %s >>>>\n", buffer); -#endif /* DEBUG */ - - if (typedefnode) - { - mxmlElementSetAttr(typedefnode, "name", buffer); - - sort_node(tree, typedefnode); - } - - if (structclass && !mxmlElementGetAttr(structclass, "name")) - { -#ifdef DEBUG - fprintf(stderr, "setting struct/class name to %s!\n", - type->last_child->value.text.string); -#endif /* DEBUG */ - mxmlElementSetAttr(structclass, "name", buffer); - - sort_node(tree, structclass); - structclass = NULL; - } - - if (typedefnode) - mxmlAdd(typedefnode, MXML_ADD_BEFORE, MXML_ADD_TO_PARENT, - type); - else - mxmlDelete(type); - - type = NULL; - typedefnode = NULL; - } - else if (type->child && - !strcmp(type->child->value.text.string, "typedef")) - { - /* - * Simple typedef... - */ - -#ifdef DEBUG - fprintf(stderr, "Typedef: <<<< %s >>>\n", buffer); -#endif /* DEBUG */ - - typedefnode = mxmlNewElement(MXML_NO_PARENT, "typedef"); - mxmlElementSetAttr(typedefnode, "name", buffer); - mxmlDelete(type->child); - - sort_node(tree, typedefnode); - - if (type->child) - type->child->value.text.whitespace = 0; - - mxmlAdd(typedefnode, MXML_ADD_AFTER, MXML_ADD_TO_PARENT, type); - type = NULL; - } - else if (!parens) - { - /* - * Variable definition... - */ - - if (type->child && - !strcmp(type->child->value.text.string, "static") && - !strcmp(tree->value.element.name, "mxmldoc")) - { - /* - * Remove static functions... - */ - - mxmlDelete(type); - type = NULL; - break; - } - - mxmlNewText(type, type->child != NULL && - type->last_child->value.text.string[0] != '(' && - type->last_child->value.text.string[0] != '*', - buffer); - -#ifdef DEBUG - fprintf(stderr, "Variable: <<<< %s >>>>\n", buffer); - fprintf(stderr, " scope = %s\n", scope ? scope : "(null)"); -#endif /* DEBUG */ - - variable = add_variable(MXML_NO_PARENT, "variable", type); - type = NULL; - - sort_node(tree, variable); - - if (scope) - mxmlElementSetAttr(variable, "scope", scope); - } - } - else - { -#ifdef DEBUG - fprintf(stderr, "Identifier: <<<< %s >>>>\n", buffer); -#endif /* DEBUG */ - - mxmlNewText(type, type->child != NULL && - type->last_child->value.text.string[0] != '(' && - type->last_child->value.text.string[0] != '*', - buffer); - } - } - else if (enumeration && !isdigit(buffer[0] & 255)) - { -#ifdef DEBUG - fprintf(stderr, "Constant: <<<< %s >>>\n", buffer); -#endif /* DEBUG */ - - constant = mxmlNewElement(MXML_NO_PARENT, "constant"); - mxmlElementSetAttr(constant, "name", buffer); - sort_node(enumeration, constant); - } - else if (type) - { - mxmlDelete(type); - type = NULL; - } - } - break; - } - -#if DEBUG > 1 - if (state != oldstate) - { - fprintf(stderr, " changed states from %s to %s on receipt of character '%c'...\n", - states[oldstate], states[state], oldch); - fprintf(stderr, " variable = %p\n", variable); - if (type) - { - fputs(" type =", stderr); - for (temp = type->child; temp; temp = temp->next) - fprintf(stderr, " \"%s\"", temp->value.text.string); - fputs("\n", stderr); - } - } -#endif /* DEBUG > 1 */ - } - - mxmlDelete(comment); - - /* - * All done, return with no errors... - */ - - return (0); -} - - -/* - * 'sort_node()' - Insert a node sorted into a tree. - */ - -static void -sort_node(mxml_node_t *tree, /* I - Tree to sort into */ - mxml_node_t *node) /* I - Node to add */ -{ - mxml_node_t *temp; /* Current node */ - const char *tempname, /* Name of current node */ - *nodename, /* Name of node */ - *scope; /* Scope */ - - -#if DEBUG > 1 - fprintf(stderr, " sort_node(tree=%p, node=%p)\n", tree, node); -#endif /* DEBUG > 1 */ - - /* - * Range check input... - */ - - if (!tree || !node || node->parent == tree) - return; - - /* - * Get the node name... - */ - - if ((nodename = mxmlElementGetAttr(node, "name")) == NULL) - return; - -#if DEBUG > 1 - fprintf(stderr, " nodename=%p (\"%s\")\n", nodename, nodename); -#endif /* DEBUG > 1 */ - - /* - * Delete any existing definition at this level, if one exists... - */ - - if ((temp = mxmlFindElement(tree, tree, node->value.element.name, - "name", nodename, MXML_DESCEND_FIRST)) != NULL) - { - /* - * Copy the scope if needed... - */ - - if ((scope = mxmlElementGetAttr(temp, "scope")) != NULL && - mxmlElementGetAttr(node, "scope") == NULL) - { -#ifdef DEBUG - fprintf(stderr, " copying scope %s for %s\n", scope, nodename); -#endif /* DEBUG */ - - mxmlElementSetAttr(node, "scope", scope); - } - - mxmlDelete(temp); - } - - /* - * Add the node into the tree at the proper place... - */ - - for (temp = tree->child; temp; temp = temp->next) - { -#if DEBUG > 1 - fprintf(stderr, " temp=%p\n", temp); -#endif /* DEBUG > 1 */ - - if ((tempname = mxmlElementGetAttr(temp, "name")) == NULL) - continue; - -#if DEBUG > 1 - fprintf(stderr, " tempname=%p (\"%s\")\n", tempname, tempname); -#endif /* DEBUG > 1 */ - - if (strcmp(nodename, tempname) < 0) - break; - } - - if (temp) - mxmlAdd(tree, MXML_ADD_BEFORE, temp, node); - else - mxmlAdd(tree, MXML_ADD_AFTER, MXML_ADD_TO_PARENT, node); -} - - -/* - * 'update_comment()' - Update a comment node. - */ - -static void -update_comment(mxml_node_t *parent, /* I - Parent node */ - mxml_node_t *comment) /* I - Comment node */ -{ - char *ptr; /* Pointer into comment */ - - -#ifdef DEBUG - fprintf(stderr, "update_comment(parent=%p, comment=%p)\n", - parent, comment); -#endif /* DEBUG */ - - /* - * Range check the input... - */ - - if (!parent || !comment) - return; - - /* - * Update the comment... - */ - - ptr = comment->value.text.string; - - if (*ptr == '\'') - { - /* - * Convert "'name()' - description" to "description". - */ - - for (ptr ++; *ptr && *ptr != '\''; ptr ++); - - if (*ptr == '\'') - { - ptr ++; - while (isspace(*ptr & 255)) - ptr ++; - - if (*ptr == '-') - ptr ++; - - while (isspace(*ptr & 255)) - ptr ++; - - safe_strcpy(comment->value.text.string, ptr); - } - } - else if (!strncmp(ptr, "I ", 2) || !strncmp(ptr, "O ", 2) || - !strncmp(ptr, "IO ", 3)) - { - /* - * 'Convert "I - description", "IO - description", or "O - description" - * to description + directory attribute. - */ - - ptr = strchr(ptr, ' '); - *ptr++ = '\0'; - - if (!strcmp(parent->value.element.name, "argument")) - mxmlElementSetAttr(parent, "direction", comment->value.text.string); - - while (isspace(*ptr & 255)) - ptr ++; - - if (*ptr == '-') - ptr ++; - - while (isspace(*ptr & 255)) - ptr ++; - - safe_strcpy(comment->value.text.string, ptr); - } - - /* - * Eliminate leading and trailing *'s... - */ - - for (ptr = comment->value.text.string; *ptr == '*'; ptr ++); - for (; isspace(*ptr & 255); ptr ++); - if (ptr > comment->value.text.string) - safe_strcpy(comment->value.text.string, ptr); - - for (ptr = comment->value.text.string + strlen(comment->value.text.string) - 1; - ptr > comment->value.text.string && *ptr == '*'; - ptr --) - *ptr = '\0'; - for (; ptr > comment->value.text.string && isspace(*ptr & 255); ptr --) - *ptr = '\0'; - -#ifdef DEBUG - fprintf(stderr, " updated comment = %s\n", comment->value.text.string); -#endif /* DEBUG */ -} - - -/* - * 'write_documentation()' - Write HTML documentation. - */ - -static void -write_documentation(mxml_node_t *doc) /* I - XML documentation */ -{ - int i; /* Looping var */ - mxml_node_t *function, /* Current function */ - *scut, /* Struct/class/union/typedef */ - *arg, /* Current argument */ - *description, /* Description of function/var */ - *type; /* Type for argument */ - const char *name, /* Name of function/type */ - *cname, /* Class name */ - *defval, /* Default value */ - *parent; /* Parent class */ - int inscope; /* Variable/method scope */ - char prefix; /* Prefix character */ - static const char * const scopes[] = /* Scope strings */ - { - "private", - "protected", - "public" - }; - - - /* - * Standard header... - */ - - puts("\n" - "\n" - "\n" - "\tDocumentation\n" - "\t\n" - "\t\n" - "\n" - ""); - - /* - * Table of contents... - */ - - puts("

Contents

"); - puts("
    "); - if (mxmlFindElement(doc, doc, "class", NULL, NULL, MXML_DESCEND_FIRST)) - puts("\t
  • Classes
  • "); - if (mxmlFindElement(doc, doc, "enumeration", NULL, NULL, MXML_DESCEND_FIRST)) - puts("\t
  • Enumerations
  • "); - if (mxmlFindElement(doc, doc, "function", NULL, NULL, MXML_DESCEND_FIRST)) - puts("\t
  • Functions
  • "); - if (mxmlFindElement(doc, doc, "struct", NULL, NULL, MXML_DESCEND_FIRST)) - puts("\t
  • Structures
  • "); - if (mxmlFindElement(doc, doc, "typedef", NULL, NULL, MXML_DESCEND_FIRST)) - puts("\t
  • Types
  • "); - if (mxmlFindElement(doc, doc, "union", NULL, NULL, MXML_DESCEND_FIRST)) - puts("\t
  • Unions
  • "); - if (mxmlFindElement(doc, doc, "variable", NULL, NULL, MXML_DESCEND_FIRST)) - puts("\t
  • Variables
  • "); - puts("
"); - - /* - * List of classes... - */ - - if (mxmlFindElement(doc, doc, "class", NULL, NULL, MXML_DESCEND_FIRST)) - { - puts("\n" - "

Classes

\n" - "
    "); - - for (scut = mxmlFindElement(doc, doc, "class", NULL, NULL, - MXML_DESCEND_FIRST); - scut; - scut = mxmlFindElement(scut, doc, "class", NULL, NULL, - MXML_NO_DESCEND)) - { - name = mxmlElementGetAttr(scut, "name"); - printf("\t
  • %s
  • \n", name, name); - } - - puts("
"); - - for (scut = mxmlFindElement(doc, doc, "class", NULL, NULL, - MXML_DESCEND_FIRST); - scut; - scut = mxmlFindElement(scut, doc, "class", NULL, NULL, - MXML_NO_DESCEND)) - { - cname = mxmlElementGetAttr(scut, "name"); - printf("\n" - "

%s

\n" - "
\n", cname, cname); - - description = mxmlFindElement(scut, scut, "description", NULL, - NULL, MXML_DESCEND_FIRST); - if (description) - { - fputs("

Description

\n" - "

", stdout); - write_element(NULL, description); - puts("

"); - } - - printf("

Definition

\n" - "
\n"
-             "class %s", cname);
-      if ((parent = mxmlElementGetAttr(scut, "parent")) != NULL)
-        printf(" %s", parent);
-      puts("\n{");
-
-      for (i = 0; i < 3; i ++)
-      {
-        inscope = 0;
-
-	for (arg = mxmlFindElement(scut, scut, "variable", "scope", scopes[i],
-                        	   MXML_DESCEND_FIRST);
-	     arg;
-	     arg = mxmlFindElement(arg, scut, "variable", "scope", scopes[i],
-                        	   MXML_NO_DESCEND))
-	{
-          if (!inscope)
-	  {
-	    inscope = 1;
-	    printf("  %s:\n", scopes[i]);
-	  }
-
-	  printf("    ");
-	  write_element(doc, mxmlFindElement(arg, arg, "type", NULL,
-                                             NULL, MXML_DESCEND_FIRST));
-	  printf(" %s;\n", mxmlElementGetAttr(arg, "name"));
-	}
-
-	for (function = mxmlFindElement(scut, scut, "function", "scope", scopes[i],
-                                	MXML_DESCEND_FIRST);
-	     function;
-	     function = mxmlFindElement(function, scut, "function", "scope", scopes[i],
-                                	MXML_NO_DESCEND))
-	{
-          if (!inscope)
-	  {
-	    inscope = 1;
-	    printf("  %s:\n", scopes[i]);
-	  }
-
-          name = mxmlElementGetAttr(function, "name");
-
-          printf("    ");
-
-	  arg = mxmlFindElement(function, function, "returnvalue", NULL,
-                        	NULL, MXML_DESCEND_FIRST);
-
-	  if (arg)
-	  {
-	    write_element(doc, mxmlFindElement(arg, arg, "type", NULL,
-                                               NULL, MXML_DESCEND_FIRST));
-	    putchar(' ');
-	  }
-	  else if (strcmp(cname, name) && strcmp(cname, name + 1))
-	    fputs("void ", stdout);
-
-	  printf("%s", cname, name, name);
-
-	  for (arg = mxmlFindElement(function, function, "argument", NULL, NULL,
-                        	     MXML_DESCEND_FIRST), prefix = '(';
-	       arg;
-	       arg = mxmlFindElement(arg, function, "argument", NULL, NULL,
-                        	     MXML_NO_DESCEND), prefix = ',')
-	  {
-	    type = mxmlFindElement(arg, arg, "type", NULL, NULL,
-	                	   MXML_DESCEND_FIRST);
-
-	    putchar(prefix);
-	    if (prefix == ',')
-	      putchar(' ');
-
-	    if (type->child)
-	    {
-	      write_element(doc, type);
-	      putchar(' ');
-	    }
-	    fputs(mxmlElementGetAttr(arg, "name"), stdout);
-            if ((defval = mxmlElementGetAttr(arg, "default")) != NULL)
-	      printf(" %s", defval);
-	  }
-
-	  if (prefix == '(')
-	    puts("(void);");
-	  else
-	    puts(");");
-	}
-      }
-
-      puts("};\n
\n" - "

Members

\n" - "

\n" - "\n" - ""); - - for (arg = mxmlFindElement(scut, scut, "variable", NULL, NULL, - MXML_DESCEND_FIRST); - arg; - arg = mxmlFindElement(arg, scut, "variable", NULL, NULL, - MXML_NO_DESCEND)) - { - printf(""); - } - - for (function = mxmlFindElement(scut, scut, "function", NULL, NULL, - MXML_DESCEND_FIRST); - function; - function = mxmlFindElement(function, scut, "function", NULL, NULL, - MXML_NO_DESCEND)) - { - name = mxmlElementGetAttr(function, "name"); - - printf(""); - } - - puts("
NameDescription
%s", mxmlElementGetAttr(arg, "name")); - - write_element(NULL, mxmlFindElement(arg, arg, "description", NULL, - NULL, MXML_DESCEND_FIRST)); - - puts("
%s()", - cname, name, name); - - description = mxmlFindElement(function, function, "description", NULL, - NULL, MXML_DESCEND_FIRST); - if (description) - write_element(NULL, description); - - arg = mxmlFindElement(function, function, "returnvalue", NULL, - NULL, MXML_DESCEND_FIRST); - - if (arg) - { - fputs("\nReturns: ", stdout); - write_element(NULL, mxmlFindElement(arg, arg, "description", NULL, - NULL, MXML_DESCEND_FIRST)); - } - - puts("

"); - } - } - - /* - * List of enumerations... - */ - - if (mxmlFindElement(doc, doc, "enumeration", NULL, NULL, MXML_DESCEND_FIRST)) - { - puts("\n" - "

Enumerations

\n" - "
    "); - - for (scut = mxmlFindElement(doc, doc, "enumeration", NULL, NULL, - MXML_DESCEND_FIRST); - scut; - scut = mxmlFindElement(scut, doc, "enumeration", NULL, NULL, - MXML_NO_DESCEND)) - { - name = mxmlElementGetAttr(scut, "name"); - printf("\t
  • %s
  • \n", name, name); - } - - puts("
"); - - for (scut = mxmlFindElement(doc, doc, "enumeration", NULL, NULL, - MXML_DESCEND_FIRST); - scut; - scut = mxmlFindElement(scut, doc, "enumeration", NULL, NULL, - MXML_NO_DESCEND)) - { - name = mxmlElementGetAttr(scut, "name"); - printf("\n" - "

%s

\n" - "
\n", name, name); - - description = mxmlFindElement(scut, scut, "description", NULL, - NULL, MXML_DESCEND_FIRST); - if (description) - { - fputs("

Description

\n" - "

", stdout); - write_element(NULL, description); - puts("

"); - } - - puts("

Values

\n" - "

\n" - "\n" - ""); - - for (arg = mxmlFindElement(scut, scut, "constant", NULL, NULL, - MXML_DESCEND_FIRST); - arg; - arg = mxmlFindElement(arg, scut, "constant", NULL, NULL, - MXML_NO_DESCEND)) - { - printf(""); - } - - puts("
NameDescription
%s", mxmlElementGetAttr(arg, "name")); - - write_element(doc, mxmlFindElement(arg, arg, "description", NULL, - NULL, MXML_DESCEND_FIRST)); - - puts("

"); - } - } - - /* - * List of functions... - */ - - if (mxmlFindElement(doc, doc, "function", NULL, NULL, MXML_DESCEND_FIRST)) - { - puts("\n" - "

Functions

\n" - "
    "); - - for (function = mxmlFindElement(doc, doc, "function", NULL, NULL, - MXML_DESCEND_FIRST); - function; - function = mxmlFindElement(function, doc, "function", NULL, NULL, - MXML_NO_DESCEND)) - { - name = mxmlElementGetAttr(function, "name"); - printf("\t
  • %s()
  • \n", name, name); - } - - puts("
"); - - for (function = mxmlFindElement(doc, doc, "function", NULL, NULL, - MXML_DESCEND_FIRST); - function; - function = mxmlFindElement(function, doc, "function", NULL, NULL, - MXML_NO_DESCEND)) - { - name = mxmlElementGetAttr(function, "name"); - printf("\n" - "

%s()

\n" - "
\n", name, name); - - description = mxmlFindElement(function, function, "description", NULL, - NULL, MXML_DESCEND_FIRST); - if (description) - { - fputs("

Description

\n" - "

", stdout); - write_element(NULL, description); - puts("

"); - } - - puts("

Syntax

\n" - "
");
-
-      arg = mxmlFindElement(function, function, "returnvalue", NULL,
-                            NULL, MXML_DESCEND_FIRST);
-
-      if (arg)
-	write_element(doc, mxmlFindElement(arg, arg, "type", NULL,
-                                           NULL, MXML_DESCEND_FIRST));
-      else
-	fputs("void", stdout);
-
-      printf("\n%s", name);
-      for (arg = mxmlFindElement(function, function, "argument", NULL, NULL,
-                        	 MXML_DESCEND_FIRST), prefix = '(';
-	   arg;
-	   arg = mxmlFindElement(arg, function, "argument", NULL, NULL,
-                        	 MXML_NO_DESCEND), prefix = ',')
-      {
-        type = mxmlFindElement(arg, arg, "type", NULL, NULL,
-	                       MXML_DESCEND_FIRST);
-
-	printf("%c\n    ", prefix);
-	if (type->child)
-	{
-	  write_element(doc, type);
-	  putchar(' ');
-	}
-	fputs(mxmlElementGetAttr(arg, "name"), stdout);
-        if ((defval = mxmlElementGetAttr(arg, "default")) != NULL)
-	  printf(" %s", defval);
-      }
-
-      if (prefix == '(')
-	puts("(void);\n
"); - else - puts(");\n"); - - puts("

Arguments

"); - - if (prefix == '(') - puts("

None.

"); - else - { - puts("

\n" - "\n" - ""); - - for (arg = mxmlFindElement(function, function, "argument", NULL, NULL, - MXML_DESCEND_FIRST); - arg; - arg = mxmlFindElement(arg, function, "argument", NULL, NULL, - MXML_NO_DESCEND)) - { - printf(""); - } - - puts("
NameDescription
%s", mxmlElementGetAttr(arg, "name")); - - write_element(NULL, mxmlFindElement(arg, arg, "description", NULL, - NULL, MXML_DESCEND_FIRST)); - - puts("

"); - } - - puts("

Returns

"); - - arg = mxmlFindElement(function, function, "returnvalue", NULL, - NULL, MXML_DESCEND_FIRST); - - if (!arg) - puts("

Nothing.

"); - else - { - fputs("

", stdout); - write_element(NULL, mxmlFindElement(arg, arg, "description", NULL, - NULL, MXML_DESCEND_FIRST)); - puts("

"); - } - } - } - - /* - * List of structures... - */ - - if (mxmlFindElement(doc, doc, "struct", NULL, NULL, MXML_DESCEND_FIRST)) - { - puts("\n" - "

Structures

\n" - "
    "); - - for (scut = mxmlFindElement(doc, doc, "struct", NULL, NULL, - MXML_DESCEND_FIRST); - scut; - scut = mxmlFindElement(scut, doc, "struct", NULL, NULL, - MXML_NO_DESCEND)) - { - name = mxmlElementGetAttr(scut, "name"); - printf("\t
  • %s
  • \n", name, name); - } - - puts("
"); - - for (scut = mxmlFindElement(doc, doc, "struct", NULL, NULL, - MXML_DESCEND_FIRST); - scut; - scut = mxmlFindElement(scut, doc, "struct", NULL, NULL, - MXML_NO_DESCEND)) - { - cname = mxmlElementGetAttr(scut, "name"); - printf("\n" - "

%s

\n" - "
\n", cname, cname); - - description = mxmlFindElement(scut, scut, "description", NULL, - NULL, MXML_DESCEND_FIRST); - if (description) - { - fputs("

Description

\n" - "

", stdout); - write_element(NULL, description); - puts("

"); - } - - printf("

Definition

\n" - "
\n"
-	     "struct %s\n{\n", cname);
-      for (arg = mxmlFindElement(scut, scut, "variable", NULL, NULL,
-                        	 MXML_DESCEND_FIRST);
-	   arg;
-	   arg = mxmlFindElement(arg, scut, "variable", NULL, NULL,
-                        	 MXML_NO_DESCEND))
-      {
-	printf("  ");
-	write_element(doc, mxmlFindElement(arg, arg, "type", NULL,
-                                           NULL, MXML_DESCEND_FIRST));
-	printf(" %s;\n", mxmlElementGetAttr(arg, "name"));
-      }
-
-      for (function = mxmlFindElement(scut, scut, "function", NULL, NULL,
-                                      MXML_DESCEND_FIRST);
-	   function;
-	   function = mxmlFindElement(function, scut, "function", NULL, NULL,
-                                      MXML_NO_DESCEND))
-      {
-        name = mxmlElementGetAttr(function, "name");
-
-        printf("  ");
-
-	arg = mxmlFindElement(function, function, "returnvalue", NULL,
-                              NULL, MXML_DESCEND_FIRST);
-
-	if (arg)
-	{
-	  write_element(doc, mxmlFindElement(arg, arg, "type", NULL,
-                                             NULL, MXML_DESCEND_FIRST));
-	  putchar(' ');
-	}
-	else if (strcmp(cname, name) && strcmp(cname, name + 1))
-	  fputs("void ", stdout);
-
-	printf("%s", cname, name, name);
-
-	for (arg = mxmlFindElement(function, function, "argument", NULL, NULL,
-                        	   MXML_DESCEND_FIRST), prefix = '(';
-	     arg;
-	     arg = mxmlFindElement(arg, function, "argument", NULL, NULL,
-                        	   MXML_NO_DESCEND), prefix = ',')
-	{
-	  type = mxmlFindElement(arg, arg, "type", NULL, NULL,
-	                	 MXML_DESCEND_FIRST);
-
-	  putchar(prefix);
-	  if (prefix == ',')
-	    putchar(' ');
-
-	  if (type->child)
-	  {
-	    write_element(doc, type);
-	    putchar(' ');
-	  }
-	  fputs(mxmlElementGetAttr(arg, "name"), stdout);
-          if ((defval = mxmlElementGetAttr(arg, "default")) != NULL)
-	    printf(" %s", defval);
-	}
-
-	if (prefix == '(')
-	  puts("(void);");
-	else
-	  puts(");");
-      }
-
-      puts("};\n
\n" - "

Members

\n" - "

\n" - "\n" - ""); - - for (arg = mxmlFindElement(scut, scut, "variable", NULL, NULL, - MXML_DESCEND_FIRST); - arg; - arg = mxmlFindElement(arg, scut, "variable", NULL, NULL, - MXML_NO_DESCEND)) - { - printf(""); - } - - for (function = mxmlFindElement(scut, scut, "function", NULL, NULL, - MXML_DESCEND_FIRST); - function; - function = mxmlFindElement(function, scut, "function", NULL, NULL, - MXML_NO_DESCEND)) - { - name = mxmlElementGetAttr(function, "name"); - - printf(""); - } - - puts("
NameDescription
%s", mxmlElementGetAttr(arg, "name")); - - write_element(NULL, mxmlFindElement(arg, arg, "description", NULL, - NULL, MXML_DESCEND_FIRST)); - - puts("
%s()", - cname, name, name); - - description = mxmlFindElement(function, function, "description", NULL, - NULL, MXML_DESCEND_FIRST); - if (description) - write_element(NULL, description); - - arg = mxmlFindElement(function, function, "returnvalue", NULL, - NULL, MXML_DESCEND_FIRST); - - if (arg) - { - fputs("\nReturns: ", stdout); - write_element(NULL, mxmlFindElement(arg, arg, "description", NULL, - NULL, MXML_DESCEND_FIRST)); - } - - puts("

"); - } - } - - /* - * List of types... - */ - - if (mxmlFindElement(doc, doc, "typedef", NULL, NULL, MXML_DESCEND_FIRST)) - { - puts("\n" - "

Types

\n" - "
    "); - - for (scut = mxmlFindElement(doc, doc, "typedef", NULL, NULL, - MXML_DESCEND_FIRST); - scut; - scut = mxmlFindElement(scut, doc, "typedef", NULL, NULL, - MXML_NO_DESCEND)) - { - name = mxmlElementGetAttr(scut, "name"); - printf("\t
  • %s
  • \n", name, name); - } - - puts("
"); - - for (scut = mxmlFindElement(doc, doc, "typedef", NULL, NULL, - MXML_DESCEND_FIRST); - scut; - scut = mxmlFindElement(scut, doc, "typedef", NULL, NULL, - MXML_NO_DESCEND)) - { - name = mxmlElementGetAttr(scut, "name"); - printf("\n" - "

%s

\n" - "
\n", name, name); - - description = mxmlFindElement(scut, scut, "description", NULL, - NULL, MXML_DESCEND_FIRST); - if (description) - { - fputs("

Description

\n" - "

", stdout); - write_element(NULL, description); - puts("

"); - } - - fputs("

Definition

\n" - "
\n"
-	    "typedef ", stdout);
-      write_element(doc, mxmlFindElement(scut, scut, "type", NULL,
-                                         NULL, MXML_DESCEND_FIRST));
-      printf(" %s;\n
\n", name); - } - } - - /* - * List of unions... - */ - - if (mxmlFindElement(doc, doc, "union", NULL, NULL, MXML_DESCEND_FIRST)) - { - puts("\n" - "

Unions

\n" - "
    "); - - for (scut = mxmlFindElement(doc, doc, "union", NULL, NULL, - MXML_DESCEND_FIRST); - scut; - scut = mxmlFindElement(scut, doc, "union", NULL, NULL, - MXML_NO_DESCEND)) - { - name = mxmlElementGetAttr(scut, "name"); - printf("\t
  • %s
  • \n", name, name); - } - - puts("
"); - - for (scut = mxmlFindElement(doc, doc, "union", NULL, NULL, - MXML_DESCEND_FIRST); - scut; - scut = mxmlFindElement(scut, doc, "union", NULL, NULL, - MXML_NO_DESCEND)) - { - name = mxmlElementGetAttr(scut, "name"); - printf("\n" - "

%s

\n" - "
\n", name, name); - - description = mxmlFindElement(scut, scut, "description", NULL, - NULL, MXML_DESCEND_FIRST); - if (description) - { - fputs("

Description

\n" - "

", stdout); - write_element(NULL, description); - puts("

"); - } - - printf("

Definition

\n" - "
\n"
-	     "union %s\n{\n", name);
-      for (arg = mxmlFindElement(scut, scut, "variable", NULL, NULL,
-                        	 MXML_DESCEND_FIRST);
-	   arg;
-	   arg = mxmlFindElement(arg, scut, "variable", NULL, NULL,
-                        	 MXML_NO_DESCEND))
-      {
-	printf("  ");
-	write_element(doc, mxmlFindElement(arg, arg, "type", NULL,
-                                           NULL, MXML_DESCEND_FIRST));
-	printf(" %s;\n", mxmlElementGetAttr(arg, "name"));
-      }
-
-      puts("};\n
\n" - "

Members

\n" - "

\n" - "\n" - ""); - - for (arg = mxmlFindElement(scut, scut, "variable", NULL, NULL, - MXML_DESCEND_FIRST); - arg; - arg = mxmlFindElement(arg, scut, "variable", NULL, NULL, - MXML_NO_DESCEND)) - { - printf(""); - } - - puts("
NameDescription
%s", mxmlElementGetAttr(arg, "name")); - - write_element(NULL, mxmlFindElement(arg, arg, "description", NULL, - NULL, MXML_DESCEND_FIRST)); - - puts("

"); - } - } - - /* - * Variables... - */ - - if (mxmlFindElement(doc, doc, "variable", NULL, NULL, MXML_DESCEND_FIRST)) - { - puts("\n" - "

Variables

\n" - "
    "); - - for (arg = mxmlFindElement(doc, doc, "variable", NULL, NULL, - MXML_DESCEND_FIRST); - arg; - arg = mxmlFindElement(arg, doc, "variable", NULL, NULL, - MXML_NO_DESCEND)) - { - name = mxmlElementGetAttr(arg, "name"); - printf("\t
  • %s
  • \n", name, name); - } - - puts("
"); - - for (arg = mxmlFindElement(doc, doc, "variable", NULL, NULL, - MXML_DESCEND_FIRST); - arg; - arg = mxmlFindElement(arg, doc, "variable", NULL, NULL, - MXML_NO_DESCEND)) - { - name = mxmlElementGetAttr(arg, "name"); - printf("\n" - "

%s

\n" - "
", name, name); - - description = mxmlFindElement(arg, arg, "description", NULL, - NULL, MXML_DESCEND_FIRST); - if (description) - { - fputs("

Description

\n" - "

", stdout); - write_element(NULL, description); - puts("

"); - } - - puts("

Definition

\n" - "
");
-
-      write_element(doc, mxmlFindElement(arg, arg, "type", NULL,
-                                         NULL, MXML_DESCEND_FIRST));
-      printf(" %s", mxmlElementGetAttr(arg, "name"));
-      if ((defval = mxmlElementGetAttr(arg, "default")) != NULL)
-	printf(" %s", defval);
-      puts(";\n
"); - } - } - - /* - * Standard footer... - */ - - puts("\n" - ""); -} - - -/* - * 'write_element()' - Write an element's text nodes. - */ - -static void -write_element(mxml_node_t *doc, /* I - Document tree */ - mxml_node_t *element) /* I - Element to write */ -{ - mxml_node_t *node; /* Current node */ - - - if (!element) - return; - - for (node = element->child; - node; - node = mxmlWalkNext(node, element, MXML_NO_DESCEND)) - if (node->type == MXML_TEXT) - { - if (node->value.text.whitespace) - putchar(' '); - - if (mxmlFindElement(doc, doc, "class", "name", node->value.text.string, - MXML_DESCEND) || - mxmlFindElement(doc, doc, "enumeration", "name", - node->value.text.string, MXML_DESCEND) || - mxmlFindElement(doc, doc, "struct", "name", node->value.text.string, - MXML_DESCEND) || - mxmlFindElement(doc, doc, "typedef", "name", node->value.text.string, - MXML_DESCEND) || - mxmlFindElement(doc, doc, "union", "name", node->value.text.string, - MXML_DESCEND)) - { - printf(""); - write_string(node->value.text.string); - printf(""); - } - else - write_string(node->value.text.string); - } -} - - -/* - * 'write_string()' - Write a string, quoting XHTML special chars as needed... - */ - -static void -write_string(const char *s) /* I - String to write */ -{ - while (*s) - { - if (*s == '&') - fputs("&", stdout); - else if (*s == '<') - fputs("<", stdout); - else if (*s == '>') - fputs(">", stdout); - else if (*s == '\"') - fputs(""", stdout); - else if (*s & 128) - { - /* - * Convert UTF-8 to Unicode constant... - */ - - int ch; /* Unicode character */ - - - ch = *s & 255; - - if ((ch & 0xe0) == 0xc0) - { - ch = ((ch & 0x1f) << 6) | (s[1] & 0x3f); - s ++; - } - else if ((ch & 0xf0) == 0xe0) - { - ch = ((((ch * 0x0f) << 6) | (s[1] & 0x3f)) << 6) | (s[2] & 0x3f); - s += 2; - } - - if (ch == 0xa0) - { - /* - * Handle non-breaking space as-is... - */ - - fputs(" ", stdout); - } - else - printf("&#x%x;", ch); - } - else - putchar(*s); - - s ++; - } -} - - -/* - * 'ws_cb()' - Whitespace callback for saving. - */ - -static const char * /* O - Whitespace string or NULL for none */ -ws_cb(mxml_node_t *node, /* I - Element node */ - int where) /* I - Where value */ -{ - const char *name; /* Name of element */ - int depth; /* Depth of node */ - static const char *spaces = " "; - /* Whitespace (40 spaces) for indent */ - - - name = node->value.element.name; - - switch (where) - { - case MXML_WS_BEFORE_CLOSE : - if (strcmp(name, "argument") && - strcmp(name, "class") && - strcmp(name, "constant") && - strcmp(name, "enumeration") && - strcmp(name, "function") && - strcmp(name, "mxmldoc") && - strcmp(name, "namespace") && - strcmp(name, "returnvalue") && - strcmp(name, "struct") && - strcmp(name, "typedef") && - strcmp(name, "union") && - strcmp(name, "variable")) - return (NULL); - - for (depth = -4; node; node = node->parent, depth += 2); - if (depth > 40) - return (spaces); - else if (depth < 2) - return (NULL); - else - return (spaces + 40 - depth); - - case MXML_WS_AFTER_CLOSE : - return ("\n"); - - case MXML_WS_BEFORE_OPEN : - for (depth = -4; node; node = node->parent, depth += 2); - if (depth > 40) - return (spaces); - else if (depth < 2) - return (NULL); - else - return (spaces + 40 - depth); - - default : - case MXML_WS_AFTER_OPEN : - if (strcmp(name, "argument") && - strcmp(name, "class") && - strcmp(name, "constant") && - strcmp(name, "enumeration") && - strcmp(name, "function") && - strcmp(name, "mxmldoc") && - strcmp(name, "namespace") && - strcmp(name, "returnvalue") && - strcmp(name, "struct") && - strcmp(name, "typedef") && - strcmp(name, "union") && - strcmp(name, "variable")) - return (NULL); - else - return ("\n"); - } -} - - -/* - * End of "$Id$". - */ diff --git a/mxml/temp1.xmlfd b/mxml/temp1.xmlfd deleted file mode 100644 index 044304ed7..000000000 --- a/mxml/temp1.xmlfd +++ /dev/null @@ -1,29 +0,0 @@ - - - - 123 - Now is the time for all good men to come to the aid of their -country. - - - diff --git a/mxml/test.xml b/mxml/test.xml deleted file mode 100644 index 044304ed7..000000000 --- a/mxml/test.xml +++ /dev/null @@ -1,29 +0,0 @@ - - - - 123 - Now is the time for all good men to come to the aid of their -country. - - - diff --git a/mxml/testmxml.c b/mxml/testmxml.c deleted file mode 100644 index 9e3f6f5e8..000000000 --- a/mxml/testmxml.c +++ /dev/null @@ -1,653 +0,0 @@ -/* - * "$Id$" - * - * Test program for Mini-XML, a small XML-like file parsing library. - * - * Copyright 2003-2005 by Michael Sweet. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * Contents: - * - * main() - Main entry for test program. - * type_cb() - XML data type callback for mxmlLoadFile()... - * whitespace_cb() - Let the mxmlSaveFile() function know when to insert - * newlines and tabs... - */ - -/* - * Include necessary headers... - */ - -#include "config.h" -#include "mxml.h" -#ifdef WIN32 -# include -#else -# include -#endif /* WIN32 */ -#include -#ifndef O_BINARY -# define O_BINARY 0 -#endif /* !O_BINARY */ - - -/* - * Local functions... - */ - -mxml_type_t type_cb(mxml_node_t *node); -const char *whitespace_cb(mxml_node_t *node, int where); - - -/* - * 'main()' - Main entry for test program. - */ - -int /* O - Exit status */ -main(int argc, /* I - Number of command-line args */ - char *argv[]) /* I - Command-line args */ -{ - int i; /* Looping var */ - FILE *fp; /* File to read */ - int fd; /* File descriptor */ - mxml_node_t *tree, /* XML tree */ - *node; /* Node which should be in test.xml */ - mxml_index_t *ind; /* XML index */ - char buffer[16384]; /* Save string */ - static const char *types[] = /* Strings for node types */ - { - "MXML_ELEMENT", - "MXML_INTEGER", - "MXML_OPAQUE", - "MXML_REAL", - "MXML_TEXT" - }; - - - /* - * Check arguments... - */ - - if (argc != 2) - { - fputs("Usage: testmxml filename.xml\n", stderr); - return (1); - } - - /* - * Test the basic functionality... - */ - - tree = mxmlNewElement(MXML_NO_PARENT, "element"); - - if (!tree) - { - fputs("ERROR: No parent node in basic test!\n", stderr); - return (1); - } - - if (tree->type != MXML_ELEMENT) - { - fprintf(stderr, "ERROR: Parent has type %s (%d), expected MXML_ELEMENT!\n", - tree->type < MXML_ELEMENT || tree->type > MXML_TEXT ? - "UNKNOWN" : types[tree->type], tree->type); - mxmlDelete(tree); - return (1); - } - - if (strcmp(tree->value.element.name, "element")) - { - fprintf(stderr, "ERROR: Parent value is \"%s\", expected \"element\"!\n", - tree->value.element.name); - mxmlDelete(tree); - return (1); - } - - mxmlNewInteger(tree, 123); - mxmlNewOpaque(tree, "opaque"); - mxmlNewReal(tree, 123.4f); - mxmlNewText(tree, 1, "text"); - - mxmlLoadString(tree, "string string string", - MXML_NO_CALLBACK); - mxmlLoadString(tree, "1 2 3", - MXML_INTEGER_CALLBACK); - mxmlLoadString(tree, "1.0 2.0 3.0", - MXML_REAL_CALLBACK); - mxmlLoadString(tree, "opaque opaque opaque", - MXML_OPAQUE_CALLBACK); - - node = tree->child; - - if (!node) - { - fputs("ERROR: No first child node in basic test!\n", stderr); - mxmlDelete(tree); - return (1); - } - - if (node->type != MXML_INTEGER) - { - fprintf(stderr, "ERROR: First child has type %s (%d), expected MXML_INTEGER!\n", - node->type < MXML_ELEMENT || node->type > MXML_TEXT ? - "UNKNOWN" : types[node->type], node->type); - mxmlDelete(tree); - return (1); - } - - if (node->value.integer != 123) - { - fprintf(stderr, "ERROR: First child value is %d, expected 123!\n", - node->value.integer); - mxmlDelete(tree); - return (1); - } - - node = node->next; - - if (!node) - { - fputs("ERROR: No second child node in basic test!\n", stderr); - mxmlDelete(tree); - return (1); - } - - if (node->type != MXML_OPAQUE) - { - fprintf(stderr, "ERROR: Second child has type %s (%d), expected MXML_OPAQUE!\n", - node->type < MXML_ELEMENT || node->type > MXML_TEXT ? - "UNKNOWN" : types[node->type], node->type); - mxmlDelete(tree); - return (1); - } - - if (!node->value.opaque || strcmp(node->value.opaque, "opaque")) - { - fprintf(stderr, "ERROR: Second child value is \"%s\", expected \"opaque\"!\n", - node->value.opaque ? node->value.opaque : "(null)"); - mxmlDelete(tree); - return (1); - } - - node = node->next; - - if (!node) - { - fputs("ERROR: No third child node in basic test!\n", stderr); - mxmlDelete(tree); - return (1); - } - - if (node->type != MXML_REAL) - { - fprintf(stderr, "ERROR: Third child has type %s (%d), expected MXML_REAL!\n", - node->type < MXML_ELEMENT || node->type > MXML_TEXT ? - "UNKNOWN" : types[node->type], node->type); - mxmlDelete(tree); - return (1); - } - - if (node->value.real != 123.4f) - { - fprintf(stderr, "ERROR: Third child value is %f, expected 123.4!\n", - node->value.real); - mxmlDelete(tree); - return (1); - } - - node = node->next; - - if (!node) - { - fputs("ERROR: No fourth child node in basic test!\n", stderr); - mxmlDelete(tree); - return (1); - } - - if (node->type != MXML_TEXT) - { - fprintf(stderr, "ERROR: Fourth child has type %s (%d), expected MXML_TEXT!\n", - node->type < MXML_ELEMENT || node->type > MXML_TEXT ? - "UNKNOWN" : types[node->type], node->type); - mxmlDelete(tree); - return (1); - } - - if (!node->value.text.whitespace || - !node->value.text.string || strcmp(node->value.text.string, "text")) - { - fprintf(stderr, "ERROR: Fourth child value is %d,\"%s\", expected 1,\"text\"!\n", - node->value.text.whitespace, - node->value.text.string ? node->value.text.string : "(null)"); - mxmlDelete(tree); - return (1); - } - - for (i = 0; i < 4; i ++) - { - node = node->next; - - if (!node) - { - fprintf(stderr, "ERROR: No group #%d child node in basic test!\n", i + 1); - mxmlDelete(tree); - return (1); - } - - if (node->type != MXML_ELEMENT) - { - fprintf(stderr, "ERROR: Group child #%d has type %s (%d), expected MXML_ELEMENT!\n", - i + 1, node->type < MXML_ELEMENT || node->type > MXML_TEXT ? - "UNKNOWN" : types[node->type], node->type); - mxmlDelete(tree); - return (1); - } - } - - /* - * Test indices... - */ - - ind = mxmlIndexNew(tree, NULL, NULL); - if (!ind) - { - fputs("ERROR: Unable to create index of all nodes!\n", stderr); - mxmlDelete(tree); - return (1); - } - - if (ind->num_nodes != 5) - { - fprintf(stderr, "ERROR: Index of all nodes contains %d " - "nodes; expected 5!\n", ind->num_nodes); - mxmlIndexDelete(ind); - mxmlDelete(tree); - return (1); - } - - mxmlIndexReset(ind); - if (!mxmlIndexFind(ind, "group", NULL)) - { - fputs("ERROR: mxmlIndexFind for \"group\" failed!\n", stderr); - mxmlIndexDelete(ind); - mxmlDelete(tree); - return (1); - } - - mxmlIndexDelete(ind); - - ind = mxmlIndexNew(tree, "group", NULL); - if (!ind) - { - fputs("ERROR: Unable to create index of groups!\n", stderr); - mxmlDelete(tree); - return (1); - } - - if (ind->num_nodes != 4) - { - fprintf(stderr, "ERROR: Index of groups contains %d " - "nodes; expected 4!\n", ind->num_nodes); - mxmlIndexDelete(ind); - mxmlDelete(tree); - return (1); - } - - mxmlIndexReset(ind); - if (!mxmlIndexEnum(ind)) - { - fputs("ERROR: mxmlIndexEnum failed!\n", stderr); - mxmlIndexDelete(ind); - mxmlDelete(tree); - return (1); - } - - mxmlIndexDelete(ind); - - ind = mxmlIndexNew(tree, NULL, "type"); - if (!ind) - { - fputs("ERROR: Unable to create index of type attributes!\n", stderr); - mxmlDelete(tree); - return (1); - } - - if (ind->num_nodes != 3) - { - fprintf(stderr, "ERROR: Index of type attributes contains %d " - "nodes; expected 3!\n", ind->num_nodes); - mxmlIndexDelete(ind); - mxmlDelete(tree); - return (1); - } - - mxmlIndexReset(ind); - if (!mxmlIndexFind(ind, NULL, "string")) - { - fputs("ERROR: mxmlIndexFind for \"string\" failed!\n", stderr); - mxmlIndexDelete(ind); - mxmlDelete(tree); - return (1); - } - - mxmlIndexDelete(ind); - - ind = mxmlIndexNew(tree, "group", "type"); - if (!ind) - { - fputs("ERROR: Unable to create index of elements and attributes!\n", stderr); - mxmlDelete(tree); - return (1); - } - - if (ind->num_nodes != 3) - { - fprintf(stderr, "ERROR: Index of elements and attributes contains %d " - "nodes; expected 3!\n", ind->num_nodes); - mxmlIndexDelete(ind); - mxmlDelete(tree); - return (1); - } - - mxmlIndexReset(ind); - if (!mxmlIndexFind(ind, "group", "string")) - { - fputs("ERROR: mxmlIndexFind for \"string\" failed!\n", stderr); - mxmlIndexDelete(ind); - mxmlDelete(tree); - return (1); - } - - mxmlIndexDelete(ind); - - /* - * Check the mxmlDelete() works properly... - */ - - for (i = 0; i < 8; i ++) - { - if (tree->child) - mxmlDelete(tree->child); - else - { - fprintf(stderr, "ERROR: Child pointer prematurely NULL on child #%d\n", - i + 1); - mxmlDelete(tree); - return (1); - } - } - - if (tree->child) - { - fputs("ERROR: Child pointer not NULL after deleting all children!\n", stderr); - return (1); - } - - if (tree->last_child) - { - fputs("ERROR: Last child pointer not NULL after deleting all children!\n", stderr); - return (1); - } - - mxmlDelete(tree); - - /* - * Open the file... - */ - - if (argv[1][0] == '<') - tree = mxmlLoadString(NULL, argv[1], type_cb); - else if ((fp = fopen(argv[1], "rb")) == NULL) - { - perror(argv[1]); - return (1); - } - else - { - /* - * Read the file... - */ - - tree = mxmlLoadFile(NULL, fp, type_cb); - - fclose(fp); - } - - if (!tree) - { - fputs("Unable to read XML file!\n", stderr); - return (1); - } - - if (!strcmp(argv[1], "test.xml")) - { - /* - * Verify that mxmlFindElement() and indirectly mxmlWalkNext() work - * properly... - */ - - if ((node = mxmlFindElement(tree, tree, "choice", NULL, NULL, - MXML_DESCEND)) == NULL) - { - fputs("Unable to find first element in XML tree!\n", stderr); - mxmlDelete(tree); - return (1); - } - - if ((node = mxmlFindElement(node, tree, "choice", NULL, NULL, - MXML_NO_DESCEND)) == NULL) - { - fputs("Unable to find second element in XML tree!\n", stderr); - mxmlDelete(tree); - return (1); - } - } - - /* - * Print the XML tree... - */ - - mxmlSaveFile(tree, stdout, whitespace_cb); - - /* - * Save the XML tree to a string and print it... - */ - - if (mxmlSaveString(tree, buffer, sizeof(buffer), whitespace_cb) > 0) - fputs(buffer, stderr); - - /* - * Delete the tree... - */ - - mxmlDelete(tree); - - /* - * Read from/write to file descriptors... - */ - - if (argv[1][0] != '<') - { - /* - * Open the file again... - */ - - if ((fd = open(argv[1], O_RDONLY | O_BINARY)) < 0) - { - perror(argv[1]); - return (1); - } - - /* - * Read the file... - */ - - tree = mxmlLoadFd(NULL, fd, type_cb); - - close(fd); - - /* - * Create filename.xmlfd... - */ - - snprintf(buffer, sizeof(buffer), "%sfd", argv[1]); - - if ((fd = open(buffer, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 0666)) < 0) - { - perror(buffer); - mxmlDelete(tree); - return (1); - } - - /* - * Write the file... - */ - - mxmlSaveFd(tree, fd, whitespace_cb); - - close(fd); - - /* - * Delete the tree... - */ - - mxmlDelete(tree); - } - - /* - * Return... - */ - - return (0); -} - - -/* - * 'type_cb()' - XML data type callback for mxmlLoadFile()... - */ - -mxml_type_t /* O - Data type */ -type_cb(mxml_node_t *node) /* I - Element node */ -{ - const char *type; /* Type string */ - - - /* - * You can lookup attributes and/or use the element name, hierarchy, etc... - */ - - if ((type = mxmlElementGetAttr(node, "type")) == NULL) - type = node->value.element.name; - - if (!strcmp(type, "integer")) - return (MXML_INTEGER); - else if (!strcmp(type, "opaque") || !strcmp(type, "pre")) - return (MXML_OPAQUE); - else if (!strcmp(type, "real")) - return (MXML_REAL); - else - return (MXML_TEXT); -} - - -/* - * 'whitespace_cb()' - Let the mxmlSaveFile() function know when to insert - * newlines and tabs... - */ - -const char * /* O - Whitespace string or NULL */ -whitespace_cb(mxml_node_t *node, /* I - Element node */ - int where) /* I - Open or close tag? */ -{ - mxml_node_t *parent; /* Parent node */ - int level; /* Indentation level */ - const char *name; /* Name of element */ - static const char *tabs = "\t\t\t\t\t\t\t\t"; - /* Tabs for indentation */ - - - /* - * We can conditionally break to a new line before or after any element. - * These are just common HTML elements... - */ - - name = node->value.element.name; - - if (!strcmp(name, "html") || !strcmp(name, "head") || !strcmp(name, "body") || - !strcmp(name, "pre") || !strcmp(name, "p") || - !strcmp(name, "h1") || !strcmp(name, "h2") || !strcmp(name, "h3") || - !strcmp(name, "h4") || !strcmp(name, "h5") || !strcmp(name, "h6")) - { - /* - * Newlines before open and after close... - */ - - if (where == MXML_WS_BEFORE_OPEN || where == MXML_WS_AFTER_CLOSE) - return ("\n"); - } - else if (!strcmp(name, "dl") || !strcmp(name, "ol") || !strcmp(name, "ul")) - { - /* - * Put a newline before and after list elements... - */ - - return ("\n"); - } - else if (!strcmp(name, "dd") || !strcmp(name, "dt") || !strcmp(name, "li")) - { - /* - * Put a tab before
  • 's,
    's, and
    's, and a newline after them... - */ - - if (where == MXML_WS_BEFORE_OPEN) - return ("\t"); - else if (where == MXML_WS_AFTER_CLOSE) - return ("\n"); - } - else if (!strcmp(name, "?xml")) - { - return (NULL); - } - else if (where == MXML_WS_BEFORE_OPEN || - ((!strcmp(name, "choice") || !strcmp(name, "option")) && - where == MXML_WS_BEFORE_CLOSE)) - { - for (level = -1, parent = node->parent; - parent; - level ++, parent = parent->parent); - - if (level > 8) - level = 8; - else if (level < 0) - level = 0; - - return (tabs + 8 - level); - } - else if (where == MXML_WS_AFTER_CLOSE || - ((!strcmp(name, "group") || !strcmp(name, "option") || - !strcmp(name, "choice")) && - where == MXML_WS_AFTER_OPEN)) - return ("\n"); - else if (where == MXML_WS_AFTER_OPEN && !node->child) - return ("\n"); - - /* - * Return NULL for no added whitespace... - */ - - return (NULL); -} - - -/* - * End of "$Id$". - */ -- cgit v1.2.3