[cvs] bogofilter Makefile.am,1.45,1.46 main.c,1.60,1.61 bogofilter.c,1.55,1.56
Fast Bayesian spam filter along lines suggested by Paul Graham
Brought to you by:
m-a
From: <re...@us...> - 2002-10-30 17:33:32
|
Update of /cvsroot/bogofilter/bogofilter In directory usw-pr-cvs1:/tmp/cvs-serv17220 Modified Files: Makefile.am main.c bogofilter.c Log Message: Call new configuration routine. Move directory checking code from main() to function. Index: Makefile.am =================================================================== RCS file: /cvsroot/bogofilter/bogofilter/Makefile.am,v retrieving revision 1.45 retrieving revision 1.46 diff -C2 -d -r1.45 -r1.46 *** Makefile.am 29 Oct 2002 21:57:02 -0000 1.45 --- Makefile.am 30 Oct 2002 17:33:27 -0000 1.46 *************** *** 9,16 **** bin_PROGRAMS = bogofilter bogoutil bogolexer bin_SCRIPTS = bogoupgrade ! check_PROGRAMS = debugtest man1_MANS = bogofilter.1 bogoutil.1 bogoupgrade.1 ! CFLAGS = -g -O2 # what to build that from --- 9,16 ---- bin_PROGRAMS = bogofilter bogoutil bogolexer bin_SCRIPTS = bogoupgrade ! check_PROGRAMS = debugtest configtest man1_MANS = bogofilter.1 bogoutil.1 bogoupgrade.1 ! CFLAGS = -g -O2 -Wall # what to build that from *************** *** 21,24 **** --- 21,25 ---- bogofilter_SOURCES = bogofilter.c bogofilter.h main.c lexer.l lexer.h \ datastore.h datastore_db.h datastore_db.c \ + config.c \ rstats.h rstats.c \ wordhash.h wordhash.c wordlists.h wordlists.c \ *************** *** 32,35 **** --- 33,39 ---- datastore.h datastore_db.h datastore_db.c wordlists.h wordlists.c \ $(MYCOMMON) + + configtest_CFLAGS = -DMAIN + configtest_SOURCES = config.c $(MYCOMMON) # what to distribute Index: main.c =================================================================== RCS file: /cvsroot/bogofilter/bogofilter/main.c,v retrieving revision 1.60 retrieving revision 1.61 diff -C2 -d -r1.60 -r1.61 *** main.c 29 Oct 2002 11:34:28 -0000 1.60 --- main.c 30 Oct 2002 17:33:27 -0000 1.61 *************** *** 42,51 **** const char *progname = "bogofilter"; run_t run_type = RUN_NORMAL; int thresh_index = 0; ! double thresh_prob = 0.0f; // EVEN_ODDS ! double thresh_rtable=0.0f; /* if the given environment variable 'var' exists, copy it to 'dest' and --- 42,54 ---- const char *progname = "bogofilter"; + char *spam_header_name = SPAM_HEADER_NAME; run_t run_type = RUN_NORMAL; int thresh_index = 0; ! double thresh_stats = EVEN_ODDS; ! double thresh_rtable = 0.4f; ! ! extern void read_config_file(const char *filename); /* if the given environment variable 'var' exists, copy it to 'dest' and *************** *** 79,82 **** --- 82,92 ---- struct stat sb; + if (*path == '\0') { + fprintf(stderr, "%s: cannot find bogofilter directory.\n" + "You must set the BOGOFILTER_DIR or HOME environment variables\n" + "or use the -d DIR option. The program aborts.\n", progname); + return 0; + } + rc = stat(path, &sb); if (rc < 0) { *************** *** 247,259 **** exit(exitcode); ! if (!directory[0]) { ! fprintf(stderr, "%s: cannot find bogofilter directory.\n" ! "You must set the BOGOFILTER_DIR or HOME environment variables\n" ! "or use the -d DIR option. The program aborts.\n", progname); exit(2); - } - if (check_directory(directory)) exit(2); setup_lists(directory); switch(run_type) { --- 257,267 ---- exit(exitcode); ! if (check_directory(directory)) exit(2); setup_lists(directory); + + read_config_file( "/etc/bogofilter.cf" ); + read_config_file( "~/.bogofilter.cf" ); switch(run_type) { Index: bogofilter.c =================================================================== RCS file: /cvsroot/bogofilter/bogofilter/bogofilter.c,v retrieving revision 1.55 retrieving revision 1.56 diff -C2 -d -r1.55 -r1.56 *** bogofilter.c 29 Oct 2002 11:34:28 -0000 1.55 --- bogofilter.c 30 Oct 2002 17:33:28 -0000 1.56 *************** *** 329,333 **** { extern int thresh_index; ! extern double thresh_prob; extern double thresh_rtable; --- 329,333 ---- { extern int thresh_index; ! extern double thresh_stats; extern double thresh_rtable; *************** *** 337,346 **** int index = (thresh_index >= 0) ? thresh_index : KEEPERS+thresh_index; discrim_t *pp = &bogostats.extrema[index]; ! if (pp->prob >= thresh_prob) compute_spamicity(&bogostats, fp); break; } case AL_ROBINSON: ! if (spamicity > thresh_prob) rstats_print(); break; --- 337,346 ---- int index = (thresh_index >= 0) ? thresh_index : KEEPERS+thresh_index; discrim_t *pp = &bogostats.extrema[index]; ! if (pp->prob >= thresh_stats) compute_spamicity(&bogostats, fp); break; } case AL_ROBINSON: ! if (spamicity > thresh_stats || spamicity > thresh_rtable) rstats_print(); break; |