NetSurf
Macros | Functions
libdom.c File Reference

libdom utilities (implementation). More...

#include <assert.h>
#include <string.h>
#include <dom/dom.h>
#include "utils/config.h"
#include "utils/log.h"
#include "utils/libdom.h"
Include dependency graph for libdom.c:

Go to the source code of this file.

Macros

#define BUF_SIZE   512
 

Functions

dom_node * libdom_find_first_element (dom_node *parent, lwc_string *element_name)
 Search children of a node for first named element. More...
 
nserror libdom_iterate_child_elements (dom_node *parent, libdom_iterate_cb cb, void *ctx)
 
nserror libdom_hubbub_error_to_nserror (dom_hubbub_error error)
 Convert libdom hubbub binding errors to nserrors. More...
 
static void ignore_dom_msg (uint32_t severity, void *ctx, const char *msg,...)
 
static bool dump_dom_element_attribute (dom_node *node, FILE *f, const char *attribute)
 Dump attribute/value for an element node. More...
 
static bool dump_dom_element (dom_node *node, FILE *f, int depth)
 Print a line in a DOM structure dump for an element. More...
 
nserror libdom_dump_structure (dom_node *node, FILE *f, int depth)
 Walk though a DOM (sub)tree, in depth first order, printing DOM structure. More...
 
nserror libdom_parse_file (const char *filename, const char *encoding, dom_document **doc)
 

Detailed Description

libdom utilities (implementation).

Definition in file libdom.c.

Macro Definition Documentation

◆ BUF_SIZE

#define BUF_SIZE   512

Function Documentation

◆ dump_dom_element()

static bool dump_dom_element ( dom_node *  node,
FILE *  f,
int  depth 
)
static

Print a line in a DOM structure dump for an element.

Parameters
nodeThe node to dump
ffile handle to dump to.
depthThe node's depth
Returns
true on success, or false on error

Definition at line 261 of file libdom.c.

References dump_dom_element_attribute(), node_name(), and type.

Referenced by libdom_dump_structure().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ dump_dom_element_attribute()

static bool dump_dom_element_attribute ( dom_node *  node,
FILE *  f,
const char *  attribute 
)
static

Dump attribute/value for an element node.

Parameters
nodeThe element node to dump attribute details for
ffile handle to dump to.
attributeThe attribute to dump
Returns
true on success, or false on error

Definition at line 199 of file libdom.c.

References type.

Referenced by dump_dom_element().

Here is the caller graph for this function:

◆ ignore_dom_msg()

static void ignore_dom_msg ( uint32_t  severity,
void *  ctx,
const char *  msg,
  ... 
)
static

Definition at line 185 of file libdom.c.

Referenced by libdom_parse_file().

Here is the caller graph for this function:

◆ libdom_dump_structure()

nserror libdom_dump_structure ( dom_node *  node,
FILE *  f,
int  depth 
)

Walk though a DOM (sub)tree, in depth first order, printing DOM structure.

Parameters
nodeThe root node to start from.
fThe file to write output into.
depthThe depth of 'node' in the (sub)tree.

Definition at line 331 of file libdom.c.

References dump_dom_element(), libdom_dump_structure(), NSERROR_DOM, and NSERROR_OK.

Referenced by html_debug_dump(), and libdom_dump_structure().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ libdom_find_first_element()

dom_node * libdom_find_first_element ( dom_node *  parent,
lwc_string *  element_name 
)

Search children of a node for first named element.

Parameters
parentdom_node to search children of, or NULL
element_namename of element to find
Returns
first child of node which is an element and matches name, or NULL if not found or parameter node is NULL

Definition at line 33 of file libdom.c.

References next_node(), node_name(), and parent.

Referenced by hotlist_load(), and hotlist_load_entry().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ libdom_hubbub_error_to_nserror()

nserror libdom_hubbub_error_to_nserror ( dom_hubbub_error  error)

Convert libdom hubbub binding errors to nserrors.

Parameters
errorThe hubbub binding error to convert
Returns
The appropriate nserror
Todo:
better error handling and reporting

Definition at line 122 of file libdom.c.

References NSERROR_BAD_ENCODING, NSERROR_BAD_PARAMETER, NSERROR_DOM, NSERROR_ENCODING_CHANGE, NSERROR_INVALID, NSERROR_NEED_DATA, NSERROR_NOMEM, NSERROR_NOT_FOUND, NSERROR_OK, and NSERROR_UNKNOWN.

Referenced by html_begin_conversion(), html_create_html_data(), html_process_data(), html_process_encoding_change(), and libdom_parse_file().

Here is the caller graph for this function:

◆ libdom_iterate_child_elements()

nserror libdom_iterate_child_elements ( dom_node *  parent,
libdom_iterate_cb  cb,
void *  ctx 
)

Definition at line 76 of file libdom.c.

References NSERROR_NOMEM, NSERROR_OK, parent, and type.

Referenced by hotlist_load_directory().

Here is the caller graph for this function:

◆ libdom_parse_file()

nserror libdom_parse_file ( const char *  filename,
const char *  encoding,
dom_document **  doc 
)

Definition at line 381 of file libdom.c.

References BUF_SIZE, ignore_dom_msg(), libdom_hubbub_error_to_nserror(), NSERROR_DOM, NSERROR_NOT_FOUND, and NSERROR_OK.

Referenced by hotlist_load().

Here is the call graph for this function:
Here is the caller graph for this function: