return 1;
}
-enum rspamd_address_type {
- RSPAMD_ADDRESS_ANY = 0u,
- RSPAMD_ADDRESS_SMTP = 1,
- RSPAMD_ADDRESS_MIME = 2,
- RSPAMD_ADDRESS_MASK = 0x3FF,
- RSPAMD_ADDRESS_RAW = (1u << 10),
- RSPAMD_ADDRESS_ORIGINAL = (1u << 11),
- RSPAMD_ADDRESS_MAX = RSPAMD_ADDRESS_MASK,
+enum lua_email_address_type {
+ LUA_ADDRESS_ANY = 0u,
+ LUA_ADDRESS_SMTP = 1,
+ LUA_ADDRESS_MIME = 2,
+ LUA_ADDRESS_MASK = 0x3FF,
+ LUA_ADDRESS_RAW = (1u << 10),
+ LUA_ADDRESS_ORIGINAL = (1u << 11),
+ LUA_ADDRESS_MAX = LUA_ADDRESS_MASK,
};
/*
* Convert element at the specified position to the type
* for get_from/get_recipients
*/
-static enum rspamd_address_type
+static enum lua_email_address_type
lua_task_str_to_get_type (lua_State *L, struct rspamd_task *task, gint pos)
{
const gchar *type = NULL;
- gint ret = RSPAMD_ADDRESS_ANY;
+ gint ret = LUA_ADDRESS_ANY;
guint64 h;
gsize sz;
if (lua_type (L, pos) == LUA_TNUMBER) {
ret = lua_tonumber (L, pos);
- if (ret >= RSPAMD_ADDRESS_ANY && ret < RSPAMD_ADDRESS_MAX) {
+ if (ret >= LUA_ADDRESS_ANY && ret < LUA_ADDRESS_MAX) {
return ret;
}
- return RSPAMD_ADDRESS_ANY;
+ return LUA_ADDRESS_ANY;
}
else if (lua_type (L, pos) == LUA_TSTRING) {
type = lua_tolstring (L, pos, &sz);
switch (h) {
case 0xDA081341FB600389ULL: /* mime */
- ret = RSPAMD_ADDRESS_MIME;
+ ret = LUA_ADDRESS_MIME;
break;
case 0xEEC8A7832F8C43ACULL: /* any */
- ret = RSPAMD_ADDRESS_ANY;
+ ret = LUA_ADDRESS_ANY;
break;
case 0x472274D5193B2A80ULL: /* smtp */
case 0xEFE0F586CC9F14A9ULL: /* envelope */
- ret = RSPAMD_ADDRESS_SMTP;
+ ret = LUA_ADDRESS_SMTP;
break;
default:
msg_err_task ("invalid email type: %*s", (gint)sz, type);
switch (h) {
case 0xDA081341FB600389ULL: /* mime */
- ret |= RSPAMD_ADDRESS_MIME;
+ ret |= LUA_ADDRESS_MIME;
break;
case 0xEEC8A7832F8C43ACULL: /* any */
- ret |= RSPAMD_ADDRESS_ANY;
+ ret |= LUA_ADDRESS_ANY;
break;
case 0x472274D5193B2A80ULL: /* smtp */
case 0xEFE0F586CC9F14A9ULL: /* envelope */
- ret |= RSPAMD_ADDRESS_SMTP;
+ ret |= LUA_ADDRESS_SMTP;
break;
case 0xAF4DE083D9AD0132: /* raw */
- ret |= RSPAMD_ADDRESS_RAW;
+ ret |= LUA_ADDRESS_RAW;
break;
case 0xC7AB6C7B7B0F5A8A: /* orig */
case 0x1778AE905589E431: /* original */
- ret |= RSPAMD_ADDRESS_ORIGINAL;
+ ret |= LUA_ADDRESS_ORIGINAL;
break;
default:
msg_err_task ("invalid email type: %*s", (gint)sz, type);
addr = g_ptr_array_index (addrs, i);
if (addr->flags & RSPAMD_EMAIL_ADDR_ORIGINAL) {
- if (flags & RSPAMD_ADDRESS_ORIGINAL) {
+ if (flags & LUA_ADDRESS_ORIGINAL) {
lua_push_email_address (L, addr);
lua_rawseti (L, -2, pos);
pos++;
what = lua_task_str_to_get_type (L, task, 2);
}
- switch (what & RSPAMD_ADDRESS_MASK) {
- case RSPAMD_ADDRESS_SMTP:
+ switch (what & LUA_ADDRESS_MASK) {
+ case LUA_ADDRESS_SMTP:
/* Here we check merely envelope rcpt */
ptrs = task->rcpt_envelope;
break;
- case RSPAMD_ADDRESS_MIME:
+ case LUA_ADDRESS_MIME:
/* Here we check merely mime rcpt */
ptrs = MESSAGE_FIELD_CHECK (task, rcpt_mime);
break;
- case RSPAMD_ADDRESS_ANY:
+ case LUA_ADDRESS_ANY:
default:
if (task->rcpt_envelope) {
ptrs = task->rcpt_envelope;
break;
}
if (ptrs) {
- lua_push_emails_address_list (L, ptrs, what & ~RSPAMD_ADDRESS_MASK);
+ lua_push_emails_address_list (L, ptrs, what & ~LUA_ADDRESS_MASK);
}
else {
lua_pushnil (L);
}
switch (what) {
- case RSPAMD_ADDRESS_SMTP:
+ case LUA_ADDRESS_SMTP:
/* Here we check merely envelope rcpt */
if (task->rcpt_envelope) {
ptrs = task->rcpt_envelope;
task->rcpt_envelope = ptrs;
}
break;
- case RSPAMD_ADDRESS_MIME:
+ case LUA_ADDRESS_MIME:
/* Here we check merely mime rcpt */
ptrs = MESSAGE_FIELD_CHECK (task, rcpt_mime);
need_update_digest = TRUE;
break;
- case RSPAMD_ADDRESS_ANY:
+ case LUA_ADDRESS_ANY:
default:
if (task->rcpt_envelope) {
if (task->rcpt_envelope) {
what = lua_task_str_to_get_type (L, task, 2);
}
- switch (what & RSPAMD_ADDRESS_MASK) {
- case RSPAMD_ADDRESS_SMTP:
+ switch (what & LUA_ADDRESS_MASK) {
+ case LUA_ADDRESS_SMTP:
/* Here we check merely envelope rcpt */
CHECK_EMAIL_ADDR (task->from_envelope);
break;
- case RSPAMD_ADDRESS_MIME:
+ case LUA_ADDRESS_MIME:
/* Here we check merely mime rcpt */
CHECK_EMAIL_ADDR_LIST (MESSAGE_FIELD_CHECK (task, from_mime));
break;
- case RSPAMD_ADDRESS_ANY:
+ case LUA_ADDRESS_ANY:
default:
CHECK_EMAIL_ADDR (task->from_envelope);
struct rspamd_email_address *addr;
PTR_ARRAY_FOREACH(ar, i, addr) {
- if (!(addr->flags & RSPAMD_ADDRESS_ORIGINAL)) {
+ if (!(addr->flags & LUA_ADDRESS_ORIGINAL)) {
ret ++;
}
}
what = lua_task_str_to_get_type (L, task, 2);
}
- switch (what & RSPAMD_ADDRESS_MASK) {
- case RSPAMD_ADDRESS_SMTP:
+ switch (what & LUA_ADDRESS_MASK) {
+ case LUA_ADDRESS_SMTP:
/* Here we check merely envelope rcpt */
nrcpt = rspamd_check_real_recipients_array_size(task->rcpt_envelope);
ret = nrcpt > 0;
break;
- case RSPAMD_ADDRESS_MIME:
+ case LUA_ADDRESS_MIME:
/* Here we check merely mime rcpt */
nrcpt = rspamd_check_real_recipients_array_size(MESSAGE_FIELD_CHECK (task, rcpt_mime));
ret = nrcpt > 0;
break;
- case RSPAMD_ADDRESS_ANY:
+ case LUA_ADDRESS_ANY:
default:
nrcpt = rspamd_check_real_recipients_array_size(task->rcpt_envelope);
ret = nrcpt > 0;
what = lua_task_str_to_get_type (L, task, 2);
}
- switch (what & RSPAMD_ADDRESS_MASK) {
- case RSPAMD_ADDRESS_SMTP:
+ switch (what & LUA_ADDRESS_MASK) {
+ case LUA_ADDRESS_SMTP:
/* Here we check merely envelope rcpt */
addr = task->from_envelope;
break;
- case RSPAMD_ADDRESS_MIME:
+ case LUA_ADDRESS_MIME:
/* Here we check merely mime rcpt */
addrs = MESSAGE_FIELD_CHECK (task, from_mime);
break;
- case RSPAMD_ADDRESS_ANY:
+ case LUA_ADDRESS_ANY:
default:
if (task->from_envelope) {
addr = task->from_envelope;
}
if (addrs && addrs->len > 0) {
- lua_push_emails_address_list (L, addrs, what & ~RSPAMD_ADDRESS_MASK);
+ lua_push_emails_address_list (L, addrs, what & ~LUA_ADDRESS_MASK);
}
else if (addr) {
/* Create table to preserve compatibility */
if (addr->addr) {
lua_createtable (L, 1, 0);
- if (what & RSPAMD_ADDRESS_ORIGINAL) {
+ if (what & LUA_ADDRESS_ORIGINAL) {
if (task->from_envelope_orig) {
lua_push_email_address (L, task->from_envelope_orig);
}
how = lua_tostring (L, 4);
}
- switch (what & RSPAMD_ADDRESS_MASK) {
- case RSPAMD_ADDRESS_SMTP:
+ switch (what & LUA_ADDRESS_MASK) {
+ case LUA_ADDRESS_SMTP:
/* Here we check merely envelope rcpt */
paddr = &task->from_envelope;
break;
- case RSPAMD_ADDRESS_MIME:
+ case LUA_ADDRESS_MIME:
/* Here we check merely mime rcpt */
addrs = MESSAGE_FIELD_CHECK (task, from_mime);
need_update_digest = TRUE;
break;
- case RSPAMD_ADDRESS_ANY:
+ case LUA_ADDRESS_ANY:
default:
if (task->from_envelope) {
paddr = &task->from_envelope;