libgpac
Documentation of the core library of GPAC
xml_parser.c File Reference
#include <gpac/xml.h>
#include <gpac/utf.h>
#include <zlib.h>
+ Include dependency graph for xml_parser.c:

Data Structures

struct  GF_XMLSaxAttribute
 
struct  GF_SAXParser
 
struct  XML_Entity
 
struct  _peek_type
 
struct  GF_DOMParser
 

Macros

#define XML_INPUT_SIZE   4096
 
#define CPYCAT_ALLOC(__str, __is_copy)
 
#define SET_STRING(v)
 

Enumerations

enum  {
  SAX_STATE_ATT_NAME , SAX_STATE_ATT_VALUE , SAX_STATE_ELEMENT , SAX_STATE_COMMENT ,
  SAX_STATE_TEXT_CONTENT , SAX_STATE_ENTITY , SAX_STATE_SKIP_DOCTYPE , SAX_STATE_CDATA ,
  SAX_STATE_DONE , SAX_STATE_XML_PROC , SAX_STATE_SYNTAX_ERROR , SAX_STATE_ALLOC_ERROR
}
 

Functions

static GF_Err gf_xml_sax_parse_intern (GF_SAXParser *parser, char *current)
 
GF_STATIC char * xml_translate_xml_string (char *str)
 
static GF_XMLSaxAttributexml_get_sax_attribute (GF_SAXParser *parser)
 
static void xml_sax_swap (GF_SAXParser *parser)
 
static void format_sax_error (GF_SAXParser *parser, u32 linepos, const char *fmt,...)
 
static void xml_sax_node_end (GF_SAXParser *parser, Bool had_children)
 
static void xml_sax_node_start (GF_SAXParser *parser)
 
static Bool xml_sax_parse_attribute (GF_SAXParser *parser)
 
static void xml_sax_flush_text (GF_SAXParser *parser)
 
static void xml_sax_store_text (GF_SAXParser *parser, u32 txt_len)
 
static char * xml_get_current_text (GF_SAXParser *parser)
 
static void xml_sax_skip_doctype (GF_SAXParser *parser)
 
static void xml_sax_skip_xml_proc (GF_SAXParser *parser)
 
static void xml_sax_parse_entity (GF_SAXParser *parser)
 
static void xml_sax_cdata (GF_SAXParser *parser)
 
static Bool xml_sax_parse_comments (GF_SAXParser *parser)
 
static GF_Err xml_sax_parse (GF_SAXParser *parser, Bool force_parse)
 
static GF_Err xml_sax_append_string (GF_SAXParser *parser, char *string)
 
static XML_Entitygf_xml_locate_entity (GF_SAXParser *parser, char *ent_start, Bool *needs_text)
 
GF_EXPORT GF_Err gf_xml_sax_parse (GF_SAXParser *parser, const void *string)
 
GF_EXPORT GF_Err gf_xml_sax_init (GF_SAXParser *parser, unsigned char *BOM)
 
static void xml_sax_reset (GF_SAXParser *parser)
 
static GF_Err xml_sax_read_file (GF_SAXParser *parser)
 
GF_EXPORT GF_Err gf_xml_sax_parse_file (GF_SAXParser *parser, const char *fileName, gf_xml_sax_progress OnProgress)
 
GF_EXPORT Bool gf_xml_sax_binary_file (GF_SAXParser *parser)
 
GF_EXPORT GF_SAXParser * gf_xml_sax_new (gf_xml_sax_node_start on_node_start, gf_xml_sax_node_end on_node_end, gf_xml_sax_text_content on_text_content, void *cbck)
 
GF_EXPORT void gf_xml_sax_del (GF_SAXParser *parser)
 
GF_EXPORT GF_Err gf_xml_sax_suspend (GF_SAXParser *parser, Bool do_suspend)
 
GF_EXPORT u32 gf_xml_sax_get_line (GF_SAXParser *parser)
 
GF_EXPORT char * gf_xml_sax_peek_node (GF_SAXParser *parser, char *att_name, char *att_value, char *substitute, char *get_attr, char *end_pattern, Bool *is_substitute)
 
GF_EXPORT const char * gf_xml_sax_get_error (GF_SAXParser *parser)
 
static void on_peek_node_start (void *cbk, const char *name, const char *ns, const GF_XMLAttribute *attributes, u32 nb_attributes)
 
GF_EXPORT char * gf_xml_get_root_type (const char *file, GF_Err *ret)
 
GF_EXPORT u32 gf_xml_sax_get_node_start_pos (GF_SAXParser *parser)
 
GF_EXPORT u32 gf_xml_sax_get_node_end_pos (GF_SAXParser *parser)
 
GF_EXPORT void gf_xml_dom_node_reset (GF_XMLNode *node, Bool reset_attribs, Bool reset_children)
 
GF_EXPORT void gf_xml_dom_node_del (GF_XMLNode *node)
 
GF_List * gf_list_new_prealloc (u32 nb_prealloc)
 
static void on_dom_node_start (void *cbk, const char *name, const char *ns, const GF_XMLAttribute *attributes, u32 nb_attributes)
 
static void on_dom_node_end (void *cbk, const char *name, const char *ns)
 
static void on_dom_text_content (void *cbk, const char *content, Bool is_cdata)
 
GF_EXPORT GF_DOMParser * gf_xml_dom_new ()
 
static void gf_xml_dom_reset (GF_DOMParser *dom, Bool full_reset)
 
GF_EXPORT void gf_xml_dom_del (GF_DOMParser *parser)
 
GF_EXPORT GF_XMLNodegf_xml_dom_detach_root (GF_DOMParser *parser)
 
static void dom_on_progress (void *cbck, u64 done, u64 tot)
 
GF_EXPORT GF_Err gf_xml_dom_parse (GF_DOMParser *dom, const char *file, gf_xml_sax_progress OnProgress, void *cbk)
 
GF_EXPORT GF_Err gf_xml_dom_parse_string (GF_DOMParser *dom, char *string)
 
GF_EXPORT GF_Err gf_xml_dom_enable_passthrough (GF_DOMParser *dom)
 
GF_EXPORT GF_XMLNodegf_xml_dom_get_root (GF_DOMParser *parser)
 
GF_EXPORT const char * gf_xml_dom_get_error (GF_DOMParser *parser)
 
GF_EXPORT u32 gf_xml_dom_get_line (GF_DOMParser *parser)
 
GF_EXPORT u32 gf_xml_dom_get_root_nodes_count (GF_DOMParser *parser)
 
GF_EXPORT GF_XMLNodegf_xml_dom_get_root_idx (GF_DOMParser *parser, u32 idx)
 
static void gf_xml_dom_node_serialize (GF_XMLNode *node, Bool content_only, Bool no_escape, char **str, u32 *alloc_size, u32 *size)
 
GF_EXPORT char * gf_xml_dom_serialize (GF_XMLNode *node, Bool content_only, Bool no_escape)
 
GF_EXPORT char * gf_xml_dom_serialize_root (GF_XMLNode *node, Bool content_only, Bool no_escape)
 
GF_EXPORT GF_XMLAttributegf_xml_dom_create_attribute (const char *name, const char *value)
 
GF_EXPORT GF_Err gf_xml_dom_append_child (GF_XMLNode *node, GF_XMLNode *child)
 
GF_XMLNodegf_xml_dom_node_new (const char *ns, const char *name)
 
GF_Err gf_xml_dom_node_check_namespace (const GF_XMLNode *n, const char *expected_node_name, const char *expected_ns_prefix)
 
void gf_xml_dump_string (FILE *file, const char *before, const char *str, const char *after)
 
GF_XMLNodegf_xml_dom_node_clone (GF_XMLNode *node)
 

Variables

static u32 XML_MAX_CONTENT_SIZE = 0
 

Data Structure Documentation

◆ GF_XMLSaxAttribute

struct GF_XMLSaxAttribute
Data Fields
u32 name_start
u32 name_end
u32 val_start
u32 val_end
Bool has_entities

◆ _tag_sax_parser

struct _tag_sax_parser

SAX XML Parser object

+ Collaboration diagram for GF_SAXParser:
Data Fields
s32 unicode_type
char * buffer
u32 alloc_size
u32 line_size
u32 current_pos
u32 node_depth
gzFile gz_in
u32 line
u32 file_size
u32 file_pos
gf_xml_sax_node_start sax_node_start
gf_xml_sax_node_end sax_node_end
gf_xml_sax_text_content sax_text_content
void * sax_cbck
gf_xml_sax_progress on_progress
u32 sax_state
u32 init_state
GF_List * entities
char att_sep
Bool in_entity
Bool suspended
u32 in_quote
u32 elt_start_pos
u32 elt_end_pos
char err_msg[1000]
u32 att_name_start
u32 elt_name_start
u32 elt_name_end
u32 text_start
u32 text_end
u32 text_check_escapes
GF_XMLAttribute * attrs
GF_XMLSaxAttribute * sax_attrs
u32 nb_attrs
u32 nb_alloc_attrs
u32 ent_rec_level

◆ XML_Entity

struct XML_Entity
Data Fields
char * name
char * value
u32 namelen
u8 sep

◆ _peek_type

struct _peek_type
Data Fields
GF_SAXParser * parser
char * res

Macro Definition Documentation

◆ XML_INPUT_SIZE

#define XML_INPUT_SIZE   4096

◆ CPYCAT_ALLOC

#define CPYCAT_ALLOC (   __str,
  __is_copy 
)
Value:
_len = (u32) strlen(__str);\
if ( _len + (__is_copy ? 0 : strlen(szLine))>=alloc_size) {\
alloc_size = 1 + (u32) strlen(__str); \
if (!__is_copy) alloc_size += (u32) strlen(szLine); \
szLine = gf_realloc(szLine, alloc_size); \
}\
if (__is_copy) { memmove(szLine, __str, sizeof(char)*_len); szLine[_len] = 0; }\
else strcat(szLine, __str); \
void * gf_realloc(void *ptr, size_t size)
Definition: alloc.c:158
uint32_t u32
Definition: setup.h:326

◆ SET_STRING

#define SET_STRING (   v)
Value:
vlen = (u32) strlen(v); \
tot_s = vlen + (*size); \
if (tot_s >= (*alloc_size)) { \
(*alloc_size) = MAX(tot_s, 2 * (*alloc_size) ) + 1; \
(*str) = gf_realloc((*str), (*alloc_size)); \
} \
memcpy((*str) + (*size), v, vlen+1); \
*size += vlen; \
#define MAX(X, Y)
Definition: setup.h:459

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
SAX_STATE_ATT_NAME 
SAX_STATE_ATT_VALUE 
SAX_STATE_ELEMENT 
SAX_STATE_COMMENT 
SAX_STATE_TEXT_CONTENT 
SAX_STATE_ENTITY 
SAX_STATE_SKIP_DOCTYPE 
SAX_STATE_CDATA 
SAX_STATE_DONE 
SAX_STATE_XML_PROC 
SAX_STATE_SYNTAX_ERROR 
SAX_STATE_ALLOC_ERROR 

Function Documentation

◆ gf_xml_sax_parse_intern()

static GF_Err gf_xml_sax_parse_intern ( GF_SAXParser *  parser,
char *  current 
)
static
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ xml_translate_xml_string()

GF_STATIC char* xml_translate_xml_string ( char *  str)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ xml_get_sax_attribute()

static GF_XMLSaxAttribute* xml_get_sax_attribute ( GF_SAXParser *  parser)
static
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ xml_sax_swap()

static void xml_sax_swap ( GF_SAXParser *  parser)
static
+ Here is the caller graph for this function:

◆ format_sax_error()

static void format_sax_error ( GF_SAXParser *  parser,
u32  linepos,
const char *  fmt,
  ... 
)
static
+ Here is the caller graph for this function:

◆ xml_sax_node_end()

static void xml_sax_node_end ( GF_SAXParser *  parser,
Bool  had_children 
)
static
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ xml_sax_node_start()

static void xml_sax_node_start ( GF_SAXParser *  parser)
static
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ xml_sax_parse_attribute()

static Bool xml_sax_parse_attribute ( GF_SAXParser *  parser)
static
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ xml_sax_flush_text()

static void xml_sax_flush_text ( GF_SAXParser *  parser)
static
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ xml_sax_store_text()

static void xml_sax_store_text ( GF_SAXParser *  parser,
u32  txt_len 
)
static
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ xml_get_current_text()

static char* xml_get_current_text ( GF_SAXParser *  parser)
static
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ xml_sax_skip_doctype()

static void xml_sax_skip_doctype ( GF_SAXParser *  parser)
static
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ xml_sax_skip_xml_proc()

static void xml_sax_skip_xml_proc ( GF_SAXParser *  parser)
static
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ xml_sax_parse_entity()

static void xml_sax_parse_entity ( GF_SAXParser *  parser)
static
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ xml_sax_cdata()

static void xml_sax_cdata ( GF_SAXParser *  parser)
static
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ xml_sax_parse_comments()

static Bool xml_sax_parse_comments ( GF_SAXParser *  parser)
static
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ xml_sax_parse()

static GF_Err xml_sax_parse ( GF_SAXParser *  parser,
Bool  force_parse 
)
static
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ xml_sax_append_string()

static GF_Err xml_sax_append_string ( GF_SAXParser *  parser,
char *  string 
)
static
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ gf_xml_locate_entity()

static XML_Entity* gf_xml_locate_entity ( GF_SAXParser *  parser,
char *  ent_start,
Bool needs_text 
)
static
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ xml_sax_reset()

static void xml_sax_reset ( GF_SAXParser *  parser)
static
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ xml_sax_read_file()

static GF_Err xml_sax_read_file ( GF_SAXParser *  parser)
static
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ on_peek_node_start()

static void on_peek_node_start ( void *  cbk,
const char *  name,
const char *  ns,
const GF_XMLAttribute attributes,
u32  nb_attributes 
)
static
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ gf_list_new_prealloc()

GF_List* gf_list_new_prealloc ( u32  nb_prealloc)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ on_dom_node_start()

static void on_dom_node_start ( void *  cbk,
const char *  name,
const char *  ns,
const GF_XMLAttribute attributes,
u32  nb_attributes 
)
static
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ on_dom_node_end()

static void on_dom_node_end ( void *  cbk,
const char *  name,
const char *  ns 
)
static
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ on_dom_text_content()

static void on_dom_text_content ( void *  cbk,
const char *  content,
Bool  is_cdata 
)
static
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ gf_xml_dom_reset()

static void gf_xml_dom_reset ( GF_DOMParser *  dom,
Bool  full_reset 
)
static
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ dom_on_progress()

static void dom_on_progress ( void *  cbck,
u64  done,
u64  tot 
)
static
+ Here is the caller graph for this function:

◆ gf_xml_dom_node_serialize()

static void gf_xml_dom_node_serialize ( GF_XMLNode node,
Bool  content_only,
Bool  no_escape,
char **  str,
u32 alloc_size,
u32 size 
)
static
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ XML_MAX_CONTENT_SIZE

u32 XML_MAX_CONTENT_SIZE = 0
static