aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/libmime/message.c15
-rw-r--r--src/libmime/mime_headers.c4
-rw-r--r--src/libserver/mempool_vars_internal.h29
-rw-r--r--src/libserver/protocol.c9
4 files changed, 47 insertions, 10 deletions
diff --git a/src/libmime/message.c b/src/libmime/message.c
index 1d0783d9b..1d61b9807 100644
--- a/src/libmime/message.c
+++ b/src/libmime/message.c
@@ -24,6 +24,7 @@
#include "smtp_parsers.h"
#include "mime_parser.h"
#include "mime_encoding.h"
+#include "libserver/mempool_vars_internal.h"
#ifdef WITH_SNOWBALL
#include "libstemmer.h"
@@ -291,26 +292,26 @@ rspamd_extract_words (struct rspamd_task *task,
gdouble *avg_len_p, *short_len_p;
avg_len_p = rspamd_mempool_get_variable (task->task_pool,
- "avg_words_len");
+ RSPAMD_MEMPOOL_AVG_WORDS_LEN);
if (avg_len_p == NULL) {
avg_len_p = rspamd_mempool_alloc (task->task_pool, sizeof (double));
*avg_len_p = total_len;
rspamd_mempool_set_variable (task->task_pool,
- "avg_words_len", avg_len_p, NULL);
+ RSPAMD_MEMPOOL_AVG_WORDS_LEN, avg_len_p, NULL);
}
else {
*avg_len_p += total_len;
}
short_len_p = rspamd_mempool_get_variable (task->task_pool,
- "short_words_cnt");
+ RSPAMD_MEMPOOL_SHORT_WORDS_CNT);
if (short_len_p == NULL) {
short_len_p = rspamd_mempool_alloc (task->task_pool, sizeof (double));
*short_len_p = short_len;
rspamd_mempool_set_variable (task->task_pool,
- "short_words_cnt", avg_len_p, NULL);
+ RSPAMD_MEMPOOL_SHORT_WORDS_CNT, avg_len_p, NULL);
}
else {
*short_len_p += short_len;
@@ -950,13 +951,15 @@ rspamd_message_parse (struct rspamd_task *task)
}
if (total_words > 0) {
- var = rspamd_mempool_get_variable (task->task_pool, "avg_words_len");
+ var = rspamd_mempool_get_variable (task->task_pool,
+ RSPAMD_MEMPOOL_AVG_WORDS_LEN);
if (var) {
*var /= (double)total_words;
}
- var = rspamd_mempool_get_variable (task->task_pool, "short_words_cnt");
+ var = rspamd_mempool_get_variable (task->task_pool,
+ RSPAMD_MEMPOOL_SHORT_WORDS_CNT);
if (var) {
*var /= (double)total_words;
diff --git a/src/libmime/mime_headers.c b/src/libmime/mime_headers.c
index b4203f0d4..ef05bfcb3 100644
--- a/src/libmime/mime_headers.c
+++ b/src/libmime/mime_headers.c
@@ -17,6 +17,7 @@
#include "mime_headers.h"
#include "smtp_parsers.h"
#include "mime_encoding.h"
+#include "libserver/mempool_vars_internal.h"
static void
rspamd_mime_header_check_special (struct rspamd_task *task,
@@ -444,7 +445,8 @@ rspamd_mime_headers_process (struct rspamd_task *task, GHashTable *target,
hexout[sizeof (hout) * 2] = '\0';
rspamd_encode_hex_buf (hout, sizeof (hout), hexout,
sizeof (hout) * 2 + 1);
- rspamd_mempool_set_variable (task->task_pool, "headers_hash",
+ rspamd_mempool_set_variable (task->task_pool,
+ RSPAMD_MEMPOOL_HEADERS_HASH,
hexout, NULL);
}
}
diff --git a/src/libserver/mempool_vars_internal.h b/src/libserver/mempool_vars_internal.h
new file mode 100644
index 000000000..d73d530e3
--- /dev/null
+++ b/src/libserver/mempool_vars_internal.h
@@ -0,0 +1,29 @@
+/*-
+ * Copyright 2016 Vsevolod Stakhov
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef RSPAMD_MEMPOOL_VARS_INTERNAL_H
+#define RSPAMD_MEMPOOL_VARS_INTERNAL_H
+
+/* Basic rspamd mempool variables names */
+#define RSPAMD_MEMPOOL_AVG_WORDS_LEN "avg_words_len"
+#define RSPAMD_MEMPOOL_SHORT_WORDS_CNT "short_words_cnt"
+#define RSPAMD_MEMPOOL_HEADERS_HASH "headers_hash"
+#define RSPAMD_MEMPOOL_SETTINGS_HASH "settings_hash"
+#define RSPAMD_MEMPOOL_MTA_TAG "MTA-Tag"
+#define RSPAMD_MEMPOOL_CACHED_REPLY "cached_reply"
+
+
+#endif
diff --git a/src/libserver/protocol.c b/src/libserver/protocol.c
index 1c11832a2..404e75ce4 100644
--- a/src/libserver/protocol.c
+++ b/src/libserver/protocol.c
@@ -23,6 +23,7 @@
#include "lua/lua_common.h"
#include "unix-std.h"
#include "protocol_internal.h"
+#include "libserver/mempool_vars_internal.h"
#include <math.h>
static GQuark
@@ -357,7 +358,8 @@ rspamd_protocol_handle_headers (struct rspamd_task *task,
hv_tok->begin, hv_tok->len, 0xdeadbabe);
hp = rspamd_mempool_alloc (task->task_pool, sizeof (*hp));
memcpy (hp, &h, sizeof (*hp));
- rspamd_mempool_set_variable (task->task_pool, "settings_hash",
+ rspamd_mempool_set_variable (task->task_pool,
+ RSPAMD_MEMPOOL_SETTINGS_HASH,
hp, NULL);
}
break;
@@ -424,7 +426,8 @@ rspamd_protocol_handle_headers (struct rspamd_task *task,
IF_HEADER (MTA_TAG_HEADER) {
gchar *mta_tag;
mta_tag = rspamd_mempool_ftokdup (task->task_pool, hv_tok);
- rspamd_mempool_set_variable (task->task_pool, "MTA-Tag",
+ rspamd_mempool_set_variable (task->task_pool,
+ RSPAMD_MEMPOOL_MTA_TAG,
mta_tag, NULL);
debug_task ("read MTA-Tag header, value: %s", mta_tag);
}
@@ -1068,7 +1071,7 @@ rspamd_protocol_write_ucl (struct rspamd_task *task,
GString *dkim_sig;
const ucl_object_t *rmilter_reply;
struct rspamd_saved_protocol_reply *cached;
- static const gchar *varname = "cached_reply";
+ static const gchar *varname = RSPAMD_MEMPOOL_CACHED_REPLY;
/* Check for cached reply */
cached = rspamd_mempool_get_variable (task->task_pool, varname);