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:56:24 +00:00
|
|
|
enum PSYC_Flags
|
|
|
|
{
|
|
|
|
PSYC_HEADER_ONLY = 1
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
enum PSYC_ReturnCodes
|
2011-04-17 10:05:14 +00:00
|
|
|
{
|
2011-04-17 11:25:06 +00:00
|
|
|
PSYC_METHOD = 1,
|
|
|
|
PSYC_INSUFFICIENT,
|
|
|
|
PSYC_ROUTING,
|
|
|
|
PSYC_ENTITY,
|
|
|
|
PSYC_COMPLETE,
|
|
|
|
PSYC_HEADER_COMPLETE,
|
2011-04-17 10:05:14 +00:00
|
|
|
};
|
|
|
|
|
2011-04-15 23:42:36 +00:00
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
unsigned int length;
|
2011-04-16 09:30:26 +00:00
|
|
|
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;
|
|
|
|
|
2011-04-17 11:59:07 +00:00
|
|
|
char inBody;
|
2011-04-15 23:42:36 +00:00
|
|
|
unsigned int length;
|
2011-04-17 10:05:14 +00:00
|
|
|
unsigned int contentLength;
|
2011-04-15 23:42:36 +00:00
|
|
|
} PSYC_State;
|
|
|
|
|
2011-04-17 11:25:06 +00:00
|
|
|
#ifndef PSYC_COMPILE_LIBRARY
|
2011-04-16 09:30:26 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2011-04-17 10:56:24 +00:00
|
|
|
inline void PSYC_initState2 (PSYC_State* state, uint8_t flags )
|
|
|
|
{
|
|
|
|
memset(state, 0, sizeof(PSYC_State));
|
|
|
|
state->flags = flags;
|
|
|
|
}
|
|
|
|
|
2011-04-15 23:42:36 +00:00
|
|
|
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 unsigned int PSYC_getBodyLength (PSYC_State* state)
|
|
|
|
{
|
|
|
|
return state->length;
|
|
|
|
}
|
2011-04-17 11:25:06 +00:00
|
|
|
#endif
|
2011-04-15 23:42:36 +00:00
|
|
|
|
2011-04-17 11:25:06 +00:00
|
|
|
int PSYC_parse(PSYC_State* state,
|
|
|
|
PSYC_Array* name, PSYC_Array* value,
|
|
|
|
uint8_t* modifier, unsigned long *expectedBytes);
|
2010-02-20 16:40:09 +00:00
|
|
|
|
|
|
|
|