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

62 lines
1,006 B
C
Raw Normal View History

2010-02-20 16:40:09 +00:00
#include <stdint.h>
2011-04-15 23:42:36 +00:00
#include <string.h>
2011-04-17 10:05:14 +00:00
enum
{
PSYC_SUCCESS = 0,
PSYC_INSUFFICIENT = 1,
PSYC_ROUTING = 2,
PSYC_ENTITY = 3,
PSYC_COMPLETE = 4,
};
2011-04-15 23:42:36 +00:00
typedef struct
{
unsigned int length;
const uint8_t * ptr;
2011-04-15 23:42:36 +00:00
} PSYC_Array;
typedef struct
{
unsigned int cursor; // current position in buffer
PSYC_Array buffer;
uint8_t flags;
char inHeader;
unsigned int length;
2011-04-17 10:05:14 +00:00
unsigned int contentLength;
2011-04-15 23:42:36 +00:00
} PSYC_State;
inline PSYC_Array PSYC_CreateArray (uint8_t* const memory, unsigned int length)
2011-04-15 23:42:36 +00:00
{
PSYC_Array arr = {length, memory};
return arr;
}
inline void PSYC_initState (PSYC_State* state)
{
memset(state, 0, sizeof(PSYC_State));
}
inline void PSYC_nextBuffer (PSYC_State* state, PSYC_Array newBuf)
{
state->buffer = newBuf;
}
inline int PSYC_parse(PSYC_State* state,
PSYC_Array* name, PSYC_Array* value,
uint8_t* modifier, unsigned long *expectedBytes);
2011-04-15 23:42:36 +00:00
inline unsigned int PSYC_getBodyLength (PSYC_State* state)
{
return state->length;
}
2010-02-20 16:40:09 +00:00