diff --git a/CHANGES b/CHANGES index 2ef63fa..34cbcd7 100644 --- a/CHANGES +++ b/CHANGES @@ -1,4 +1,4 @@ -CHANGES - 11/30/2005 +CHANGES - 12/02/2005 -------------------- CHANGES IN Mini-XML 2.3 @@ -11,8 +11,8 @@ CHANGES IN Mini-XML 2.3 "@private@", and "@since version@" comments. - Fixed function and enumeraion type bugs in mxmldoc. - Fixed XML schema for mxmldoc. - - The mxmldoc program now supports --title and --intro - options. + - The mxmldoc program now supports --intro, --section, + and --title options. - The mxmlLoad*() functions could leak a node on an error (STR #27) - The mxml_vsnprintf() function could get in an infinite diff --git a/doc/intro.html b/doc/intro.html index 7d6a8c1..76359a2 100644 --- a/doc/intro.html +++ b/doc/intro.html @@ -1,6 +1,6 @@ - Mini-XML Programmers Manual, Version 2.2.3 + Mini-XML Programmers Manual, Version 2.3 @@ -9,7 +9,7 @@

Introduction

-

This programmers manual describes Mini-XML version 2.2.3, a +

This programmers manual describes Mini-XML version 2.3, a small XML parsing library that you can use to read and write XML and XML-like data files in your application without requiring large non-standard libraries. Mini-XML only requires an ANSI C diff --git a/doc/mxml.html b/doc/mxml.html index c8030f9..0fb9778 100644 --- a/doc/mxml.html +++ b/doc/mxml.html @@ -1,7 +1,7 @@ -Mini-XML Programmers Manual, Version 2.2.3 +Mini-XML Programmers Manual, Version 2.3 @@ -19,8 +19,8 @@ PRE { font-family: monospace } --> -

Mini-XML Programmers Manual, Version 2.2.3
-

Mini-XML Programmers Manual, Version 2.2.3


+
Mini-XML Programmers Manual, Version 2.3
+

Mini-XML Programmers Manual, Version 2.3


Michael Sweet
Copyright 2003-2005
@@ -62,53 +62,42 @@ Copyright 2003-2005
  • Changing Node Values
  • Formatted Text
  • Indexing
  • - -4 - Using the mxmldoc Utility - -A - GNU Library General Public License +A - Mini-XML License B - Release Notes C - Library Reference

    Introduction

    -

    This programmers manual describes Mini-XML version 2.2.3, a small XML +

    This programmers manual describes Mini-XML version 2.3, a small XML parsing library that you can use to read and write XML and XML-like data files in your application without requiring large non-standard libraries. Mini-XML only requires an ANSI C compatible compiler (GCC @@ -1053,364 +1044,63 @@ mxmlIndexEnum.

    mxmlIndexDelete(ind);
    -

    4 - Using the mxmldoc Utility

    -

    This chapter describes how to use the mxmldoc(1) utility - that comes with Mini-XML to automatically generate documentation for - your programs.

    -

    The Basics

    -

    The mxmldoc utility scans C and C++ source and header files - and produces an XML file describing the library interface and an XHTML - file providing a human-readable reference to the code. Each source and - header file must conform to some simple code commenting conventions so - that mxmldoc can extract the necessary descriptive text.

    -

    The mxmldoc command requires the name of an XML file to - store the code information; this file is created and updated as - necessary. The XML file is optionally followed by a list of source - files to scan. After scanning any source files on the command-line, -mxmldoc writes XHTML documentation to the standard output, which - can be redirected to the file using the >filename syntax:

    -
    -    mxmldoc myfile.xml >myfile.html ENTER
    -    mxmldoc myfile.xml file1.c file2.cxx file3.h >myfile.html ENTER
    -
    -

    If no source files are provided on the command-line, the current - contents of the XML file are converted to XHTML.

    -

    Code Documentation Conventions

    -

    As noted previously, source code must be commented properly for -mxmldoc to generate correct documentation for the code. Single line - comments can use the C++ // comment sequence, however all - multi-line comments must use the C /* ... */ comment sequence.

    -

    Functions and Methods

    -

    All implementations of functions and methods must begin with a - comment header describing what the function does, the possible input - limits (if any), and the possible output values (if any), and any - special information needed, as follows:

    -
    -    /*
    -     * 'do_this()' - Compute y = this(x).
    -     *
    -     * Notes: none.
    -     */
     
    -    float            /* O - Inverse power value, 0.0 <= y <= 1.1 */
    -    do_this(float x) /* I - Power value (0.0 <= x <= 1.1) */
    -    {
    -      ...
    -      return (y);
    -    }
    -
    -

    Return/output values are indicated using an "O" prefix, input values - are indicated using the "I" prefix, and values that are both input and - output use the "IO" prefix for the corresponding in-line comment.

    -

    Variables and Class/Structure/Union Members

    -

    Each variable or member must be declared on a separate line and must - be immediately followed by a comment describing the variable or member, - as follows:

    -
    -    int this_variable;   /* The current state of this */
    -    int that_variable;   /* The current state of that */
    -
    -

    Types

    -

    Each type must have a comment block immediately before the typedef, - as follows:

    -
    -    /*
    -     * This type is for foobar options.
    -     */
    -    typedef int this_type_t;
    -
    - - -

    Classes, Structures, and Unions

    -

    Each class, structure, and union must have a comment block - immediately before the definition, and each member must be documented - in accordance with the function and variable documentation - requirements, as follows:

    -
    -    /*
    -     * This structure is for foobar options.
    -     */
    -    struct this_struct_s
    -    {
    -      int this_member;   /* Current state for this */
    -      int that_member;   /* Current state for that */
    -    };
    -
    -    /*
    -     * This class is for barfoo options.
    -     */
    -    class this_class_c
    -    {
    -      int this_member;   /* Current state for this */
    -      int that_member;   /* Current state for that */
    -
    -      /*
    -       * 'get_this()' - Get the current state for this.
    -       */
    -      int                /* O - Current state for this */
    -      get_this()
    -      {
    -        return (this_member);
    -      }
    -    };
    -
    -

    Enumerations

    -

    Each enumeration must have a comment block immediately before the - definition describing what the enumeration is for, and each enumeration - value must have a comment immediately after the value, as follows:

    -
    -   /*
    -    * Enumeration of media trays.
    -    */
    -    enum this_enum_e
    -    {
    -      THIS_TRAY,   /* This tray */
    -      THAT_TRAY    /* That tray */
    -    };
    -
    + -

    XML Schema

    -

    Listing 4-1 shows the XML schema file mxmldoc.xsd which is - included with Mini-XML. This schema file can be used to convert the XML - files produced by mxmldoc into other formats.

    -
    - - - -
    Listing 4-1, XML Schema File "mxmldoc.xsd" -
    -
    -<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    -  <xsd:annotation>
    -    <xsd:documentation xml:lang="en">
    -      Mini-XML 2.2 documentation schema for mxmldoc output.
    -      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.
    -    </xsd:documentation>
    -  </xsd:annotation>
    -
    -  <!-- basic element definitions -->
    -  <xsd:element name="argument" type="argumentType"/>
    -  <xsd:element name="class" type="classType"/>
    -  <xsd:element name="constant" type="constantType"/>
    -  <xsd:element name="description" type="xsd:string"/>
    -  <xsd:element name="enumeration" type="enumerationType"/>
    -  <xsd:element name="function" type="functionType"/>
    -  <xsd:element name="mxmldoc" type="mxmldocType"/>
    -  <xsd:element name="namespace" type="namespaceType"/>
    -  <xsd:element name="returnvalue" type="returnvalueType"/>
    -  <xsd:element name="seealso" type="identifierList"/>
    -  <xsd:element name="struct" type="structType"/>
    -  <xsd:element name="typedef" type="typedefType"/>
    -  <xsd:element name="type" type="xsd:string"/>
    -  <xsd:element name="union" type="unionType"/>
    -  <xsd:element name="variable" type="variableType"/>
    -
    -  <!-- descriptions of complex elements -->
    -  <xsd:complexType name="argumentType">
    -    <xsd:sequence>
    -      <xsd:element ref="type" minOccurs="1" maxOccurs="1"/>
    -      <xsd:element ref="description" minOccurs="0" maxOccurs="1"/>
    -    </xsd:sequence>
    -    <xsd:attribute name="default" type="xsd:string" use="optional"/>
    -    <xsd:attribute name="name" type="identifier" use="required"/>
    -    <xsd:attribute name="direction" type="direction" use="optional" default="I"/>
    -  </xsd:complexType>
    -
    -  <xsd:complexType name="classType">
    -    <xsd:sequence>
    -      <xsd:element ref="description" minOccurs="0" maxOccurs="1"/>
    -      <xsd:choice minOccurs="0" maxOccurs="unbounded">
    -	<xsd:element ref="class"/>
    -
    -
    -
    - - -
    - - - -
    Listing 4-1, XML Schema File "mxmldoc.xsd" - (con't)
    -
    -	<xsd:element ref="enumeration"/>
    -	<xsd:element ref="function"/>
    -	<xsd:element ref="struct"/>
    -	<xsd:element ref="typedef"/>
    -	<xsd:element ref="union"/>
    -	<xsd:element ref="variable"/>
    -      </xsd:choice>
    -    </xsd:sequence>
    -    <xsd:attribute name="name" type="identifier" use="required"/>
    -    <xsd:attribute name="parent" type="xsd:string" use="optional"/>
    -  </xsd:complexType>
    -
    -  <xsd:complexType name="constantType">
    -    <xsd:sequence>
    -      <xsd:element ref="description" minOccurs="0" maxOccurs="1"/>
    -    </xsd:sequence>
    -    <xsd:attribute name="name" type="identifier" use="required"/>
    -  </xsd:complexType>
    -
    -  <xsd:complexType name="enumerationType">
    -    <xsd:sequence>
    -      <xsd:element ref="description" minOccurs="0" maxOccurs="1"/>
    -      <xsd:element ref="constant" minOccurs="1" maxOccurs="unbounded"/>
    -    </xsd:sequence>
    -    <xsd:attribute name="name" type="identifier" use="required"/>
    -  </xsd:complexType>
    -
    -  <xsd:complexType name="functionType">
    -    <xsd:sequence>
    -      <xsd:element ref="returnvalue" minOccurs="0" maxOccurs="1"/>
    -      <xsd:element ref="description" minOccurs="0" maxOccurs="1"/>
    -      <xsd:element ref="argument" minOccurs="1" maxOccurs="unbounded"/>
    -      <xsd:element ref="seealso" minOccurs="0" maxOccurs="1"/>
    -    </xsd:sequence>
    -    <xsd:attribute name="name" type="identifier" use="required"/>
    -    <xsd:attribute name="scope" type="scope" use="optional"/>
    -  </xsd:complexType>
    -
    -  <xsd:complexType name="mxmldocType">
    -    <xsd:choice minOccurs="0" maxOccurs="unbounded">
    -      <xsd:element ref="class"/>
    -      <xsd:element ref="enumeration"/>
    -      <xsd:element ref="function"/>
    -      <xsd:element ref="namespace"/>
    -      <xsd:element ref="struct"/>
    -      <xsd:element ref="typedef"/>
    -      <xsd:element ref="union"/>
    -      <xsd:element ref="variable"/>
    -    </xsd:choice>
    -  </xsd:complexType>
    -
    -  <xsd:complexType name="namespaceType">
    -    <xsd:sequence>
    -      <xsd:element ref="description" minOccurs="0" maxOccurs="1"/>
    -      <xsd:choice minOccurs="0" maxOccurs="unbounded">
    -	<xsd:element ref="class"/>
    -	<xsd:element ref="enumeration"/>
    -	<xsd:element ref="function"/>
    -
    -
    -
    - - -
    - - - -
    Listing 4-1, XML Schema File "mxmldoc.xsd" - (con't)
    -
    -	<xsd:element ref="struct"/>
    -	<xsd:element ref="typedef"/>
    -	<xsd:element ref="union"/>
    -	<xsd:element ref="variable"/>
    -      </xsd:choice>
    -    </xsd:sequence>
    -    <xsd:attribute name="name" type="identifier" use="required"/>
    -  </xsd:complexType>
    -
    -  <xsd:complexType name="returnvalueType">
    -    <xsd:sequence>
    -      <xsd:element ref="type" minOccurs="1" maxOccurs="1"/>
    -      <xsd:element ref="description" minOccurs="0" maxOccurs="1"/>
    -    </xsd:sequence>
    -  </xsd:complexType>
    -
    -  <xsd:complexType name="structType">
    -    <xsd:sequence>
    -      <xsd:element ref="description" minOccurs="0" maxOccurs="1"/>
    -      <xsd:choice minOccurs="0" maxOccurs="unbounded">
    -	<xsd:element ref="variable"/>
    -	<xsd:element ref="function"/>
    -      </xsd:choice>
    -    </xsd:sequence>
    -    <xsd:attribute name="name" type="identifier" use="required"/>
    -  </xsd:complexType>
    -
    -  <xsd:complexType name="typedefType">
    -    <xsd:sequence>
    -      <xsd:element ref="type" minOccurs="1" maxOccurs="1"/>
    -      <xsd:element ref="description" minOccurs="0" maxOccurs="1"/>
    -    </xsd:sequence>
    -    <xsd:attribute name="name" type="identifier" use="required"/>
    -  </xsd:complexType>
    -
    -  <xsd:complexType name="unionType">
    -    <xsd:sequence>
    -      <xsd:element ref="description" minOccurs="0" maxOccurs="1"/>
    -      <xsd:element ref="variable" minOccurs="0" maxOccurs="unbounded"/>
    -    </xsd:sequence>
    -    <xsd:attribute name="name" type="identifier" use="required"/>
    -  </xsd:complexType>
    -
    -  <xsd:complexType name="variableType">
    -    <xsd:sequence>
    -      <xsd:element ref="type" minOccurs="1" maxOccurs="1"/>
    -      <xsd:element ref="description" minOccurs="0" maxOccurs="1"/>
    -    </xsd:sequence>
    -    <xsd:attribute name="name" type="identifier" use="required"/>
    -  </xsd:complexType>
    -
    -  <!-- data types -->
    -  <xsd:simpleType name="direction">
    -    <xsd:restriction base="xsd:string">
    -      <xsd:enumeration value="I"/>
    -      <xsd:enumeration value="O"/>
    -      <xsd:enumeration value="IO"/>
    -    </xsd:restriction>
    -
    -
    -
    - - -
    - - - -
    Listing 4-1, XML Schema File "mxmldoc.xsd" - (con't)
    -
    -  </xsd:simpleType>
    -
    -  <xsd:simpleType name="identifier">
    -    <xsd:restriction base="xsd:string">
    -      <xsd:pattern value="[a-zA-Z_(.]([a-zA-Z_(.,)* 0-9])*"/>
    -    </xsd:restriction>
    -  </xsd:simpleType>
    -
    -  <xsd:simpleType name="identifierList">
    -    <xsd:list itemType="identifier"/>
    -  </xsd:simpleType>
    -
    -  <xsd:simpleType name="scope">
    -    <xsd:restriction base="xsd:string">
    -      <xsd:enumeration value=""/>
    -      <xsd:enumeration value="private"/>
    -      <xsd:enumeration value="protected"/>
    -      <xsd:enumeration value="public"/>
    -    </xsd:restriction>
    -  </xsd:simpleType>
    -</xsd:schema>
    -
    -
    -
    -
    -

    A - GNU Library General Public - License

    +

    mxmldoc(1)

    +

    Name

    + mxmldoc - mini-xml documentation generator +

    Synopsis

    + mxmldoc [ --intro introfile.html ] [ --section section + ] [ --title title ] [ filename.xml ] [ source file(s) + ] > filename.html +

    Description

    + mxmldoc scans the specified C and C++ source files to produce an + XML representation of globally accessible classes, constants, + enumerations, functions, structures, typedefs, unions, and variables. + The XML file is updated as necessary and a HTML representation of the + XML file is written to the standard output. If no source files are + specified then the current XML file is converted to HTML on the + standard output. +

    In general, any C or C++ source code is handled by mxmldoc, + however it was specifically written to handle code with documentation + that is formatted according to the CUPS Configuration Management Plan + which is available at "http://www.cups.org/documentation.php".

    +

    Options

    +
    +
    --intro introfile.html
    +
    Inserts the specified file at the top of the output documentation.
    +
    --section section
    +
    Sets the section/keywords in the output documentation.
    +
    --title title
    +
    Sets the title of the output documentation.
    +
    +

    See Also

    + mxml(3), Mini-XML Programmers Manual, http://www.easysw.com/~mike/mxml/ +

    Copyright

    + Copyright 2003-2005 by Michael Sweet.
    +

    A - Mini-XML License

    +

    October 18, 2005

    +

    The Mini-XML library and included programs are provided under the + terms of the GNU Library General Public License (LGPL) with the + following exceptions:

    +
      +
    1. Static linking of applications to the Mini-XML library does not + constitute a derivative work and does not require the author to provide + source code for the application, use the shared Mini-XML libraries, or + link their applications against a user-supplied version of Mini-XML. +

      If you link the application to a modified version of Mini-XML, + then the changes to Mini-XML must be provided under the terms of the + LGPL in sections 1, 2, and 4.

      +
    2. +
    3. You do not have to provide a copy of the Mini-XML license with + programs that are linked to the Mini-XML library, nor do you have to + identify the Mini-XML license in your program or documentation as + required by section 6 of the LGPL.
    4. +
    +
    +

    GNU LIBRARY GENERAL PUBLIC LICENSE

    Version 2, June 1991
    Copyright (C) 1991 Free Software Foundation, Inc.
    59 Temple Place - Suite 330, Boston, MA 02111-1307, USA @@ -1784,7 +1474,7 @@ mxmldoc to generate correct documentation for the code. Single line SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.

    END OF TERMS AND CONDITIONS

    -

    How to Apply These Terms to Your New Libraries

    +

    How to Apply These Terms to Your New Libraries

    If you develop a new library, and you want it to be of the greatest possible use to the public, we recommend making it free software that everyone can redistribute and change. You can do so by permitting @@ -1829,9 +1519,18 @@ Ty Coon, President of Vice

    That's all there is to it!


    B - Release Notes

    -

    Changes in Mini-XML 2.2.3

    +

    Changes in Mini-XML 2.3

    -

    Changes in Mini-XML 2.2.2

    +

    Changes in Mini-XML 2.2.2

    -

    Changes in Mini-XML 2.2.1

    +

    Changes in Mini-XML 2.2.1

    -

    Changes in Mini-XML 2.2

    +

    Changes in Mini-XML 2.2

    -

    Changes in Mini-XML 2.1

    +

    Changes in Mini-XML 2.1

    -

    Changes in Mini-XML 2.0

    +

    Changes in Mini-XML 2.0

    -

    Changes in Mini-XML 1.3

    +

    Changes in Mini-XML 1.3

    -

    Changes in Mini-XML 1.2

    +

    Changes in Mini-XML 1.2

    -

    Changes in Mini-XML 1.1.2

    +

    Changes in Mini-XML 1.1.2

    -

    Changes in Mini-XML 1.1.1

    +

    Changes in Mini-XML 1.1.1

    -

    Changes in Mini-XML 1.1

    +

    Changes in Mini-XML 1.1

    -

    Changes in Mini-XML 1.0

    +

    Changes in Mini-XML 1.0

    -

    Changes in Mini-XML 0.93

    +

    Changes in Mini-XML 0.93

    -

    Changes in Mini-XML 0.92

    +

    Changes in Mini-XML 0.92

    -

    Changes in Mini-XML 0.91

    +

    Changes in Mini-XML 0.91

    -

    Changes in Mini-XML 0.9

    +

    Changes in Mini-XML 0.9


    C - Library Reference

    -

    Contents

    +

    Contents

    -

    Enumerations

    +

    Enumerations

    -

    mxml_type_e

    -
    +

    mxml_type_e

    Description

    The XML node type.

    Values

    -

    - - - +
    +
    NameDescription
    + - + - +
    NameDescription
    MXML_CUSTOMCustom data
    MXML_CUSTOM + +  Mini-XML 2.1 Custom data
    MXML_ELEMENTXML element with attributes
    MXML_IGNOREIgnore/throw away node
    MXML_IGNORE + +  Mini-XML 2.3 Ignore/throw away node
    MXML_INTEGERInteger value
    MXML_OPAQUEOpaque string
    MXML_REALReal value
    MXML_TEXTText fragment
    - + -

    Functions

    +

    Functions

    -

    mxmlAdd()

    -
    +

    mxmlAdd()

    Description

    Add a node to a tree. Adds the specified node to the parent. If the child argument is not NULL, puts the new node before or after the @@ -2127,10 +1835,10 @@ mxmlAdd( mxml_node_t * node);

    Arguments

    -

    +
    - +
    NameDescription
    NameDescription
    parentParent node
    whereWhere to add, MXML_ADD_BEFORE or @@ -2139,12 +1847,12 @@ mxmlAdd( MXML_ADD_TO_PARENT
    nodeNode to add
    +

    Returns

    Nothing.

    -

    mxmlDelete()

    -
    +

    mxmlDelete()

    Description

    Delete a node and all of its children. If the specified node has a parent, this function first removes the node from its parent using the @@ -2156,19 +1864,19 @@ mxmlDelete( mxml_node_t * node);

    Arguments

    -

    +
    - +
    NameDescription
    NameDescription
    nodeNode to delete
    +

    Returns

    Nothing.

    -

    mxmlElementGetAttr()

    -
    +

    mxmlElementGetAttr()

    Description

    Get an attribute. This function returns NULL if the node is not an element or the named attribute does not exist.

    @@ -2180,20 +1888,20 @@ mxmlElementGetAttr( const char * name);

    Arguments

    -

    +
    - +
    NameDescription
    NameDescription
    nodeElement node
    nameName of attribute
    +

    Returns

    Attribute value or NULL

    -

    mxmlElementSetAttr()

    -
    +

    mxmlElementSetAttr()

    Description

    Set an attribute. If the named attribute already exists, the value of the attribute is replaced by the new string value. The string value is @@ -2208,44 +1916,36 @@ mxmlElementSetAttr( const char * value);

    Arguments

    -

    +
    - +
    NameDescription
    NameDescription
    nodeElement node
    nameName of attribute
    valueAttribute value
    +

    Returns

    Nothing.

    -

    mxmlEntityAddCallback()

    -
    +

    +mxmlEntityAddCallback()

    Description

    Add a callback to convert entities to Unicode.

    Syntax

     int
    -mxmlEntityAddCallback(
    -    int (*cb)(const char *name));
    +mxmlEntityAddCallback(void);
     

    Arguments

    -

    - - - - - -
    NameDescription
    (*cb)(const char *name)Callback function to - add
    +

    None.

    Returns

    0 on success, -1 on failure

    -

    mxmlEntityGetName()

    -
    +

    mxmlEntityGetName()

    Description

    Get the name that corresponds to the character value. If val does not need to be represented by a named entity, NULL is returned.

    @@ -2256,19 +1956,19 @@ mxmlEntityGetName( int val);

    Arguments

    -

    +
    - +
    NameDescription
    NameDescription
    valCharacter value
    +

    Returns

    Entity name or NULL

    -

    mxmlEntityGetValue()

    -
    +

    mxmlEntityGetValue()

    Description

    Get the character corresponding to a named entity. The entity name can also be a numeric constant. -1 is returned if the name is not @@ -2280,42 +1980,34 @@ mxmlEntityGetValue( const char * name);

    Arguments

    -

    +
    - +
    NameDescription
    NameDescription
    nameEntity name
    +

    Returns

    Character value or -1 on error

    -

    mxmlEntityRemoveCallback()

    -
    +

    +mxmlEntityRemoveCallback()

    Description

    Remove a callback.

    Syntax

     void
    -mxmlEntityRemoveCallback(
    -    int (*cb)(const char *name));
    +mxmlEntityRemoveCallback(void);
     

    Arguments

    -

    - - - - - -
    NameDescription
    (*cb)(const char *name)Callback function to - remove
    +

    None.

    Returns

    Nothing.

    -

    mxmlFindElement()

    -
    +

    mxmlFindElement()

    Description

    Find the named element. The search is constrained by the name, attribute name, and value; any NULL names or values are treated as @@ -2338,10 +2030,10 @@ mxmlFindElement( int descend);

    Arguments

    -

    +
    - + @@ -2351,12 +2043,12 @@ mxmlFindElement(
    NameDescription
    NameDescription
    nodeCurrent node
    topTop node
    descendDescend into tree - MXML_DESCEND, MXML_NO_DESCEND, or MXML_DESCEND_FIRST
    +

    Returns

    Element node or NULL

    -

    mxmlIndexDelete()

    -
    +

    mxmlIndexDelete()

    Description

    Delete an index.

    Syntax

    @@ -2366,19 +2058,19 @@ mxmlIndexDelete( mxml_index_t * ind);

    Arguments

    -

    +
    - +
    NameDescription
    NameDescription
    indIndex to delete
    +

    Returns

    Nothing.

    -

    mxmlIndexEnum()

    -
    +

    mxmlIndexEnum()

    Description

    Return the next node in the index. Nodes are returned in the sorted order of the index.

    @@ -2389,19 +2081,19 @@ mxmlIndexEnum( mxml_index_t * ind);

    Arguments

    -

    +
    - +
    NameDescription
    NameDescription
    indIndex to enumerate
    +

    Returns

    Next node or NULL if there is none

    -

    mxmlIndexFind()

    -
    +

    mxmlIndexFind()

    Description

    Find the next matching node. You should call mxmlIndexReset() prior to using this function for the first time with a particular set of @@ -2416,21 +2108,21 @@ mxmlIndexFind( const char * value);

    Arguments

    -

    +
    - +
    NameDescription
    NameDescription
    indIndex to search
    elementElement name to find, if any
    valueAttribute value, if any
    +

    Returns

    Node or NULL if none found

    -

    mxmlIndexNew()

    -
    +

    mxmlIndexNew()

    Description

    Create a new index. The index will contain all nodes that contain the named element and/or attribute. If both "element" and "attr" are NULL, @@ -2446,21 +2138,21 @@ mxmlIndexNew( const char * attr);

    Arguments

    -

    +
    - +
    NameDescription
    NameDescription
    nodeXML node tree
    elementElement to index or NULL for all
    attrAttribute to index or NULL for none
    +

    Returns

    New index

    -

    mxmlIndexReset()

    -
    +

    mxmlIndexReset()

    Description

    Reset the enumeration/find pointer in the index and return the first node in the index. This function should be called prior to using @@ -2472,19 +2164,19 @@ mxmlIndexReset( mxml_index_t * ind);

    Arguments

    -

    +
    - +
    NameDescription
    NameDescription
    indIndex to reset
    +

    Returns

    First node or NULL if there is none

    -

    mxmlLoadFd()

    -
    +

    mxmlLoadFd()

    Description

    Load a file descriptor into an XML node tree. The nodes in the specified file are added to the specified top node. If no top node is @@ -2500,26 +2192,23 @@ mxmlIndexReset( mxml_node_t * mxmlLoadFd( mxml_node_t * top, - int fd, - mxml_type_t (*cb)(mxml_node_t *node)); + int fd);

    Arguments

    -

    +
    - + -
    NameDescription
    NameDescription
    topTop node
    fdFile descriptor to read from
    (*cb)(mxml_node_t *node)Callback function or - MXML_NO_CALLBACK
    +

    Returns

    First node or NULL if the file could not be read.

    -

    mxmlLoadFile()

    -
    +

    mxmlLoadFile()

    Description

    Load a file into an XML node tree. The nodes in the specified file are added to the specified top node. If no top node is provided, the @@ -2535,26 +2224,23 @@ mxmlLoadFd( mxml_node_t * mxmlLoadFile( mxml_node_t * top, - FILE * fp, - mxml_type_t (*cb)(mxml_node_t *node)); + FILE * fp);

    Arguments

    -

    +
    - + -
    NameDescription
    NameDescription
    topTop node
    fpFile to read from
    (*cb)(mxml_node_t *node)Callback function or - MXML_NO_CALLBACK
    +

    Returns

    First node or NULL if the file could not be read.

    -

    mxmlLoadString()

    -
    +

    mxmlLoadString()

    Description

    Load a string into an XML node tree. The nodes in the specified string are added to the specified top node. If no top node is provided, @@ -2570,26 +2256,25 @@ mxmlLoadFile( mxml_node_t * mxmlLoadString( mxml_node_t * top, - const char * s, - mxml_type_t (*cb)(mxml_node_t *node)); + const char * s);

    Arguments

    -

    +
    - + -
    NameDescription
    NameDescription
    topTop node
    sString to load
    (*cb)(mxml_node_t *node)Callback function or - MXML_NO_CALLBACK
    +

    Returns

    First node or NULL if the string has errors.

    -

    mxmlNewCDATA()

    -
    +

    + + Mini-XML 2.3 mxmlNewCDATA()

    Description

    Create a new CDATA node. The new CDATA node is added to the end of the specified parent's child list. The constant MXML_NO_PARENT can be @@ -2604,20 +2289,22 @@ mxmlNewCDATA( const char * data);

    Arguments

    -

    +
    - +
    NameDescription
    NameDescription
    parentParent node or MXML_NO_PARENT
    dataData string
    +

    Returns

    New node

    -

    mxmlNewCustom()

    -
    +

    + + Mini-XML 2.1 mxmlNewCustom()

    Description

    Create a new custom data node. The new custom node is added to the end of the specified parent's child list. The constant MXML_NO_PARENT @@ -2629,26 +2316,23 @@ mxmlNewCDATA( mxml_node_t * mxmlNewCustom( mxml_node_t * parent, - void * data, - void (*destroy)(void *)); + void * data);

    Arguments

    -

    +
    - + - -
    NameDescription
    NameDescription
    parentParent node or MXML_NO_PARENT
    dataPointer to data
    (*destroy)(void *)Function to destroy data
    +

    Returns

    New node

    -

    mxmlNewElement()

    -
    +

    mxmlNewElement()

    Description

    Create a new element node. The new element node is added to the end of the specified parent's child list. The constant MXML_NO_PARENT can @@ -2661,20 +2345,20 @@ mxmlNewElement( const char * name);

    Arguments

    -

    +
    - +
    NameDescription
    NameDescription
    parentParent node or MXML_NO_PARENT
    nameName of element
    +

    Returns

    New node

    -

    mxmlNewInteger()

    -
    +

    mxmlNewInteger()

    Description

    Create a new integer node. The new integer node is added to the end of the specified parent's child list. The constant MXML_NO_PARENT can @@ -2687,20 +2371,20 @@ mxmlNewInteger( int integer);

    Arguments

    -

    +
    - +
    NameDescription
    NameDescription
    parentParent node or MXML_NO_PARENT
    integerInteger value
    +

    Returns

    New node

    -

    mxmlNewOpaque()

    -
    +

    mxmlNewOpaque()

    Description

    Create a new opaque string. The new opaque node is added to the end of the specified parent's child list. The constant MXML_NO_PARENT can @@ -2714,20 +2398,20 @@ mxmlNewOpaque( const char * opaque);

    Arguments

    -

    +
    - +
    NameDescription
    NameDescription
    parentParent node or MXML_NO_PARENT
    opaqueOpaque string
    +

    Returns

    New node

    -

    mxmlNewReal()

    -
    +

    mxmlNewReal()

    Description

    Create a new real number node. The new real number node is added to the end of the specified parent's child list. The constant @@ -2741,20 +2425,20 @@ mxmlNewReal( double real);

    Arguments

    -

    +
    - +
    NameDescription
    NameDescription
    parentParent node or MXML_NO_PARENT
    realReal number value
    +

    Returns

    New node

    -

    mxmlNewText()

    -
    +

    mxmlNewText()

    Description

    Create a new text fragment node. The new text node is added to the end of the specified parent's child list. The constant MXML_NO_PARENT @@ -2771,22 +2455,22 @@ mxmlNewText( const char * string);

    Arguments

    -

    +
    - +
    NameDescription
    NameDescription
    parentParent node or MXML_NO_PARENT
    whitespace1 = leading whitespace, 0 = no whitespace
    stringString
    +

    Returns

    New node

    -

    mxmlNewTextf()

    -
    +

    mxmlNewTextf()

    Description

    Create a new formatted text fragment node. The new text node is added to the end of the specified parent's child list. The constant @@ -2804,10 +2488,10 @@ mxmlNewTextf( ...);

    Arguments

    -

    +
    - +
    NameDescription
    NameDescription
    parentParent node or MXML_NO_PARENT
    whitespace1 = leading whitespace, 0 = no @@ -2815,12 +2499,12 @@ mxmlNewTextf(
    formatPrintf-style frmat string
    ...Additional args as needed
    +

    Returns

    New node

    -

    mxmlRemove()

    -
    +

    mxmlRemove()

    Description

    Remove a node from its parent. Does not free memory used by the node - use mxmlDelete() for that. This function does nothing if the node has @@ -2832,19 +2516,20 @@ mxmlRemove( mxml_node_t * node);

    Arguments

    -

    +
    - +
    NameDescription
    NameDescription
    nodeNode to remove
    +

    Returns

    Nothing.

    -

    mxmlSaveAllocString()

    -
    +

    mxmlSaveAllocString() +

    Description

    Save an XML node tree to an allocated string. This function returns a pointer to a string containing the textual representation of the XML @@ -2859,25 +2544,22 @@ mxmlRemove(

     char *
     mxmlSaveAllocString(
    -    mxml_node_t * node,
    -    const char * (*cb)(mxml_node_t *node, int ws));
    +    mxml_node_t * node);
     

    Arguments

    -

    +
    - + -
    NameDescription
    NameDescription
    nodeNode to write
    (*cb)(mxml_node_t *node, int ws)Whitespace - callback or MXML_NO_CALLBACK
    +

    Returns

    Allocated string or NULL

    -

    mxmlSaveFd()

    -
    +

    mxmlSaveFd()

    Description

    Save an XML tree to a file descriptor. The callback argument specifies a function that returns a whitespace string or NULL before @@ -2889,26 +2571,23 @@ mxmlSaveAllocString( int mxmlSaveFd( mxml_node_t * node, - int fd, - const char * (*cb)(mxml_node_t *node, int ws)); + int fd);

    Arguments

    -

    +
    - + -
    NameDescription
    NameDescription
    nodeNode to write
    fdFile descriptor to write to
    (*cb)(mxml_node_t *node, int ws)Whitespace - callback or MXML_NO_CALLBACK
    +

    Returns

    0 on success, -1 on error.

    -

    mxmlSaveFile()

    -
    +

    mxmlSaveFile()

    Description

    Save an XML tree to a file. The callback argument specifies a function that returns a whitespace string or NULL before and after each @@ -2920,26 +2599,23 @@ mxmlSaveFd( int mxmlSaveFile( mxml_node_t * node, - FILE * fp, - const char * (*cb)(mxml_node_t *node, int ws)); + FILE * fp);

    Arguments

    -

    +
    - + -
    NameDescription
    NameDescription
    nodeNode to write
    fpFile to write to
    (*cb)(mxml_node_t *node, int ws)Whitespace - callback or MXML_NO_CALLBACK
    +

    Returns

    0 on success, -1 on error.

    -

    mxmlSaveString()

    -
    +

    mxmlSaveString()

    Description

    Save an XML node tree to a string. This function returns the total number of bytes that would be required for the string but only copies @@ -2954,27 +2630,26 @@ int mxmlSaveString( mxml_node_t * node, char * buffer, - int bufsize, - const char * (*cb)(mxml_node_t *node, int ws)); + int bufsize);

    Arguments

    -

    +
    - + -
    NameDescription
    NameDescription
    nodeNode to write
    bufferString buffer
    bufsizeSize of string buffer
    (*cb)(mxml_node_t *node, int ws)Whitespace - callback or MXML_NO_CALLBACK
    +

    Returns

    Size of string

    -

    mxmlSetCDATA()

    -
    +

    + + Mini-XML 2.3 mxmlSetCDATA()

    Description

    Set the element name of a CDATA node. The node is not changed if it is not a CDATA element node.

    @@ -2986,20 +2661,22 @@ mxmlSetCDATA( const char * data);

    Arguments

    -

    +
    - +
    NameDescription
    NameDescription
    nodeNode to set
    dataNew data string
    +

    Returns

    0 on success, -1 on failure

    -

    mxmlSetCustom()

    -
    +

    + + Mini-XML 2.1 mxmlSetCustom()

    Description

    Set the data and destructor of a custom data node. The node is not changed if it is not a custom node.

    @@ -3008,25 +2685,24 @@ mxmlSetCDATA( int mxmlSetCustom( mxml_node_t * node, - void * data, - void (*destroy)(void *)); + void * data);

    Arguments

    -

    +
    - + -
    NameDescription
    NameDescription
    nodeNode to set
    dataNew data pointer
    (*destroy)(void *)New destructor function
    +

    Returns

    0 on success, -1 on failure

    -

    mxmlSetCustomHandlers()

    -
    +

    +mxmlSetCustomHandlers()

    Description

    Set the handling functions for custom data. The load function accepts a node pointer and a data string and must return 0 on success and @@ -3036,24 +2712,24 @@ mxmlSetCustom(

     void
     mxmlSetCustomHandlers(
    -    mxml_custom_load_cb_t load,
    -    mxml_custom_save_cb_t save);
    +    mxml_custom_load_cb_t load,
    +    mxml_custom_save_cb_t save);
     

    Arguments

    -

    +
    - +
    NameDescription
    NameDescription
    loadLoad function
    saveSave function
    +

    Returns

    Nothing.

    -

    mxmlSetElement()

    -
    +

    mxmlSetElement()

    Description

    Set the name of an element node. The node is not changed if it is not an element node.

    @@ -3065,43 +2741,35 @@ mxmlSetElement( const char * name);

    Arguments

    -

    +
    - +
    NameDescription
    NameDescription
    nodeNode to set
    nameNew name string
    +

    Returns

    0 on success, -1 on failure

    -

    mxmlSetErrorCallback()

    -
    +

    mxmlSetErrorCallback() +

    Description

    Set the error message callback.

    Syntax

     void
    -mxmlSetErrorCallback(
    -    void (*cb)(const char *));
    +mxmlSetErrorCallback(void);
     

    Arguments

    -

    - - - - - - -
    NameDescription
    (*cb)(const char *)Error callback function
    +

    None.

    Returns

    Nothing.

    -

    mxmlSetInteger()

    -
    +

    mxmlSetInteger()

    Description

    Set the value of an integer node. The node is not changed if it is not an integer node.

    @@ -3113,20 +2781,20 @@ mxmlSetInteger( int integer);

    Arguments

    -

    +
    - +
    NameDescription
    NameDescription
    nodeNode to set
    integerInteger value
    +

    Returns

    0 on success, -1 on failure

    -

    mxmlSetOpaque()

    -
    +

    mxmlSetOpaque()

    Description

    Set the value of an opaque node. The node is not changed if it is not an opaque node.

    @@ -3138,20 +2806,20 @@ mxmlSetOpaque( const char * opaque);

    Arguments

    -

    +
    - +
    NameDescription
    NameDescription
    nodeNode to set
    opaqueOpaque string
    +

    Returns

    0 on success, -1 on failure

    -

    mxmlSetReal()

    -
    +

    mxmlSetReal()

    Description

    Set the value of a real number node. The node is not changed if it is not a real number node.

    @@ -3163,20 +2831,20 @@ mxmlSetReal( double real);

    Arguments

    -

    +
    - +
    NameDescription
    NameDescription
    nodeNode to set
    realReal number value
    +

    Returns

    0 on success, -1 on failure

    -

    mxmlSetText()

    -
    +

    mxmlSetText()

    Description

    Set the value of a text node. The node is not changed if it is not a text node.

    @@ -3189,22 +2857,22 @@ mxmlSetText( const char * string);

    Arguments

    -

    +
    - +
    NameDescription
    NameDescription
    nodeNode to set
    whitespace1 = leading whitespace, 0 = no whitespace
    stringString
    +

    Returns

    0 on success, -1 on failure

    -

    mxmlSetTextf()

    -
    +

    mxmlSetTextf()

    Description

    Set the value of a text node to a formatted string. The node is not changed if it is not a text node.

    @@ -3218,10 +2886,10 @@ mxmlSetTextf( ...);

    Arguments

    -

    +
    - +
    NameDescription
    NameDescription
    nodeNode to set
    whitespace1 = leading whitespace, 0 = no @@ -3229,12 +2897,12 @@ mxmlSetTextf(
    formatPrintf-style format string
    ...Additional arguments as needed
    +

    Returns

    0 on success, -1 on failure

    -

    mxmlWalkNext()

    -
    +

    mxmlWalkNext()

    Description

    Walk to the next logical node in the tree. The descend argument controls whether the first child is considered to be the next node. The @@ -3248,22 +2916,22 @@ mxmlWalkNext( int descend);

    Arguments

    -

    +
    - +
    NameDescription
    NameDescription
    nodeCurrent node
    topTop node
    descendDescend into tree - MXML_DESCEND, MXML_NO_DESCEND, or MXML_DESCEND_FIRST
    +

    Returns

    Next node or NULL

    -

    mxmlWalkPrev()

    -
    +

    mxmlWalkPrev()

    Description

    Walk to the previous logical node in the tree. The descend argument controls whether the previous node's last child is considered to be the @@ -3278,35 +2946,37 @@ mxmlWalkPrev( int descend);

    Arguments

    -

    +
    - +
    NameDescription
    NameDescription
    nodeCurrent node
    topTop node
    descendDescend into tree - MXML_DESCEND, MXML_NO_DESCEND, or MXML_DESCEND_FIRST
    +

    Returns

    Previous node or NULL

    -

    Structures

    +

    Structures

    -

    mxml_attr_s

    -
    +

    mxml_attr_s

    Description

    -

    An XML element attribute value.

    +

    Data types...

    Definition

     struct mxml_attr_s
    @@ -3316,18 +2986,18 @@ struct mxml_attr_s
     };
     

    Members

    -

    - - - +
    +
    NameDescription
    +
    NameDescription
    nameAttribute name
    valueAttribute value
    - + -

    mxml_custom_s

    -
    +

    + + Mini-XML 2.1 mxml_custom_s

    Description

    An XML custom value.

    Definition

    @@ -3338,17 +3008,38 @@ struct mxml_custom_s };

    Members

    -

    - - - +
    +
    NameDescription
    +
    NameDescription
    dataPointer to (allocated) custom data
    - + -

    mxml_index_s

    -
    +

    mxml_element_s

    +

    Description

    +

    An XML element value.

    +

    Definition

    +
    +struct mxml_element_s
    +{
    +  mxml_attr_t * attrs;
    +  char * name;
    +  int num_attrs;
    +};
    +
    +

    Members

    +
    + + + + + + +
    NameDescription
    attrsAttributes
    nameName of element
    num_attrsNumber of attributes
    +
    + +

    mxml_index_s

    Description

    An XML node index.

    Definition

    @@ -3363,10 +3054,9 @@ struct mxml_index_s };

    Members

    -

    - - - +
    +
    NameDescription
    + @@ -3374,10 +3064,9 @@ struct mxml_index_s
    NameDescription
    alloc_nodesAllocated nodes in index
    attrAttribute used for indexing or NULL
    nodesNode array
    num_nodesNumber of nodes in index
    - + -

    mxml_node_s

    -
    +

    mxml_node_s

    Description

    An XML node.

    Definition

    @@ -3394,10 +3083,9 @@ struct mxml_node_s };

    Members

    -

    - - - +
    +
    NameDescription
    + @@ -3407,10 +3095,9 @@ struct mxml_node_s
    NameDescription
    childFirst child node
    last_childLast child node
    typeNode type
    valueNode value
    - + -

    mxml_text_s

    -
    +

    mxml_text_s

    Description

    An XML text value.

    Definition

    @@ -3422,45 +3109,23 @@ struct mxml_text_s };

    Members

    -

    - - - +
    +
    NameDescription
    +
    NameDescription
    stringFragment string
    whitespaceLeading whitespace?
    - + -

    mxml_value_s

    -
    -

    Description

    -

    An XML element value.

    -

    Definition

    -
    -struct mxml_value_s
    -{
    -  mxml_attr_t * attrs;
    -  char * name;
    -  int num_attrs;
    -};
    -
    -

    Members

    -

    - - - - - - - -
    NameDescription
    attrsAttributes
    nameName of element
    num_attrsNumber of attributes
    - - -

    Types

    +

    Types

    -

    mxml_attr_t

    -
    +

    mxml_attr_t

    Description

    -

    An XML element attribute value.

    +

    Data types...

    Definition

     typedef struct mxml_attr_s mxml_attr_t;
     
    -

    mxml_custom_t

    -
    +

    mxml_custom_load_cb_t +

    +

    Description

    +

    Custom data load callback function

    +

    Definition

    +
    +typedef int (*mxml_custom_load_cb_t)(mxml_node_t *, const char *);
    +
    + + +

    mxml_custom_save_cb_t +

    +

    Description

    +

    Custom data save callback function

    +

    Definition

    +
    +typedef char * (*mxml_custom_save_cb_t)(mxml_node_t *);
    +
    + + +

    + + Mini-XML 2.1 mxml_custom_t

    Description

    An XML custom value.

    Definition

    @@ -3489,18 +3174,16 @@ typedef struct mxml_custom_s mxml_custom_t; -

    mxml_element_t

    -
    +

    mxml_element_t

    Description

    An XML element value.

    Definition

    -typedef struct mxml_value_s mxml_element_t;
    +typedef struct mxml_element_s mxml_element_t;
     
    -

    mxml_index_t

    -
    +

    mxml_index_t

    Description

    An XML node index.

    Definition

    @@ -3509,8 +3192,7 @@ typedef struct mxml_index_s mxml_index_t; -

    mxml_node_t

    -
    +

    mxml_node_t

    Description

    An XML node.

    Definition

    @@ -3519,8 +3201,7 @@ typedef struct mxml_node_s mxml_node_t; -

    mxml_text_t

    -
    +

    mxml_text_t

    Description

    An XML text value.

    Definition

    @@ -3529,8 +3210,7 @@ typedef struct mxml_text_s mxml_text_t; -

    mxml_value_t

    -
    +

    mxml_value_t

    Description

    An XML node value.

    Definition

    @@ -3539,14 +3219,13 @@ typedef union mxml_value_u mxml_value_t; -

    Unions

    +

    Unions

    -

    mxml_value_u

    -
    +

    mxml_value_u

    Description

    An XML node value.

    Definition

    @@ -3562,17 +3241,18 @@ union mxml_value_u };

    Members

    -

    - - - +
    +
    NameDescription
    + - +
    NameDescription
    customCustom data
    custom + +  Mini-XML 2.1 Custom data
    elementElement
    integerInteger number
    opaqueOpaque string
    realReal number
    textText fragment
    - + diff --git a/doc/mxml.man b/doc/mxml.man index ade7b6c..daf3a78 100644 --- a/doc/mxml.man +++ b/doc/mxml.man @@ -15,7 +15,7 @@ .\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the .\" GNU General Public License for more details. .\" -.TH mxml 3 "mini-XML" "25 February 2005" "Michael Sweet" +.TH mxml 3 "mini-XML" "2 December 2005" "Michael Sweet" .SH NAME mxml \- mini-xml library .SH INCLUDE FILE @@ -31,9 +31,7 @@ most vendors' ANSI C compilers) and a "make" program. .PP Mini-XML provides the following functionality: .IP \(bu 4 -Reading and writing of UTF-8 encoded XML files. -.IP \(bu 4 -Reading and writing of UTF-8 encoded XML strings. +Reading of UTF-8 and UTF-16 and writing of UTF-8 encoded XML files and strings. .IP \(bu 4 Data is stored in a linked-list tree structure, preserving the XML data hierarchy. @@ -44,7 +42,7 @@ values with no preset limits, just available memory. Supports integer, real, opaque ("cdata"), and text data types in "leaf" nodes. .IP \(bu 4 -Functions for creating and managing trees of data. +Functions for creating, indexing, and managing trees of data. .IP \(bu 4 "Find" and "walk" functions for easily locating and navigating trees of data. @@ -53,9 +51,7 @@ 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. Also, since Mini-XML does not support the -UTF-16 encoding, it is technically not a conforming XML -consumer/client. +specification. .SH USING MINI-XML Mini-XML provides a single header file which you include: .nf diff --git a/doc/mxmldoc.html b/doc/mxmldoc.html index 71fe78d..4803b0a 100644 --- a/doc/mxmldoc.html +++ b/doc/mxmldoc.html @@ -1,378 +1,66 @@ + + + + + mxmldoc + - -

    4 - Using the mxmldoc -Utility

    - -

    This chapter describes how to use the mxmldoc(1) -utility that comes with Mini-XML to automatically generate -documentation for your programs.

    - -

    The Basics

    - -

    The mxmldoc utility scans C and C++ source and -header files and produces an XML file describing the library -interface and an XHTML file providing a human-readable reference -to the code. Each source and header file must conform to some -simple code commenting conventions so that mxmldoc can -extract the necessary descriptive text.

    - -

    The mxmldoc command requires the name of an XML file -to store the code information; this file is created and updated -as necessary. The XML file is optionally followed by a list of -source files to scan. After scanning any source files on the -command-line, mxmldoc writes XHTML documentation to the -standard output, which can be redirected to the file using the ->filename syntax:

    - -
    -    mxmldoc myfile.xml >myfile.html ENTER
    -    mxmldoc myfile.xml file1.c file2.cxx file3.h >myfile.html ENTER
    -
    - -

    If no source files are provided on the command-line, the -current contents of the XML file are converted to XHTML.

    - -

    Code Documentation Conventions

    - -

    As noted previously, source code must be commented properly -for mxmldoc to generate correct documentation for the -code. Single line comments can use the C++ // comment -sequence, however all multi-line comments must use the C /* -... */ comment sequence.

    - -

    Functions and Methods

    - -

    All implementations of functions and methods must begin with -a comment header describing what the function does, the possible -input limits (if any), and the possible output values (if any), -and any special information needed, as follows:

    - -
    -    /*
    -     * 'do_this()' - Compute y = this(x).
    -     *
    -     * Notes: none.
    -     */
    -
    -    float            /* O - Inverse power value, 0.0 <= y <= 1.1 */
    -    do_this(float x) /* I - Power value (0.0 <= x <= 1.1) */
    -    {
    -      ...
    -      return (y);
    -    }
    -
    - -

    Return/output values are indicated using an "O" prefix, input -values are indicated using the "I" prefix, and values that are -both input and output use the "IO" prefix for the corresponding -in-line comment.

    - -

    Variables and Class/Structure/Union Members

    - -

    Each variable or member must be declared on a separate line -and must be immediately followed by a comment describing the -variable or member, as follows:

    - -
    -    int this_variable;   /* The current state of this */
    -    int that_variable;   /* The current state of that */
    -
    - -

    Types

    - -

    Each type must have a comment block immediately before the -typedef, as follows:

    - -
    -    /*
    -     * This type is for foobar options.
    -     */
    -    typedef int this_type_t;
    -
    - - -

    Classes, Structures, and Unions

    - -

    Each class, structure, and union must have a comment block -immediately before the definition, and each member must be documented -in accordance with the function and variable documentation -requirements, as follows:

    - -
    -    /*
    -     * This structure is for foobar options.
    -     */
    -    struct this_struct_s
    -    {
    -      int this_member;   /* Current state for this */
    -      int that_member;   /* Current state for that */
    -    };
    -
    -    /*
    -     * This class is for barfoo options.
    -     */
    -    class this_class_c
    -    {
    -      int this_member;   /* Current state for this */
    -      int that_member;   /* Current state for that */
    -
    -      /*
    -       * 'get_this()' - Get the current state for this.
    -       */
    -      int                /* O - Current state for this */
    -      get_this()
    -      {
    -        return (this_member);
    -      }
    -    };
    -
    - -

    Enumerations

    - -

    Each enumeration must have a comment block immediately before -the definition describing what the enumeration is for, and each -enumeration value must have a comment immediately after the -value, as follows:

    - -
    -   /*
    -    * Enumeration of media trays.
    -    */
    -    enum this_enum_e
    -    {
    -      THIS_TRAY,   /* This tray */
    -      THAT_TRAY    /* That tray */
    -    };
    -
    - -

    XML Schema

    - -

    Listing 4-1 shows the XML schema file mxmldoc.xsd -which is included with Mini-XML. This schema file can be used to -convert the XML files produced by mxmldoc into other -formats.

    - -
    - - -
    Listing 4-1, XML Schema File "mxmldoc.xsd"
    -
    -<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    -  <xsd:annotation>
    -    <xsd:documentation xml:lang="en">
    -      Mini-XML 2.2 documentation schema for mxmldoc output.
    -      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.
    -    </xsd:documentation>
    -  </xsd:annotation>
    -
    -  <!-- basic element definitions -->
    -  <xsd:element name="argument" type="argumentType"/>
    -  <xsd:element name="class" type="classType"/>
    -  <xsd:element name="constant" type="constantType"/>
    -  <xsd:element name="description" type="xsd:string"/>
    -  <xsd:element name="enumeration" type="enumerationType"/>
    -  <xsd:element name="function" type="functionType"/>
    -  <xsd:element name="mxmldoc" type="mxmldocType"/>
    -  <xsd:element name="namespace" type="namespaceType"/>
    -  <xsd:element name="returnvalue" type="returnvalueType"/>
    -  <xsd:element name="seealso" type="identifierList"/>
    -  <xsd:element name="struct" type="structType"/>
    -  <xsd:element name="typedef" type="typedefType"/>
    -  <xsd:element name="type" type="xsd:string"/>
    -  <xsd:element name="union" type="unionType"/>
    -  <xsd:element name="variable" type="variableType"/>
    -
    -  <!-- descriptions of complex elements -->
    -  <xsd:complexType name="argumentType">
    -    <xsd:sequence>
    -      <xsd:element ref="type" minOccurs="1" maxOccurs="1"/>
    -      <xsd:element ref="description" minOccurs="0" maxOccurs="1"/>
    -    </xsd:sequence>
    -    <xsd:attribute name="default" type="xsd:string" use="optional"/>
    -    <xsd:attribute name="name" type="identifier" use="required"/>
    -    <xsd:attribute name="direction" type="direction" use="optional" default="I"/>
    -  </xsd:complexType>
    -
    -  <xsd:complexType name="classType">
    -    <xsd:sequence>
    -      <xsd:element ref="description" minOccurs="0" maxOccurs="1"/>
    -      <xsd:choice minOccurs="0" maxOccurs="unbounded">
    -	<xsd:element ref="class"/>
    -
    -
    - -
    - - -
    Listing 4-1, XML Schema File "mxmldoc.xsd" (con't)
    -
    -	<xsd:element ref="enumeration"/>
    -	<xsd:element ref="function"/>
    -	<xsd:element ref="struct"/>
    -	<xsd:element ref="typedef"/>
    -	<xsd:element ref="union"/>
    -	<xsd:element ref="variable"/>
    -      </xsd:choice>
    -    </xsd:sequence>
    -    <xsd:attribute name="name" type="identifier" use="required"/>
    -    <xsd:attribute name="parent" type="xsd:string" use="optional"/>
    -  </xsd:complexType>
    -
    -  <xsd:complexType name="constantType">
    -    <xsd:sequence>
    -      <xsd:element ref="description" minOccurs="0" maxOccurs="1"/>
    -    </xsd:sequence>
    -    <xsd:attribute name="name" type="identifier" use="required"/>
    -  </xsd:complexType>
    -
    -  <xsd:complexType name="enumerationType">
    -    <xsd:sequence>
    -      <xsd:element ref="description" minOccurs="0" maxOccurs="1"/>
    -      <xsd:element ref="constant" minOccurs="1" maxOccurs="unbounded"/>
    -    </xsd:sequence>
    -    <xsd:attribute name="name" type="identifier" use="required"/>
    -  </xsd:complexType>
    -
    -  <xsd:complexType name="functionType">
    -    <xsd:sequence>
    -      <xsd:element ref="returnvalue" minOccurs="0" maxOccurs="1"/>
    -      <xsd:element ref="description" minOccurs="0" maxOccurs="1"/>
    -      <xsd:element ref="argument" minOccurs="1" maxOccurs="unbounded"/>
    -      <xsd:element ref="seealso" minOccurs="0" maxOccurs="1"/>
    -    </xsd:sequence>
    -    <xsd:attribute name="name" type="identifier" use="required"/>
    -    <xsd:attribute name="scope" type="scope" use="optional"/>
    -  </xsd:complexType>
    -
    -  <xsd:complexType name="mxmldocType">
    -    <xsd:choice minOccurs="0" maxOccurs="unbounded">
    -      <xsd:element ref="class"/>
    -      <xsd:element ref="enumeration"/>
    -      <xsd:element ref="function"/>
    -      <xsd:element ref="namespace"/>
    -      <xsd:element ref="struct"/>
    -      <xsd:element ref="typedef"/>
    -      <xsd:element ref="union"/>
    -      <xsd:element ref="variable"/>
    -    </xsd:choice>
    -  </xsd:complexType>
    -
    -  <xsd:complexType name="namespaceType">
    -    <xsd:sequence>
    -      <xsd:element ref="description" minOccurs="0" maxOccurs="1"/>
    -      <xsd:choice minOccurs="0" maxOccurs="unbounded">
    -	<xsd:element ref="class"/>
    -	<xsd:element ref="enumeration"/>
    -	<xsd:element ref="function"/>
    -
    -
    - -
    - - -
    Listing 4-1, XML Schema File "mxmldoc.xsd" (con't)
    -
    -	<xsd:element ref="struct"/>
    -	<xsd:element ref="typedef"/>
    -	<xsd:element ref="union"/>
    -	<xsd:element ref="variable"/>
    -      </xsd:choice>
    -    </xsd:sequence>
    -    <xsd:attribute name="name" type="identifier" use="required"/>
    -  </xsd:complexType>
    -
    -  <xsd:complexType name="returnvalueType">
    -    <xsd:sequence>
    -      <xsd:element ref="type" minOccurs="1" maxOccurs="1"/>
    -      <xsd:element ref="description" minOccurs="0" maxOccurs="1"/>
    -    </xsd:sequence>
    -  </xsd:complexType>
    -
    -  <xsd:complexType name="structType">
    -    <xsd:sequence>
    -      <xsd:element ref="description" minOccurs="0" maxOccurs="1"/>
    -      <xsd:choice minOccurs="0" maxOccurs="unbounded">
    -	<xsd:element ref="variable"/>
    -	<xsd:element ref="function"/>
    -      </xsd:choice>
    -    </xsd:sequence>
    -    <xsd:attribute name="name" type="identifier" use="required"/>
    -  </xsd:complexType>
    -
    -  <xsd:complexType name="typedefType">
    -    <xsd:sequence>
    -      <xsd:element ref="type" minOccurs="1" maxOccurs="1"/>
    -      <xsd:element ref="description" minOccurs="0" maxOccurs="1"/>
    -    </xsd:sequence>
    -    <xsd:attribute name="name" type="identifier" use="required"/>
    -  </xsd:complexType>
    -
    -  <xsd:complexType name="unionType">
    -    <xsd:sequence>
    -      <xsd:element ref="description" minOccurs="0" maxOccurs="1"/>
    -      <xsd:element ref="variable" minOccurs="0" maxOccurs="unbounded"/>
    -    </xsd:sequence>
    -    <xsd:attribute name="name" type="identifier" use="required"/>
    -  </xsd:complexType>
    -
    -  <xsd:complexType name="variableType">
    -    <xsd:sequence>
    -      <xsd:element ref="type" minOccurs="1" maxOccurs="1"/>
    -      <xsd:element ref="description" minOccurs="0" maxOccurs="1"/>
    -    </xsd:sequence>
    -    <xsd:attribute name="name" type="identifier" use="required"/>
    -  </xsd:complexType>
    -
    -  <!-- data types -->
    -  <xsd:simpleType name="direction">
    -    <xsd:restriction base="xsd:string">
    -      <xsd:enumeration value="I"/>
    -      <xsd:enumeration value="O"/>
    -      <xsd:enumeration value="IO"/>
    -    </xsd:restriction>
    -
    -
    - -
    - - -
    Listing 4-1, XML Schema File "mxmldoc.xsd" (con't)
    -
    -  </xsd:simpleType>
    -
    -  <xsd:simpleType name="identifier">
    -    <xsd:restriction base="xsd:string">
    -      <xsd:pattern value="[a-zA-Z_(.]([a-zA-Z_(.,)* 0-9])*"/>
    -    </xsd:restriction>
    -  </xsd:simpleType>
    -
    -  <xsd:simpleType name="identifierList">
    -    <xsd:list itemType="identifier"/>
    -  </xsd:simpleType>
    -
    -  <xsd:simpleType name="scope">
    -    <xsd:restriction base="xsd:string">
    -      <xsd:enumeration value=""/>
    -      <xsd:enumeration value="private"/>
    -      <xsd:enumeration value="protected"/>
    -      <xsd:enumeration value="public"/>
    -    </xsd:restriction>
    -  </xsd:simpleType>
    -</xsd:schema>
    -
    -
    +

    mxmldoc(1)

    +

    Name

    +mxmldoc - mini-xml documentation generator +

    Synopsis

    +mxmldoc +[ --intro +introfile.html +] [ --section +section +] [ --title +title +] [ +filename.xml +] [ +source file(s) +] > +filename.html +

    Description

    +mxmldoc scans the specified C and C++ source files to +produce an XML representation of globally accessible classes, +constants, enumerations, functions, structures, typedefs, +unions, and variables. The XML file is updated as necessary and +a HTML representation of the XML file is written to the standard +output. If no source files are specified then the current XML +file is converted to HTML on the standard output. +

    In general, any C or C++ source code is handled by +mxmldoc, however it was specifically written to handle +code with documentation that is formatted according to the CUPS +Configuration Management Plan which is available at +"http://www.cups.org/documentation.php". +

    Options

    +
    +
    --intro introfile.html +
    +
    Inserts the specified file at the top of the output documentation. +
    +
    --section section +
    +
    Sets the section/keywords in the output documentation. +
    +
    --title title +
    +
    Sets the title of the output documentation. +
    +
    +

    See Also

    +mxml(3), Mini-XML Programmers Manual, http://www.easysw.com/~mike/mxml/ +

    Copyright

    +Copyright 2003-2005 by Michael Sweet. diff --git a/doc/mxmldoc.man b/doc/mxmldoc.man index 149ac0d..32ac1f8 100644 --- a/doc/mxmldoc.man +++ b/doc/mxmldoc.man @@ -15,13 +15,15 @@ .\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the .\" GNU General Public License for more details. .\" -.TH mxmldoc 1 "mini-XML" "21 September 2005" "Michael Sweet" +.TH mxmldoc 1 "mini-XML" "2 December 2005" "Michael Sweet" .SH NAME mxmldoc \- mini-xml documentation generator .SH SYNOPSIS .B mxmldoc [ --intro .I introfile.html +] [ --section +.I section ] [ --title .I title ] [ @@ -50,6 +52,10 @@ Configuration Management Plan which is available at .br Inserts the specified file at the top of the output documentation. .TP 5 +\--section section +.br +Sets the section/keywords in the output documentation. +.TP 5 \--title title .br Sets the title of the output documentation. diff --git a/doc/relnotes.html b/doc/relnotes.html index 59a7db9..4d258b0 100644 --- a/doc/relnotes.html +++ b/doc/relnotes.html @@ -21,8 +21,8 @@
  • Fixed XML schema for mxmldoc.
  • -
  • The mxmldoc program now supports --title and --intro - options.
  • +
  • The mxmldoc program now supports --intro, --section, + and --title options.
  • The mxmlLoad*() functions could leak a node on an error (STR #27)
  • diff --git a/mxmldoc.c b/mxmldoc.c index c0e361f..4710c12 100644 --- a/mxmldoc.c +++ b/mxmldoc.c @@ -150,7 +150,8 @@ static void update_comment(mxml_node_t *parent, mxml_node_t *comment); static void usage(const char *option); static void write_description(mxml_node_t *description); -static void write_documentation(const char *title, +static void write_documentation(const char *section, + const char *title, const char *intro, mxml_node_t *doc); static void write_element(mxml_node_t *doc, mxml_node_t *element); @@ -171,6 +172,7 @@ main(int argc, /* I - Number of command-line args */ FILE *fp; /* File to read */ mxml_node_t *doc; /* XML documentation tree */ mxml_node_t *mxmldoc; /* mxmldoc node */ + const char *section; /* Section/keywords of documentation */ const char *title; /* Title of documentation */ const char *introfile; /* Introduction file */ const char *xmlfile; /* XML file */ @@ -181,6 +183,7 @@ main(int argc, /* I - Number of command-line args */ * Check arguments... */ + section = NULL; title = NULL; introfile = NULL; xmlfile = NULL; @@ -189,19 +192,7 @@ main(int argc, /* I - Number of command-line args */ mxmldoc = NULL; for (i = 1; i < argc; i ++) - if (!strcmp(argv[i], "--title") && !title) - { - /* - * Set title... - */ - - i ++; - if (i < argc) - title = argv[i]; - else - usage(NULL); - } - else if (!strcmp(argv[i], "--intro") && !introfile) + if (!strcmp(argv[i], "--intro") && !introfile) { /* * Set intro file... @@ -213,6 +204,30 @@ main(int argc, /* I - Number of command-line args */ else usage(NULL); } + else if (!strcmp(argv[i], "--section") && !section) + { + /* + * Set section/keywords... + */ + + i ++; + if (i < argc) + section = argv[i]; + else + usage(NULL); + } + else if (!strcmp(argv[i], "--title") && !title) + { + /* + * Set title... + */ + + i ++; + if (i < argc) + title = argv[i]; + else + usage(NULL); + } else if (argv[i][0] == '-') { /* @@ -343,7 +358,8 @@ main(int argc, /* I - Number of command-line args */ * Write HTML documentation... */ - write_documentation(title ? title : "Documentation", introfile, mxmldoc); + write_documentation(section, title ? title : "Documentation", introfile, + mxmldoc); /* * Delete the tree and return... @@ -2174,6 +2190,7 @@ write_description( static void write_documentation( + const char *section, /* I - Section */ const char *title, /* I - Title */ const char *introfile, /* I - Intro file */ mxml_node_t *doc) /* I - XML documentation */ @@ -2204,24 +2221,31 @@ write_documentation( * Standard header... */ - printf("\n" - "\n" - "\n" - "\t%s\n" - "\t\n" - "\t\n" - "\n" - "\n", title); + puts("\n" + ""); + + if (section) + printf("\n", section); + + printf("\n" + "\t%s\n", title); + if (section) + printf("\t\n", section); + + puts("\t\n" + "\t\n" + "\n" + ""); /* * Intro...