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

commiting broken state

This commit is contained in:
Marenz 2011-04-18 10:09:35 +02:00
parent 2294dabea2
commit 1f89fb579b
3 changed files with 108 additions and 62 deletions

View file

@ -9,12 +9,14 @@ enum PSYC_Flags
enum PSYC_ReturnCodes
{
PSYC_METHOD = 1,
PSYC_ERROR_EXPECTED_TAB = -8,
PSYC_BODY = 1,
PSYC_BODY_INCOMPLETE,
PSYC_INSUFFICIENT,
PSYC_ROUTING,
PSYC_ENTITY,
PSYC_COMPLETE,
PSYC_HEADER_COMPLETE,
PSYC_ENTITY_INCOMPLETE,
PSYC_HEADER_DONE,
};
@ -24,14 +26,16 @@ typedef struct
const uint8_t * ptr;
} PSYC_Array;
typedef struct
{
unsigned int cursor; // current position in buffer
PSYC_Array buffer;
uint8_t flags;
char inBody;
unsigned int length;
unsigned int contentParsed; //
char inContent;
unsigned int valueRemaining;
unsigned int contentLength;
} PSYC_State;
@ -42,22 +46,26 @@ typedef struct
* @param length length of that buffer
*
* @returns an instance of the PSYC_Array struct */
inline PSYC_Array PSYC_CreateArray (uint8_t* const memory, unsigned int length)
inline PSYC_Array PSYC_createArray (uint8_t* const memory, unsigned int length)
{
PSYC_Array arr = {length, memory};
return arr;
}
/* @brief initiates the state struct with flags
*
* @param state pointer to the state struct that should be initiated
* @param flags the flags that one ones to set, se PSYC_Flags */
* @param flags the flags that one ones to set, see PSYC_Flags */
inline void PSYC_initState2 (PSYC_State* state, uint8_t flags )
{
memset(state, 0, sizeof(PSYC_State));
state->flags = flags;
}
/* @brief initiates the state struct
*
* @param state pointer to the state struct that should be initiated */
inline void PSYC_initState (PSYC_State* state)
{
memset(state, 0, sizeof(PSYC_State));
@ -66,16 +74,23 @@ inline void PSYC_initState (PSYC_State* state)
inline void PSYC_nextBuffer (PSYC_State* state, PSYC_Array newBuf)
{
state->buffer = newBuf;
state->cursor = 0;
}
inline unsigned int PSYC_getBodyLength (PSYC_State* state)
inline unsigned int PSYC_getContentLength (PSYC_State* s)
{
return state->length;
return s->contentLength;
}
inline unsigned int PSYC_getValueRemaining (PSYC_State* s)
{
return s->valueRemaining;
}
#endif
int PSYC_parse(PSYC_State* state,
PSYC_Array* name, PSYC_Array* value,
uint8_t* modifier, unsigned long *expectedBytes);
uint8_t* modifier, PSYC_Array* name, PSYC_Array* value,
unsigned long* bytesParsed, unsigned long *bytesExpected);