Smrender
 All Data Structures Files Functions Variables Macros
Data Structures | Macros | Enumerations | Functions
libhpxml.h File Reference
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include "bstring.h"
Include dependency graph for libhpxml.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  hpx_ctrl_t
 
struct  hpx_attr_t
 
struct  hpx_tag_t
 
struct  hpx_tree_t
 

Macros

#define IS_XML1CHAR(x)   (isalpha(x) || (x == '_') || (x == ':'))
 
#define IS_XMLCHAR(x)   (isalpha(x) || isdigit(x) || (x == '.') || (x == '-') || (x == '_') || (x == ':'))
 
#define hpx_init_simple()   hpx_init(0, 10*1024*1024)
 
#define MMAP_PAGES   (1L << 15)
 

Enumerations

enum  {
  HPX_ILL, HPX_OPEN, HPX_SINGLE, HPX_CLOSE,
  HPX_LITERAL, HPX_ATT, HPX_INSTR, HPX_COMMENT
}
 

Functions

long hpx_lineno (void)
 
void hpx_tm_free (hpx_tag_t *t)
 
void hpx_tm_free_tree (hpx_tree_t *)
 
hpx_tag_thpx_tm_create (int n)
 
int hpx_process_elem (bstring_t b, hpx_tag_t *p)
 
hpx_ctrl_thpx_init (int fd, long len)
 
void hpx_init_membuf (hpx_ctrl_t *ctl, void *buf, int len)
 
void hpx_free (hpx_ctrl_t *ctl)
 
int hpx_get_elem (hpx_ctrl_t *ctl, bstring_t *b, int *in_tag, long *lno)
 
long hpx_get_eleml (hpx_ctrl_t *ctl, bstringl_t *b, int *in_tag, long *lno)
 
int hpx_fprintf_tag (FILE *f, const hpx_tag_t *p)
 
int hpx_tree_resize (hpx_tree_t **tl, int n)
 

Detailed Description

This file contains all structures and prototypes for the high performance XML parser library libhpxml.

Author
Bernhard R. Fischer

Function Documentation

long hpx_get_eleml ( hpx_ctrl_t ctl,
bstringl_t b,
int *  in_tag,
long *  lno 
)
Parameters
ctlPointer to valid hpx_ctrl_t structure.
bPointer to bstring_t. This structure will be filled out by this function.
in_tagis set to 1 or 0, either it is a tag or not. It is optional and may be NULL.
lnoPointer to integer which will contain the starting line number of b. lno may be NULL.
Returns
Length of element (always >= 1) if everything is ok. b will contain a valid bstring to the element. -1 is returned in case of error. On eof, 0 is returned.
hpx_ctrl_t* hpx_init ( int  fd,
long  len 
)
Parameters
fdInput file descriptor.
lenRead buffer length. If len is negative, the file is memory mapped with mmap(). This works only if it was compiled with WITH_MMAP.
mattrMaximum number of attributes per tag.
Returns
Pointer to allocated hpx_ctrl_t structure. On error NULL is returned and errno is set. If compiled without WITH_MMAP and hpx_init() is called with negative len parameter, NULL is returned and errno is set to EINVAL.
void hpx_init_membuf ( hpx_ctrl_t ctl,
void *  buf,
int  len 
)

This function initializes a hpx_ctrl_t structure to be used for input from a memory buffer (instead of a file).

Parameters
ctlPointer to hpx_ctrl_t structure which will be initialized properly.
bufPointer to memory buffer.
lenNumber of bytes within memory buffer.
int hpx_process_elem ( bstring_t  b,
hpx_tag_t p 
)

Parses bstring into hpx_tag_t structure. The bstring buffer must contain a single XML element with correct boundaries. This is either a tag (<....>) or just text.

Parameters
bBstring containing pointer to an element.
inMust be set to 0 if element is literal text, otherwise 1 if it is a tag.
pPointer to valid hpx_tag_t structure. The structure will we filled out.
Returns
Returns 0 if the bstring could be successfully parsed, otherwise -1.
void hpx_tm_free_tree ( hpx_tree_t tlist)

This function recursively frees a tree with all its subtrees and tags.

Parameters
tlistPointer to tree which should be freed.
int hpx_tree_resize ( hpx_tree_t **  tl,
int  n 
)

Resize tag tree.

Parameters
nNumber of sub tags to add to tree.