Functions | Variables

src/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_INT roxml_malloc (int size, int num, int type)
 alloc memory function
node_t *ROXML_INT roxml_create_node (int pos, void *src, int type)
 internal function
void ROXML_INT roxml_close_node (node_t *n, node_t *close)
 internal function
void ROXML_INT roxml_free_node (node_t *n)
 internal function
void ROXML_INT roxml_del_tree (node_t *n)
 internal function
void ROXML_INT roxml_process_begin_node (roxml_load_ctx_t *context, int position)
 node creation during parsing
node_t *ROXML_INT roxml_load (node_t *current_node, FILE *file, char *buffer)
 generic load function
void ROXML_INT roxml_set_type (node_t *n, int type)
 node type setter function
xpath_node_t *ROXML_INT roxml_set_axes (xpath_node_t *node, char *axes, int *offset)
 axes setter function
int ROXML_INT roxml_get_node_internal_position (node_t *n)
 node absolute position get
int ROXML_INT roxml_parse_xpath (char *path, xpath_node_t **xpath, int context)
 xpath parsing function
void ROXML_INT roxml_free_xcond (xpath_cond_t *xcond)
 xpath condition free function
void ROXML_INT roxml_free_xpath (xpath_node_t *xpath, int nb)
 xpath free function
double ROXML_INT roxml_double_oper (double a, double b, int op)
 double operation function
int ROXML_INT roxml_double_cmp (double a, double b, int op)
 double comparison function
int ROXML_INT roxml_validate_predicat (xpath_node_t *xn, node_t *candidat)
 predicat validation function
int ROXML_INT roxml_request_id (node_t *root)
 id reservation function
int ROXML_INT roxml_in_pool (node_t *root, node_t *n, int req_id)
 node pool presence tester function
void ROXML_INT roxml_release_id (node_t *root, node_t **pool, int pool_len, int req_id)
 release id function
void roxml_del_from_pool (node_t *root, node_t *n, int req_id)
 pool node delete function
int ROXML_INT roxml_add_to_pool (node_t *root, node_t *n, int req_id)
 add a token top node function
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
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
void ROXML_INT roxml_parent_node_at (node_t *parent, node_t *n, int position)
 node relocate function
void ROXML_INT roxml_print_space (FILE *f, char **buf, int *offset, int *len, int lvl)
 space printing function
void ROXML_INT roxml_write_string (char **buf, FILE *f, char *str, int *offset, int *len)
 string writter function
void ROXML_INT roxml_write_node (node_t *n, FILE *f, char *buf, int human, int lvl, int *offset, int *len)
 tree write function
void ROXML_INT roxml_del_arg_node (node_t *n)
 attribute node deletion function
void ROXML_INT roxml_del_txt_node (node_t *n)
 text node deletion function
void ROXML_INT roxml_del_std_node (node_t *n)
 node deletion function
node_troxml_parent_node (node_t *parent, node_t *n)
 internal function
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
void roxml_compute_or (node_t *root, node_t **node_set, int *count, int req_id, int glob_id)
 node set or function
node_t ** roxml_exec_xpath (node_t *root, node_t *n, xpath_node_t *xpath, int index, int *count)
 real xpath execution

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 <blunderer@blunderer.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.

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:
root the root node
n the node to mark
req_id the id to use
Returns:
0 if already in the pool, else 1

Definition at line 638 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:
xp the xpath nodes to test
root the root node
context the current context node
ans the pointer to answers pool
nb the number of answers in pool
max the current size of the pool
ignore a flag for some axes that are going thru all document  
req_id the pool id
Returns:

Definition at line 772 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:
n is the node to close
close is the node that close node n
Returns:
void

Definition at line 65 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:
root the root of the tree
node_set the node set containing the 2 pools
count number of node in the node set
cur_req_id the id of the first group
prev_req_id the id of the second group

Definition at line 1220 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:
root the root of the tree
node_set the node set containing the 2 pools
count number of node in the node set
req_id the id of the first group
glob_id the id of the second group
Returns:

Definition at line 1235 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:
pos is the beginning offset of the node in the file
src is the pointer to the buffer or file
type is the type of node between arg and val
Returns:
the new node

Definition at line 54 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:
n the node to delete
Returns:

Definition at line 1139 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:
root the root of the tree
n the node to remove
req_id the pool id
Returns:

Definition at line 613 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:
n the node to delete
Returns:

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

void ROXML_INT roxml_del_tree ( node_t n  ) 

internal function

This function delete a tree recursively

Parameters:
n is one node of the tree
Returns:
void see roxml_close

Definition at line 104 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:
n the node to delete
Returns:

Definition at line 1153 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:
a first operand
b second operand
op the operator to use
Returns:
1 if comparison is ok, esle 0

Definition at line 419 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:
a first operand
b second operand
op the operator to use
Returns:
1 if comparison is ok, esle 0

Definition at line 405 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:
root the root of the tree
n the context node
xpath the xpath structure
index the number of xpath condition in string
count the 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 1247 of file roxml-internal.c.

void ROXML_INT roxml_free_node ( node_t n  ) 

internal function

This function delete a node

Parameters:
n is one node of the tree
Returns:
void

Definition at line 81 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:
xcond the xcond to free
Returns:

Definition at line 379 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:
xpath the xpath to free
nb the number of xpath structures in the table
Returns:

Definition at line 390 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:
n the node
Returns:
the absolute position starting at 1

Definition at line 296 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:
root the root of the tree
n the node to test
req_id the pool id
Returns:

Definition at line 578 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_node the XML root
file file descriptor of document
buffer address of buffer that contains xml
Returns:
the root node or NULL see roxml_close

Definition at line 132 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:
size the size of memory to allocate for each elem
num the number of element
type the kind of pointer

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

node_t* roxml_parent_node ( node_t parent,
node_t n 
)

internal function

This function give a node to its parent and the parent to the node

Parameters:
parent is the parent node
n is one orphan node of the tree
Returns:
the parented node

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

void ROXML_INT roxml_parent_node_at ( node_t parent,
node_t n,
int  position 
)

node relocate function

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

Parameters:
parent the parent node
n the node to parent
position the position, 0 means or > nb children means at the end
Returns:

Definition at line 933 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:
path the xpath string
xpath the parsed xpath
context 0 for a real xpath, 1 for a xpath in predicat
Returns:
the number of xpath list in the table

Definition at line 317 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:
f the file pointer if any
buf the pointer to string if any
offset the current offset in stream
len the total len of buffer if any
lvl the level in the tree
Returns:

Definition at line 998 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:
context the parsing context
position the position in the file
Returns:

Definition at line 114 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:
root the root of the tree that was used for id request
pool the result from xpath search using this id
pool_len the number of node in pool
req_id the id to release
Returns:

Definition at line 601 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:
root the root of the tree where id table is stored
Returns:
the id between 1 - 255 or -1 if failed

Definition at line 554 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:
node the xpath node to fill
axes the string where axe is extracted from
offset the detected offset in axe string
Returns:
the filled xpath_node

Definition at line 195 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:
n the node to modify
type the new type to set
Returns:

Definition at line 189 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:
root the root node
candidat the node to test
ans the pointer to answers pool
nb the number of answers in pool
max the current size of the pool
xn the xpath node to test
req_id the pool id
Returns:
1 if axe is validated, else 0

Definition at line 672 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:
xn the xpath node containing the predicat to test
candidat the node to test
Returns:
1 if predicat is validated, else 0

Definition at line 437 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:
n the node to write
f the file pointer if any
buf the pointer to string if any
human 1 to use the human format else 0
lvl the current level in tree
offset the current offset in stream
len the total len of buffer if any
Returns:

Definition at line 1025 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:
f the file pointer if any
buf the pointer to string if any
str the string to write
offset the current offset in stream
len the total len of buffer if any
Returns:

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