#include <ucw-xml/dtd.h>
#ifdef CONFIG_UCW_CLEAN_ABI
+#define xml_do_pop ucw_xml_do_pop
+#define xml_do_push ucw_xml_do_push
#define xml_fatal_expected ucw_xml_fatal_expected
#define xml_fatal_expected_quot ucw_xml_fatal_expected_quot
#define xml_fatal_expected_white ucw_xml_fatal_expected_white
#define xml_parse_pe_ref ucw_xml_parse_pe_ref
#define xml_parse_pubid_literal ucw_xml_parse_pubid_literal
#define xml_parse_system_literal ucw_xml_parse_system_literal
+#define xml_parse_white ucw_xml_parse_white
#define xml_pop_comment ucw_xml_pop_comment
+#define xml_pop_dom ucw_xml_pop_dom
#define xml_pop_pi ucw_xml_pop_pi
#define xml_push_comment ucw_xml_push_comment
+#define xml_push_dom ucw_xml_push_dom
#define xml_push_entity ucw_xml_push_entity
#define xml_push_pi ucw_xml_push_pi
#define xml_push_source ucw_xml_push_source
uint flags;
};
-static inline void *xml_do_push(struct xml_context *ctx, uint size)
-{
- /* Saves ctx->stack and ctx->flags state */
- struct mempool_state state;
- mp_save(ctx->stack, &state);
- struct xml_stack *s = mp_alloc(ctx->stack, size);
- s->state = state;
- s->flags = ctx->flags;
- s->next = ctx->stack_list;
- ctx->stack_list = s;
- return s;
-}
-
-static inline void xml_do_pop(struct xml_context *ctx, struct xml_stack *s)
-{
- /* Restore ctx->stack and ctx->flags state */
- ctx->stack_list = s->next;
- ctx->flags = s->flags;
- mp_restore(ctx->stack, &s->state);
-}
+void *xml_do_push(struct xml_context *ctx, uint size);
+void xml_do_pop(struct xml_context *ctx, struct xml_stack *s);
static inline void xml_push(struct xml_context *ctx)
{
struct mempool_state state;
};
-static inline struct xml_node *xml_push_dom(struct xml_context *ctx, struct mempool_state *state)
-{
- /* Create a new DOM node */
- TRACE(ctx, "push_dom");
- struct xml_dom_stack *s = xml_do_push(ctx, sizeof(*s));
- if (state)
- s->state = *state;
- else
- mp_save(ctx->pool, &s->state);
- struct xml_node *n = mp_alloc(ctx->pool, sizeof(*n));
- n->user = NULL;
- if (n->parent = ctx->node)
- clist_add_tail(&n->parent->sons, &n->n);
- return ctx->node = n;
-}
-
-static inline void xml_pop_dom(struct xml_context *ctx, uint free)
-{
- /* Leave DOM subtree */
- TRACE(ctx, "pop_dom");
- ASSERT(ctx->node);
- struct xml_node *p = ctx->node->parent;
- struct xml_dom_stack *s = (void *)ctx->stack_list;
- if (free)
- {
- /* See xml_pop_element() for cleanup of attribute hash table */
- if (p)
- clist_remove(&ctx->node->n);
- mp_restore(ctx->pool, &s->state);
- }
- ctx->node = p;
- xml_do_pop(ctx, &s->stack);
-}
+struct xml_node *xml_push_dom(struct xml_context *ctx, struct mempool_state *state);
+void xml_pop_dom(struct xml_context *ctx, uint free);
#define XML_HASH_HDR_SIZE ALIGN_TO(sizeof(void *), CPU_STRUCT_ALIGN)
#define XML_HASH_GIVE_ALLOC struct HASH_PREFIX(table); \
void NONRET xml_fatal_expected_white(struct xml_context *ctx);
void NONRET xml_fatal_expected_quot(struct xml_context *ctx);
-static inline uint xml_parse_white(struct xml_context *ctx, uint mandatory)
-{
- /* mandatory=1 -> S ::= (#x20 | #x9 | #xD | #xA)+
- * mandatory=0 -> S? */
- uint cnt = 0;
- while (xml_peek_cat(ctx) & XML_CHAR_WHITE)
- {
- xml_skip_char(ctx);
- cnt++;
- }
- if (unlikely(mandatory && !cnt))
- xml_fatal_expected_white(ctx);
- return cnt;
-}
+uint xml_parse_white(struct xml_context *ctx, uint mandatory);
static inline void xml_parse_char(struct xml_context *ctx, uint c)
{
xml_parse_white(ctx, 0);
}
+/*** Memory management ***/
+
+void *xml_do_push(struct xml_context *ctx, uint size)
+{
+ /* Saves ctx->stack and ctx->flags state */
+ struct mempool_state state;
+ mp_save(ctx->stack, &state);
+ struct xml_stack *s = mp_alloc(ctx->stack, size);
+ s->state = state;
+ s->flags = ctx->flags;
+ s->next = ctx->stack_list;
+ ctx->stack_list = s;
+ return s;
+}
+
+void xml_do_pop(struct xml_context *ctx, struct xml_stack *s)
+{
+ /* Restore ctx->stack and ctx->flags state */
+ ctx->stack_list = s->next;
+ ctx->flags = s->flags;
+ mp_restore(ctx->stack, &s->state);
+}
+
+struct xml_node *xml_push_dom(struct xml_context *ctx, struct mempool_state *state)
+{
+ /* Create a new DOM node */
+ TRACE(ctx, "push_dom");
+ struct xml_dom_stack *s = xml_do_push(ctx, sizeof(*s));
+ if (state)
+ s->state = *state;
+ else
+ mp_save(ctx->pool, &s->state);
+ struct xml_node *n = mp_alloc(ctx->pool, sizeof(*n));
+ n->user = NULL;
+ if (n->parent = ctx->node)
+ clist_add_tail(&n->parent->sons, &n->n);
+ return ctx->node = n;
+}
+
+void xml_pop_dom(struct xml_context *ctx, uint free)
+{
+ /* Leave DOM subtree */
+ TRACE(ctx, "pop_dom");
+ ASSERT(ctx->node);
+ struct xml_node *p = ctx->node->parent;
+ struct xml_dom_stack *s = (void *)ctx->stack_list;
+ if (free)
+ {
+ /* See xml_pop_element() for cleanup of attribute hash table */
+ if (p)
+ clist_remove(&ctx->node->n);
+ mp_restore(ctx->pool, &s->state);
+ }
+ ctx->node = p;
+ xml_do_pop(ctx, &s->stack);
+}
+
+/*** Basics ***/
+
+uint xml_parse_white(struct xml_context *ctx, uint mandatory)
+{
+ /* mandatory=1 -> S ::= (#x20 | #x9 | #xD | #xA)+
+ * mandatory=0 -> S? */
+ uint cnt = 0;
+ while (xml_peek_cat(ctx) & XML_CHAR_WHITE)
+ {
+ xml_skip_char(ctx);
+ cnt++;
+ }
+ if (unlikely(mandatory && !cnt))
+ xml_fatal_expected_white(ctx);
+ return cnt;
+}
+
/*** Names and nmtokens ***/
static char *
}
}
-static inline uint
+static uint
xml_end_chars(struct xml_context *ctx, char **out)
{
struct fastbuf *fb = &ctx->chars;
return len;
}
-static inline uint
+static uint
xml_report_chars(struct xml_context *ctx, char **out)
{
struct fastbuf *fb = &ctx->chars;
return len;
}
-static inline uint
+static uint
xml_flush_chars(struct xml_context *ctx)
{
char *text, *rtext;
return len;
}
-static inline void
+static void
xml_pop_chars(struct xml_context *ctx)
{
xml_pop_dom(ctx, !(ctx->flags & XML_ALLOC_CHARS));
TRACE(ctx, "pop_chars");
}
-static inline void
+static void
xml_append_chars(struct xml_context *ctx)
{
TRACE(ctx, "append_chars");