aboutsummaryrefslogtreecommitdiffstats
path: root/src/libserver/buffer.h
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2014-07-23 12:53:08 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2014-07-23 12:53:08 +0100
commitfe79d8c5a39f2b717f78cc3f3ef21b3cfc46500b (patch)
treec84e6a5d4c5cd78a7a2cc3c7adbc7af5d0541682 /src/libserver/buffer.h
parente0483657ff6cf1adc828ccce457814d61fe90a0d (diff)
downloadrspamd-fe79d8c5a39f2b717f78cc3f3ef21b3cfc46500b.tar.gz
rspamd-fe79d8c5a39f2b717f78cc3f3ef21b3cfc46500b.zip
Revert "Unify code style."
This reverts commit e0483657ff6cf1adc828ccce457814d61fe90a0d.
Diffstat (limited to 'src/libserver/buffer.h')
-rw-r--r--src/libserver/buffer.h93
1 files changed, 45 insertions, 48 deletions
diff --git a/src/libserver/buffer.h b/src/libserver/buffer.h
index 0a4c54462..5ed42bfb3 100644
--- a/src/libserver/buffer.h
+++ b/src/libserver/buffer.h
@@ -7,8 +7,8 @@
#define RSPAMD_BUFFER_H
#include "config.h"
-#include "fstring.h"
#include "mem_pool.h"
+#include "fstring.h"
typedef gboolean (*dispatcher_read_callback_t)(f_str_t *in, void *user_data);
typedef gboolean (*dispatcher_write_callback_t)(void *user_data);
@@ -18,17 +18,17 @@ typedef void (*dispatcher_err_callback_t)(GError *err, void *user_data);
* Types of IO handling
*/
enum io_policy {
- BUFFER_LINE, /**< call handler when we have line ready */
- BUFFER_CHARACTER, /**< call handler when we have some characters */
- BUFFER_ANY /**< call handler whenever we got data in buffer */
+ BUFFER_LINE, /**< call handler when we have line ready */
+ BUFFER_CHARACTER, /**< call handler when we have some characters */
+ BUFFER_ANY /**< call handler whenever we got data in buffer */
};
/**
* Buffer structure
*/
typedef struct rspamd_buffer_s {
- f_str_t *data; /**< buffer logic */
- gchar *pos; /**< current position */
+ f_str_t *data; /**< buffer logic */
+ gchar *pos; /**< current position */
} rspamd_buffer_t;
struct rspamd_out_buffer_s {
@@ -38,33 +38,33 @@ struct rspamd_out_buffer_s {
};
typedef struct rspamd_io_dispatcher_s {
- rspamd_buffer_t *in_buf; /**< input buffer */
+ rspamd_buffer_t *in_buf; /**< input buffer */
struct {
guint pending;
struct rspamd_out_buffer_s *buffers;
- } out_buffers; /**< output buffers chain */
- struct timeval *tv; /**< io timeout */
- struct event *ev; /**< libevent io event */
- rspamd_mempool_t *pool; /**< where to store data */
- enum io_policy policy; /**< IO policy */
- size_t nchars; /**< how many chars to read */
- gint fd; /**< descriptor */
- guint32 peer_addr; /**< address of peer for debugging */
- gboolean wanna_die; /**< if dispatcher should be stopped */
- dispatcher_read_callback_t read_callback; /**< read callback */
- dispatcher_write_callback_t write_callback; /**< write callback */
- dispatcher_err_callback_t err_callback; /**< error callback */
- void *user_data; /**< user's data for callbacks */
- gulong default_buf_size; /**< default size for buffering */
- off_t offset; /**< for sendfile use */
+ } out_buffers; /**< output buffers chain */
+ struct timeval *tv; /**< io timeout */
+ struct event *ev; /**< libevent io event */
+ rspamd_mempool_t *pool; /**< where to store data */
+ enum io_policy policy; /**< IO policy */
+ size_t nchars; /**< how many chars to read */
+ gint fd; /**< descriptor */
+ guint32 peer_addr; /**< address of peer for debugging */
+ gboolean wanna_die; /**< if dispatcher should be stopped */
+ dispatcher_read_callback_t read_callback; /**< read callback */
+ dispatcher_write_callback_t write_callback; /**< write callback */
+ dispatcher_err_callback_t err_callback; /**< error callback */
+ void *user_data; /**< user's data for callbacks */
+ gulong default_buf_size; /**< default size for buffering */
+ off_t offset; /**< for sendfile use */
size_t file_size;
gint sendfile_fd;
- gboolean in_sendfile; /**< whether buffer is in sendfile mode */
- gboolean strip_eol; /**< strip or not line ends in BUFFER_LINE policy */
- gboolean is_restored; /**< call a callback when dispatcher is restored */
- gboolean half_closed; /**< connection is half closed */
- gboolean want_read; /**< whether we want to read more data */
- struct event_base *ev_base; /**< event base for io operations */
+ gboolean in_sendfile; /**< whether buffer is in sendfile mode */
+ gboolean strip_eol; /**< strip or not line ends in BUFFER_LINE policy */
+ gboolean is_restored; /**< call a callback when dispatcher is restored */
+ gboolean half_closed; /**< connection is half closed */
+ gboolean want_read; /**< whether we want to read more data */
+ struct event_base *ev_base; /**< event base for io operations */
#ifndef HAVE_SENDFILE
void *map;
#endif
@@ -81,14 +81,13 @@ typedef struct rspamd_io_dispatcher_s {
* @param user_data pointer to user's data
* @return new dispatcher object or NULL in case of failure
*/
-rspamd_io_dispatcher_t * rspamd_create_dispatcher (struct event_base *base,
- gint fd,
- enum io_policy policy,
- dispatcher_read_callback_t read_cb,
- dispatcher_write_callback_t write_cb,
- dispatcher_err_callback_t err_cb,
- struct timeval *tv,
- void *user_data);
+rspamd_io_dispatcher_t* rspamd_create_dispatcher (struct event_base *base, gint fd,
+ enum io_policy policy,
+ dispatcher_read_callback_t read_cb,
+ dispatcher_write_callback_t write_cb,
+ dispatcher_err_callback_t err_cb,
+ struct timeval *tv,
+ void *user_data);
/**
* Set new policy for dispatcher
@@ -96,9 +95,9 @@ rspamd_io_dispatcher_t * rspamd_create_dispatcher (struct event_base *base,
* @param policy IO policy
* @param nchars number of characters in buffer for character policy
*/
-void rspamd_set_dispatcher_policy (rspamd_io_dispatcher_t *d,
- enum io_policy policy,
- size_t nchars);
+void rspamd_set_dispatcher_policy (rspamd_io_dispatcher_t *d,
+ enum io_policy policy,
+ size_t nchars);
/**
* Write data when it would be possible
@@ -107,9 +106,9 @@ void rspamd_set_dispatcher_policy (rspamd_io_dispatcher_t *d,
* @param len length of data
*/
gboolean rspamd_dispatcher_write (rspamd_io_dispatcher_t *d,
- const void *data,
- size_t len, gboolean delayed,
- gboolean allocated) G_GNUC_WARN_UNUSED_RESULT;
+ const void *data,
+ size_t len, gboolean delayed,
+ gboolean allocated) G_GNUC_WARN_UNUSED_RESULT;
/**
* Write a GString to dispatcher
@@ -120,9 +119,9 @@ gboolean rspamd_dispatcher_write (rspamd_io_dispatcher_t *d,
* @return TRUE if write has been queued successfully
*/
gboolean rspamd_dispatcher_write_string (rspamd_io_dispatcher_t *d,
- GString *str,
- gboolean delayed,
- gboolean free_on_write) G_GNUC_WARN_UNUSED_RESULT;
+ GString *str,
+ gboolean delayed,
+ gboolean free_on_write) G_GNUC_WARN_UNUSED_RESULT;
/**
* Send specified descriptor to dispatcher
@@ -130,9 +129,7 @@ gboolean rspamd_dispatcher_write_string (rspamd_io_dispatcher_t *d,
* @param fd descriptor of file
* @param len length of data
*/
-gboolean rspamd_dispatcher_sendfile (rspamd_io_dispatcher_t *d,
- gint fd,
- size_t len) G_GNUC_WARN_UNUSED_RESULT;
+gboolean rspamd_dispatcher_sendfile (rspamd_io_dispatcher_t *d, gint fd, size_t len) G_GNUC_WARN_UNUSED_RESULT;
/**
* Pause IO events on dispatcher