mirror of
git://git.psyc.eu/libpsyc
synced 2024-08-15 03:19:02 +00:00
functions for creating packet & modifier structs, rendering
This commit is contained in:
parent
e047884a0d
commit
3afb723bf8
13 changed files with 267 additions and 99 deletions
|
@ -87,7 +87,7 @@ typedef struct
|
|||
{
|
||||
size_t cursor; ///< current position in buffer
|
||||
size_t startc; ///< position where the parsing would be resumed
|
||||
PSYC_Array buffer; ///< buffer with data to be parsed
|
||||
PSYC_String buffer; ///< buffer with data to be parsed
|
||||
uint8_t flags; ///< flags for the parser, see PSYC_ParseFlag
|
||||
PSYC_Part part; ///< part of the packet being parsed currently
|
||||
|
||||
|
@ -105,23 +105,13 @@ typedef struct
|
|||
{
|
||||
size_t cursor; ///< current position in buffer
|
||||
size_t startc; ///< line start position
|
||||
PSYC_Array buffer;
|
||||
PSYC_String buffer;
|
||||
PSYC_ListType type; ///< list type
|
||||
|
||||
size_t elemParsed; ///< number of bytes parsed from the elem so far
|
||||
size_t elemLength; ///< expected length of the elem
|
||||
} PSYC_ParseListState;
|
||||
|
||||
/**
|
||||
* Shortcut for creating an array.
|
||||
*
|
||||
* @param memory Pointer to the buffer.
|
||||
* @param length Length of that buffer.
|
||||
*
|
||||
* @return An instance of the PSYC_Array struct.
|
||||
*/
|
||||
inline PSYC_Array PSYC_createArray (const char* memory, size_t length);
|
||||
|
||||
/**
|
||||
* Initiates the state struct.
|
||||
*
|
||||
|
@ -144,9 +134,9 @@ inline void PSYC_initParseState2 (PSYC_ParseState* state, uint8_t flags);
|
|||
*/
|
||||
inline void PSYC_initParseListState (PSYC_ParseListState* state);
|
||||
|
||||
inline void PSYC_nextParseBuffer (PSYC_ParseState* state, PSYC_Array newBuf);
|
||||
inline void PSYC_nextParseBuffer (PSYC_ParseState* state, PSYC_String newBuf);
|
||||
|
||||
inline void PSYC_nextParseListBuffer (PSYC_ParseListState* state, PSYC_Array newBuf);
|
||||
inline void PSYC_nextParseListBuffer (PSYC_ParseListState* state, PSYC_String newBuf);
|
||||
|
||||
inline size_t PSYC_getContentLength (PSYC_ParseState* s);
|
||||
|
||||
|
@ -158,17 +148,17 @@ inline size_t PSYC_getContentLength (PSYC_ParseState* s);
|
|||
* @param state An initialized PSYC_ParseState
|
||||
* @param operator A pointer to a character. In case of a variable, it will
|
||||
* be set to the operator of that variable
|
||||
* @param name A pointer to a PSYC_Array. It will point to the name of
|
||||
* @param name A pointer to a PSYC_String. It will point to the name of
|
||||
* the variable or method and its length will be set accordingly
|
||||
* @param value A pointer to a PSYC_Array. It will point to the
|
||||
* @param value A pointer to a PSYC_String. It will point to the
|
||||
* value/body the variable/method and its length will be set accordingly
|
||||
*/
|
||||
PSYC_ParseRC PSYC_parse(PSYC_ParseState* state, char* oper, PSYC_Array* name, PSYC_Array* value);
|
||||
PSYC_ParseRC PSYC_parse(PSYC_ParseState* state, char* oper, PSYC_String* name, PSYC_String* value);
|
||||
|
||||
/**
|
||||
* List value parser.
|
||||
*/
|
||||
PSYC_ParseListRC PSYC_parseList(PSYC_ParseListState* state, PSYC_Array *name, PSYC_Array* value, PSYC_Array* elem);
|
||||
PSYC_ParseListRC PSYC_parseList(PSYC_ParseListState* state, PSYC_String *name, PSYC_String* value, PSYC_String* elem);
|
||||
|
||||
#endif // PSYC_PARSER_H
|
||||
|
||||
|
|
|
@ -32,11 +32,14 @@ typedef struct
|
|||
char buffer[]; ///< OMG a C99 feature! variable size buffer!
|
||||
} PSYC_RenderState;
|
||||
|
||||
PSYC_RenderRC PSYC_render(PSYC_Packet *packet, char *buffer, size_t buflen);
|
||||
|
||||
/**
|
||||
* Initiates the state struct.
|
||||
*
|
||||
* @param state Pointer to the state struct that should be initiated.
|
||||
*/
|
||||
/*
|
||||
inline void PSYC_initRenderState (PSYC_RenderState* state);
|
||||
|
||||
int PSYC_renderModifier(PSYC_RenderState* render,
|
||||
|
@ -47,5 +50,5 @@ int PSYC_renderModifier(PSYC_RenderState* render,
|
|||
int PSYC_renderBody(PSYC_RenderState* render,
|
||||
const char* method, size_t mlength,
|
||||
const char* data, size_t dlength);
|
||||
|
||||
*/
|
||||
#endif // PSYC_RENDER_H
|
||||
|
|
|
@ -10,6 +10,11 @@
|
|||
# define PSYC_CONTENT_SIZE_THRESHOLD 444
|
||||
#endif
|
||||
|
||||
/* beyond this a modifier value length must be provided */
|
||||
#ifndef PSYC_MODIFIER_SIZE_THRESHOLD
|
||||
# define PSYC_MODIFIER_SIZE_THRESHOLD 404
|
||||
#endif
|
||||
|
||||
#define C_GLYPH_PACKET_DELIMITER '|'
|
||||
#define S_GLYPH_PACKET_DELIMITER "|"
|
||||
#define PSYC_PACKET_DELIMITER "\n|\n"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue