<libroxml
version="3.0.2"
/>
|
XML serialize to file or buffer module. More...
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include <unistd.h>
#include "roxml_core.h"
Go to the source code of this file.
Functions | |
ROXML_STATIC ROXML_INT void | roxml_realloc_buf (char **buf, int *len, int min_len) |
ROXML_STATIC ROXML_INT void | roxml_print_spaces (FILE *f, char **buf, int *offset, int *len, int lvl) |
space printing function | |
ROXML_STATIC ROXML_INT void | roxml_write_string (FILE *f, char **buf, int *offset, int *len, char *str,...) |
string writter function | |
ROXML_STATIC ROXML_INT void | roxml_write_other_node (node_t *n, FILE *f, char **buf, int *offset, int *len, char *name) |
ROXML_STATIC ROXML_INT void | roxml_write_elm_name_open (node_t *n, FILE *f, char **buf, int *offset, int *len, char *name, char *ns) |
ROXML_STATIC ROXML_INT void | roxml_write_elm_name_close (node_t *n, FILE *f, char **buf, int *offset, int *len, char *name, char *ns) |
ROXML_STATIC ROXML_INT void | roxml_write_elm_attr (node_t *n, FILE *f, char **buf, int *offset, int *len) |
ROXML_STATIC ROXML_INT void | roxml_write_node (node_t *n, FILE *f, char **buf, int human, int lvl, int *offset, int *len) |
tree write function | |
ROXML_STATIC ROXML_INT void | roxml_commit_nodes (node_t *n, FILE *f, char **buf, int human, int *size, int *len) |
ROXML_API int | roxml_commit_file (node_t *n, char *dest, int human) |
sync to named file function | |
ROXML_API int | roxml_commit_buffer (node_t *n, char **buffer, int human) |
sync to a memory buffer function | |
ROXML_API int | roxml_commit_fd (node_t *n, int fd, int human) |
sync to file descriptor function | |
ROXML_API int | roxml_commit_changes (node_t *n, char *dest, char **buffer, int human) |
sync function | |
XML serialize to file or buffer module.
(C) Copyright 2014 Tristan Lelong trist.nosp@m.an.l.nosp@m.elong.nosp@m.@lib.nosp@m.roxml.nosp@m..net
SPDX-Licence-Identifier: LGPL-2.1+ The author added a static linking exception, see License.txt.
Definition in file roxml_commit.c.
roxml_commit_buffer | ( | node_t * | n, |
char ** | buffer, | ||
int | human | ||
) |
sync to a memory buffer function
this function syncs changes from the RAM tree to the given buffer in human or one-line format The tree will be processed starting with the root node 'n' and following with all its children or if n is the root, all its siblings and children. The tree will be dumped to a buffer if 'buffer' is not null. the buffer is allocated by the library and a pointer to it will be stored into 'buffer'. The allocated buffer can be freed using free()
n | the root node of the tree to write |
buffer | the address of a buffer where the tree will be written. This buffer have to be freed after use |
human | 0 for one-line tree, or 1 for human format (using indentation, newlines...) |
One should do:
to generate the following xml bloc:
<root> <!-- sample XML file --> <item id="42"> <price> 24 </price> </item> </root>
or also
to generate the following xml bloc:
<root><!-- sample XML file --><item id="42"><price>24</price></item></root>
Definition at line 296 of file roxml_commit.c.
roxml_commit_changes | ( | node_t * | n, |
char * | dest, | ||
char ** | buffer, | ||
int | human | ||
) |
sync function
This function is now deprecated and one should use roxml_commit_buffer or roxml_commit_file that achieves the exact same goal.
n | the root node of the tree to write |
dest | the path to a file to write tree to |
buffer | the address of a buffer where the tree will be written. This buffer have to be freed after use |
human | 0 for one-line tree, or 1 for human format (using tabs, newlines...) |
This is a legacy function that proposes the same functionnalities as both roxml_commit_file
and roxml_commit_buffer
. New code should use the latter functions when needed.
One should do:
to generate the following xml bloc:
<root> <!-- sample XML file --> <item id="42"> <price> 24 </price> </item> </root>
or also
to generate the following xml bloc:
<root><!-- sample XML file --><item id="42"><price>24</price></item></root>
the buffer variant works more or less the same way
to generate the following xml bloc:
<root><!-- sample XML file --><item id="42"><price>24</price></item></root>
Definition at line 357 of file roxml_commit.c.
roxml_commit_fd | ( | node_t * | n, |
int | fd, | ||
int | human | ||
) |
sync to file descriptor function
this function synchronizes changes from the RAM tree to the given file in human or one-line format. The tree will be processed starting with the root node 'n' and following with all its children or if n is the root, all its siblings and children. The tree will be dumped to a file if fd is a valid file descriptor.
n | the root node of the tree to write |
fd | the file descriptor to write tree to |
human | 0 for one-line tree, or 1 for human format (using tabs, newlines...) |
The file described by fd is not truncated so this function allows one to append an XML subtree to an existing file.
One should do:
to generate the following xml bloc:
<root> <!-- sample XML file --> <item id="42"> <price> 24 </price> </item> </root>
or also
to generate the following xml bloc:
<root><!-- sample XML file --><item id="42"><price>24</price></item></root>
Definition at line 317 of file roxml_commit.c.
roxml_commit_file | ( | node_t * | n, |
char * | dest, | ||
int | human | ||
) |
sync to named file function
this function sync changes from the RAM tree to the given file in human or one-line format The tree will be processed starting with the root node 'n' and following with all its children or if n is the root, all its siblings and children. The tree will be dumped to a file if 'dest' is not null and contains a valid path.
n | the root node of the tree to write |
dest | the path to a file to write tree to |
human | 0 for one-line tree, or 1 for human format (using tabs, newlines...) |
One should do:
to generate the following xml bloc:
<root> <!-- sample XML file --> <item id="42"> <price> 24 </price> </item> </root>
or also
to generate the following xml bloc:
<root><!-- sample XML file --><item id="42"><price>24</price></item></root>
Definition at line 272 of file roxml_commit.c.
ROXML_STATIC ROXML_INT void roxml_commit_nodes | ( | node_t * | n, |
FILE * | f, | ||
char ** | buf, | ||
int | human, | ||
int * | size, | ||
int * | len | ||
) |
Definition at line 249 of file roxml_commit.c.
roxml_print_spaces | ( | 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
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 |
Definition at line 37 of file roxml_commit.c.
ROXML_STATIC ROXML_INT void roxml_realloc_buf | ( | char ** | buf, |
int * | len, | ||
int | min_len | ||
) |
Definition at line 18 of file roxml_commit.c.
ROXML_STATIC ROXML_INT void roxml_write_elm_attr | ( | node_t * | n, |
FILE * | f, | ||
char ** | buf, | ||
int * | offset, | ||
int * | len | ||
) |
Definition at line 156 of file roxml_commit.c.
ROXML_STATIC ROXML_INT void roxml_write_elm_name_close | ( | node_t * | n, |
FILE * | f, | ||
char ** | buf, | ||
int * | offset, | ||
int * | len, | ||
char * | name, | ||
char * | ns | ||
) |
Definition at line 141 of file roxml_commit.c.
ROXML_STATIC ROXML_INT void roxml_write_elm_name_open | ( | node_t * | n, |
FILE * | f, | ||
char ** | buf, | ||
int * | offset, | ||
int * | len, | ||
char * | name, | ||
char * | ns | ||
) |
Definition at line 127 of file roxml_commit.c.
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
n | the node to write |
f | the file pointer if any |
buf | the pointer to the buffer 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 |
Definition at line 203 of file roxml_commit.c.
ROXML_STATIC ROXML_INT void roxml_write_other_node | ( | node_t * | n, |
FILE * | f, | ||
char ** | buf, | ||
int * | offset, | ||
int * | len, | ||
char * | name | ||
) |
Definition at line 89 of file roxml_commit.c.
void roxml_write_string | ( | FILE * | f, |
char ** | buf, | ||
int * | offset, | ||
int * | len, | ||
char * | str, | ||
... | |||
) |
string writter function
this function write a string to output when committing change
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 |
Definition at line 67 of file roxml_commit.c.