mirror of
git://git.psyc.eu/libpsyc
synced 2024-08-15 03:19:02 +00:00
parser, text: added functions for accessing state variables
This commit is contained in:
parent
a2133e15f9
commit
95ef2fd538
2 changed files with 5 additions and 5 deletions
|
@ -233,7 +233,7 @@ int main (int argc, char **argv)
|
||||||
if (ret == PSYC_PARSE_ENTITY)
|
if (ret == PSYC_PARSE_ENTITY)
|
||||||
{
|
{
|
||||||
packets[i].entity.lines++;
|
packets[i].entity.lines++;
|
||||||
mod->flag = parsers[i].valueLength ?
|
mod->flag = psyc_getParseValueLength(&parsers[i]) ?
|
||||||
PSYC_MODIFIER_NEED_LENGTH : PSYC_MODIFIER_NO_LENGTH;
|
PSYC_MODIFIER_NEED_LENGTH : PSYC_MODIFIER_NO_LENGTH;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -246,7 +246,7 @@ int main (int argc, char **argv)
|
||||||
|
|
||||||
case PSYC_PARSE_COMPLETE:
|
case PSYC_PARSE_COMPLETE:
|
||||||
printf("# Done parsing.\n");
|
printf("# Done parsing.\n");
|
||||||
packets[i].flag = parsers[i].contentLengthFound ?
|
packets[i].flag = psyc_isParseContentLengthFound(&parsers[i]) ?
|
||||||
PSYC_PACKET_NEED_LENGTH : PSYC_PACKET_NO_LENGTH;
|
PSYC_PACKET_NEED_LENGTH : PSYC_PACKET_NO_LENGTH;
|
||||||
|
|
||||||
psyc_setPacketLength(&packets[i]);
|
psyc_setPacketLength(&packets[i]);
|
||||||
|
@ -261,12 +261,12 @@ int main (int argc, char **argv)
|
||||||
if (verbose)
|
if (verbose)
|
||||||
printf("# Insufficient data.\n");
|
printf("# Insufficient data.\n");
|
||||||
|
|
||||||
contbytes = parsers[i].buffer.length - parsers[i].cursor;
|
contbytes = psyc_getParseRemainingLength(&parsers[i]);
|
||||||
|
|
||||||
if (contbytes > 0) // copy end of parsebuf before start of recvbuf
|
if (contbytes > 0) // copy end of parsebuf before start of recvbuf
|
||||||
{
|
{
|
||||||
assert(recvbuf - contbytes >= buf); // make sure it's still in the buffer
|
assert(recvbuf - contbytes >= buf); // make sure it's still in the buffer
|
||||||
memcpy(recvbuf - contbytes, parsebuf + parsers[i].cursor, contbytes);
|
memcpy(recvbuf - contbytes, psyc_getParseRemainingBuffer(&parsers[i]), contbytes);
|
||||||
}
|
}
|
||||||
ret = 0;
|
ret = 0;
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -36,7 +36,7 @@ int testText (char *template, size_t tmplen, char *buffer, size_t buflen, psycSt
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
ret = psyc_text(&state, getValue);
|
ret = psyc_text(&state, getValue);
|
||||||
length += state.written;
|
length += psyc_getTextBytesWritten(&state);
|
||||||
switch (ret)
|
switch (ret)
|
||||||
{
|
{
|
||||||
case PSYC_TEXT_INCOMPLETE:
|
case PSYC_TEXT_INCOMPLETE:
|
||||||
|
|
Loading…
Reference in a new issue