<libroxml  version="3.0.2" />
contact: tristan.lelong@libroxml.net
roxml_buff.c
Go to the documentation of this file.
1
12#include "roxml_core.h"
13#include "roxml_parser.h"
14#include "roxml_internal.h"
15
16ROXML_INT int roxml_read_buff(int pos, int size, char *buffer, node_t *node)
17{
18 int ret_len = 0;
19 char *r1 = buffer;
20 char const *r2 = node->src.buf + pos;
21
22 while (size-- && (*r1++ = *r2++)) ;
23
24 ret_len = r1 - buffer;
25
26 return ret_len;
27}
28
29ROXML_INT void roxml_close_buff(node_t *n)
30{
31 return;
32}
33
34ROXML_INT int roxml_parse_buff(roxml_load_ctx_t *context, roxml_parser_item_t *parser, char *buffer)
35{
36 int ret = 0;
37
38 context->type = ROXML_BUFF;
39 context->src = (void *)buffer;
40 ret = roxml_parse_line(parser, buffer, 0, context);
41
42 if (ret >= 0 && context->lvl != 0)
43 ROXML_PARSE_ERROR("mismatch in open/close nodes");
44 return (ret < 0) ? 1 : 0;
45}
46
48{
49 node_t *current_node = NULL;
50 if (buffer == NULL) {
51 errno = ENODATA;
52 return NULL;
53 }
54
55 current_node = roxml_create_node(0, buffer, ROXML_ELM_NODE | ROXML_BUFF);
56
57 return roxml_load(current_node, NULL, buffer);
58}
#define ROXML_ELM_NODE
Definition roxml.h:70
#define ROXML_API
Definition roxml.h:24
ROXML_INT int roxml_read_buff(int pos, int size, char *buffer, node_t *node)
read xml doc function
Definition roxml_buff.c:16
ROXML_INT void roxml_close_buff(node_t *n)
unload function
Definition roxml_buff.c:29
ROXML_INT int roxml_parse_buff(roxml_load_ctx_t *context, roxml_parser_item_t *parser, char *buffer)
generic load function
Definition roxml_buff.c:34
ROXML_API node_t * roxml_load_buf(char *buffer)
load function for buffers
Definition roxml_buff.c:47
ROXML_INT node_t * roxml_create_node(int pos, void *src, int type)
internal function
Definition roxml_core.c:46
ROXML_INT node_t * roxml_load(node_t *current_node, FILE *file, char *buffer)
generic load function
Definition roxml_core.c:201
XML parsing core module.
#define ROXML_BUFF
internal header required by all libroxml sources
ROXML_INT int roxml_parse_line(roxml_parser_item_t *parser, char *line, int len, void *ctx)
line parsing function
Parsing engine.
node_t structure
void * src
xml parsing context
the parser item struct