You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spamassassin.apache.org by jm...@apache.org on 2004/04/29 02:51:55 UTC
svn commit: rev 10393 - incubator/spamassassin/trunk/spamc
Author: jm
Date: Wed Apr 28 17:51:55 2004
New Revision: 10393
Modified:
incubator/spamassassin/trunk/spamc/libspamc.h
incubator/spamassassin/trunk/spamc/spamc.c
Log:
bug 2855: added spamc -E switch, to return exit code based on spam/nonspam status in normal use
Modified: incubator/spamassassin/trunk/spamc/libspamc.h
==============================================================================
--- incubator/spamassassin/trunk/spamc/libspamc.h (original)
+++ incubator/spamassassin/trunk/spamc/libspamc.h Wed Apr 28 17:51:55 2004
@@ -73,7 +73,6 @@
/* 2003/04/16 SJF: randomize hostname order (quasi load balancing) */
#define SPAMC_RANDOMIZE_HOSTS (1<<23)
-
/* Aug 14, 2002 bj: A struct for storing a message-in-progress */
typedef enum
{
Modified: incubator/spamassassin/trunk/spamc/spamc.c
==============================================================================
--- incubator/spamassassin/trunk/spamc/spamc.c (original)
+++ incubator/spamassassin/trunk/spamc/spamc.c Wed Apr 28 17:51:55 2004
@@ -82,6 +82,9 @@
/* safe fallback defaults to on now - CRH */
int flags = SPAMC_RAW_MODE | SPAMC_SAFE_FALLBACK;
+/* global to control whether we should exit(0)/exit(1) on ham/spam */
+int use_exit_code = 0;
+
/* Aug 14, 2002 bj: global to hold -e command */
char **exec_argv;
@@ -99,6 +102,7 @@
usg("Options:\n");
usg(" -B Assume input is a single BSMTP-formatted message.\n");
usg(" -c Just print the summary line and set an exit code.\n");
+ usg(" -E Filter as normal, and set an exit code.\n");
usg(" -d host Specify host to connect to.\n"
" [default: localhost]\n");
usg(" -e command [args] Pipe the output to the given command instead of stdout.\n"
@@ -131,9 +135,9 @@
struct transport *ptrn)
{
#ifndef _WIN32
- const char *opts = "-BcrRd:e:fhyp:t:s:u:xSHU:";
+ const char *opts = "-BcrRd:e:fhyp:t:s:u:xSHU:E";
#else
- const char *opts = "-BcrRd:fhyp:t:s:u:xSH";
+ const char *opts = "-BcrRd:fhyp:t:s:u:xSHE";
#endif
int opt;
@@ -192,6 +196,11 @@
flags |= SPAMC_REPORT_IFSPAM;
break;
}
+ case 'E':
+ {
+ use_exit_code = 1;
+ break;
+ }
case 'R':
{
flags |= SPAMC_REPORT;
@@ -396,12 +405,15 @@
if (message_write(out_fd, &m) >= 0) {
result = m.is_spam;
- if ((flags & SPAMC_CHECK_ONLY) && result != EX_TOOBIG) {
+ if ((flags & SPAMC_CHECK_ONLY) && result != EX_TOOBIG) {
message_cleanup(&m);
ret = result;
}
else {
message_cleanup(&m);
+ if (use_exit_code && result != EX_TOOBIG) {
+ ret = result;
+ }
}
#ifdef _WIN32
WSACleanup();
@@ -433,6 +445,9 @@
if (ret == EX_TOOBIG) {
ret = 0;
}
+ else if (use_exit_code) {
+ ret = result;
+ }
else if (flags & SPAMC_SAFE_FALLBACK) {
ret = EX_OK;
}