Re: Printing path/filename of scanned file in Spamprobe 1.4

Brian Burton <[email protected]> Wed, 04 Jan 2006 14:49:03 -0500
Newsgroups gmane.mail.spam.spamprobe.general
Message-ID <[email protected]>
Anthony Volodkin wrote:
> So the output of a score command would look like this:
> /var/mail/messages/message1005 GOOD 0.0002504 
> b2c089e0c228a2e27288083780432f94
> 
> In the new 1.4 release this modification has become non-trivial (at 
> least with my C++ skills).
> Does anyone know how I can modify spamprobe 1.4 to do this, or perhaps 
> have a patch?

I've attached a quick and dirty patch that does this.  Future releases 
might break it but at least this gives you an idea of where the changes 
need to be plugged in.  I'll probably move the printMessageScore() 
method down into Command_receive later.

All the best,
++Brian
sp_filename_diff.txt (text/plain, 2 KB)
Index: src/spamprobe/AbstractCommand.cc
===================================================================
--- src/spamprobe/AbstractCommand.cc	(revision 225)
+++ src/spamprobe/AbstractCommand.cc	(working copy)
@@ -82,13 +82,18 @@
                                         SpamFilter &filter,
                                         bool is_spam,
                                         double score,
-                                        Message &msg)
+                                        Message &msg,
+                                        const File *source)
 {
+  if (source) {
+    cout << source->getPath()
+         << ' ';
+  }
   cout << (is_spam ? "SPAM " : "GOOD ")
        << scoreToString(score)
        << ' '
-       << msg.getDigest()
-       << endl;
+       << msg.getDigest();
+  cout << endl;
   if (config.commandConfig()->shouldShowTerms() && msg.getTopTokenCount() > 0) {
     printTerms(filter.getDB(), cout, msg, "    ");
   }
Index: src/spamprobe/Command_receive.cc
===================================================================
--- src/spamprobe/Command_receive.cc	(revision 216)
+++ src/spamprobe/Command_receive.cc	(working copy)
@@ -103,7 +103,7 @@
 {
   SpamFilter::Score score = filter.scoreMessage(message);
   is_spam = score.isSpam();
-  printMessageScore(config, filter, is_spam, score.getValue(), message);
+  printMessageScore(config, filter, is_spam, score.getValue(), message, stream_file);
   if (isReadOnly()) {
     // no updates needed
   } else if (m_isTrain) {
Index: src/spamprobe/AbstractCommand.h
===================================================================
--- src/spamprobe/AbstractCommand.h	(revision 222)
+++ src/spamprobe/AbstractCommand.h	(working copy)
@@ -103,7 +103,8 @@
                          SpamFilter &filter,
                          bool is_spam,
                          double score,
-                         Message &msg);
+                         Message &msg,
+                         const File *source);
 
   void setIsSingleMessageCommand(bool value)
   {
PGP.sig (application/pgp-signature, 487 B) - not displayed