1 /**************************************************************************
2 ** (c) Copyright 2007, Andromeda Technology & Automation
3 ** This is free software; you can redistribute it and/or modify it under the
4 ** terms of the GNU General Public License, see the file COPYING.
5 ***************************************************************************
6 ** MODULE INFORMATION *
7 ***********************
8 ** FILE NAME : spamdetect.cpp
9 ** SYSTEM NAME : Gnucomo - Gnu Computer Monitoring
10 ** VERSION NUMBER : $Revision: 1.1 $
17 ***************************************************************************
18 ** ADMINISTRATIVE INFORMATION *
19 ********************************
20 ** ORIGINAL AUTHOR : Arjen Baart - arjen@andromeda.nl
21 ** CREATION DATE : Nov 14, 2007
22 ** LAST UPDATE : Nov Nov 14, 2007
24 **************************************************************************/
26 /*****************************
27 $Log: spamdetect.cpp,v $
28 Revision 1.1 2007-11-14 16:20:05 arjen
29 New program: spamdetect.
30 Expirimental utility to log manually reported spam and have
31 Gnucomo detect the spammer's IP address.
33 *****************************/
35 static const char *RCSID = "$Id: spamdetect.cpp,v 1.1 2007-11-14 16:20:05 arjen Exp $";
38 #include <AXE/String.h>
43 int main(int argc, char *argv[])
45 const char *usage = "Usage: spamdetect\n";
51 regex fwd_header("---- Original Message -----");
52 regex received("^Received:");
54 regex returnpath("^Return-Path:");
56 openlog("gnucomo", 0, LOG_MAIL);
59 while (std::cin >> line)
61 std::cout << line << "\n";
65 if (line == fwd_header)
68 std::cout << "Forward header detected.\n";
73 // Inside the forwarded header
74 if (line == received || line == from || line == returnpath)
78 std::cout << "(1)Header = " << header << "\n";
82 if (line == regex("^[^ ]+: "))
84 std::cout << "Logging " << header << "\n";
85 syslog(LOG_WARNING, "%s", (char *)header);
88 std::cout << "Next header.\n";
89 if (line == received || line == from || line == returnpath)
93 std::cout << "(1)Header = " << header << "\n";
96 else if (line == String(""))
98 std::cout << "End of headers detected.\n";
105 std::cout << "(2)Header = " << header << "\n";