2011-04-22 09:50:13 +00:00
|
|
|
#include "syntax.h"
|
|
|
|
|
2011-04-21 12:20:24 +00:00
|
|
|
/**
|
|
|
|
* Struct for keeping render state.
|
|
|
|
*/
|
2011-04-20 20:22:55 +00:00
|
|
|
typedef enum {
|
|
|
|
PSYC_FINE = 0,
|
|
|
|
PSYC_NEED_LENGTH = 1
|
|
|
|
} PSYC_RenderFlag;
|
|
|
|
|
2011-04-22 09:50:13 +00:00
|
|
|
typedef enum {
|
|
|
|
PSYC_FLAG_ROUTING = 1
|
|
|
|
} PSYC_RenderHeaderFlag;
|
|
|
|
|
2011-04-20 20:22:55 +00:00
|
|
|
typedef struct {
|
|
|
|
PSYC_RenderFlag flag; ///< flags for the renderer
|
2011-04-21 12:20:24 +00:00
|
|
|
PSYC_Part part; ///< part of the packet being rendered
|
2011-04-20 20:22:55 +00:00
|
|
|
size_t cursor; ///< current position in buffer
|
2011-04-22 09:50:13 +00:00
|
|
|
size_t spot; ///< space for rendered length between the headers
|
2011-04-21 12:20:24 +00:00
|
|
|
size_t contentLength; ///< length of the content part
|
2011-04-20 20:22:55 +00:00
|
|
|
size_t length; ///< how big is the buffer we allocated
|
2011-04-22 09:50:13 +00:00
|
|
|
char buffer[]; ///< OMG a C99 feature! variable size buffer!
|
2011-04-20 20:22:55 +00:00
|
|
|
} PSYC_RenderState;
|
|
|
|
|
2011-04-21 12:20:24 +00:00
|
|
|
int PSYC_renderHeader(PSYC_RenderState* render,
|
2011-04-22 09:50:13 +00:00
|
|
|
const char* name, size_t nlength,
|
|
|
|
const char* value, size_t vlength,
|
|
|
|
PSYC_RenderHeaderFlag flags, char modifier);
|
2011-04-18 14:54:56 +00:00
|
|
|
|
2011-04-21 12:20:24 +00:00
|
|
|
int PSYC_renderBody(PSYC_RenderState* render,
|
2011-04-22 09:50:13 +00:00
|
|
|
const char* method, size_t mlength,
|
|
|
|
const char* data, size_t dlength);
|
2011-04-18 14:54:56 +00:00
|
|
|
|
2011-04-21 12:20:24 +00:00
|
|
|
int PSYC_doneRender(PSYC_RenderState* render,
|
2011-04-18 14:54:56 +00:00
|
|
|
uint8_t** buf, size_t* written);
|