#include "smtp_parsers.h"
#include "mime_parser.h"
#include "mime_encoding.h"
+#include "libserver/mempool_vars_internal.h"
#ifdef WITH_SNOWBALL
#include "libstemmer.h"
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;
}
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;
#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,
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);
}
}
--- /dev/null
+/*-
+ * 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
#include "lua/lua_common.h"
#include "unix-std.h"
#include "protocol_internal.h"
+#include "libserver/mempool_vars_internal.h"
#include <math.h>
static GQuark
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;
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);
}
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);