diff --git a/doc/reference.html b/doc/reference.html index a2b3797..4b71439 100644 --- a/doc/reference.html +++ b/doc/reference.html @@ -25,7 +25,7 @@
  • mxml_type_e
  • -

    NOmxml_type_e

    +

    mxml_type_e


    Description

    The XML node type.

    @@ -33,13 +33,13 @@

    - - - - - - - + + + + + + +
    NameDescription
    NOMXML_CUSTOMCustom data
    NOMXML_ELEMENTXML element with attributes
    NOMXML_IGNOREIgnore/throw away node
    NOMXML_INTEGERInteger value
    NOMXML_OPAQUEOpaque string
    NOMXML_REALReal value
    NOMXML_TEXTText fragment
    MXML_CUSTOMCustom data
    MXML_ELEMENTXML element with attributes
    MXML_IGNOREIgnore/throw away node
    MXML_INTEGERInteger value
    MXML_OPAQUEOpaque string
    MXML_REALReal value
    MXML_TEXTText fragment

    Functions

    @@ -88,7 +88,7 @@
  • mxmlWalkPrev()
  • -

    NOmxmlAdd()

    +

    mxmlAdd()


    Description

    Add a node to a tree. @@ -120,7 +120,7 @@ mxmlAdd(

    Returns

    Nothing.

    -

    NOmxmlDelete()

    +

    mxmlDelete()


    Description

    Delete a node and all of its children. @@ -142,7 +142,7 @@ mxmlDelete(

    Returns

    Nothing.

    -

    NOmxmlElementGetAttr()

    +

    mxmlElementGetAttr()


    Description

    Get an attribute. @@ -166,7 +166,7 @@ mxmlElementGetAttr(

    Returns

    Attribute value or NULL

    -

    NOmxmlElementSetAttr()

    +

    mxmlElementSetAttr()


    Description

    Set an attribute. @@ -194,7 +194,7 @@ mxmlElementSetAttr(

    Returns

    Nothing.

    -

    NOmxmlEntityAddCallback()

    +

    mxmlEntityAddCallback()


    Description

    Add a callback to convert entities to Unicode.

    @@ -208,7 +208,7 @@ mxmlEntityAddCallback(void);

    Returns

    0 on success, -1 on failure

    -

    NOmxmlEntityGetName()

    +

    mxmlEntityGetName()


    Description

    Get the name that corresponds to the character value. @@ -229,7 +229,7 @@ mxmlEntityGetName(

    Returns

    Entity name or NULL

    -

    NOmxmlEntityGetValue()

    +

    mxmlEntityGetValue()


    Description

    Get the character corresponding to a named entity. @@ -251,7 +251,7 @@ mxmlEntityGetValue(

    Returns

    Character value or -1 on error

    -

    NOmxmlEntityRemoveCallback()

    +

    mxmlEntityRemoveCallback()


    Description

    Remove a callback.

    @@ -265,7 +265,7 @@ mxmlEntityRemoveCallback(void);

    Returns

    Nothing.

    -

    NOmxmlFindElement()

    +

    mxmlFindElement()


    Description

    Find the named element. @@ -303,7 +303,7 @@ mxmlFindElement(

    Returns

    Element node or NULL

    -

    NOmxmlIndexDelete()

    +

    mxmlIndexDelete()


    Description

    Delete an index.

    @@ -322,7 +322,7 @@ mxmlIndexDelete(

    Returns

    Nothing.

    -

    NOmxmlIndexEnum()

    +

    mxmlIndexEnum()


    Description

    Return the next node in the index. @@ -343,7 +343,7 @@ mxmlIndexEnum(

    Returns

    Next node or NULL if there is none

    -

    NOmxmlIndexFind()

    +

    mxmlIndexFind()


    Description

    Find the next matching node. @@ -371,7 +371,7 @@ mxmlIndexFind(

    Returns

    Node or NULL if none found

    -

    NOmxmlIndexNew()

    +

    mxmlIndexNew()


    Description

    Create a new index. @@ -400,7 +400,7 @@ mxmlIndexNew(

    Returns

    New index

    -

    NOmxmlIndexReset()

    +

    mxmlIndexReset()


    Description

    Reset the enumeration/find pointer in the index and @@ -423,7 +423,7 @@ mxmlIndexReset(

    Returns

    First node or NULL if there is none

    -

    NOmxmlLoadFd()

    +

    mxmlLoadFd()


    Description

    Load a file descriptor into an XML node tree. @@ -455,7 +455,7 @@ mxmlLoadFd(

    Returns

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

    -

    NOmxmlLoadFile()

    +

    mxmlLoadFile()


    Description

    Load a file into an XML node tree. @@ -487,7 +487,7 @@ mxmlLoadFile(

    Returns

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

    -

    NOmxmlLoadString()

    +

    mxmlLoadString()


    Description

    Load a string into an XML node tree. @@ -519,7 +519,7 @@ mxmlLoadString(

    Returns

    First node or NULL if the string has errors.

    -

    NOmxmlNewCDATA()

    +

    mxmlNewCDATA()


    Description

    Create a new CDATA node. @@ -545,7 +545,7 @@ mxmlNewCDATA(

    Returns

    New node

    -

    NOmxmlNewCustom()

    +

    mxmlNewCustom()


    Description

    Create a new custom data node. @@ -571,7 +571,7 @@ mxmlNewCustom(

    Returns

    New node

    -

    NOmxmlNewElement()

    +

    mxmlNewElement()


    Description

    Create a new element node. @@ -596,7 +596,7 @@ mxmlNewElement(

    Returns

    New node

    -

    NOmxmlNewInteger()

    +

    mxmlNewInteger()


    Description

    Create a new integer node. @@ -621,7 +621,7 @@ mxmlNewInteger(

    Returns

    New node

    -

    NOmxmlNewOpaque()

    +

    mxmlNewOpaque()


    Description

    Create a new opaque string. @@ -647,7 +647,7 @@ mxmlNewOpaque(

    Returns

    New node

    -

    NOmxmlNewReal()

    +

    mxmlNewReal()


    Description

    Create a new real number node. @@ -672,7 +672,7 @@ mxmlNewReal(

    Returns

    New node

    -

    NOmxmlNewText()

    +

    mxmlNewText()


    Description

    Create a new text fragment node. @@ -701,7 +701,7 @@ mxmlNewText(

    Returns

    New node

    -

    NOmxmlNewTextf()

    +

    mxmlNewTextf()


    Description

    Create a new formatted text fragment node. @@ -732,7 +732,7 @@ mxmlNewTextf(

    Returns

    New node

    -

    NOmxmlRemove()

    +

    mxmlRemove()


    Description

    Remove a node from its parent. @@ -754,7 +754,7 @@ mxmlRemove(

    Returns

    Nothing.

    -

    NOmxmlSaveAllocString()

    +

    mxmlSaveAllocString()


    Description

    Save an XML node tree to an allocated string. @@ -785,7 +785,7 @@ mxmlSaveAllocString(

    Returns

    Allocated string or NULL

    -

    NOmxmlSaveFd()

    +

    mxmlSaveFd()


    Description

    Save an XML tree to a file descriptor. @@ -812,7 +812,7 @@ mxmlSaveFd(

    Returns

    0 on success, -1 on error.

    -

    NOmxmlSaveFile()

    +

    mxmlSaveFile()


    Description

    Save an XML tree to a file. @@ -839,7 +839,7 @@ mxmlSaveFile(

    Returns

    0 on success, -1 on error.

    -

    NOmxmlSaveString()

    +

    mxmlSaveString()


    Description

    Save an XML node tree to a string. @@ -872,7 +872,7 @@ mxmlSaveString(

    Returns

    Size of string

    -

    NOmxmlSetCDATA()

    +

    mxmlSetCDATA()


    Description

    Set the element name of a CDATA node. @@ -895,7 +895,7 @@ mxmlSetCDATA(

    Returns

    0 on success, -1 on failure

    -

    NOmxmlSetCustom()

    +

    mxmlSetCustom()


    Description

    Set the data and destructor of a custom data node. @@ -918,7 +918,7 @@ mxmlSetCustom(

    Returns

    0 on success, -1 on failure

    -

    NOmxmlSetCustomHandlers()

    +

    mxmlSetCustomHandlers()


    Description

    Set the handling functions for custom data. @@ -945,7 +945,7 @@ mxmlSetCustomHandlers(

    Returns

    Nothing.

    -

    NOmxmlSetElement()

    +

    mxmlSetElement()


    Description

    Set the name of an element node. @@ -968,7 +968,7 @@ mxmlSetElement(

    Returns

    0 on success, -1 on failure

    -

    NOmxmlSetErrorCallback()

    +

    mxmlSetErrorCallback()


    Description

    Set the error message callback.

    @@ -982,7 +982,7 @@ mxmlSetErrorCallback(void);

    Returns

    Nothing.

    -

    NOmxmlSetInteger()

    +

    mxmlSetInteger()


    Description

    Set the value of an integer node. @@ -1005,7 +1005,7 @@ mxmlSetInteger(

    Returns

    0 on success, -1 on failure

    -

    NOmxmlSetOpaque()

    +

    mxmlSetOpaque()


    Description

    Set the value of an opaque node. @@ -1028,7 +1028,7 @@ mxmlSetOpaque(

    Returns

    0 on success, -1 on failure

    -

    NOmxmlSetReal()

    +

    mxmlSetReal()


    Description

    Set the value of a real number node. @@ -1051,7 +1051,7 @@ mxmlSetReal(

    Returns

    0 on success, -1 on failure

    -

    NOmxmlSetText()

    +

    mxmlSetText()


    Description

    Set the value of a text node. @@ -1076,7 +1076,7 @@ mxmlSetText(

    Returns

    0 on success, -1 on failure

    -

    NOmxmlSetTextf()

    +

    mxmlSetTextf()


    Description

    Set the value of a text node to a formatted string. @@ -1103,7 +1103,7 @@ mxmlSetTextf(

    Returns

    0 on success, -1 on failure

    -

    NOmxmlWalkNext()

    +

    mxmlWalkNext()


    Description

    Walk to the next logical node in the tree. @@ -1130,7 +1130,7 @@ mxmlWalkNext(

    Returns

    Next node or NULL

    -

    NOmxmlWalkPrev()

    +

    mxmlWalkPrev()


    Description

    Walk to the previous logical node in the tree. @@ -1167,7 +1167,7 @@ mxmlWalkPrev(

  • mxml_value_s
  • -

    NOmxml_attr_s

    +

    mxml_attr_s


    Description

    An XML element attribute value.

    @@ -1183,11 +1183,11 @@ struct mxml_attr_s

    - - + +
    NameDescription
    NOnameAttribute name
    NOvalueAttribute value
    nameAttribute name
    valueAttribute value

    -

    NOmxml_custom_s

    +

    mxml_custom_s


    Description

    An XML custom value.

    @@ -1202,10 +1202,10 @@ struct mxml_custom_s

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

    -

    NOmxml_index_s

    +

    mxml_index_s


    Description

    An XML node index.

    @@ -1224,14 +1224,14 @@ struct mxml_index_s

    - - - - - + + + + +
    NameDescription
    NOalloc_nodesAllocated nodes in index
    NOattrAttribute used for indexing or NULL
    NOcur_nodeCurrent node
    NOnodesNode array
    NOnum_nodesNumber of nodes in index
    alloc_nodesAllocated nodes in index
    attrAttribute used for indexing or NULL
    cur_nodeCurrent node
    nodesNode array
    num_nodesNumber of nodes in index

    -

    NOmxml_node_s

    +

    mxml_node_s


    Description

    An XML node.

    @@ -1252,16 +1252,16 @@ struct mxml_node_s

    - - - - - - - + + + + + + +
    NameDescription
    NOchildFirst child node
    NOlast_childLast child node
    NOnextNext node under same parent
    NOparentParent node
    NOprevPrevious node under same parent
    NOtypeNode type
    NOvalueNode value
    childFirst child node
    last_childLast child node
    nextNext node under same parent
    parentParent node
    prevPrevious node under same parent
    typeNode type
    valueNode value

    -

    NOmxml_text_s

    +

    mxml_text_s


    Description

    An XML text value.

    @@ -1277,11 +1277,11 @@ struct mxml_text_s

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

    -

    NOmxml_value_s

    +

    mxml_value_s


    Description

    An XML element value.

    @@ -1298,9 +1298,9 @@ struct mxml_value_s

    - - - + + +
    NameDescription
    NOattrsAttributes
    NOnameName of element
    NOnum_attrsNumber of attributes
    attrsAttributes
    nameName of element
    num_attrsNumber of attributes

    Types

    @@ -1316,7 +1316,7 @@ struct mxml_value_s
  • mxml_value_t
  • -

    NOmxml_attr_t

    +

    mxml_attr_t


    Description

    An XML element attribute value.

    @@ -1325,7 +1325,7 @@ struct mxml_value_s typedef struct mxml_attr_s mxml_attr_t; -

    NOmxml_custom_load_cb_t

    +

    mxml_custom_load_cb_t


    Description

    Custom data load callback function

    @@ -1334,7 +1334,7 @@ typedef struct mxml_attr_s mxml_attr_t; typedef int (*mxml_custom_load_cb_t)(mxml_node_t *, const char *); -

    NOmxml_custom_save_cb_t

    +

    mxml_custom_save_cb_t


    Description

    Custom data save callback function

    @@ -1343,7 +1343,7 @@ typedef int (*mxml_custom_load_cb_t)(mxml_node_t *, c typedef char * (*mxml_custom_save_cb_t)(mxml_node_t *); -

    NOmxml_custom_t

    +

    mxml_custom_t


    Description

    An XML custom value.

    @@ -1352,7 +1352,7 @@ typedef char * (*mxml_custom_save_cb_t)(mxml_node_t * typedef struct mxml_custom_s mxml_custom_t; -

    NOmxml_element_t

    +

    mxml_element_t


    Description

    An XML element value.

    @@ -1361,7 +1361,7 @@ typedef struct mxml_custom_s mxml_custom_t; typedef struct mxml_value_s mxml_element_t; -

    NOmxml_index_t

    +

    mxml_index_t


    Description

    An XML node index.

    @@ -1370,7 +1370,7 @@ typedef struct mxml_value_s mxml_element_t; typedef struct mxml_index_s mxml_index_t; -

    NOmxml_node_t

    +

    mxml_node_t


    Description

    An XML node.

    @@ -1379,7 +1379,7 @@ typedef struct mxml_index_s mxml_index_t; typedef struct mxml_node_s mxml_node_t; -

    NOmxml_text_t

    +

    mxml_text_t


    Description

    An XML text value.

    @@ -1388,7 +1388,7 @@ typedef struct mxml_node_s mxml_node_t; typedef struct mxml_text_s mxml_text_t; -

    NOmxml_value_t

    +

    mxml_value_t


    Description

    An XML node value.

    @@ -1402,7 +1402,7 @@ typedef union mxml_value_u mxml_value_t;
  • mxml_value_u
  • -

    NOmxml_value_u

    +

    mxml_value_u


    Description

    An XML node value.

    @@ -1422,12 +1422,12 @@ union mxml_value_u

    - - - - - - + + + + + +
    NameDescription
    NOcustomCustom data
    NOelementElement
    NOintegerInteger number
    NOopaqueOpaque string
    NOrealReal number
    NOtextText fragment
    customCustom data
    elementElement
    integerInteger number
    opaqueOpaque string
    realReal number
    textText fragment

    diff --git a/mxmldoc.c b/mxmldoc.c index fa550c1..b6e3c62 100644 --- a/mxmldoc.c +++ b/mxmldoc.c @@ -21,6 +21,7 @@ * main() - Main entry for test program. * add_variable() - Add a variable or argument. * get_comment_info() - Get info from comment. + * get_text() - Get the text for a node. * new_documentation() - Create a new documentation tree. * safe_strcpy() - Copy a string allowing for overlapping strings. * scan_file() - Scan a source file. @@ -137,6 +138,7 @@ static mxml_node_t *add_variable(mxml_node_t *parent, const char *name, mxml_node_t *type); static char *get_comment_info(mxml_node_t *description); +static char *get_text(mxml_node_t *node, char *buffer, int buflen); static mxml_node_t *new_documentation(mxml_node_t **mxmldoc); static void safe_strcpy(char *dst, const char *src); static int scan_file(const char *filename, FILE *fp, @@ -478,29 +480,72 @@ static char * /* O - Info from comment */ get_comment_info( mxml_node_t *description) /* I - Description node */ { + char text[10240], /* Description text */ + since[255], /* @since value */ + *ptr; /* Pointer into text */ static char info[1024]; /* Info string */ - int infolen; /* Length of info string */ - mxml_node_t *current; /* Current text node in description */ if (!description) - return ("NULL"); + return (""); - for (current = description->child; current; current = current->next) - if (!strcmp(current->value.text.string, "@deprecated@")) + get_text(description, text, sizeof(text)); + + for (ptr = strchr(text, '@'); ptr; ptr = strchr(ptr, '@')) + { + if (!strncmp(ptr, "@deprecated@", 12)) return ("DEPRECATED"); - else if (!strcmp(current->value.text.string, "@since") && current->next) + else if (!strncmp(ptr, "@since ", 7)) { - current = current->next; - snprintf(info, sizeof(info), "%s", - current->value.text.string); - infolen = strlen(info); - strncpy(info + infolen - 1, "", sizeof(info) - infolen); - info[sizeof(info) - 1] = '\0'; + strncpy(since, ptr + 7, sizeof(since) - 1); + since[sizeof(since) - 1] = '\0'; + + if ((ptr = strchr(since, '@')) != NULL) + *ptr = '\0'; + + snprintf(info, sizeof(info), "%s", since); return (info); } + } - return ("NO"); + return (""); +} + + +/* + * 'get_text()' - Get the text for a node. + */ + +static char * /* O - Text in node */ +get_text(mxml_node_t *node, /* I - Node to get */ + char *buffer, /* I - Buffer */ + int buflen) /* I - Size of buffer */ +{ + char *ptr, /* Pointer into buffer */ + *end; /* End of buffer */ + int len; /* Length of node */ + mxml_node_t *current; /* Current node */ + + + ptr = buffer; + end = buffer + buflen - 1; + + for (current = node->child; current && ptr < end; current = current->next) + { + if (current->value.text.whitespace) + *ptr++ = ' '; + + len = strlen(current->value.text.string); + if (len > (end - ptr)) + len = end - ptr; + + memcpy(ptr, current->value.text.string, len); + ptr += len; + } + + *ptr = '\0'; + + return (buffer); } @@ -2004,30 +2049,70 @@ static void write_description( mxml_node_t *description) /* I - Description node */ { - mxml_node_t *current; /* Current text node in description */ - + char text[10240], /* Text for description */ + *ptr; /* Pointer into text */ if (!description) return; - for (current = description->child; current; current = current->next) - if (!strcmp(current->value.text.string, "@deprecated@")) - continue; - else if (!strcmp(current->value.text.string, "@since") && current->next) + get_text(description, text, sizeof(text)); + + for (ptr = text; *ptr; ptr ++) + { + if (*ptr == '@' && !strncmp(ptr + 1, "deprecated@", 11) && + !strncmp(ptr + 1, "since ", 6)) { - do + ptr ++; + while (*ptr && *ptr != '@') + ptr ++; + + if (!*ptr) + return; + } + else if (*ptr == '&') + fputs("&", stdout); + else if (*ptr == '<') + fputs("<", stdout); + else if (*ptr == '>') + fputs(">", stdout); + else if (*ptr == '\"') + fputs(""", stdout); + else if (*ptr & 128) + { + /* + * Convert UTF-8 to Unicode constant... + */ + + int ch; /* Unicode character */ + + + ch = *ptr & 255; + + if ((ch & 0xe0) == 0xc0) { - current = current->next; + ch = ((ch & 0x1f) << 6) | (ptr[1] & 0x3f); + ptr ++; } - while (current && !strchr(current->value.text.string, '@')); + else if ((ch & 0xf0) == 0xe0) + { + ch = ((((ch * 0x0f) << 6) | (ptr[1] & 0x3f)) << 6) | (ptr[2] & 0x3f); + ptr += 2; + } + + if (ch == 0xa0) + { + /* + * Handle non-breaking space as-is... + */ + + fputs(" ", stdout); + } + else + printf("&#x%x;", ch); } else - { - if (current->value.text.whitespace) - putchar(' '); - - write_string(current->value.text.string); - } + putchar(*ptr); + } }