pkg-psyc: fixes for parser

This commit is contained in:
Gabor Adam Toth 2011-05-08 21:28:31 +02:00
parent c9bc7364fa
commit 4953d4bc3b
1 changed files with 11 additions and 7 deletions

View File

@ -24,11 +24,14 @@
#ifdef USE_PSYC
# include "pkg-psyc.h"
# include <stdio.h>
# include <unistd.h>
# include <fcntl.h>
# include <psyc.h>
# include <psyc/parser.h>
# include <psyc/render.h>
/*-------------------------------------------------------------------------*/
@ -88,10 +91,10 @@ f_psyc_render(svalue_t *sp) {
// TODO: handle _lists
// FIXME: handle mappings
packet = psyc_newPacket2(NULL, 0, NULL, 0,
meth, mlen, body, blen,
PSYC_PACKET_CHECK_LENGTH);
meth, mlen, body, blen,
PSYC_PACKET_CHECK_LENGTH);
printf("rendering... packet.length = %d\n", packet.length);
printf("rendering... packet.length = %ld\n", packet.length);
// alloc_mstring creates an *untabled* string suitable for tmp data
memsafe(out = alloc_mstring(packet.length), packet.length, "f_psyc_render");
psyc_render(&packet, get_txt(out), packet.length);
@ -117,6 +120,7 @@ f_psyc_parse (svalue_t *sp) {
psycString name = {0,0}, value = {0,0}, elem = {0,0};
psycParseListState listState;
int ret;
size_t len;
psycState *state = O_GET_PSYC_STATE(current_object);
if (!state) {
@ -133,9 +137,9 @@ f_psyc_parse (svalue_t *sp) {
errorf("\npsyc_parse got %ld int* bytes... not supported yet\n", i);
}
else if (sp->type == T_STRING) {
printf("\npsyc_parse got a %d bytes long string...\n", mstrsize(sp->u.str));
psyc_setParseBuffer(&state, psyc_newString(get_txt(sp->u.str),
mstrsize(sp->u.str)));
printf("\npsyc_parse got a %ld bytes long string...\n", mstrsize(sp->u.str));
psyc_setParseBuffer(state->parser, psyc_newString(get_txt(sp->u.str),
mstrsize(sp->u.str)));
}
if (!state->packet) {
@ -152,7 +156,7 @@ f_psyc_parse (svalue_t *sp) {
put_mapping(&v->item[PSYC_ENTITY], map);
do {
ret = psyc_parse(&state, &oper, &name, &value);
ret = psyc_parse(state->parser, &oper, &name, &value);
switch (ret) {
case PSYC_PARSE_ENTITY_START: case PSYC_PARSE_BODY_START: