2011-04-22 15:09:32 +00:00
|
|
|
#ifndef PSYC_RENDER_H
|
|
|
|
# define PSYC_RENDER_H
|
|
|
|
|
2011-04-25 21:14:22 +00:00
|
|
|
/**
|
|
|
|
* @file psyc/render.h
|
|
|
|
* @brief Interface for PSYC packet rendering.
|
|
|
|
*
|
|
|
|
* All rendering functions and the definitions they use are
|
|
|
|
* defined in this file.
|
|
|
|
*/
|
2011-04-22 09:50:13 +00:00
|
|
|
|
2011-04-25 21:14:22 +00:00
|
|
|
/**
|
|
|
|
* @defgroup rendering Rendering Functions
|
|
|
|
*
|
|
|
|
* This module contains all rendering functions.
|
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
2011-04-25 21:40:38 +00:00
|
|
|
* Return codes for psyc_render.
|
2011-04-25 21:14:22 +00:00
|
|
|
*/
|
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
//PSYC_RENDER_ERROR_ROUTING = -2,
|
|
|
|
PSYC_RENDER_ERROR = -1,
|
|
|
|
PSYC_RENDER_SUCCESS = 0,
|
2011-04-25 21:40:38 +00:00
|
|
|
} psycRenderRC;
|
2011-04-25 21:14:22 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Render a PSYC packet into a buffer.
|
|
|
|
*/
|
2011-04-25 21:40:38 +00:00
|
|
|
psycRenderRC psyc_render(psycPacket *packet, char *buffer, size_t buflen);
|
2011-04-25 21:14:22 +00:00
|
|
|
|
2011-04-26 15:23:06 +00:00
|
|
|
/**
|
|
|
|
* Render a PSYC list into a buffer.
|
|
|
|
*/
|
|
|
|
inline psycRenderRC psyc_renderList(psycList *list, char *buffer, size_t buflen);
|
|
|
|
|
2011-04-25 21:14:22 +00:00
|
|
|
/*
|
2011-04-22 15:09:32 +00:00
|
|
|
typedef enum
|
|
|
|
{
|
2011-04-22 18:22:20 +00:00
|
|
|
PSYC_RENDER_CHECK_LENGTH = 0,
|
|
|
|
PSYC_RENDER_NEED_LENGTH = 1,
|
|
|
|
PSYC_RENDER_NO_LENGTH = 2,
|
2011-04-22 15:09:32 +00:00
|
|
|
PSYC_RENDER_ROUTING = 3,
|
2011-04-25 21:40:38 +00:00
|
|
|
} psycRenderFlag;
|
2011-04-25 21:14:22 +00:00
|
|
|
*/
|
2011-04-22 09:50:13 +00:00
|
|
|
|
2011-04-22 15:09:32 +00:00
|
|
|
/**
|
|
|
|
* Struct for keeping render state.
|
|
|
|
*/
|
2011-04-25 21:14:22 +00:00
|
|
|
/*
|
2011-04-22 15:09:32 +00:00
|
|
|
typedef struct
|
|
|
|
{
|
2011-04-25 21:40:38 +00:00
|
|
|
psycRenderFlag flag; ///< flags for the renderer
|
|
|
|
psycPart 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-25 21:40:38 +00:00
|
|
|
} psycRenderState;
|
2011-04-25 21:14:22 +00:00
|
|
|
*/
|
2011-04-22 15:09:32 +00:00
|
|
|
/**
|
|
|
|
* Initiates the state struct.
|
|
|
|
*
|
|
|
|
* @param state Pointer to the state struct that should be initiated.
|
|
|
|
*/
|
2011-04-25 12:20:13 +00:00
|
|
|
/*
|
2011-04-25 21:40:38 +00:00
|
|
|
inline void psyc_initRenderState (psycRenderState* state);
|
2011-04-22 15:09:32 +00:00
|
|
|
|
2011-04-25 21:40:38 +00:00
|
|
|
int psyc_renderModifier(psycRenderState* render,
|
2011-04-22 09:50:13 +00:00
|
|
|
const char* name, size_t nlength,
|
|
|
|
const char* value, size_t vlength,
|
2011-04-25 21:40:38 +00:00
|
|
|
psycRenderFlag flags, char oper);
|
2011-04-18 14:54:56 +00:00
|
|
|
|
2011-04-25 21:40:38 +00:00
|
|
|
int psyc_renderBody(psycRenderState* render,
|
2011-04-22 09:50:13 +00:00
|
|
|
const char* method, size_t mlength,
|
|
|
|
const char* data, size_t dlength);
|
2011-04-25 12:20:13 +00:00
|
|
|
*/
|
2011-04-22 15:09:32 +00:00
|
|
|
#endif // PSYC_RENDER_H
|
2011-04-25 21:14:22 +00:00
|
|
|
|
|
|
|
/** @} */ // end of rendering group
|