xine-lib: xine-lib-1.2.12/src/xine-utils/xmlparser.c File Reference

xine-lib 1.2.12

Macros | Enumerations | Functions | Variables
xmlparser.c File Reference
`#include <unistd.h>`
`#include <stdio.h>`
`#include <stdlib.h>`
`#include <string.h>`
`#include <stdarg.h>`
`#include <ctype.h>`
`#include <xine/xineutils.h>`
`#include <xine/xmllexer.h>`
`#include <xine/xmlparser.h>`

## Macros
#define | LOG_MODULE "xmlparser"
#define | LOG_VERBOSE
#define | TOKEN_SIZE 4 * 1024
#define | DATA_SIZE 4 * 1024
#define | MAX_RECURSION 10
#define | Q_STATE(CURRENT, NEW) (STATE_##NEW + state - STATE_##CURRENT)

## Enumerations
enum | parser_state_t { STATE_IDLE , STATE_NODE , STATE_ATTRIBUTE , STATE_NODE_CLOSE , STATE_TAG_TERM , STATE_ATTRIBUTE_EQUALS , STATE_STRING , STATE_TAG_TERM_IGNORE , STATE_Q_NODE , STATE_Q_ATTRIBUTE , STATE_Q_NODE_CLOSE , STATE_Q_TAG_TERM , STATE_Q_ATTRIBUTE_EQUALS , STATE_Q_STRING , STATE_COMMENT , STATE_DOCTYPE , STATE_CDATA }

## Functions
static char * | strtoupper (char *str)
static xml_node_t * | new_xml_node (void)
static void | free_xml_node (xml_node_t *node)
static xml_property_t * | new_xml_property (void)
static void | free_xml_property (xml_property_t *property)
void | xml_parser_init (const char *buf, int size, int mode)
xml_parser_t * | xml_parser_init_r (const char *buf, int size, int mode)
void | xml_parser_finalize_r (xml_parser_t *xml_parser)
static void | xml_parser_free_props (xml_property_t *current_property)
static void | xml_parser_free_tree_rec (xml_node_t *current_node, int free_next)
void | xml_parser_free_tree (xml_node_t *current_node)
static xml_node_t * | xml_parser_append_text (xml_node_t *node, xml_node_t *subnode, const char *text, int flags)
static int | xml_parser_get_node_internal (xml_parser_t *xml_parser, char **token_buffer, int *token_buffer_size, char **pname_buffer, int *pname_buffer_size, char **nname_buffer, int *nname_buffer_size, xml_node_t *current_node, char *root_names[], int rec, int flags)
static int | xml_parser_get_node (xml_parser_t *xml_parser, xml_node_t *current_node, int flags)
int | xml_parser_build_tree_with_options (xml_node_t **root_node, int flags)
int | xml_parser_build_tree_with_options_r (xml_parser_t *xml_parser, xml_node_t **root_node, int flags)
int | xml_parser_build_tree (xml_node_t **root_node)
int | xml_parser_build_tree_r (xml_parser_t *xml_parser, xml_node_t **root_node)
const char * | xml_parser_get_property (const xml_node_t *node, const char *name)
int | xml_parser_get_property_int (const xml_node_t *node, const char *name, int def_value)
int | xml_parser_get_property_bool (const xml_node_t *node, const char *name, int def_value)
static int | xml_escape_string_internal (char *buf, const char *s, xml_escape_quote_t quote_type)
char * | xml_escape_string (const char *s, xml_escape_quote_t quote_type)
static void | xml_parser_dump_node (const xml_node_t *node, int indent)
void | xml_parser_dump_tree (const xml_node_t *node)

## Variables
xml_parser_t * | static_xml_parser
static const char | cdata [] = CDATA_MARKER

## Macro Definition Documentation

## ◆ DATA_SIZE

#define DATA_SIZE 4 * 1024

## ◆ LOG_MODULE

#define LOG_MODULE "xmlparser"

## ◆ LOG_VERBOSE

#define LOG_VERBOSE

## ◆ MAX_RECURSION

#define MAX_RECURSION 10

## ◆ Q_STATE

#define Q_STATE | ( |  | CURRENT,
|  |  | NEW
| ) |  | (STATE_##NEW + state - STATE_##CURRENT)

## ◆ TOKEN_SIZE

#define TOKEN_SIZE 4 * 1024

## Enumeration Type Documentation

## ◆ parser_state_t

enum parser_state_t

Enumerator
STATE_IDLE |
STATE_NODE |
STATE_ATTRIBUTE |
STATE_NODE_CLOSE |
STATE_TAG_TERM |
STATE_ATTRIBUTE_EQUALS |
STATE_STRING |
STATE_TAG_TERM_IGNORE |
STATE_Q_NODE |
STATE_Q_ATTRIBUTE |
STATE_Q_NODE_CLOSE |
STATE_Q_TAG_TERM |
STATE_Q_ATTRIBUTE_EQUALS |
STATE_Q_STRING |
STATE_COMMENT |
STATE_DOCTYPE |
STATE_CDATA |

## Function Documentation

## ◆ free_xml_node()

static void free_xml_node | ( | xml_node_t * | node | ) |
| static

References _x_freep(), cdata, xml_node_s::data, and xml_node_s::name.

Referenced by xml_parser_build_tree_with_options_r(), and xml_parser_free_tree_rec().

## ◆ free_xml_property()

static void free_xml_property | ( | xml_property_t * | property | ) |
| static

References _x_freep(), xml_property_s::name, and xml_property_s::value.

Referenced by xml_parser_free_props().

## ◆ new_xml_node()

static xml_node_t * new_xml_node | ( | void |  | ) |
| static

Referenced by xml_parser_append_text(), xml_parser_build_tree_with_options_r(), and xml_parser_get_node_internal().

## ◆ new_xml_property()

static xml_property_t * new_xml_property | ( | void |  | ) |
| static

Referenced by xml_parser_get_node_internal().

## ◆ strtoupper()

static char * strtoupper | ( | char * | str | ) |
| static

Referenced by xml_parser_get_node_internal().

## ◆ xml_escape_string()

char * xml_escape_string | ( | const char * | s,
|  | xml_escape_quote_t | quote_type
| ) |  |

References NULL, and xml_escape_string_internal().

Referenced by xml_parser_dump_node().

## ◆ xml_escape_string_internal()

static int xml_escape_string_internal | ( | char * | buf,
|  | const char * | s,
|  | xml_escape_quote_t | quote_type
| ) |  |
| static

References XML_ESCAPE_DOUBLE_QUOTE, and XML_ESCAPE_SINGLE_QUOTE.

Referenced by xml_escape_string().

## ◆ xml_parser_append_text()

static xml_node_t * xml_parser_append_text | ( | xml_node_t * | node,
|  | xml_node_t * | subnode,
|  | const char * | text,
|  | int | flags
| ) |  |
| static

References cdata, xml_node_s::data, xml_node_s::name, new_xml_node(), xml_node_s::next, NULL, and XML_PARSER_MULTI_TEXT.

Referenced by xml_parser_get_node_internal().

## ◆ xml_parser_build_tree()

int xml_parser_build_tree | ( | xml_node_t ** | root_node | ) |

References static_xml_parser, and xml_parser_build_tree_with_options_r().

## ◆ xml_parser_build_tree_r()

int xml_parser_build_tree_r | ( | xml_parser_t * | xml_parser,
|  | xml_node_t ** | root_node
| ) |  |

References xml_parser_build_tree_with_options_r().

Referenced by demux_asf_parse_asx_references(), parse_asx(), parse_qtl(), parse_rss(), parse_smi(), parse_xspf(), and spudec_decode_data().

## ◆ xml_parser_build_tree_with_options()

int xml_parser_build_tree_with_options | ( | xml_node_t ** | root_node,
|  | int | flags
| ) |  |

References static_xml_parser, and xml_parser_build_tree_with_options_r().

## ◆ xml_parser_build_tree_with_options_r()

int xml_parser_build_tree_with_options_r | ( | xml_parser_t * | xml_parser,
|  | xml_node_t ** | root_node,
|  | int | flags
| ) |  |

References cdata, xml_node_s::child, free_xml_node(), lprintf, xml_node_s::name, new_xml_node(), xml_node_s::next, NULL, xml_parser_free_tree(), and xml_parser_get_node().

Referenced by xml_parser_build_tree(), xml_parser_build_tree_r(), and xml_parser_build_tree_with_options().

## ◆ xml_parser_dump_node()

static void xml_parser_dump_node | ( | const xml_node_t * | node,
|  | int | indent
| ) |  |
| static

References xml_node_s::child, xml_node_s::data, xml_property_s::name, xml_node_s::name, xml_property_s::next, xml_node_s::next, xml_node_s::props, xml_property_s::value, XML_ESCAPE_SINGLE_QUOTE, xml_escape_string(), and xml_parser_dump_node().

Referenced by xml_parser_dump_node(), and xml_parser_dump_tree().

## ◆ xml_parser_dump_tree()

void xml_parser_dump_tree | ( | const xml_node_t * | node | ) |

References xml_node_s::next, and xml_parser_dump_node().

## ◆ xml_parser_finalize_r()

void xml_parser_finalize_r | ( | xml_parser_t * | xml_parser | ) |

References xml_parser_s::lexer, and lexer_finalize_r().

Referenced by demux_asf_parse_asx_references(), parse_asx(), parse_qtl(), parse_rss(), parse_smi(), parse_xspf(), spudec_decode_data(), and xml_parser_init().

## ◆ xml_parser_free_props()

static void xml_parser_free_props | ( | xml_property_t * | current_property | ) |
| static

References free_xml_property(), and xml_property_s::next.

Referenced by xml_parser_free_tree_rec(), and xml_parser_get_node_internal().

## ◆ xml_parser_free_tree()

void xml_parser_free_tree | ( | xml_node_t * | current_node | ) |

References lprintf, and xml_parser_free_tree_rec().

Referenced by demux_asf_parse_asx_references(), parse_asx(), parse_qtl(), parse_rss(), parse_smi(), parse_xspf(), and xml_parser_build_tree_with_options_r().

## ◆ xml_parser_free_tree_rec()

static void xml_parser_free_tree_rec | ( | xml_node_t * | current_node,
|  | int | free_next
| ) |  |
| static

References xml_node_s::child, free_xml_node(), lprintf, xml_node_s::name, xml_node_s::next, xml_node_s::props, xml_parser_free_props(), and xml_parser_free_tree_rec().

Referenced by xml_parser_free_tree(), xml_parser_free_tree_rec(), and xml_parser_get_node_internal().

## ◆ xml_parser_get_node()

static int xml_parser_get_node | ( | xml_parser_t * | xml_parser,
|  | xml_node_t * | current_node,
|  | int | flags
| ) |  |
| static

References MAX_RECURSION, TOKEN_SIZE, and xml_parser_get_node_internal().

Referenced by xml_parser_build_tree_with_options_r().

## ◆ xml_parser_get_node_internal()

static int xml_parser_get_node_internal | ( | xml_parser_t * | xml_parser,
|  | char ** | token_buffer,
|  | int * | token_buffer_size,
|  | char ** | pname_buffer,
|  | int * | pname_buffer_size,
|  | char ** | nname_buffer,
|  | int * | nname_buffer_size,
|  | xml_node_t * | current_node,
|  | char * | root_names[],
|  | int | rec,
|  | int | flags
| ) |  |
| static

References _x_assert, xml_node_s::child, xml_node_s::data, xml_parser_s::lexer, lexer_decode_entities(), lexer_get_token_d_r(), lprintf, MAX_RECURSION, xml_parser_s::mode, xml_property_s::name, xml_node_s::name, new_xml_node(), new_xml_property(), xml_property_s::next, xml_node_s::next, NULL, xml_node_s::props, Q_STATE, STATE_ATTRIBUTE, STATE_ATTRIBUTE_EQUALS, STATE_CDATA, STATE_COMMENT, STATE_DOCTYPE, STATE_IDLE, STATE_NODE, STATE_NODE_CLOSE, STATE_Q_ATTRIBUTE, STATE_Q_ATTRIBUTE_EQUALS, STATE_Q_NODE, STATE_Q_STRING, STATE_STRING, STATE_TAG_TERM, STATE_TAG_TERM_IGNORE, STRING, strtoupper(), T_C_START, T_C_STOP, T_CDATA_START, T_CDATA_STOP, T_DATA, T_DOCTYPE_START, T_EOF, T_EOL, T_EQUAL, T_ERROR, T_IDENT, T_M_START_1, T_M_START_2, T_M_STOP_1, T_M_STOP_2, T_SEPAR, T_STRING, T_TI_START, T_TI_STOP, xml_property_s::value, xml_parser_append_text(), XML_PARSER_CASE_INSENSITIVE, xml_parser_free_props(), xml_parser_free_tree_rec(), xml_parser_get_node_internal(), and XML_PARSER_RELAXED.

Referenced by xml_parser_get_node(), and xml_parser_get_node_internal().

## ◆ xml_parser_get_property()

const char * xml_parser_get_property | ( | const xml_node_t * | node,
|  | const char * | name
| ) |  |

References lprintf, xml_property_s::name, name, xml_property_s::next, NULL, xml_node_s::props, and xml_property_s::value.

Referenced by asx_get_time_value(), demux_asf_parse_asx_references(), parse_asx(), parse_qtl(), parse_rss(), parse_smi(), xml_parser_get_property_bool(), and xml_parser_get_property_int().

## ◆ xml_parser_get_property_bool()

int xml_parser_get_property_bool | ( | const xml_node_t * | node,
|  | const char * | name,
|  | int | def_value
| ) |  |

References name, v, and xml_parser_get_property().

## ◆ xml_parser_get_property_int()

int xml_parser_get_property_int | ( | const xml_node_t * | node,
|  | const char * | name,
|  | int | def_value
| ) |  |

References name, v, and xml_parser_get_property().

## ◆ xml_parser_init()

void xml_parser_init | ( | const char * | buf,
|  | int | size,
|  | int | mode
| ) |  |

References mode(), static_xml_parser, xml_parser_finalize_r(), and xml_parser_init_r().

## ◆ xml_parser_init_r()

xml_parser_t * xml_parser_init_r | ( | const char * | buf,
|  | int | size,
|  | int | mode
| ) |  |

References xml_parser_s::lexer, lexer_init_r(), xml_parser_s::mode, mode(), and NULL.

Referenced by demux_asf_parse_asx_references(), parse_asx(), parse_qtl(), parse_rss(), parse_smi(), parse_xspf(), spudec_decode_data(), and xml_parser_init().

## Variable Documentation

## ◆ cdata

const char cdata[] = CDATA_MARKER
| static

Referenced by free_xml_node(), xml_parser_append_text(), and xml_parser_build_tree_with_options_r().

## ◆ static_xml_parser

xml_parser_t* static_xml_parser

Referenced by xml_parser_build_tree(), xml_parser_build_tree_with_options(), and xml_parser_init().