aboutsummaryrefslogtreecommitdiffstats
path: root/src/libserver/protocol.h
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2014-05-02 12:16:43 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2014-05-02 12:16:43 +0100
commite6ddee95a731f41a9cca17fe5082bfcda9623924 (patch)
treec0004d9df9b55c09e272882013d17961776c4316 /src/libserver/protocol.h
parenta9b063159312d25427b5baff169a671ede0d38e5 (diff)
downloadrspamd-e6ddee95a731f41a9cca17fe5082bfcda9623924.tar.gz
rspamd-e6ddee95a731f41a9cca17fe5082bfcda9623924.zip
Move protocol functions to libserver.
Diffstat (limited to 'src/libserver/protocol.h')
-rw-r--r--src/libserver/protocol.h53
1 files changed, 53 insertions, 0 deletions
diff --git a/src/libserver/protocol.h b/src/libserver/protocol.h
new file mode 100644
index 000000000..b3643ac7a
--- /dev/null
+++ b/src/libserver/protocol.h
@@ -0,0 +1,53 @@
+/**
+ * @file protocol.h
+ * Rspamd protocol definition
+ */
+
+#ifndef RSPAMD_PROTOCOL_H
+#define RSPAMD_PROTOCOL_H
+
+#include "config.h"
+#include "filter.h"
+#include "http.h"
+#include "task.h"
+
+#define RSPAMD_BASE_ERROR 500
+#define RSPAMD_FILTER_ERROR RSPAMD_BASE_ERROR + 1
+#define RSPAMD_NETWORK_ERROR RSPAMD_BASE_ERROR + 2
+#define RSPAMD_PROTOCOL_ERROR RSPAMD_BASE_ERROR + 3
+#define RSPAMD_LENGTH_ERROR RSPAMD_BASE_ERROR + 4
+#define RSPAMD_STATFILE_ERROR RSPAMD_BASE_ERROR + 5
+
+struct metric;
+
+/**
+ * Process HTTP request to the task structure
+ * @param task
+ * @param msg
+ * @return
+ */
+gboolean rspamd_protocol_handle_request (struct rspamd_task *task, struct rspamd_http_message *msg);
+
+/**
+ * Write task results to http message
+ * @param msg
+ * @param task
+ */
+void rspamd_protocol_http_reply (struct rspamd_http_message *msg, struct rspamd_task *task);
+
+/**
+ * Write reply for specified task command
+ * @param task task object
+ * @return 0 if we wrote reply and -1 if there was some error
+ */
+void rspamd_protocol_write_reply (struct rspamd_task *task);
+
+
+/**
+ * Register custom fucntion to extend protocol
+ * @param name symbolic name of custom function
+ * @param func callback function for writing reply
+ */
+void register_protocol_command (const gchar *name, protocol_reply_func func);
+
+#endif