dancer-xml-0.8.2.1/loadxml.c File Reference

Internal functions used inside the XML parser. More...

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "dancer-xml.h"

Functions

dxml_elementdxml_read_xml (FILE *f)
 Read the XML file and load it as the element structure.
void dxml_free_xml (dxml_element *e)
 free the allocated xml structure

Internal static functions used inside XML parser.

This section describes function that are used only inside the XML parsing system.

#define ERROR_RETURN   return NULL;
static void dxml_free_attrib (dxml_attribute *a)
 Free attribute of a XML element.
static void * mallocwm (int l)
 malloc with an error message on error, exits with 1.
static int skipwhitechars (FILE *f)
 skip whitechar characters.
static int checkchar (int expect, FILE *f)
 check if the next char is c and barf if not.
static dxml_elementinitialize_element (void)
 Initializes element for use.
static char * read_character_stream (FILE *f, const char *stop_chars)
 read character stream
static dxml_elementread_PCDATA (FILE *f)
 reads PCdata, and returns.
static dxml_attributeread_attribute (FILE *f)
 read attributes, and end with / (/>) or > and give it back to the caller name="string" -- no space allowed?
static int skip_read_PI (FILE *f, int strict)
 read PI or doctype decl, <? .
static int skip_read_comment (FILE *f)
 read comment, <!(--) -->
static int read_element_start (FILE *f)
 read the start of <.
static dxml_elementread_element (FILE *f)
 Read an element tag start -- end.


Detailed Description

Internal functions used inside the XML parser.


Define Documentation

#define ERROR_RETURN   return NULL;

Referenced by read_element().


Function Documentation

static int checkchar ( int  expect,
FILE *  f 
) [static]

check if the next char is c and barf if not.

return 1 if error.

Referenced by dxml_read_xml(), read_attribute(), and read_element().

static void dxml_free_attrib ( dxml_attribute a  )  [static]

void dxml_free_xml ( dxml_element e  ) 

dxml_element* dxml_read_xml ( FILE *  f  ) 

Read the XML file and load it as the element structure.

Returns:
NULL on fail.
Parameters:
f File pointer to the XML file

References checkchar(), read_element(), and skipwhitechars().

Referenced by main(), process_file(), and read_open().

static dxml_element* initialize_element ( void   )  [static]

static void* mallocwm ( int  l  )  [static]

malloc with an error message on error, exits with 1.

Parameters:
l size of memory to allocate

Referenced by initialize_element(), read_attribute(), and read_character_stream().

static dxml_attribute* read_attribute ( FILE *  f  )  [static]

read attributes, and end with / (/>) or > and give it back to the caller name="string" -- no space allowed?

Returns:
NULL if no attribute or error.

References dxml_attribute::attribute_data, dxml_attribute::attribute_name, checkchar(), dxml_free_attrib(), mallocwm(), dxml_element::next, read_character_stream(), and skipwhitechars().

Referenced by read_element().

static char* read_character_stream ( FILE *  f,
const char *  stop_chars 
) [static]

read character stream

Returns:
NULL on error

References mallocwm().

Referenced by read_attribute(), read_element(), and read_PCDATA().

static dxml_element* read_element ( FILE *  f  )  [static]

Read an element tag start -- end.

assume that the pointer is at <tagname att="..."> ^ i.e. "<" is already read.

Returns:
NULL if error.

References checkchar(), dxml_element::child, dxml_free_attrib(), dxml_free_xml(), dxml_element::element_attribute, dxml_element::element_name, ERROR_RETURN, initialize_element(), dxml_element::next, read_attribute(), read_character_stream(), read_element_start(), read_PCDATA(), and skipwhitechars().

Referenced by dxml_read_xml().

static int read_element_start ( FILE *  f  )  [static]

read the start of <.

.. part

Returns:
0 if it is not a XML normal start tag, that no further processing is required. 1 if it is a normal start tag. 2 on error.

References skip_read_comment(), and skip_read_PI().

Referenced by read_element().

static dxml_element* read_PCDATA ( FILE *  f  )  [static]

reads PCdata, and returns.

Returns:
NULL on error.

References dxml_free_xml(), dxml_element::element_name, dxml_element::element_type_pcdata, initialize_element(), and read_character_stream().

Referenced by read_element().

static int skip_read_comment ( FILE *  f  )  [static]

read comment, <!(--) -->

Returns:
0 on success, 1 on error

References skip_read_PI(), and skipwhitechars().

Referenced by read_element_start().

static int skip_read_PI ( FILE *  f,
int  strict 
) [static]

read PI or doctype decl, <? .

.. ?>

Returns:
1 on error.
Parameters:
strict Check for < ?

References skipwhitechars().

Referenced by read_element_start(), and skip_read_comment().

static int skipwhitechars ( FILE *  f  )  [static]

skip whitechar characters.

..

Returns:
0 on success, 1 on EOF

Referenced by dxml_read_xml(), read_attribute(), read_element(), skip_read_comment(), and skip_read_PI().


Generated on Wed Jun 3 16:57:21 2009 for dancer-xml Reference by  doxygen 1.5.9