1
0
Fork 0
mirror of git://git.psyc.eu/libpsyc synced 2024-08-15 03:19:02 +00:00

adjusted functions for flag PARSE_BEGIN_AT_CONTENT

This commit is contained in:
Marenz 2011-04-30 15:43:00 +02:00
parent d48aa1e53b
commit 10e8deff47
3 changed files with 14 additions and 2 deletions

View file

@ -22,6 +22,7 @@ extern (C):
enum ParseFlag
{
PARSE_HEADER_ONLY = 1,
PARSE_BEGIN_AT_CONTENT = 2,
}
/**

View file

@ -23,7 +23,7 @@ typedef enum
{
PSYC_PARSE_HEADER_ONLY = 1,
/// Expects only the content part of a packet. The length of the content must fit exactly in this case
PSYC_BEGIN_PARSE_AT_CONTENT = 2,
PSYC_PARSE_BEGIN_AT_CONTENT = 2,
} psycParseFlag;
/**

View file

@ -24,6 +24,9 @@ inline void psyc_initParseState2 (psycParseState* state, uint8_t flags)
{
memset(state, 0, sizeof(psycParseState));
state->flags = flags;
if (flags & PSYC_PARSE_BEGIN_AT_CONTENT)
state->part = PSYC_PART_CONTENT;
}
inline void psyc_initParseListState (psycParseListState* state)
@ -33,6 +36,12 @@ inline void psyc_initParseListState (psycParseListState* state)
inline void psyc_nextParseBuffer (psycParseState* state, psycString newBuf)
{
if (state->flags & PSYC_PARSE_BEGIN_AT_CONTENT)
{
state->contentLength = newBuf.length;
state->contentLengthFound = PSYC_TRUE;
}
state->buffer = newBuf;
state->cursor = 0;
}
@ -275,6 +284,7 @@ psycParseRC psyc_parse(psycParseState* state, char* oper, psycString* name, psyc
{
state->contentLengthFound = 1;
state->contentLength = 0;
do
{
state->contentLength = 10 * state->contentLength + state->buffer.ptr[state->cursor] - '0';
@ -308,7 +318,8 @@ psycParseRC psyc_parse(psycParseState* state, char* oper, psycString* name, psyc
case PSYC_PART_CONTENT:
// In case of an incomplete binary variable resume parsing it.
if (state->valueParsed < state->valueLength) {
if (state->valueParsed < state->valueLength)
{
ret = psyc_parseBinaryValue(state, value, &(state->valueLength), &(state->valueParsed));
state->contentParsed += value->length;