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

98 lines
2.8 KiB
C
Raw Normal View History

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-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.
* @{
*/
/**
* 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
*/
#ifdef __INLINE_PSYC_RENDER
inline
#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);
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.
*/
#ifdef __INLINE_PSYC_RENDER
inline
#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
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