if (res == NULL) {
/* Treat the whole query as path */
- task->msg.start = msg->url->str + u.field_data[UF_QUERY].off;
+ task->msg.begin = msg->url->str + u.field_data[UF_QUERY].off;
task->msg.len = u.field_data[UF_QUERY].len;
}
else {
- task->msg.start = rspamd_mempool_strdup (task->task_pool, res->str);
+ task->msg.begin = rspamd_mempool_strdup (task->task_pool, res->str);
task->msg.len = res->len;
}
{
struct rspamd_task *task = ud;
- munmap ((void *)task->msg.start, task->msg.len);
+ munmap ((void *)task->msg.begin, task->msg.len);
}
gboolean
if (task->flags & RSPAMD_TASK_FLAG_FILE) {
g_assert (task->msg.len > 0);
- r = rspamd_strlcpy (filepath, task->msg.start,
+ r = rspamd_strlcpy (filepath, task->msg.begin,
MIN (sizeof (filepath), task->msg.len + 1));
rspamd_decode_url (filepath, filepath, r + 1);
}
close (fd);
- task->msg.start = map;
+ task->msg.begin = map;
task->msg.len = st.st_size;
rspamd_mempool_add_destructor (task->task_pool, rspamd_task_unmapper, task);
}
else {
debug_task ("got input of length %z", task->msg.len);
- task->msg.start = start;
+ task->msg.begin = start;
task->msg.len = len;
if (task->msg.len == 0) {
if (control_len > 0) {
parser = ucl_parser_new (UCL_PARSER_KEY_LOWERCASE);
- if (!ucl_parser_add_chunk (parser, task->msg.start, control_len)) {
+ if (!ucl_parser_add_chunk (parser, task->msg.begin, control_len)) {
msg_warn_task ("processing of control chunk failed: %s",
ucl_parser_get_error (parser));
ucl_parser_free (parser);
ucl_object_unref (control_obj);
}
- task->msg.start += control_len;
+ task->msg.begin += control_len;
task->msg.len -= control_len;
}
}
struct rspamd_stat_sqlite3_ctx *ctx = (struct rspamd_stat_sqlite3_ctx *)c;
struct mime_text_part *part;
blake2b_state st;
- rspamd_fstring_t *word;
+ rspamd_ftok_t *word;
guchar out[BLAKE2B_OUTBYTES];
guint i, j;
if (part->words != NULL) {
for (j = 0; j < part->words->len; j ++) {
- word = &g_array_index (part->words, rspamd_fstring_t, j);
+ word = &g_array_index (part->words, rspamd_ftok_t, j);
blake2b_update (&st, word->begin, word->len);
}
}
const gchar *name, const gchar *prefix, GArray *ar)
{
struct raw_header *rh, *cur;
- rspamd_fstring_t str;
+ rspamd_ftok_t str;
rh = g_hash_table_lookup (task->raw_headers, name);
struct mime_text_part *tp;
GList *cur;
GArray *ar;
- rspamd_fstring_t elt;
+ rspamd_ftok_t elt;
guint i;
ar = g_array_sized_new (FALSE, FALSE, sizeof (elt), 4);
const gchar *prefix)
{
rspamd_token_t *new = NULL;
- rspamd_fstring_t *token;
+ rspamd_ftok_t *token;
struct rspamd_osb_tokenizer_config *osb_cf;
guint64 *hashpipe, cur, seed;
guint32 h1, h2;
memset (hashpipe, 0xfe, window_size * sizeof (hashpipe[0]));
for (w = 0; w < input->len; w ++) {
- token = &g_array_index (input, rspamd_fstring_t, w);
+ token = &g_array_index (input, rspamd_ftok_t, w);
if (osb_cf->ht == RSPAMD_OSB_HASH_COMPAT) {
cur = rspamd_fstrhash_lc (token, is_utf);
#include "tokenizers.h"
#include "stat_internal.h"
-typedef gboolean (*token_get_function) (rspamd_fstring_t * buf, gchar **pos,
- rspamd_fstring_t * token,
+typedef gboolean (*token_get_function) (rspamd_ftok_t * buf, gchar const **pos,
+ rspamd_ftok_t * token,
GList **exceptions, gboolean is_utf, gsize *rl, gboolean check_signature);
const gchar t_delimiters[255] = {
/* Get next word from specified f_str_t buf */
static gboolean
-rspamd_tokenizer_get_word_compat (rspamd_fstring_t * buf,
- gchar **cur, rspamd_fstring_t * token,
+rspamd_tokenizer_get_word_compat (rspamd_ftok_t * buf,
+ gchar const **cur, rspamd_ftok_t * token,
GList **exceptions, gboolean is_utf, gsize *rl, gboolean unused)
{
gsize remain, pos;
- guchar *p;
+ const gchar *p;
struct process_exception *ex = NULL;
if (buf == NULL) {
pos++;
p++;
remain--;
- } while (remain > 0 && t_delimiters[*p]);
+ } while (remain > 0 && t_delimiters[(guchar)*p]);
token->begin = p;
- while (remain > 0 && !t_delimiters[*p]) {
+ while (remain > 0 && !t_delimiters[(guchar)*p]) {
if (ex != NULL && ex->pos == pos) {
*exceptions = g_list_next (*exceptions);
*cur = p + ex->len;
}
static gboolean
-rspamd_tokenizer_get_word (rspamd_fstring_t * buf,
- gchar **cur, rspamd_fstring_t * token,
+rspamd_tokenizer_get_word (rspamd_ftok_t * buf,
+ gchar const **cur, rspamd_ftok_t * token,
GList **exceptions, gboolean is_utf, gsize *rl,
gboolean check_signature)
{
gsize remain, pos, siglen = 0;
- gchar *p, *next_p, *sig = NULL;
+ const gchar *p, *next_p, *sig = NULL;
gunichar uc;
guint processed = 0;
struct process_exception *ex = NULL;
gsize min_len, GList *exceptions, gboolean compat,
gboolean check_signature)
{
- rspamd_fstring_t token, buf;
- gchar *pos = NULL;
+ rspamd_ftok_t token, buf;
+ const gchar *pos = NULL;
gsize l;
GArray *res;
GList *cur = exceptions;
buf.begin = text;
buf.len = len;
- buf.size = buf.len;
token.begin = NULL;
token.len = 0;
func = rspamd_tokenizer_get_word;
}
- res = g_array_sized_new (FALSE, FALSE, sizeof (rspamd_fstring_t), 128);
+ res = g_array_sized_new (FALSE, FALSE, sizeof (rspamd_ftok_t), 128);
while (func (&buf, &pos, &token, &cur, is_utf, &l, FALSE)) {
if (l == 0 || (min_len > 0 && l < min_len)) {
gint token_node_compare_func (gconstpointer a, gconstpointer b);
-/* Tokenize text into array of words (rspamd_fstring_t type) */
+/* Tokenize text into array of words (rspamd_ftok_t type) */
GArray * rspamd_tokenize_text (gchar *text, gsize len, gboolean is_utf,
gsize min_len, GList *exceptions, gboolean compat,
gboolean check_signature);
* Return hash value for a string
*/
guint32
-rspamd_fstrhash_lc (const rspamd_fstring_t * str, gboolean is_utf)
+rspamd_fstrhash_lc (const rspamd_ftok_t * str, gboolean is_utf)
{
gsize i;
guint32 j, hval;
return 0;
}
- p = str->str;
+ p = str->begin;
hval = str->len;
if (is_utf) {
- while (end < str->str + str->len) {
+ while (end < str->begin + str->len) {
if (!g_utf8_validate (p, str->len, &end)) {
return rspamd_fstrhash_lc (str, FALSE);
}
/*
* Return fast hash value for fixed string converted to lowercase
*/
-guint32 rspamd_fstrhash_lc (const rspamd_fstring_t *str, gboolean is_utf);
+guint32 rspamd_fstrhash_lc (const rspamd_ftok_t *str, gboolean is_utf);
/**
* Return true if two strings are equal