2013-07-16 14:53:51 +00:00
|
|
|
/*
|
|
|
|
This file is part of libpsyc.
|
|
|
|
Copyright (C) 2011,2012 Carlo v. Loesch, Gabor X Toth, Mathias L. Baumann,
|
|
|
|
and other contributing authors.
|
|
|
|
|
|
|
|
libpsyc is free software: you can redistribute it and/or modify it under the
|
|
|
|
terms of the GNU Affero General Public License as published by the Free
|
|
|
|
Software Foundation, either version 3 of the License, or (at your option) any
|
|
|
|
later version. As a special exception, libpsyc is distributed with additional
|
|
|
|
permissions to link libpsyc libraries with non-AGPL works.
|
|
|
|
|
|
|
|
libpsyc is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
|
|
FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
|
|
|
details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Affero General Public License and
|
|
|
|
the linking exception along with libpsyc in a COPYING file.
|
|
|
|
*/
|
|
|
|
|
2011-04-22 15:09:32 +00:00
|
|
|
#ifndef PSYC_RENDER_H
|
2011-11-11 21:18:24 +00:00
|
|
|
#define PSYC_RENDER_H
|
2011-04-22 15:09:32 +00:00
|
|
|
|
2011-11-30 12:51:50 +00:00
|
|
|
#include "packet.h"
|
2011-05-03 23:00:35 +00:00
|
|
|
|
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
|
|
|
*/
|
2011-11-11 21:18:24 +00:00
|
|
|
typedef enum {
|
|
|
|
/// 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.
|
|
|
|
PSYC_RENDER_ERROR = -1,
|
|
|
|
/// Packet is rendered successfully in the buffer.
|
|
|
|
PSYC_RENDER_SUCCESS = 0,
|
2011-10-31 19:26:47 +00:00
|
|
|
} PsycRenderRC;
|
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-10-31 19:04:16 +00:00
|
|
|
* you can use psyc_packet_length_set() for calculating & setting these values.
|
2011-05-09 14:56:26 +00:00
|
|
|
* 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
|
|
|
*
|
2011-11-03 13:27:01 +00:00
|
|
|
* @see psyc_packet_init()
|
|
|
|
* @see psyc_packet_init_raw()
|
|
|
|
* @see psyc_packet_length_set()
|
2011-04-25 21:14:22 +00:00
|
|
|
*/
|
2011-05-16 22:27:26 +00:00
|
|
|
#ifdef __INLINE_PSYC_RENDER
|
2016-08-21 07:58:36 +00:00
|
|
|
inline
|
2011-05-16 22:27:26 +00:00
|
|
|
#endif
|
2011-11-11 21:18:24 +00:00
|
|
|
PsycRenderRC
|
|
|
|
psyc_render (PsycPacket *packet, char *buffer, size_t buflen);
|
2011-04-25 21:14:22 +00:00
|
|
|
|
2012-02-15 21:39:19 +00:00
|
|
|
size_t
|
|
|
|
psyc_render_modifier (PsycModifier *mod, char *buffer);
|
|
|
|
|
2012-02-06 14:05:08 +00:00
|
|
|
PsycRenderRC
|
|
|
|
psyc_render_elem (PsycElem *elem, char *buffer, size_t buflen);
|
|
|
|
|
|
|
|
PsycRenderRC
|
|
|
|
psyc_render_dict_key (PsycDictKey *elem, char *buffer, size_t buflen);
|
|
|
|
|
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
|
2016-08-21 07:58:36 +00:00
|
|
|
inline
|
2011-05-16 22:27:26 +00:00
|
|
|
#endif
|
2011-11-26 14:03:10 +00:00
|
|
|
PsycRenderRC
|
2011-11-11 21:18:24 +00:00
|
|
|
psyc_render_list (PsycList *list, char *buffer, size_t buflen);
|
2011-04-26 15:23:06 +00:00
|
|
|
|
2011-11-26 14:03:10 +00:00
|
|
|
PsycRenderRC
|
2012-02-06 14:05:08 +00:00
|
|
|
psyc_render_dict (PsycDict *dict, char *buffer, size_t buflen);
|
2011-12-28 22:45:16 +00:00
|
|
|
|
2011-05-09 12:37:57 +00:00
|
|
|
/** @} */ // end of render group
|
2011-05-09 07:02:15 +00:00
|
|
|
|
|
|
|
#endif
|