Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions man/mailfilter.1
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ Simulate deletes
\fB\-i\fR, \fB\-\-ignore-time-stamps\fR
Ignore invalid Message-ID time stamps (Do not use unless you know better!)
.TP
\fB\-m\fR, \fB\-\-max-messages\fR=\fINUMBER\fR
Maximum number messages to check, starting from end (POP3 only)
.TP
\fB\-v\fR, \fB\-\-verbose\fR=\fILEVEL\fR
Specify level of verbosity
.TP
Expand Down
8 changes: 8 additions & 0 deletions src/account.cc
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,14 @@ int Account :: check (void)
+ int_to_string (messages)
+ " message(s).", 3);

if (Preferences :: Instance ().max_messages() > 0
&& messages > Preferences :: Instance ().max_messages())
{
logger->print_msg ("Examining last "
+ int_to_string (Preferences :: Instance ().max_messages())
+ " message(s).", 3);
}

// Scan mailbox for spam and unwanted bulk.
if (proto->scan () < 0)
{
Expand Down
9 changes: 8 additions & 1 deletion src/mailfilter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ static struct option long_options[] =
{"test", 0, NULL, VALUE_TEST},
{"return-value", 0, NULL, VALUE_RETURN},
{"skip-ssl-verify", 0, NULL, VALUE_SKIP_SSL_VERIFY},
{"max-messages", 1, NULL, VALUE_MAX_MESSAGES},
{0, 0, 0, 0}
};

Expand Down Expand Up @@ -207,7 +208,7 @@ void get_opts (int argc, char* argv[])
int option = 0;
int option_index = 0;

while ((option = getopt_long (argc, argv, "hL:M:Vv:tirs",
while ((option = getopt_long (argc, argv, "hL:M:Vv:tirsm:",
long_options, &option_index)) != -1)
{
switch (option)
Expand Down Expand Up @@ -235,6 +236,8 @@ void get_opts (int argc, char* argv[])
cout << "Enable additional return values" << endl;
cout << " -s, --skip-ssl-verify ";
cout << "Skip verification of SSL certificates (Do not use unless you know better!)" << endl;
cout << " -m, --max-messages=NUMBER ";
cout << "Maximum number messages to check, starting from end (POP3 only)" << endl;
cout << " -t, --test ";
cout << "Simulate deletes" << endl;
cout << " -i, --ignore-time-stamps ";
Expand Down Expand Up @@ -284,6 +287,10 @@ void get_opts (int argc, char* argv[])
case VALUE_SKIP_SSL_VERIFY:
Preferences :: Instance ().set_skip_ssl_verify (true);
break;
case 'm':
case VALUE_MAX_MESSAGES:
Preferences :: Instance ().set_max_messages (atoi (optarg));
break;
case 'M':
case VALUE_MAILFILTERRC:
Preferences :: Instance ().set_rc_file (optarg);
Expand Down
1 change: 1 addition & 0 deletions src/mailfilter.hh
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ using namespace std;
#define VALUE_RETURN 7
#define VALUE_TIMESTAMP 8
#define VALUE_SKIP_SSL_VERIFY 9
#define VALUE_MAX_MESSAGES 10

#define ERROR_MSG(msg) \
cerr << PACKAGE_NAME \
Expand Down
10 changes: 9 additions & 1 deletion src/pop3.cc
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ int POP3 :: scan (void) const

Header* msg_header;
int num_messages;
int max_messages;
int start_message;
stringstream msg_no;
string cmd;

Expand All @@ -114,10 +116,16 @@ int POP3 :: scan (void) const
logger->print_err ("Error occurred while sending STAT to server.");
return GEN_FAILURE_FLAG;
}
start_message = 1;
max_messages = Preferences :: Instance ().max_messages();
if (max_messages > 0 && num_messages > max_messages)
{
start_message = num_messages - max_messages + 1;
}

try
{
for (int i = 1; i <= num_messages; i++)
for (int i = start_message; i <= num_messages; i++)
{
// Reserve heap for the message to be stored, parsed, and
// processed.
Expand Down
7 changes: 7 additions & 0 deletions src/preferences.cc
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ Preferences :: Preferences ()
ret_status = false;
_ignore_time_stamp= false;
_skip_ssl_verify = false;
_max_messages = 0;
high_score = 100;
time_out_val = 30;
negative_allows = 0;
Expand Down Expand Up @@ -480,3 +481,9 @@ void Preferences :: set_skip_ssl_verify (bool skip)

bool Preferences :: skip_ssl_verify (void)
{ return _skip_ssl_verify; }

void Preferences :: set_max_messages (int val)
{ _max_messages = val; }

int Preferences :: max_messages (void)
{ return _max_messages; }
3 changes: 3 additions & 0 deletions src/preferences.hh
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ protected:
bool ret_status;
bool _ignore_time_stamp;
bool _skip_ssl_verify;
int _max_messages;
int high_score;
unsigned time_out_val;
int max_size;
Expand Down Expand Up @@ -130,6 +131,8 @@ public:
void set_return_status (bool);
void set_skip_ssl_verify (bool);
bool skip_ssl_verify (void);
void set_max_messages (int);
int max_messages (void);
vector<Account>* accounts (void);
vector<Filter>* allow_filters (void);
vector<Filter>* deny_filters (void);
Expand Down