Main Page   Data Structures   File List   Data Fields   Globals  

tree.c File Reference

Tree operations. More...


Functions

air_xml_node_tair_xml_node_alloc_by_name (ualloc_t *ua, char *name)
air_err_t air_xml_node_destroy (air_xml_node_t *n)
void print_tree_inner (air_xml_node_t *node, int parent_type, int cnt, int flags)
void air_xml_tree_print (air_xml_node_t *node, int flags)
air_err_t air_xml_node_attr_name2index (air_xml_node_t *node, air_xml_node_attr_name_t a_name, air_xml_node_attr_id_t *index)
int air_xml_have_snml ()
 Determine if this build of libair supports the SNML DTD. More...

int air_xml_have_idmef ()
 Determine if this build of libair supports the IDMEF DTD. More...

int air_xml_have_iodef ()
 Determine if this build of libair supports the IODEF DTD. More...

int air_xml_have_config ()
 Determine if this build of libair supports the aircert-config DTD. More...

air_err_t air_xml_tree_module_init (ualloc_t *ua)
 Initializes the air_xml module. More...

air_err_t air_xml_tree_get_last_error (air_xml_tree_t *t)
 Returns the last error that occurred on the given tree. More...

air_err_t air_xml_tree_destroy (air_xml_tree_t *t)
 Deallocates a tree. More...

air_err_t air_xml_tree_get_root (air_xml_tree_t *t, air_xml_node_t **root_node)
 Returns the root node of the tree. More...

air_err_t air_xml_tree_count_nodes (air_xml_tree_t *t, unsigned int *cnt)
 Returns the number of nodes in the tree. More...

char * air_xml_tree_type2str (air_xml_schema_type_t name_en)
 returns the string equivalent of a tree type. More...

air_xml_schema_type_t air_xml_tree_str2type (char *name_str)
 returns the enumerated ID equivalent of a tree type specified as a string name. More...

air_err_t air_xml_tree_dup (air_xml_tree_t *src, air_xml_tree_t **dst)
 makes an identical copy of a tree. More...

air_err_t air_xml_node_dup (ualloc_t *ua, air_xml_node_t *src_node, air_xml_node_t **dst_node, int mode)
air_err_t air_xml_node_replicate (air_xml_node_t *source_node, air_xml_node_t **target_node, int method)
air_err_t air_xml_node_create (air_xml_node_t *source_node, air_xml_node_t **new_node)
 Creates a new node (another instance of an element) and links it as the sibling of the source node. More...

air_err_t air_xml_node_erase (air_xml_node_t **node)
 Removes a node from the tree. More...

air_err_t air_xml_node_isset (air_xml_node_t *n)
 Checks if the node is set. More...

air_err_t air_xml_node_attr_isset_by_name (air_xml_node_t *n, air_xml_node_attr_name_t attr_name)
 Returns whether the given attribute (specified by name) is set. More...

air_err_t air_xml_node_set (air_xml_node_t *node)
 explicitly mark a node as set. More...

air_err_t air_xml_node_unset (air_xml_node_t *node)
 explicitly mark a node as unset. More...

air_err_t air_xml_tree_walk_by_path (air_xml_node_t *root_node, char *path, air_xml_node_t **node)
 Finds a given node in the tree specified by a path. More...

air_err_t air_xml_tree_walk_by_path2 (air_xml_node_t *root_node, char *path, air_xml_node_t **node)
 Identical in functionality as air_xml_tree_walk_by_path(), but this routine will return the node even if it is not set. More...

air_err_t air_xml_tree_walk_by_path_inner (air_xml_node_t *root_node, char *path, air_xml_node_t **node, air_flags_t flags)
air_err_t air_xml_tree_isset (air_xml_tree_t *tree, char *path)
 Returns whether the entity (be it a node or attribute) specified by the path is set. More...

air_xml_node_attr_name_t air_xml_path_get_lattr (air_ualloc_t *ua, char *path)
air_asciz_t air_xml_path_get_parent (air_ualloc_t *ua, char *path)
air_asciz_t air_xml_path_get_lnode (air_ualloc_t *ua, char *path)
int air_xml_path_get_lnode_count (air_ualloc_t *ua, char *path)
air_err_t air_xml_tree_get_inner (air_xml_tree_t *tree, char *path, air_asciz_t *node_data, air_size_t *data_size, air_flags_t mode)
air_err_t air_xml_tree_get (air_xml_tree_t *tree, char *path, air_asciz_t *node_data, air_size_t *data_size)
 Returns the node or attribute value specified by the path. More...

air_err_t air_xml_tree_get_value (air_xml_tree_t *tree, char *path, air_asciz_t *node_data, air_size_t *data_size)
 Returns the node value specified by the path. More...

air_err_t air_xml_tree_attr_get_by_name (air_xml_tree_t *tree, char *path, air_asciz_t *attr_value, air_size_t *attr_size)
 Returns the attribute value specified by the path. More...

air_err_t air_xml_tree_set_inner (air_xml_tree_t *tree, char *path, air_asciz_t node_data, air_size_t *data_size, air_flags_t mode)
air_err_t air_xml_tree_set (air_xml_tree_t *tree, char *path, air_asciz_t data, air_size_t *data_size)
 Sets the value of a node or attribute specified by the path. More...

air_err_t air_xml_tree_set2 (air_xml_tree_t *tree, char *path, air_asciz_t data, air_size_t *data_size)
air_err_t air_xml_tree_set_value (air_xml_tree_t *tree, char *path, air_asciz_t data, air_size_t *data_size)
 Sets the value of a node specified by the path. More...

air_err_t air_xml_tree_attr_set_by_name (air_xml_tree_t *tree, char *path, air_asciz_t data, air_size_t *data_size)
 Sets the value of an attribute specified by the path. More...

air_err_t air_xml_node_expand_recursive (air_xml_node_t **n)
air_err_t air_xml_node_get_child (air_xml_node_t *n, air_xml_node_type_t node_type, int nth, air_xml_node_t **rez, air_flags_t flags)
 Gets a given child node of the current node. More...

air_err_t air_xml_node_get_parent (air_xml_node_t *n, air_xml_node_t **parent_node)
 Gets the parent node of the current node. More...

air_err_t air_xml_node_get_index (air_xml_node_t *n, air_size_t *out_count)
air_err_t air_xml_node_get_sibling_count (air_xml_node_t *n, air_size_t *out_count)
air_err_t air_xml_node_get_sibling (air_xml_node_t *n, air_size_t idx)
air_err_t air_xml_node_get_first_sibling (air_xml_node_t *n, air_xml_node_t **out_sib)
 get the first sibling of a node. More...

air_err_t air_xml_node_get_next_sibling (air_xml_node_t *n, air_xml_node_t **out_sib)
 get a sibling. More...

air_err_t air_xml_node_get_tree (air_xml_node_t *n, air_xml_tree_t **tree)
 Gets the tree of the current node. More...

air_err_t air_xml_node_get_value (air_xml_node_t *source_node, air_asciz_t *node_data, air_size_t *data_size)
 Extracts the PCDATA of a particular tree node (i.e., xml element). More...

air_err_t air_xml_node_attr_get_by_name (air_xml_node_t *source_node, air_xml_node_attr_name_t attr_name, air_asciz_t *attr_value, air_size_t *attr_size)
 Extracts an attribute value specified by name from a node (i.e., xml element). More...

air_err_t air_xml_node_attr_get_by_index (air_xml_node_t *source_node, air_xml_node_attr_id_t attr_id, air_asciz_t *attr_value, air_size_t *attr_size)
 Extracts an attribute value specified by its order in the attribute list of a node (i.e., xml element). More...

air_err_t air_xml_node_set_value (air_xml_node_t *target_node, air_asciz_t data_value, air_size_t *data_size)
 Sets the PCDATA of a particular tree node (i.e., xml element). More...

air_err_t air_xml_node_append_value (air_xml_node_t *target_node, air_asciz_t data_value, air_size_t *data_size)
 Appends new PCDATA to a particular tree node (i.e., xml element). More...

air_err_t air_xml_node_attr_set_by_name (air_xml_node_t *target_node, air_xml_node_attr_name_t attr_name, air_asciz_t attr_value, air_size_t *data_size)
 Sets an attribute value specified by name on a node (i.e., xml element). More...

air_err_t air_xml_node_attr_set_by_index (air_xml_node_t *target_node, air_xml_node_attr_id_t attr_id, air_asciz_t attr_value, air_size_t *data_size)
 Sets an attribute value specified by index on a node (i.e., xml element). More...

air_err_t air_xml_node_get_type (air_xml_node_t *n, air_xml_node_type_t *out_type)
 returns the type of a given node. More...

char * air_xml_node_type2str (air_xml_node_type_en name_en)
 returns the string equivalent of a node type (element name). More...

air_xml_node_type_en air_xml_node_str2type (char *name_str)
 returns the enumerated ID equivalent of a node type (element name) specified as a string name. More...

air_asciz_t air_xml_node_path (air_xml_node_t *n, air_flags_t flags)
 path to given node from the root of the tree. More...

air_err_t air_xml_iter_create (air_xml_node_t *node, air_xml_iter_t **iter)
air_err_t air_xml_iter_free (air_xml_iter_t *iter)
air_err_t air_xml_iter_reset (air_xml_iter_t *iter)
void air_xml_iter_set_type (air_xml_iter_t *iter, air_xml_node_type_en type)
void air_xml_iter_clear_type (air_xml_iter_t *iter)
air_err_t air_xml_iter_next (air_xml_iter_t *iter, air_xml_node_t **child)
air_err_t ih_node_attr_iter_create (air_xml_node_t *node, ih_node_attr_iter_t **iter)
 Creates a new node attribute iterator. More...

air_err_t ih_node_attr_iter_next (ih_node_attr_iter_t **iter, air_xml_node_attr_name_t *attr_name, air_xml_node_data_t *attr_value, air_size_t *data_size)
 Gets the next attribute in the iterated through node. More...

air_err_t ih_node_attr_iter_free (ih_node_attr_iter_t **iter)
 Deallocates an node attribute iterator. More...

air_err_t ih_tree_iter_create (air_xml_node_t *root_node, ih_tree_iter_t **iter)
 Creates a new tree iterator. More...

air_err_t ih_tree_iter_next (ih_tree_iter_t **iter, air_xml_node_t **node)
 Gets the next node in the tree. More...

air_err_t ih_tree_iter_free (ih_tree_iter_t **iter)
 Deallocates a tree iterator. More...


Variables

char * air_xml_tree_node_name []
char * air_xml_tree_schema_type_name []


Detailed Description

Tree operations.

The internal representation of an XML document is a tree structure (air_xml_tree_t) composed of nodes corresponding to XML elements (air_xml_node_t).


Function Documentation

int air_xml_have_snml  
 

Determine if this build of libair supports the SNML DTD.

Returns:
1 if this build supports SNML, 0 otherwise.

int air_xml_have_idmef  
 

Determine if this build of libair supports the IDMEF DTD.

Returns:
1 if this build supports IDMEF, 0 otherwise.

int air_xml_have_iodef  
 

Determine if this build of libair supports the IODEF DTD.

Returns:
1 if this build supports IODEF, 0 otherwise.

int air_xml_have_config  
 

Determine if this build of libair supports the aircert-config DTD.

Returns:
1 if this build supports aircert-config, 0 otherwise.

air_err_t air_xml_tree_module_init ualloc_t *    ua
 

Initializes the air_xml module.

Provides the air_xml module an air ualloc context for memory allocation. Presently a no-op, because ualloc contexts are bound to each air XML tree at creation time.

Parameters:
ua  memory allocator
Returns:
status of the operation
Return values:
AIR_E_NONE  no error

air_err_t air_xml_tree_get_last_error air_xml_tree_t   t
 

Returns the last error that occurred on the given tree.

Parameters:
t  the tree
Returns:
the last error which occurred on the tree, or AIR_E_NULL if the given tree is null.

air_err_t air_xml_tree_destroy air_xml_tree_t   t
 

Deallocates a tree.

Parameters:
t  tree to deallocate
See also:
air_xml_tree_create
Returns:
status of the operation
Return values:
AIR_E_NONE  no error

air_err_t air_xml_tree_get_root air_xml_tree_t   t,
air_xml_node_t **    root_node
 

Returns the root node of the tree.

Parameters:
t  tree
root_node  root node of the tree
Returns:
status of the operation
Return values:
AIR_E_NONE  no error
AIR_E_NULL  a NULL tree was passed

air_err_t air_xml_tree_count_nodes air_xml_tree_t   t,
unsigned int *    cnt
 

Returns the number of nodes in the tree.

Parameters:
t  tree
cnt  number of nodes in the tree
Returns:
status of the operation
Return values:
AIR_E_NONE  no error

char* air_xml_tree_type2str air_xml_schema_type_t    name_en
 

returns the string equivalent of a tree type.

Parameters:
name_en  enumerated ID of a tree type
See also:
air_xml_tree_type2str
Returns:
name of tree type as a string, or the string "??unknown??" if the enum ID is unknown

air_xml_schema_type_t air_xml_tree_str2type char *    name_str
 

returns the enumerated ID equivalent of a tree type specified as a string name.

Parameters:
name_str  tree type as a string
See also:
air_xml_tree_str2type
Returns:
type of tree as a string, -1 if the tree type is not found

air_err_t air_xml_tree_dup air_xml_tree_t   src,
air_xml_tree_t **    dst
 

makes an identical copy of a tree.

Note: a new copy of the air_ualloc_t of the source is not made. The new copy and the original tree will both point to the identical ualloc_t structure.

Parameters:
src  (IN) tree to copy
dst  (OUT) new copy of the tree
Returns:
status of the operation

air_err_t air_xml_node_dup ualloc_t *    ua,
air_xml_node_t   src_node,
air_xml_node_t **    dst_node,
int    mode
 

air_xml_node_dup() Internal function that duplicates a given node (and all of its attributes and children). Depending on the value of mode; the actual contents of attributes and the node will be copied,

  • AIR_XML_TREE_DUP_NEW: do not copy attribute data or element contents
  • AIR_XML_TREE_DUP_CLONE: copy all attribute and element contents

air_err_t air_xml_node_create air_xml_node_t   source_node,
air_xml_node_t **    new_node
 

Creates a new node (another instance of an element) and links it as the sibling of the source node.

Parameters:
source_node  node to create a new instance of
new_node  new node
See also:
air_xml_node_create air_xml_node_erase
Returns:
status of the operation
Return values:
AIR_E_NONE  no error
AIR_E_NULL  unexpected NULL value
AIR_E_NOMEM  memory allocation failure
AIR_E_XML_ROOT  a root node was passed for duplication, but roots cannot be duplicated
AIR_E_XML_BAD_CARDINALITY  violation of DTD occurance indicator constraints

air_err_t air_xml_node_erase air_xml_node_t **    node
 

Removes a node from the tree.

Parameters:
node  node to remove from the tree
NOTE: This function is presently unimplemented.

See also:
air_xml_node_create air_xml_node_erase
Returns:
status of the operation

air_err_t air_xml_node_isset air_xml_node_t   n
 

Checks if the node is set.

Parameters:
n  node to check
Returns:
status of the operation
Return values:
AIR_E_NULL  null node
AIR_E_SET  node is set
AIR_E_NOT_SET  node is not set

air_err_t air_xml_node_attr_isset_by_name air_xml_node_t   n,
air_xml_node_attr_name_t    attr_name
 

Returns whether the given attribute (specified by name) is set.

Parameters:
n  (IN) node to check attr_name (IN) attribute name to check
Returns:
status of the operation
Return values:
AIR_E_NULL  null node
AIR_E_SET  attribute is set
AIR_E_NOT_SET  attribute is not set
AIR_E_XML_BAD_ATTR_NAME  invalid attribute name

air_err_t air_xml_node_set air_xml_node_t   node
 

explicitly mark a node as set.

Parameters:
node  the node to set
Returns:
the status of the operation
Return values:
AIR_E_NONE  no error
AIR_E_NULL  node is NULL

air_err_t air_xml_node_unset air_xml_node_t   node
 

explicitly mark a node as unset.

Parameters:
node  the node to unset
Returns:
the status of the operation
Return values:
AIR_E_NONE  no error
AIR_E_NULL  node is NULL

air_err_t air_xml_tree_walk_by_path air_xml_node_t   root_node,
char *    path,
air_xml_node_t **    node
 

Finds a given node in the tree specified by a path.

/<node_name>/<node_name>[(<sequence>) | :<attribute>[=<value>]][<attribute>]

An air XML path is similar to an XML XPath. It consists of a string composed of node names seperated by a deliminator ('/'). Consider the following document:

       <foo>
          <a>
            <d> </d>
            <b>
              <c> </c>
            </b>
          </a>
       </foo> 

A path of "/foo/a/b/c" will traverse foo->a->b->c and return node "c". Since the previous path started with a "/", traversal of the tree started at the root. Relative paths from the specified node are also acceptable (e.g., "a/b/c").

Since it is possible for multiple nodes to appear a sequence primitive is supported ( '(number)' ). This sequence primitive counts from one. Consider the following document:

       <foo>
          <a z="yyy">
            <d> </d>
            <b>
              <c> slot 1 </c>
            </b>
            <b>
              <c> slot 2 </c>
            </b>
          </a>
       </foo> 

A root_node = foo and a path of "a/b(2)/c" will return the the "c" node with the data "slot 2".

The special sequence primitive '(n)' is supported, and resolves to the last node having the given path; the path "a/b(n)/c" is equivalent to the example above.

This notation also supports specifying an attribute using the '@' symbol. For example, the path "/foo/a@z" specifies the 'z' attribute of the 'a' element.

Primitive attribute and value matching is also possible. For example,

  • "/foo/a:z=yyy/d" : return the node found at the path "/foo/a/d" only when the "a" node has an attribute "z" with a value of "yyy"
  • "/foo/a:z=xxx/d" : returns an AIR_E_XML_BAD_PATH, because the "a" node does not have an "a" attribute with value "zzz"
  • "/foo/a:z/d" : returns the node found at path "/foo/a/d" only when the "a" node has some value set for attribute "z"
Parameters:
root_node  node from which to start the traversal
path  path to desired node
node  node at the end of the path
Returns:
status of the operation
Return values:
AIR_E_NONE  no error
AIR_E_NULL  null node given
AIR_E_XML_BAD_PATH  invalid path (no such node was found using only set nodes)
AIR_E_XML_NULL_PATH  empty path given

air_err_t air_xml_tree_walk_by_path2 air_xml_node_t   root_node,
char *    path,
air_xml_node_t **    node
 

Identical in functionality as air_xml_tree_walk_by_path(), but this routine will return the node even if it is not set.

Parameters:
root_node  node from which to start the traversal
path  path to desired node
node  node at the end of the path
See also:
air_xml_tree_walk_by_path
Returns:
status of the operation
Return values:
AIR_E_NONE  no error
AIR_E_NULL  null node given
AIR_E_XML_BAD_PATH  invalid path (no such node)
AIR_E_XML_NULL_PATH  empty path given

air_err_t air_xml_tree_isset air_xml_tree_t   tree,
char *    path
 

Returns whether the entity (be it a node or attribute) specified by the path is set.

Parameters:
tree  tree
path  path to the entity whose isset value should be checked
Returns:
status of the operation
Return values:
AIR_E_SET  isset
AIR_E_NOT_SET  not set or other error
AIR_E_XML_NULL_PATH  empty path given
AIR_E_XML_NULL_TREE  null tree given

air_err_t air_xml_tree_get air_xml_tree_t   tree,
char *    path,
air_asciz_t *    node_data,
air_size_t   data_size
 

Returns the node or attribute value specified by the path.

It is up to the caller to understand based on the specified path whether a node or attribute value has been specified.

Parameters:
tree  tree
path  t path to the data to extract
node_data  extracted node data
data_size  IN: size allocated for the value; or if set to 0, then this routine allocates the memory OUT: size used for the value
Returns:
status of the operation
Return values:
AIR_E_NONE  no error
AIR_E_XML_NULL_TREE  null tree given
AIR_E_XML_NULL_PATH  null path given
AIR_E_XML_NO_ROOT  no root element exists in the tree
AIR_E_XML_BAD_PATH  invalid path (no such node)

air_err_t air_xml_tree_get_value air_xml_tree_t   tree,
char *    path,
air_asciz_t *    node_data,
air_size_t   data_size
 

Returns the node value specified by the path.

Parameters:
tree  tree
path  t path to the data to extract
node_data  extracted node data
data_size  IN: size allocated for the value; or if set to 0, then this routine allocates the memory OUT: size used for the value
Returns:
status of the operation
Return values:
AIR_E_NONE  no error
AIR_E_XML_NULL_TREE  null tree given
AIR_E_XML_NULL_PATH  null path given
AIR_E_XML_NO_ROOT  no root element exists in the tree
AIR_E_XML_BAD_PATH  invalid path (no such node)

air_err_t air_xml_tree_attr_get_by_name air_xml_tree_t   tree,
char *    path,
air_asciz_t *    attr_value,
air_size_t   attr_size
 

Returns the attribute value specified by the path.

Parameters:
tree  tree
path  t path to the node/attribute to extract
node_data  extracted attribute data
data_size  IN: size allocated for the value; or if set to 0, then this routine allocates the memory OUT: size used for the value
Returns:
status of the operation
Return values:
AIR_E_NONE  no error
AIR_E_XML_NULL_TREE  null tree given
AIR_E_XML_NULL_PATH  null path given
AIR_E_XML_NO_ROOT  no root element exists in the tree
AIR_E_XML_BAD_PATH  invalid path (no such node)

air_err_t air_xml_tree_set air_xml_tree_t   tree,
char *    path,
air_asciz_t    data,
air_size_t   data_size
 

Sets the value of a node or attribute specified by the path.

It is up to the caller to understand based on the specified path whether a node or attribute value will be set.

Parameters:
tree  tree
path  t path to the node/attribute to assign
node_data  value to assign to the node/attribute
data_size  IN: size of the data; OUT: size copied into the node
Returns:
status of the operation
Return values:
AIR_E_NONE  no error
AIR_E_XML_NULL_TREE  null tree given
AIR_E_XML_NULL_PATH  null path given
AIR_E_XML_NO_ROOT  no root element exists in the tree
AIR_E_XML_BAD_PATH  invalid path (no such node)

air_err_t air_xml_tree_set_value air_xml_tree_t   tree,
char *    path,
air_asciz_t    data,
air_size_t   data_size
 

Sets the value of a node specified by the path.

Parameters:
tree  tree
path  t path to the node to assign
node_data  value to assign to the node
data_size  IN: size of the data; OUT: size copied into the node
Returns:
status of the operation
Return values:
AIR_E_NONE  no error
AIR_E_XML_NULL_TREE  null tree given
AIR_E_XML_NULL_PATH  null path given
AIR_E_XML_NO_ROOT  no root element exists in the tree
AIR_E_XML_BAD_PATH  invalid path (no such node)

air_err_t air_xml_tree_attr_set_by_name air_xml_tree_t   tree,
char *    path,
air_asciz_t    data,
air_size_t   data_size
 

Sets the value of an attribute specified by the path.

Parameters:
tree  tree
path  t path to the attribute to assign
node_data  value to assign to the attribute
data_size  IN: size of the data; OUT: size copied into the node
Returns:
status of the operation
Return values:
AIR_E_NONE  no error
AIR_E_XML_NULL_TREE  null tree given
AIR_E_XML_NULL_PATH  null path given
AIR_E_XML_NO_ROOT  no root element exists in the tree
AIR_E_XML_BAD_PATH  invalid path (no such node)

air_err_t air_xml_node_get_child air_xml_node_t   n,
air_xml_node_type_t    node_type,
int    nth,
air_xml_node_t **    rez,
air_flags_t    flags
 

Gets a given child node of the current node.

Parameters:
n  current node
node_type  type of the child node to retrieve
nth  the sequence number of the child node to retrive. This assumes that there can be multiple children of the same type. The first child is nth = 1.
rez  nth child of type node_type of n
flags  flags that modify the traversal behavior AIR_XML_F_EXPAND_RECURSIVE:
Returns:
status of the operation
Return values:
AIR_E_NONE  no error
AIR_E_NULL  null node given
AIR_E_XML_BAD_PATH  invalid path (no such node)

air_err_t air_xml_node_get_parent air_xml_node_t   n,
air_xml_node_t **    parent_node
 

Gets the parent node of the current node.

Parameters:
n  current node
node_data  returned parent node of the current node
Returns:
status of the operation
  • AIR_E_NONE no error
  • AIR_E_NULL null node given

air_err_t air_xml_node_get_first_sibling air_xml_node_t   n,
air_xml_node_t **    out_sib
 

get the first sibling of a node.

Parameters:
n  node whose first sibling to get
out_sib  first sibling if any
Returns:
An air return code:
  • AIR_E_NONE: operation succeeded
  • AIR_E_NOT_FOUND: n has no siblings
  • AIR_E_XML_ROOT: it's the root, dummy
  • AIR_E_NULL: one of n or out_sib is NULL

air_err_t air_xml_node_get_next_sibling air_xml_node_t   n,
air_xml_node_t **    out_sib
 

get a sibling.

Parameters:
n  node whose sibling to get
out_sib  next sibling of n, if any
Returns:
A standard air return code:
  • AIR_E_NONE: operation succeeded
  • AIR_E_NOT_FOUND: n has no next sibling
  • AIR_E_XML_ROOT: n is the root of the tree and thus has no siblings
  • AIR_E_NULL: one of n or out_sib was NULL

air_err_t air_xml_node_get_tree air_xml_node_t   n,
air_xml_tree_t **    tree
 

Gets the tree of the current node.

Parameters:
n  current node
tree  returned tree
Returns:
status of the operation
Return values:
AIR_E_NONE  no error
AIR_E_NULL  null node given

air_err_t air_xml_node_get_value air_xml_node_t   source_node,
air_asciz_t *    node_data,
air_size_t   data_size
 

Extracts the PCDATA of a particular tree node (i.e., xml element).

Parameters:
source_node  node from which to extract the PCDATA
node_data  extracted node data
data_size  IN: size allocated for the value; or if set to 0, then this routine allocates the memory; if NULL, routine allocate memory for node_data OUT: size used for the value
See also:
air_xml_node_attr_get_by_name air_xml_node_attr_get_by_index
Returns:
status of the operation
Return values:
AIR_E_NONE  no error
AIR_E_NULL  null node or buffer given
AIR_E_NOT_SET  unset node
AIR_E_NOMEM  memory allocation failure
AIR_E_XML_NULL_DATA  empty data

air_err_t air_xml_node_attr_get_by_name air_xml_node_t   source_node,
air_xml_node_attr_name_t    attr_name,
air_asciz_t *    attr_value,
air_size_t   attr_size
 

Extracts an attribute value specified by name from a node (i.e., xml element).

Parameters:
source_node  node from which to extract the attribute
attr_name  name of the attribute to extract
attr_value  extracted attribute value
attr_size  IN: size allocated for the value; or if set to 0, then this routine allocates the memory if NULL, routine allocate memory for attr_value OUT: size used for the value
See also:
air_xml_node_attr_get_by_index air_xml_node_get_value
Returns:
status of the operation
Return values:
AIR_E_NONE  no error
AIR_E_NULL  null node given
AIR_E_NOMEM  memory allocation failure
AIR_E_XML_BAD_ATTR_NAME  invalid attribute name (no such attribute)
AIR_E_XML_BAD_ATTR_INDEX  internal error (corrupt tree)
AIR_E_NOT_SET  cannot get data from an unset node

air_err_t air_xml_node_attr_get_by_index air_xml_node_t   source_node,
air_xml_node_attr_id_t    attr_id,
air_asciz_t *    attr_value,
air_size_t   attr_size
 

Extracts an attribute value specified by its order in the attribute list of a node (i.e., xml element).

Parameters:
source_node  node from which to extract the attribute
attr_id  sequence id of the attribute value to extract. The first attribute is 1.
attr_value  extracted attribute value
attr_size  IN: size allocated for the value; or if set to 0, then this routine allocates the memory if NULL, routine allocate memory for node_data OUT: size used for the value
See also:
air_xml_node_attr_get_by_name air_xml_node_get_value
Returns:
status of the operation
Return values:
AIR_E_NONE  no error
AIR_E_NULL  null node given
AIR_E_NOMEM  memory allocation failure
AIR_E_XML_BAD_ATTR_INDEX  invalid attribute index/id (no such attribute)
AIR_E_NOT_SET  cannot get data from an unset node

air_err_t air_xml_node_set_value air_xml_node_t   target_node,
air_asciz_t    data_value,
air_size_t   data_size
 

Sets the PCDATA of a particular tree node (i.e., xml element).

Parameters:
target_node  node at which to add the PCDATA
node_data  data to add
data_size  IN: size of the data; if NULL, node_data must be terminated with a \0 OUT: size copied into the node
See also:
air_xml_node_append_value , air_xml_node_set_attr_by_name , air_xml_node_set_attr_by_index
Returns:
status of the operation
Return values:
AIR_E_NONE  no error
AIR_E_NULL  null node given
AIR_E_NOMEM  memory allocation failure
AIR_E_XML_NULL_DATA  data to set is NULL, or size of data = 0

air_err_t air_xml_node_append_value air_xml_node_t   target_node,
air_asciz_t    data_value,
air_size_t   data_size
 

Appends new PCDATA to a particular tree node (i.e., xml element).

Parameters:
target_node  node at which to append the PCDATA
node_data  data to append
data_size  IN: size of the data; OUT: size copied into the node
See also:
air_xml_node_set_value air_xml_node_set_attr_by_name air_xml_node_set_attr_by_index
Returns:
status of the operation
Return values:
AIR_E_NONE  no error
AIR_E_NULL  null node given
AIR_E_NOMEM  memory allocation failure
AIR_E_XML_NULL_DATA  data to set is NULL

air_err_t air_xml_node_attr_set_by_name air_xml_node_t   target_node,
air_xml_node_attr_name_t    attr_name,
air_asciz_t    attr_value,
air_size_t   data_size
 

Sets an attribute value specified by name on a node (i.e., xml element).

Parameters:
target_node  node on which to set the attribute
attr_name  name of the attribute to set
attr_value  value of the attribute
attr_size  IN: size allocated for the value; OUT: size used for the value
See also:
air_xml_node_set_attr_by_index air_xml_node_set_value air_xml_node_append_value
Returns:
status of the operation
Return values:
AIR_E_NONE  no error
AIR_E_NULL  null node given
AIR_E_NOMEM  memory allocation failure
AIR_E_XML_BAD_ATTR_NAME  invalid attribute name (no such attribute)
AIR_E_XML_BAD_ATTR_INDEX  internal error (corrupt tree)
AIR_E_XML_NULL_DATA  data to set is NULL

air_err_t air_xml_node_attr_set_by_index air_xml_node_t   target_node,
air_xml_node_attr_id_t    attr_id,
air_asciz_t    attr_value,
air_size_t   data_size
 

Sets an attribute value specified by index on a node (i.e., xml element).

Parameters:
target_node  node on which to set the attribute
attr_id  index of the attribute to set. The first attribute is 1.
attr_value  value of the attribute
attr_size  IN: size allocated for the value; if NULL, node_data must be terminated with a \0 OUT: size used for the value
See also:
air_xml_node_set_attr_by_name air_xml_node_set_value air_xml_node_append_value
Returns:
status of the operation
Return values:
AIR_E_NONE  no error
AIR_E_NULL  null node given
AIR_E_NOMEM  memory allocation failure
AIR_E_XML_BAD_ATTR_INDEX  invalid attribute index/id (no such attribute)
AIR_E_XML_NULL_DATA  data to set is NULL

air_err_t air_xml_node_get_type air_xml_node_t   n,
air_xml_node_type_t   out_type
 

returns the type of a given node.

Parameters:
n  the node
out_type  the type of the given node
Returns:
the status of the operation
Return values:
AIR_E_NONE  no error
AIR_E_NULL  node or out_type is NULL

char* air_xml_node_type2str air_xml_node_type_en    name_en
 

returns the string equivalent of a node type (element name).

Parameters:
name_en  enumerated ID of a node type (element name)
See also:
air_xml_node_type2str
Returns:
name of node as a string, and a NULL string if the enum ID is unknown

air_xml_node_type_en air_xml_node_str2type char *    name_str
 

returns the enumerated ID equivalent of a node type (element name) specified as a string name.

Parameters:
name_str  node type (element name) as a string
See also:
air_xml_node_str2type
Returns:
name of node as a string, -1 if the node name is not found

air_asciz_t air_xml_node_path air_xml_node_t   n,
air_flags_t    flags
 

path to given node from the root of the tree.

Parameters:
n  node whose path is desired
flags  flags to modify
Returns:
name of node as a string, -1 if the node name is not found

air_err_t ih_node_attr_iter_create air_xml_node_t   node,
ih_node_attr_iter_t **    iter
 

Creates a new node attribute iterator.

Parameters:
node  node who's attributes will be iterated through
iter  new attribute iterator
See also:
ih_node_attr_iter_next ih_node_attr_iter_free ih_tree_iter_create
Returns:
status of the operation

air_err_t ih_node_attr_iter_next ih_node_attr_iter_t **    iter,
air_xml_node_attr_name_t   attr_name,
air_xml_node_data_t   attr_value,
air_size_t   data_size
 

Gets the next attribute in the iterated through node.

Parameters:
iter  attribute iterator
attr_name  name of the attribute to extract
attr_value  extracted attribute value
data_size  IN: size allocated for the value; OUT: size used for the value
See also:
ih_node_attr_iter_create ih_node_attr_iter_free ih_tree_iter_next
Returns:
status of the operation

air_err_t ih_node_attr_iter_free ih_node_attr_iter_t **    iter
 

Deallocates an node attribute iterator.

Parameters:
iter  attribute iterator
See also:
ih_node_attr_iter_create ih_node_attr_iter_next ih_tree_iter_free
Returns:
status of the operation

air_err_t ih_tree_iter_create air_xml_node_t   root_node,
ih_tree_iter_t **    iter
 

Creates a new tree iterator.

Parameters:
root_node  root node for the iterator
iter  new tree iterator
See also:
ih_tree_iter_next ih_tree_iter_free ih_node_attr_iter_create
Returns:
status of the operation

air_err_t ih_tree_iter_next ih_tree_iter_t **    iter,
air_xml_node_t **    node
 

Gets the next node in the tree.

Parameters:
iter  attribute iterator
attr_name  name of the attribute to extract
attr_value  extracted attribute value
data_size  IN: size allocated for the value; OUT: size used for the value
See also:
ih_tree_iter_create ih_tree_iter_free ih_node_attr_iter_next
Returns:
status of the operation

air_err_t ih_tree_iter_free ih_tree_iter_t **    iter
 

Deallocates a tree iterator.

Parameters:
iter  tree iterator to free
See also:
ih_tree_iter_create ih_tree_iter_next ih_node_attr_iter_free
Returns:
status of the operation


Variable Documentation

char* air_xml_tree_schema_type_name[]
 

Initial value:

 { "snml",  
                                      "iodef", 
                                      "idmef", 
                                      "config", }


libair v0.3.33