2011-04-22 15:09:32 +00:00
|
|
|
#ifndef PSYC_RENDER_H
|
|
|
|
|
2011-05-03 23:00:35 +00:00
|
|
|
#include <psyc/packet.h>
|
|
|
|
|
2011-04-25 21:14:22 +00:00
|
|
|
/**
|
|
|
|
* @file psyc/render.h
|
|
|
|
* @brief Interface for PSYC packet rendering.
|
|
|
|
*
|
2011-05-09 12:37:57 +00:00
|
|
|
* All rendering functions and the definitions they use are defined here.
|
2011-04-25 21:14:22 +00:00
|
|
|
*/
|
2011-04-22 09:50:13 +00:00
|
|
|
|
2011-04-25 21:14:22 +00:00
|
|
|
/**
|
2011-05-03 23:30:09 +00:00
|
|
|
* @defgroup render Rendering Functions
|
2011-04-25 21:14:22 +00:00
|
|
|
*
|
|
|
|
* 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
|
|
|
|
{
|
2011-05-09 14:32:39 +00:00
|
|
|
/// Error, method is missing, but data is present.
|
|
|
|
PSYC_RENDER_ERROR_METHOD_MISSING = -3,
|
|
|
|
/// Error, a modifier name is missing.
|
|
|
|
PSYC_RENDER_ERROR_MODIFIER_NAME_MISSING = -2,
|
|
|
|
/// Error, buffer is too small to render the packet.
|
2011-04-25 21:14:22 +00:00
|
|
|
PSYC_RENDER_ERROR = -1,
|
2011-05-09 14:32:39 +00:00
|
|
|
/// Packet is rendered successfully in the buffer.
|
2011-04-25 21:14:22 +00:00
|
|
|
PSYC_RENDER_SUCCESS = 0,
|
2011-04-25 21:40:38 +00:00
|
|
|
} psycRenderRC;
|
2011-04-25 21:14:22 +00:00
|
|
|
|
2011-05-09 14:32:39 +00:00
|
|
|
/**
|
|
|
|
* Return codes for psyc_renderList.
|
|
|
|
*/
|
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
/// Error, buffer is too small to render the list.
|
|
|
|
PSYC_RENDER_LIST_ERROR = -1,
|
|
|
|
/// List is rendered successfully in the buffer.
|
|
|
|
PSYC_RENDER_LIST_SUCCESS = 0,
|
|
|
|
} psycRenderListRC;
|
|
|
|
|
2011-04-25 21:14:22 +00:00
|
|
|
/**
|
|
|
|
* Render a PSYC packet into a buffer.
|
2011-05-09 14:32:39 +00:00
|
|
|
*
|
|
|
|
* The packet structure should contain the packet parts, either routing, entity,
|
|
|
|
* method & data, or routing & content when rendering raw content.
|
|
|
|
* It should also contain the contentLength & total length of the packet,
|
2011-05-09 14:56:26 +00:00
|
|
|
* you can use psyc_setPacketLength() for calculating & setting these values.
|
|
|
|
* This function renders packet->length bytes to the buffer,
|
|
|
|
* if buflen is less than that an error is returned.
|
2011-05-09 14:32:39 +00:00
|
|
|
*
|
|
|
|
* @see psyc_newPacket
|
|
|
|
* @see psyc_newPacket2
|
|
|
|
* @see psyc_newRawPacket
|
|
|
|
* @see psyc_newRawPacket2
|
|
|
|
* @see psyc_setPacketLength
|
2011-04-25 21:14:22 +00:00
|
|
|
*/
|
2011-05-16 22:27:26 +00:00
|
|
|
#ifdef __INLINE_PSYC_RENDER
|
|
|
|
static inline
|
|
|
|
#endif
|
2011-05-03 23:00:35 +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.
|
|
|
|
*/
|
2011-05-16 22:27:26 +00:00
|
|
|
#ifdef __INLINE_PSYC_RENDER
|
|
|
|
static inline
|
|
|
|
#endif
|
2011-05-09 14:32:39 +00:00
|
|
|
psycRenderListRC psyc_renderList (psycList *list, char *buffer, size_t buflen);
|
2011-04-26 15:23:06 +00:00
|
|
|
|
2011-05-09 12:37:57 +00:00
|
|
|
/** @} */ // end of render group
|
2011-05-09 07:02:15 +00:00
|
|
|
|
|
|
|
#define PSYC_RENDER_H
|
|
|
|
#endif
|