diff --git a/src/dom/Doxyfile b/src/dom/Doxyfile new file mode 100644 index 00000000..e7c5022f --- /dev/null +++ b/src/dom/Doxyfile @@ -0,0 +1,237 @@ +# Doxyfile 1.5.1 + +#--------------------------------------------------------------------------- +# Project related configuration options +#--------------------------------------------------------------------------- +PROJECT_NAME = "ELinks DOM" +PROJECT_NUMBER = 0.12.GIT +OUTPUT_DIRECTORY = doc +CREATE_SUBDIRS = NO +OUTPUT_LANGUAGE = English +USE_WINDOWS_ENCODING = NO +BRIEF_MEMBER_DESC = YES +REPEAT_BRIEF = YES +ABBREVIATE_BRIEF = "The $name class" \ + "The $name widget" \ + "The $name file" \ + is \ + provides \ + specifies \ + contains \ + represents \ + a \ + an \ + the +ALWAYS_DETAILED_SEC = NO +INLINE_INHERITED_MEMB = NO +FULL_PATH_NAMES = YES +STRIP_FROM_PATH = . +STRIP_FROM_INC_PATH = +SHORT_NAMES = NO +JAVADOC_AUTOBRIEF = YES +MULTILINE_CPP_IS_BRIEF = NO +DETAILS_AT_TOP = NO +INHERIT_DOCS = YES +SEPARATE_MEMBER_PAGES = NO +TAB_SIZE = 3 +ALIASES = +OPTIMIZE_OUTPUT_FOR_C = YES +OPTIMIZE_OUTPUT_JAVA = NO +BUILTIN_STL_SUPPORT = NO +DISTRIBUTE_GROUP_DOC = NO +SUBGROUPING = YES +#--------------------------------------------------------------------------- +# Build related configuration options +#--------------------------------------------------------------------------- +EXTRACT_ALL = YES +EXTRACT_PRIVATE = YES +EXTRACT_STATIC = YES +EXTRACT_LOCAL_CLASSES = YES +EXTRACT_LOCAL_METHODS = YES +HIDE_UNDOC_MEMBERS = NO +HIDE_UNDOC_CLASSES = NO +HIDE_FRIEND_COMPOUNDS = NO +HIDE_IN_BODY_DOCS = NO +INTERNAL_DOCS = NO +CASE_SENSE_NAMES = NO +HIDE_SCOPE_NAMES = NO +SHOW_INCLUDE_FILES = YES +INLINE_INFO = YES +SORT_MEMBER_DOCS = YES +SORT_BRIEF_DOCS = NO +SORT_BY_SCOPE_NAME = NO +GENERATE_TODOLIST = YES +GENERATE_TESTLIST = YES +GENERATE_BUGLIST = YES +GENERATE_DEPRECATEDLIST= YES +ENABLED_SECTIONS = +MAX_INITIALIZER_LINES = 30 +SHOW_USED_FILES = YES +SHOW_DIRECTORIES = NO +FILE_VERSION_FILTER = +#--------------------------------------------------------------------------- +# configuration options related to warning and progress messages +#--------------------------------------------------------------------------- +QUIET = YES +WARNINGS = YES +WARN_IF_UNDOCUMENTED = YES +WARN_IF_DOC_ERROR = YES +WARN_NO_PARAMDOC = NO +WARN_FORMAT = "$file:$line: $text" +WARN_LOGFILE = +#--------------------------------------------------------------------------- +# configuration options related to the input files +#--------------------------------------------------------------------------- +INPUT = . +FILE_PATTERNS = *.c \ + *.h \ + *.inc +RECURSIVE = YES +EXCLUDE = +EXCLUDE_SYMLINKS = NO +EXCLUDE_PATTERNS = +EXAMPLE_PATH = +EXAMPLE_PATTERNS = * +EXAMPLE_RECURSIVE = NO +IMAGE_PATH = +INPUT_FILTER = +FILTER_PATTERNS = +FILTER_SOURCE_FILES = NO +#--------------------------------------------------------------------------- +# configuration options related to source browsing +#--------------------------------------------------------------------------- +SOURCE_BROWSER = YES +INLINE_SOURCES = NO +STRIP_CODE_COMMENTS = YES +REFERENCED_BY_RELATION = YES +REFERENCES_RELATION = YES +REFERENCES_LINK_SOURCE = YES +USE_HTAGS = NO +VERBATIM_HEADERS = YES +#--------------------------------------------------------------------------- +# configuration options related to the alphabetical class index +#--------------------------------------------------------------------------- +ALPHABETICAL_INDEX = NO +COLS_IN_ALPHA_INDEX = 5 +IGNORE_PREFIX = +#--------------------------------------------------------------------------- +# configuration options related to the HTML output +#--------------------------------------------------------------------------- +GENERATE_HTML = YES +HTML_OUTPUT = html +HTML_FILE_EXTENSION = .html +HTML_HEADER = +HTML_FOOTER = +HTML_STYLESHEET = +HTML_ALIGN_MEMBERS = YES +GENERATE_HTMLHELP = NO +CHM_FILE = +HHC_LOCATION = +GENERATE_CHI = NO +BINARY_TOC = NO +TOC_EXPAND = NO +DISABLE_INDEX = NO +ENUM_VALUES_PER_LINE = 4 +GENERATE_TREEVIEW = NO +TREEVIEW_WIDTH = 250 +#--------------------------------------------------------------------------- +# configuration options related to the LaTeX output +#--------------------------------------------------------------------------- +GENERATE_LATEX = NO +LATEX_OUTPUT = latex +LATEX_CMD_NAME = latex +MAKEINDEX_CMD_NAME = makeindex +COMPACT_LATEX = NO +PAPER_TYPE = a4wide +EXTRA_PACKAGES = +LATEX_HEADER = +PDF_HYPERLINKS = NO +USE_PDFLATEX = NO +LATEX_BATCHMODE = NO +LATEX_HIDE_INDICES = NO +#--------------------------------------------------------------------------- +# configuration options related to the RTF output +#--------------------------------------------------------------------------- +GENERATE_RTF = NO +RTF_OUTPUT = rtf +COMPACT_RTF = NO +RTF_HYPERLINKS = NO +RTF_STYLESHEET_FILE = +RTF_EXTENSIONS_FILE = +#--------------------------------------------------------------------------- +# configuration options related to the man page output +#--------------------------------------------------------------------------- +GENERATE_MAN = NO +MAN_OUTPUT = man +MAN_EXTENSION = .3 +MAN_LINKS = NO +#--------------------------------------------------------------------------- +# configuration options related to the XML output +#--------------------------------------------------------------------------- +GENERATE_XML = NO +XML_OUTPUT = xml +XML_SCHEMA = +XML_DTD = +XML_PROGRAMLISTING = YES +#--------------------------------------------------------------------------- +# configuration options for the AutoGen Definitions output +#--------------------------------------------------------------------------- +GENERATE_AUTOGEN_DEF = NO +#--------------------------------------------------------------------------- +# configuration options related to the Perl module output +#--------------------------------------------------------------------------- +GENERATE_PERLMOD = NO +PERLMOD_LATEX = NO +PERLMOD_PRETTY = YES +PERLMOD_MAKEVAR_PREFIX = +#--------------------------------------------------------------------------- +# Configuration options related to the preprocessor +#--------------------------------------------------------------------------- +ENABLE_PREPROCESSING = YES +MACRO_EXPANSION = NO +EXPAND_ONLY_PREDEF = NO +SEARCH_INCLUDES = YES +INCLUDE_PATH = +INCLUDE_FILE_PATTERNS = +PREDEFINED = +EXPAND_AS_DEFINED = +SKIP_FUNCTION_MACROS = YES +#--------------------------------------------------------------------------- +# Configuration::additions related to external references +#--------------------------------------------------------------------------- +TAGFILES = +GENERATE_TAGFILE = +ALLEXTERNALS = NO +EXTERNAL_GROUPS = YES +PERL_PATH = /usr/bin/perl +#--------------------------------------------------------------------------- +# Configuration options related to the dot tool +#--------------------------------------------------------------------------- +CLASS_DIAGRAMS = NO +HIDE_UNDOC_RELATIONS = YES +HAVE_DOT = YES +CLASS_GRAPH = YES +COLLABORATION_GRAPH = YES +GROUP_GRAPHS = YES +UML_LOOK = NO +TEMPLATE_RELATIONS = NO +INCLUDE_GRAPH = YES +INCLUDED_BY_GRAPH = YES +CALL_GRAPH = YES +CALLER_GRAPH = NO +GRAPHICAL_HIERARCHY = YES +DIRECTORY_GRAPH = YES +DOT_IMAGE_FORMAT = png +DOT_PATH = +DOTFILE_DIRS = +MAX_DOT_GRAPH_WIDTH = 1024 +MAX_DOT_GRAPH_HEIGHT = 1024 +MAX_DOT_GRAPH_DEPTH = 1000 +DOT_TRANSPARENT = NO +DOT_MULTI_TARGETS = NO +GENERATE_LEGEND = YES +DOT_CLEANUP = YES +#--------------------------------------------------------------------------- +# Configuration::additions related to the search engine +#--------------------------------------------------------------------------- +SEARCHENGINE = NO diff --git a/src/dom/node.c b/src/dom/node.c index e0f336ce..6f97cfb6 100644 --- a/src/dom/node.c +++ b/src/dom/node.c @@ -331,7 +331,10 @@ get_dom_node_child(struct dom_node *parent, enum dom_node_type type, /* Nodes */ struct dom_node * -init_dom_node_(unsigned char *file, int line, +init_dom_node_at( +#ifdef DEBUG_MEMLEAK + unsigned char *file, int line, +#endif struct dom_node *parent, enum dom_node_type type, struct dom_string *string, int allocated) { diff --git a/src/dom/node.h b/src/dom/node.h index b1705ae1..fedebccf 100644 --- a/src/dom/node.h +++ b/src/dom/node.h @@ -1,3 +1,58 @@ +/** DOM node module + * + * @file dom/node.h + * + * This module defines the various node and node list data structures + * and functionality to modify and access them, such as adding a node as + * a child to a given node and getting the text string of a node as + * defined by the DOM specification. + * + * @par Node hierarchy + * + * DOM documents are represented as a collection of nodes arranged in a + * hierarchic structure. At the root is either a #DOM_NODE_DOCUMENT or + * #DOM_NODE_DOCUMENT_FRAGMENT node, each of which may have multiple + * child nodes. There is a well-defined order that dictates which child + * nodes may be descendants of a given type of node. For example, text + * and attribute nodes can have no children, while elements node may + * have both attribute and element nodes as children but with each type + * in different node lists. The hierarchy is somewhat encoded in the + * type specific node data, however, certain node types also define + * "custom" node lists for conveniently storing additional "embedded" + * data, such as processing instruction nodes having an attribute node + * list for conveniently accessing variable-value pairs given for + * XML-specific processing instructions: + * + * @verbatim @endverbatim + * + * @par Node lists + * + * There are two types of list: unordered (the default) and + * alphabetically ordered (also called "maps"). Both types of list + * stores all contained nodes in the index-oriented #dom_node_list data + * structure. + * + * When inserting a node into a list, first use either + * #get_dom_node_list_index or #get_dom_node_map_index (depending on + * whether the list is unordered or ordered respectively) to calculate + * the index at which to insert the new node. Then use + * #add_to_dom_node_list to insert the node in the list at the given + * position. Alternatively (and mostly preferred), simply use + * #add_dom_node to have all of the above done automatically plus some + * additional checks. + * + * A variety of node list accessors are defined. The node structure does + * not define any "next" or "previous" members to get siblings due to + * reduce memory usage (this might have to change --jonas). Instead, use + * #get_dom_node_next and #get_dom_node_next to access siblings. To + * lookup the existence of a node in a sorted node list (map) use + * #get_dom_node_map_entry. If a specific and unique node subtype should + * be found use #get_dom_node_child that given a parent node will find a + * child node based on a specific child node type and subtype. Finally, + * list can be iterated in forward and reverse order using + * #foreach_dom_node and #foreachback_dom_node. + */ + #ifndef EL_DOM_NODE_H #define EL_DOM_NODE_H @@ -6,27 +61,28 @@ struct dom_node_list; struct dom_document; +/** DOM node types */ enum dom_node_type { - DOM_NODE_UNKNOWN = 0, /* for internal purpose only */ + DOM_NODE_UNKNOWN = 0, /**< Node type used internally. */ - DOM_NODE_ELEMENT = 1, - DOM_NODE_ATTRIBUTE = 2, - DOM_NODE_TEXT = 3, - DOM_NODE_CDATA_SECTION = 4, - DOM_NODE_ENTITY_REFERENCE = 5, - DOM_NODE_ENTITY = 6, - DOM_NODE_PROCESSING_INSTRUCTION = 7, - DOM_NODE_COMMENT = 8, - DOM_NODE_DOCUMENT = 9, - DOM_NODE_DOCUMENT_TYPE = 10, - DOM_NODE_DOCUMENT_FRAGMENT = 11, - DOM_NODE_NOTATION = 12, + DOM_NODE_ELEMENT = 1, /**< Element node */ + DOM_NODE_ATTRIBUTE = 2, /**< Attribute node */ + DOM_NODE_TEXT = 3, /**< Text node */ + DOM_NODE_CDATA_SECTION = 4, /**< CData section node */ + DOM_NODE_ENTITY_REFERENCE = 5, /**< Entity reference node */ + DOM_NODE_ENTITY = 6, /**< Entity node */ + DOM_NODE_PROCESSING_INSTRUCTION = 7, /**< Processing instruction node */ + DOM_NODE_COMMENT = 8, /**< Comment node */ + DOM_NODE_DOCUMENT = 9, /**< Document root node */ + DOM_NODE_DOCUMENT_TYPE = 10, /**< Document type (DTD) node */ + DOM_NODE_DOCUMENT_FRAGMENT = 11, /**< Document fragment node */ + DOM_NODE_NOTATION = 12, /**< Notation node */ - DOM_NODES + DOM_NODES /**< The number of DOM nodes */ }; -/* Following is the node specific datastructures. They may contain no more - * than 4 pointers or something equivalent. */ +/* Following is the node specific data structures. They may contain no + * more than 4 pointers or something equivalent. */ /* The document URI is stored in the string / length members. */ struct dom_document_node { @@ -173,26 +229,38 @@ union dom_node_data { */ }; -/* This structure is size critical so keep ordering to make it easier to pack - * and avoid unneeded members. */ +/** DOM node + * + * The node data structure is an abstract container that can be used to + * represent the hierarchic structure of a document, such as relation + * between elements, attributes, etc. + * + * @note This structure is size critical so keep ordering to make + * it easier to pack and avoid unneeded members. + */ struct dom_node { - /* The type of the node */ + /** The type of the node. Holds a #dom_node_type enum value. */ uint16_t type; /* -> enum dom_node_type */ - /* Was the node string allocated? */ + /** Was the node string allocated? */ unsigned int allocated:1; - /* Can contain either stuff like element name or for attributes the - * attribute name. */ + /** Type specific node string. Can contain either stuff like + * element name or for attributes the attribute name. */ struct dom_string string; + /** The parent node. The parent node is NULL for the root node. */ struct dom_node *parent; - /* Various info depending on the type of the node. */ + /** Type specific node data. */ union dom_node_data data; }; -/* A node list can be used for storing indexed nodes */ +/** DOM node list + * + * A node list can be used for storing indexed nodes. If a node list + * should be sorted alphabetically use the #get_dom_node_map_index + * function to find the index of new nodes before inserting them. */ struct dom_node_list { size_t size; struct dom_node *entries[1]; @@ -250,18 +318,34 @@ get_dom_node_map_entry(struct dom_node_list *node_map, /* Removes the node and all its children and free()s itself */ void done_dom_node(struct dom_node *node); +#ifndef DEBUG_MEMLEAK + /* The allocated argument is used as the value of node->allocated if >= 0. * Use -1 to default node->allocated to the value of parent->allocated. */ + struct dom_node * -init_dom_node_(unsigned char *file, int line, - struct dom_node *parent, enum dom_node_type type, - struct dom_string *string, int allocated); +init_dom_node_at(struct dom_node *parent, enum dom_node_type type, + struct dom_string *string, int allocated); #define init_dom_node(type, string, allocated) \ - init_dom_node_(__FILE__, __LINE__, NULL, type, string, allocated) + init_dom_node_at(NULL, type, string, allocated) #define add_dom_node(parent, type, string) \ - init_dom_node_(__FILE__, __LINE__, parent, type, string, -1) + init_dom_node_at(parent, type, string, -1) + +#else +struct dom_node * +init_dom_node_at(unsigned char *file, int line, + struct dom_node *parent, enum dom_node_type type, + struct dom_string *string, int allocated); + +#define init_dom_node(type, string, allocated) \ + init_dom_node_at(__FILE__, __LINE__, NULL, type, string, allocated) + +#define add_dom_node(parent, type, string) \ + init_dom_node_at(__FILE__, __LINE__, parent, type, string, -1) + +#endif /* DEBUG_MEMLEAK */ #define add_dom_element(parent, string) \ add_dom_node(parent, DOM_NODE_ELEMENT, string)