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

60 lines
1.5 KiB
C
Raw Normal View History

2011-04-22 15:09:32 +00:00
#ifndef PSYC_RENDER_H
# define PSYC_RENDER_H
2011-04-22 09:50:13 +00:00
#include "syntax.h"
2011-04-22 15:09:32 +00:00
#define PSYC_FLAG_UNDEFINED 0
#define PSYC_FLAG_NOT_BINARY 1
#define PSYC_FLAG_YES_BINARY 2
#define PSYC_FLAG_CHECK_BINARY 3
typedef enum
{
PSYC_RENDER_CHECK_BINARY = 0,
PSYC_RENDER_BINARY = 1,
PSYC_RENDER_NOT_BINARY = 2,
PSYC_RENDER_ROUTING = 3,
2011-04-20 20:22:55 +00:00
} PSYC_RenderFlag;
2011-04-22 15:09:32 +00:00
typedef enum
{
PSYC_RENDER_ERROR_ROUTING = -2,
PSYC_RENDER_ERROR = -1,
PSYC_RENDER_SUCCESS = 0,
} PSYC_RenderRC;
2011-04-22 09:50:13 +00:00
2011-04-22 15:09:32 +00:00
/**
* Struct for keeping render state.
*/
typedef struct
{
2011-04-20 20:22:55 +00:00
PSYC_RenderFlag flag; ///< flags for the renderer
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
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-22 15:09:32 +00:00
/**
* Initiates the state struct.
*
* @param state Pointer to the state struct that should be initiated.
*/
inline void PSYC_initRenderState (PSYC_RenderState* state)
{
memset(state, 0, sizeof(PSYC_RenderState));
}
int PSYC_renderVar(PSYC_RenderState* render,
2011-04-22 09:50:13 +00:00
const char* name, size_t nlength,
const char* value, size_t vlength,
2011-04-22 15:09:32 +00:00
PSYC_RenderFlag flags, char modifier);
2011-04-18 14:54:56 +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-22 15:09:32 +00:00
#endif // PSYC_RENDER_H