mirror of
git://git.psyced.org/git/psyclpc
synced 2024-08-15 03:20:16 +00:00
pkg-psyc: fixes for parser
This commit is contained in:
parent
c9bc7364fa
commit
4953d4bc3b
1 changed files with 11 additions and 7 deletions
|
@ -24,11 +24,14 @@
|
||||||
|
|
||||||
#ifdef USE_PSYC
|
#ifdef USE_PSYC
|
||||||
|
|
||||||
|
# include "pkg-psyc.h"
|
||||||
|
|
||||||
# include <stdio.h>
|
# include <stdio.h>
|
||||||
# include <unistd.h>
|
# include <unistd.h>
|
||||||
# include <fcntl.h>
|
# include <fcntl.h>
|
||||||
|
|
||||||
# include <psyc.h>
|
# include <psyc.h>
|
||||||
|
# include <psyc/parser.h>
|
||||||
# include <psyc/render.h>
|
# include <psyc/render.h>
|
||||||
|
|
||||||
/*-------------------------------------------------------------------------*/
|
/*-------------------------------------------------------------------------*/
|
||||||
|
@ -88,10 +91,10 @@ f_psyc_render(svalue_t *sp) {
|
||||||
// TODO: handle _lists
|
// TODO: handle _lists
|
||||||
// FIXME: handle mappings
|
// FIXME: handle mappings
|
||||||
packet = psyc_newPacket2(NULL, 0, NULL, 0,
|
packet = psyc_newPacket2(NULL, 0, NULL, 0,
|
||||||
meth, mlen, body, blen,
|
meth, mlen, body, blen,
|
||||||
PSYC_PACKET_CHECK_LENGTH);
|
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
|
// alloc_mstring creates an *untabled* string suitable for tmp data
|
||||||
memsafe(out = alloc_mstring(packet.length), packet.length, "f_psyc_render");
|
memsafe(out = alloc_mstring(packet.length), packet.length, "f_psyc_render");
|
||||||
psyc_render(&packet, get_txt(out), packet.length);
|
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};
|
psycString name = {0,0}, value = {0,0}, elem = {0,0};
|
||||||
psycParseListState listState;
|
psycParseListState listState;
|
||||||
int ret;
|
int ret;
|
||||||
|
size_t len;
|
||||||
|
|
||||||
psycState *state = O_GET_PSYC_STATE(current_object);
|
psycState *state = O_GET_PSYC_STATE(current_object);
|
||||||
if (!state) {
|
if (!state) {
|
||||||
|
@ -133,9 +137,9 @@ f_psyc_parse (svalue_t *sp) {
|
||||||
errorf("\npsyc_parse got %ld int* bytes... not supported yet\n", i);
|
errorf("\npsyc_parse got %ld int* bytes... not supported yet\n", i);
|
||||||
}
|
}
|
||||||
else if (sp->type == T_STRING) {
|
else if (sp->type == T_STRING) {
|
||||||
printf("\npsyc_parse got a %d bytes long string...\n", mstrsize(sp->u.str));
|
printf("\npsyc_parse got a %ld bytes long string...\n", mstrsize(sp->u.str));
|
||||||
psyc_setParseBuffer(&state, psyc_newString(get_txt(sp->u.str),
|
psyc_setParseBuffer(state->parser, psyc_newString(get_txt(sp->u.str),
|
||||||
mstrsize(sp->u.str)));
|
mstrsize(sp->u.str)));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!state->packet) {
|
if (!state->packet) {
|
||||||
|
@ -152,7 +156,7 @@ f_psyc_parse (svalue_t *sp) {
|
||||||
put_mapping(&v->item[PSYC_ENTITY], map);
|
put_mapping(&v->item[PSYC_ENTITY], map);
|
||||||
|
|
||||||
do {
|
do {
|
||||||
ret = psyc_parse(&state, &oper, &name, &value);
|
ret = psyc_parse(state->parser, &oper, &name, &value);
|
||||||
|
|
||||||
switch (ret) {
|
switch (ret) {
|
||||||
case PSYC_PARSE_ENTITY_START: case PSYC_PARSE_BODY_START:
|
case PSYC_PARSE_ENTITY_START: case PSYC_PARSE_BODY_START:
|
||||||
|
|
Loading…
Reference in a new issue