summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
999768b)
(spam_level): Rename from is_spam . Return 0 for not spam, and 1, 2, or 3 for
exceeding 1, 2, or 3 * the user's configured threshold.
(process): Construct spam folder name with the spam_level .
-static bool
-is_spam(char *message)
+static int
+spam_level(char *message)
{
struct transport t;
struct message m;
int status;
if (!get_transport(&t)) {
{
struct transport t;
struct message m;
int status;
if (!get_transport(&t)) {
}
if (!get_message(message, &m)) {
}
if (!get_message(message, &m)) {
}
if ((status = message_filter(&t, logname(), flags, &m)) != EX_OK) {
warnx("non-fatal: message_filter");
}
if ((status = message_filter(&t, logname(), flags, &m)) != EX_OK) {
warnx("non-fatal: message_filter");
}
if (m.is_spam == EX_ISSPAM) {
}
if (m.is_spam == EX_ISSPAM) {
+ if (m.score > m.threshold * 3) {
+ return 3;
+ } else if (m.score > m.threshold * 2) {
+ return 2;
+ }
+ return 1;
} else if (m.is_spam == EX_NOTSPAM) {
} else if (m.is_spam == EX_NOTSPAM) {
}
warnx("non-fatal: message_filter returned %d", m.is_spam);
}
warnx("non-fatal: message_filter returned %d", m.is_spam);
}
static int
process(char *tmp)
{
size_t len = strlen(tmp);
}
static int
process(char *tmp)
{
size_t len = strlen(tmp);
- errfn = malloc(len + 1);
- /* 5 for spam/ and 1 for terminating null */
- char *new = malloc(len + 5 + 1);
+ /* 6 for spamN/ and 1 for terminating null */
+ char *new = malloc(len + 6 + 1);
+ int level = spam_level(tmp);
/* Nothing to do about a malloc failure but dump core. */
/* Nothing to do about a malloc failure but dump core. */
+ errfn = malloc(len + 1);
strcpy(errfn, "err");
strcat(errfn, tmp + 3);
strcpy(errfn, "err");
strcat(errfn, tmp + 3);
- new[0] = '\0';
- if (is_spam(tmp)) {
- strcpy(new, "spam/");
+ if (level > 0) {
+ snprintf(new, 7, "spam%d/", level);
+ } else {
+ new[0] = '\0';
}
strcat(new, "new");
strcat(new, tmp + 3);
}
strcat(new, "new");
strcat(new, tmp + 3);