<libroxml  version="3.0.1" />
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 
16 ROXML_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 
29 ROXML_INT void roxml_close_buff(node_t *n)
30 {
31  return;
32 }
33 
34 ROXML_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 }
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
node_t structure
Definition: roxml_types.h:133
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_line(roxml_parser_item_t *parser, char *line, int len, void *ctx)
line parsing function
Definition: roxml_parser.c:149
#define ROXML_API
Definition: roxml.h:24
Parsing engine.
void * src
Definition: roxml_types.h:138
internal header required by all libroxml sources
XML parsing core module.
xml parsing context
Definition: roxml_types.h:158
the parser item struct
#define ROXML_ELM_NODE
Definition: roxml.h:70
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
#define ROXML_BUFF
ROXML_INT node_t * roxml_load(node_t *current_node, FILE *file, char *buffer)
generic load function
Definition: roxml_core.c:201