<libroxml  version="2.3.0" />
contact: tristan.lelong@libroxml.net
Functions | Variables
roxml-internal.c File Reference

source for libroxml.so More...

#include "roxml-internal.h"
#include "roxml-parse-engine.h"

Go to the source code of this file.

Functions

void ROXML_INTroxml_malloc (int size, int num, int type)
 alloc memory function More...
 
int ROXML_INT roxml_read (int pos, int size, char *buffer, node_t *node)
 read xml doc function More...
 
node_t ROXML_INTroxml_create_node (int pos, void *src, int type)
 internal function More...
 
void ROXML_INT roxml_close_node (node_t *n, node_t *close)
 internal function More...
 
void ROXML_INT roxml_free_node (node_t *n)
 internal function More...
 
void ROXML_INT roxml_del_tree (node_t *n)
 internal function More...
 
int roxml_is_number (char *input)
 number tester More...
 
int ROXML_INT roxml_is_separator (char sep)
 separator tester More...
 
void ROXML_INT roxml_process_unaliased_ns (roxml_load_ctx_t *context)
 namespace without alias name creation during parsing More...
 
void ROXML_INT roxml_process_begin_node (roxml_load_ctx_t *context, int position)
 node creation during parsing More...
 
node_t ROXML_INTroxml_load (node_t *current_node, FILE *file, char *buffer)
 generic load function More...
 
node_t ROXML_INTroxml_lookup_nsdef (node_t *nsdef, char *ns)
 name space lookup in list More...
 
void ROXML_INT roxml_set_type (node_t *n, int type)
 node type setter function More...
 
xpath_node_t ROXML_INTroxml_set_axes (xpath_node_t *node, char *axes, int *offset)
 axes setter function More...
 
int ROXML_INT roxml_get_node_internal_position (node_t *n)
 node absolute position get More...
 
int ROXML_INT roxml_parse_xpath (char *path, xpath_node_t **xpath, int context)
 xpath parsing function More...
 
void ROXML_INT roxml_free_xcond (xpath_cond_t *xcond)
 xpath condition free function More...
 
void ROXML_INT roxml_free_xpath (xpath_node_t *xpath, int nb)
 xpath free function More...
 
double ROXML_INT roxml_double_oper (double a, double b, int op)
 double operation function More...
 
int ROXML_INT roxml_double_cmp (double a, double b, int op)
 double comparison function More...
 
int ROXML_INT roxml_string_cmp (char *sa, char *sb, int op)
 string comparison function More...
 
int ROXML_INT roxml_validate_predicat (xpath_node_t *xn, node_t *candidat)
 predicat validation function More...
 
int ROXML_INT roxml_request_id (node_t *root)
 id reservation function More...
 
int ROXML_INT roxml_in_pool (node_t *root, node_t *n, int req_id)
 node pool presence tester function More...
 
void ROXML_INT roxml_release_id (node_t *root, node_t **pool, int pool_len, int req_id)
 release id function More...
 
void roxml_del_from_pool (node_t *root, node_t *n, int req_id)
 pool node delete function More...
 
int ROXML_INT roxml_add_to_pool (node_t *root, node_t *n, int req_id)
 add a token top node function More...
 
int ROXML_INT roxml_validate_axes (node_t *root, node_t *candidat, node_t ***ans, int *nb, int *max, xpath_node_t *xn, int req_id)
 axe validation function More...
 
void ROXML_INT roxml_check_node (xpath_node_t *xp, node_t *root, node_t *context, node_t ***ans, int *nb, int *max, int ignore, int req_id)
 real xpath validation function More...
 
void roxml_compute_and (node_t *root, node_t **node_set, int *count, int cur_req_id, int prev_req_id)
 node set and function More...
 
void roxml_compute_or (node_t *root, node_t **node_set, int *count, int req_id, int glob_id)
 node set or function More...
 
node_t ** roxml_exec_xpath (node_t *root, node_t *n, xpath_node_t *xpath, int index, int *count)
 real xpath execution More...
 
node_t ROXML_INTroxml_append_node (node_t *parent, node_t *n)
 node append function More...
 
node_t ROXML_INTroxml_parent_node (node_t *parent, node_t *n, int position)
 node relocate function More...
 
void ROXML_INT roxml_print_space (FILE *f, char **buf, int *offset, int *len, int lvl)
 space printing function More...
 
void ROXML_INT roxml_write_string (char **buf, FILE *f, char *str, int *offset, int *len)
 string writter function More...
 
void ROXML_INT roxml_write_node (node_t *n, FILE *f, char **buf, int human, int lvl, int *offset, int *len)
 tree write function More...
 
void ROXML_INT roxml_reset_ns (node_t *n, node_t *ns)
 internal function More...
 
void ROXML_INT roxml_del_arg_node (node_t *n)
 attribute node deletion function More...
 
void ROXML_INT roxml_del_txt_node (node_t *n)
 text node deletion function More...
 
void ROXML_INT roxml_del_std_node (node_t *n)
 node deletion function More...
 

Variables

memory_cell_t head_cell = { PTR_NONE, 0, NULL, 0, NULL, NULL }
 head of memory manager
 

Detailed Description

source for libroxml.so

This is the source file for lib libroxml.so internal functions

Author
blunderer blund.nosp@m.erer.nosp@m.@blun.nosp@m.dere.nosp@m.r.org
Date
11 Jan 2010

Copyright (C) 2010 blunderer

This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. The author added a static linking exception, see License.txt.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA

Definition in file roxml-internal.c.

Function Documentation

int ROXML_INT roxml_add_to_pool ( node_t root,
node_t n,
int  req_id 
)

add a token top node function

this function add a token to target node. This token is used to garanty unicity in xpath results

Parameters
rootthe root node
nthe node to mark
req_idthe id to use
Returns
0 if already in the pool, else 1

Definition at line 849 of file roxml-internal.c.

node_t ROXML_INT* roxml_append_node ( node_t parent,
node_t n 
)

node append function

this function add a given node as the last child of another node

Parameters
parentthe parent node
nthe node to parent
Returns

Definition at line 1323 of file roxml-internal.c.

void ROXML_INT roxml_check_node ( xpath_node_t xp,
node_t root,
node_t context,
node_t ***  ans,
int *  nb,
int *  max,
int  ignore,
int  req_id 
)

real xpath validation function

this function perform the xpath test on a tree

Parameters
xpthe xpath nodes to test
rootthe root node
contextthe current context node
ansthe pointer to answers pool
nbthe number of answers in pool
maxthe current size of the pool
ignorea flag for some axes that are going thru all document  
req_idthe pool id
Returns

Definition at line 1019 of file roxml-internal.c.

void ROXML_INT roxml_close_node ( node_t n,
node_t close 
)

internal function

This function close the node (add the end offset) and parent the node

Parameters
nis the node to close
closeis the node that close node n
Returns
void

Definition at line 90 of file roxml-internal.c.

void roxml_compute_and ( node_t root,
node_t **  node_set,
int *  count,
int  cur_req_id,
int  prev_req_id 
)

node set and function

this function computes the AND of two node pools. The resulting pool will have the same ID as cur_req_id.

Parameters
rootthe root of the tree
node_setthe node set containing the 2 pools
countnumber of node in the node set
cur_req_idthe id of the first group
prev_req_idthe id of the second group

Definition at line 1208 of file roxml-internal.c.

void roxml_compute_or ( node_t root,
node_t **  node_set,
int *  count,
int  req_id,
int  glob_id 
)

node set or function

this function computes the OR of two node pools. The resulting pool will have the same ID as glob_id.

Parameters
rootthe root of the tree
node_setthe node set containing the 2 pools
countnumber of node in the node set
req_idthe id of the first group
glob_idthe id of the second group
Returns

Definition at line 1234 of file roxml-internal.c.

node_t ROXML_INT* roxml_create_node ( int  pos,
void *  src,
int  type 
)

internal function

This function allocate a new node

Parameters
posis the beginning offset of the node in the file
srcis the pointer to the buffer or file
typeis the type of node between arg and val
Returns
the new node

Definition at line 79 of file roxml-internal.c.

void ROXML_INT roxml_del_arg_node ( node_t n)

attribute node deletion function

this function delete an attribute node

Parameters
nthe node to delete
Returns

Definition at line 1680 of file roxml-internal.c.

void roxml_del_from_pool ( node_t root,
node_t n,
int  req_id 
)

pool node delete function

this function remove one node from a pool

Parameters
rootthe root of the tree
nthe node to remove
req_idthe pool id
Returns

Definition at line 817 of file roxml-internal.c.

void ROXML_INT roxml_del_std_node ( node_t n)

node deletion function

this function delete a standard node

Parameters
nthe node to delete
Returns

Definition at line 1735 of file roxml-internal.c.

void ROXML_INT roxml_del_tree ( node_t n)

internal function

This function delete a tree recursively

Parameters
nis one node of the tree
Returns
void see roxml_close

Definition at line 141 of file roxml-internal.c.

void ROXML_INT roxml_del_txt_node ( node_t n)

text node deletion function

this function delete a text node

Parameters
nthe node to delete
Returns

Definition at line 1715 of file roxml-internal.c.

int ROXML_INT roxml_double_cmp ( double  a,
double  b,
int  op 
)

double comparison function

this function compare two doubles using one defined operator

Parameters
afirst operand
bsecond operand
opthe operator to use
Returns
1 if comparison is ok, esle 0

Definition at line 567 of file roxml-internal.c.

double ROXML_INT roxml_double_oper ( double  a,
double  b,
int  op 
)

double operation function

this function compare two doubles using one defined operator

Parameters
afirst operand
bsecond operand
opthe operator to use
Returns
1 if comparison is ok, esle 0

Definition at line 553 of file roxml-internal.c.

node_t** roxml_exec_xpath ( node_t root,
node_t n,
xpath_node_t xpath,
int  index,
int *  count 
)

real xpath execution

this function exec a decoded xpath strcuture

Parameters
rootthe root of the tree
nthe context node
xpaththe xpath structure
indexthe number of xpath condition in string
countthe pointer to a variable that is filled with the resulting node number
Returns
the resulting node set that have to be freed with roxml_release

Definition at line 1245 of file roxml-internal.c.

void ROXML_INT roxml_free_node ( node_t n)

internal function

This function delete a node without handling its tree

Parameters
nis one node of the tree
Returns
void

Definition at line 107 of file roxml-internal.c.

void ROXML_INT roxml_free_xcond ( xpath_cond_t xcond)

xpath condition free function

this function frees an xpath_cond_t cell

Parameters
xcondthe xcond to free
Returns

Definition at line 527 of file roxml-internal.c.

void ROXML_INT roxml_free_xpath ( xpath_node_t xpath,
int  nb 
)

xpath free function

this function frees the parsed xpath structure

Parameters
xpaththe xpath to free
nbthe number of xpath structures in the table
Returns

Definition at line 538 of file roxml-internal.c.

int ROXML_INT roxml_get_node_internal_position ( node_t n)

node absolute position get

this function returns the absolute position of the node between siblings

Parameters
nthe node
Returns
the absolute position starting at 1

Definition at line 431 of file roxml-internal.c.

int ROXML_INT roxml_in_pool ( node_t root,
node_t n,
int  req_id 
)

node pool presence tester function

this function test is a node is in a pool

Parameters
rootthe root of the tree
nthe node to test
req_idthe pool id
Returns

Definition at line 768 of file roxml-internal.c.

int roxml_is_number ( char *  input)

number tester

This function tells if a string is a number

Parameters
inputstring to test
Returns
1 if the string was a number else 0

Definition at line 152 of file roxml-internal.c.

int ROXML_INT roxml_is_separator ( char  sep)

separator tester

This function tells if a char is a string separator

Parameters
sepchar to test
Returns
1 if the char was a separator else 0

Definition at line 171 of file roxml-internal.c.

node_t ROXML_INT* roxml_load ( node_t current_node,
FILE *  file,
char *  buffer 
)

generic load function

This function load a document and all the corresponding nodes file and buffer params are exclusive. You usualy want to load either a file OR a buffer

Parameters
current_nodethe XML root
filefile descriptor of document
bufferaddress of buffer that contains xml
Returns
the root node or NULL see roxml_close

Definition at line 228 of file roxml-internal.c.

node_t ROXML_INT* roxml_lookup_nsdef ( node_t nsdef,
char *  ns 
)

name space lookup in list

this function look for requested name space in nsdef list

Parameters
nsdefthe nsdef list
nsthe namespace to find
Returns
the nsdef node or NULL

Definition at line 327 of file roxml-internal.c.

void ROXML_INT* roxml_malloc ( int  size,
int  num,
int  type 
)

alloc memory function

this function allocate some memory that will be reachable at any time by libroxml memory manager

Parameters
sizethe size of memory to allocate for each elem
numthe number of element
typethe kind of pointer

Definition at line 38 of file roxml-internal.c.

node_t ROXML_INT* roxml_parent_node ( node_t parent,
node_t n,
int  position 
)

node relocate function

this function change the position of a node in its parent list

Parameters
parentthe parent node
nthe node to parent
positionthe position, 0 means or > nb children means at the end
Returns

Definition at line 1360 of file roxml-internal.c.

int ROXML_INT roxml_parse_xpath ( char *  path,
xpath_node_t **  xpath,
int  context 
)

xpath parsing function

this function convert an xpath string to a table of list of xpath_node_t

Parameters
paththe xpath string
xpaththe parsed xpath
context0 for a real xpath, 1 for a xpath in predicat
Returns
the number of xpath list in the table

Definition at line 455 of file roxml-internal.c.

void ROXML_INT roxml_print_space ( FILE *  f,
char **  buf,
int *  offset,
int *  len,
int  lvl 
)

space printing function

this function add some space to output when committing change in human format

Parameters
fthe file pointer if any
bufthe pointer to string if any
offsetthe current offset in stream
lenthe total len of buffer if any
lvlthe level in the tree
Returns

Definition at line 1423 of file roxml-internal.c.

void ROXML_INT roxml_process_begin_node ( roxml_load_ctx_t context,
int  position 
)

node creation during parsing

this function create a new node upon finding new opening sign. It closes previous node if necessary

Parameters
contextthe parsing context
positionthe position in the file
Returns

Definition at line 207 of file roxml-internal.c.

void ROXML_INT roxml_process_unaliased_ns ( roxml_load_ctx_t context)

namespace without alias name creation during parsing

this function create a new namespace without alias (default ns or remove ns)

Parameters
contextthe parsing context
Returns

Definition at line 184 of file roxml-internal.c.

int ROXML_INT roxml_read ( int  pos,
int  size,
char *  buffer,
node_t node 
)

read xml doc function

this function read inside a xml doc (file or buffer) and fill the given buffer

Parameters
posthe pos in the xml document
sizethe size of the data to read
bufferthe destination buffer
nodethe node that belong to the tree we want to read to
Returns
the number of bytes read

Definition at line 59 of file roxml-internal.c.

void ROXML_INT roxml_release_id ( node_t root,
node_t **  pool,
int  pool_len,
int  req_id 
)

release id function

this function release a previously required id and remove all id token from the pool

Parameters
rootthe root of the tree that was used for id request
poolthe result from xpath search using this id
pool_lenthe number of node in pool
req_idthe id to release
Returns

Definition at line 798 of file roxml-internal.c.

int ROXML_INT roxml_request_id ( node_t root)

id reservation function

this function request an available id for a new xpath search on the tree

Parameters
rootthe root of the tree where id table is stored
Returns
the id between 1 - 255 or -1 if failed

Definition at line 745 of file roxml-internal.c.

void ROXML_INT roxml_reset_ns ( node_t n,
node_t ns 
)

internal function

This function remove the namespace of a node if it is the one specified as argument, and replace it with its parent one

Parameters
nis one node of the tree
nsis one nsdef of the tree
Returns
void

Definition at line 1646 of file roxml-internal.c.

xpath_node_t ROXML_INT* roxml_set_axes ( xpath_node_t node,
char *  axes,
int *  offset 
)

axes setter function

this function set the axe to a xpath node from xpath string

Parameters
nodethe xpath node to fill
axesthe string where axe is extracted from
offsetthe detected offset in axe string
Returns
the filled xpath_node

Definition at line 352 of file roxml-internal.c.

void ROXML_INT roxml_set_type ( node_t n,
int  type 
)

node type setter function

this function change the type of a node

Parameters
nthe node to modify
typethe new type to set
Returns

Definition at line 346 of file roxml-internal.c.

int ROXML_INT roxml_string_cmp ( char *  sa,
char *  sb,
int  op 
)

string comparison function

this function compare two strings using one defined operator

Parameters
safirst operand
sbsecond operand
opthe operator to use
Returns
1 if comparison is ok, else 0

Definition at line 585 of file roxml-internal.c.

int ROXML_INT roxml_validate_axes ( node_t root,
node_t candidat,
node_t ***  ans,
int *  nb,
int *  max,
xpath_node_t xn,
int  req_id 
)

axe validation function

this function validate if an axe is matching the current node

Parameters
rootthe root node
candidatthe node to test
ansthe pointer to answers pool
nbthe number of answers in pool
maxthe current size of the pool
xnthe xpath node to test
req_idthe pool id
Returns
1 if axe is validated, else 0

Definition at line 888 of file roxml-internal.c.

int ROXML_INT roxml_validate_predicat ( xpath_node_t xn,
node_t candidat 
)

predicat validation function

this function check for predicat validity. predicat is part between brackets

Parameters
xnthe xpath node containing the predicat to test
candidatthe node to test
Returns
1 if predicat is validated, else 0

Definition at line 607 of file roxml-internal.c.

void ROXML_INT roxml_write_node ( node_t n,
FILE *  f,
char **  buf,
int  human,
int  lvl,
int *  offset,
int *  len 
)

tree write function

this function write each node of the tree to output

Parameters
nthe node to write
fthe file pointer if any
bufthe pointer to the buffer string if any
human1 to use the human format else 0
lvlthe current level in tree
offsetthe current offset in stream
lenthe total len of buffer if any
Returns

Definition at line 1468 of file roxml-internal.c.

void ROXML_INT roxml_write_string ( char **  buf,
FILE *  f,
char *  str,
int *  offset,
int *  len 
)

string writter function

this function write a string to output when committing change

Parameters
fthe file pointer if any
bufthe pointer to string if any
strthe string to write
offsetthe current offset in stream
lenthe total len of buffer if any
Returns

Definition at line 1448 of file roxml-internal.c.