ze-filter  (ze-filter-0.8.0-develop-180218)
ze-message-tbx.c
Go to the documentation of this file.
1 
2 /*
3  *
4  * ze-filter - Mail Server Filter for sendmail
5  *
6  * Copyright (c) 2001-2018 - Jose-Marcio Martins da Cruz
7  *
8  * Auteur : Jose Marcio Martins da Cruz
9  * jose.marcio.mc@gmail.org
10  *
11  * Historique :
12  * Creation : janvier 2002
13  *
14  * This program is free software, but with restricted license :
15  *
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
20  *
21  * More details about ze-filter license can be found at ze-filter
22  * web site : http://foss.jose-marcio.org
23  */
24 
25 #include <ze-sys.h>
26 #include <libze.h>
27 #include <libml.h>
28 
29 #include "ze-filter.h"
30 
31 extern int ze_logLevel;
32 
33 static void usage();
34 
35 static bool cli_handle_message(char *fname, int msgNb, void *arg);
36 
37 typedef struct {
38  int nb;
39  int html_flags[32];
40  int plain_flags[32];
41  int mime_flags[32];
42  int msg_flags[32];
43 
44  int checks;
45 
48 
49  double score;
50  char header[256];
51 
52  int argc;
53  char **argv;
54 } msgtbx_T;
55 
56 static bool launch_workers(int n, char *fname, msgtbx_T * mstatp);
57 
58 static bool cli_toolbox(msgtbx_T * mstatp);
59 
60 
61 /* ****************************************************************************
62  * *
63  * *
64  **************************************************************************** */
65 static bool get_msg_headers(char *, spamchk_T *);
66 int add_header(char *, spamchk_T *);
67 
68 extern bool mailregexlog2file;
69 
70 #define M_MBOX 0
71 #define M_MAILDIR 1
72 #define M_FILE 2
73 #define M_LIST 3
74 #define M_INTERACTIVE 4
75 
76 int
77 main(int argc, char **argv)
78 {
79  const char *args = "hvl:m:t:b:p:c:rs:S";
80  int c;
81  int verbose = 0;
82  char fname[256];
83  int level = 9;
84  int argi;
85  int mtype = M_MBOX;
86  char *bayesdb = NULL;
87 
88  msgtbx_T mstat;
89  int docheck = 0;
90 
91  char *checks = "all";
92 
93  int nthreads = 1;
94 
95  double spam_threshold = 0.75;
96  bool spam_judgement = FALSE;
97 
99 
101  ze_logLevel = 0;
102  memset(fname, 0, sizeof (fname));
103 
104  while ((c = getopt(argc, argv, args)) != -1) {
105  switch (c) {
106  case 'h':
107  usage();
108  exit(0);
109  break;
110  case 'c':
111  if (optarg != NULL && strlen(optarg) > 0)
112  conf_file = optarg;
113  break;
114  case 'v':
115  verbose++;
116  break;
117  case 'r':
119  break;
120  case 'l':
121  level = atoi(optarg);
122  break;
123  case 'm':
124  checks = optarg;
125  break;
126  case 'N':
127  nthreads = atoi(optarg);
128  if (nthreads < 1)
129  nthreads = 1;
130  break;
131  case 'b':
132  bayesdb = optarg;
133  break;
134  case 's':
135  {
136  double v = 0;
137 
138  errno = 0;
139  v = strtod(optarg, NULL);
140  if (errno == 0)
141  spam_threshold = v;
142  }
143  break;
144  case 'S':
145  spam_judgement = TRUE;
146  break;
147  case 't':
148  if (STRCASEEQUAL(optarg, "mbox")) {
149  mtype = M_MBOX;
150  break;
151  }
152  if (STRNCASEEQUAL(optarg, "file", strlen("file"))) {
153  mtype = M_FILE;
154  break;
155  }
156  if (STRCASEEQUAL(optarg, "maildir")) {
157  mtype = M_MAILDIR;
158  break;
159  }
160  if (STRNCASEEQUAL(optarg, "dir", strlen("dir"))) {
161  mtype = M_MAILDIR;
162  break;
163  }
164  if (STRNCASEEQUAL(optarg, "list", strlen("list"))) {
165  mtype = M_LIST;
166  break;
167  }
168  if (STRNCASEEQUAL(optarg, "interactive", strlen("interactive"))) {
169  mtype = M_INTERACTIVE;
170  break;
171  }
172  mtype = M_MBOX;
173  break;
174  default:
175  printf("Error ... \n");
176  exit(0);
177  }
178  }
179 
180  if (FALSE) {
181  usage();
182  exit(1);
183  }
184 
186 
187  if (cf_opt.arg_c != NULL)
189 
190  configure("ze-message-toolbox", conf_file, FALSE);
191 
192  ze_logLevel = level + verbose;
193 
194  ze_logLevel = level;
195 
196  while (optind < argc && *argv[optind] == '-')
197  optind++;
198 
199  if (checks != NULL && strlen(checks) > 0) {
200  char *p = NULL;
201  int iargc;
202  char *iargv[8];
203 
204  if ((p = strdup(checks)) == NULL) {
205  exit(EX_SOFTWARE);
206  }
207 
208  docheck = 0;
209 
210  iargc = zeStr2Tokens(p, 8, iargv, ";, ");
211  while (iargc-- > 0) {
212  if (strncasecmp(iargv[iargc], "all", strlen(iargv[iargc])) == 0) {
213  docheck = 0xFFFF;
214  continue;
215  }
216  if (strncasecmp(iargv[iargc], "oracle", strlen(iargv[iargc])) == 0) {
217  SET_BIT(docheck, 0);
218  continue;
219  }
220  if (strncasecmp(iargv[iargc], "regex", strlen(iargv[iargc])) == 0) {
221  SET_BIT(docheck, 1);
222  continue;
223  }
224  if (strncasecmp(iargv[iargc], "urlbl", strlen(iargv[iargc])) == 0) {
225  SET_BIT(docheck, 2);
226  continue;
227  }
228  if (strncasecmp(iargv[iargc], "bayes", strlen(iargv[iargc])) == 0) {
229  SET_BIT(docheck, 3);
230  continue;
231  }
232  }
233  FREE(p);
234  }
235 
236  if (docheck == 0) {
237  fprintf(stderr, "No checks defined...\n");
238  usage();
239  exit(1);
240  }
241 
242  if (GET_BIT(docheck, 3)) {
243  char path[1024];
244  char *dbname = ZE_CDBDIR "/ze-bayes.db";
245  char *cfdir;
246 
247  size_t msgSize, partSize;
248  double rhs = 1.;
249 
250  dbname = cf_get_str(CF_DB_BAYES);
251  dbname = STRNULL(bayesdb, dbname);
252  ZE_MessageInfo(1, " Will open bayes database %s", dbname);
253  memset(path, 0, sizeof (path));
254  cfdir = cf_get_str(CF_CDBDIR);
255  ADJUST_FILENAME(path, dbname, cfdir, "ze-bayes.db");
256  ZE_MessageInfo(1, " database path %s", path);
257 
258  if (strlen(path) > 0 && !bfilter_init(path))
259  ZE_MessageInfo(2, "Error while opening %s database", path);
260 
262  if (msgSize < 10000)
263  msgSize = 400000;
265  if (partSize < 10000)
266  partSize = 40000;
267 
268  (void) set_bfilter_max_sizes(msgSize, partSize);
269 
270  rhs = ((double) cf_get_int(CF_BAYES_HAM_SPAM_RATIO) / 1000);
271  if (rhs < 0.1 || rhs > 10.)
272  rhs = 1;
273 
274  (void) set_bfilter_ham_spam_ratio(rhs);
275  }
276 
277  (void) configure_msg_eval_function(NULL);
278 
279  memset(&mstat, 0, sizeof (mstat));
280  mstat.checks = docheck;
281  mstat.spam_threshold = spam_threshold;
282  mstat.spam_judgement = spam_judgement;
283 
284  {
285  int nb;
286 
287  switch (mtype) {
288  case M_MBOX:
289  for (argi = optind; argi < argc; argi++)
290  nb += mbox_handle(argv[argi], cli_handle_message, &mstat);
291  break;
292  case M_MAILDIR:
293  for (argi = optind; argi < argc; argi++)
294  nb += maildir_handle(argv[argi], cli_handle_message, &mstat);
295  break;
296  case M_FILE:
297  for (argi = optind; argi < argc; argi++)
298  nb += cli_handle_message(argv[argi], nb, &mstat);
299  break;
300  case M_LIST:
301  for (argi = optind; argi < argc; argi++)
302  launch_workers(nthreads, argv[argi], &mstat);
303  break;
304  case M_INTERACTIVE:
305  cli_toolbox(&mstat);
306  break;
307  }
308  }
309 
310 
311  if (0 && GET_BIT(docheck, 0)) {
312  int i, j;
313  char *p;
314 
315  ZE_MessageInfo(8, " MSG.. HTML. PLAIN (%d messages)\n", mstat.nb);
316  for (i = 0; i < 32; i++)
317  ZE_MessageInfo(7, "%3d : %5ld %5ld %5ld\n", i,
318  mstat.msg_flags[i], mstat.html_flags[i],
319  mstat.plain_flags[i]);
320 
321  for (j = ORACLE_TYPE_MSG; j <= ORACLE_TYPE_PLAIN; j++) {
322  ZE_MessageInfo(8, "");
323  for (i = 0; i < 32; i++) {
324  if ((p = oracle_get_label(j, i)) != NULL && strlen(p) > 0) {
325  double v = oracle_get_score(j, i);
326 
327  ZE_MessageInfo(8, "%3d %3d : %5.2f %s", j, i, v, p);
328  }
329  }
330  }
331  }
332 
333  return 0;
334 }
335 
336 /* ****************************************************************************
337  * *
338  * *
339  **************************************************************************** */
340 inline int
341 add_header(h, spam)
342  char *h;
343  spamchk_T *spam;
344 {
345  char *f, *v;
346 
347  if ((h == NULL) || (strlen(h) == 0))
348  return 0;
349 
350  f = h;
351  v = h + strcspn(h, ":");
352  *v = '\0';
353  v++;
354  v += strspn(v, " \t");
355 
356  ZE_MessageInfo(20, "Header - %s", h);
357 
358  (void) add_to_msgheader_list(&spam->hdrs, f, v);
359 
360  return 1;
361 }
362 
363 /* ****************************************************************************
364  * *
365  * *
366  **************************************************************************** */
367 static bool
368 get_msg_headers(fname, spam)
369  char *fname;
370  spamchk_T *spam;
371 {
372  int nl = 0, nh = 0;
373  char line[1024];
374  char header[0x8000];
375  FILE *fin;
376 
377  if ((fname == NULL) || (strlen(fname) == 0))
378  return FALSE;
379 
380  if ((fin = fopen(fname, "r")) == NULL) {
381  ZE_LogSysError("fopen(%s)", fname);
382  return FALSE;
383  }
384 
385  memset(header, 0, sizeof (header));
386  while (fgets(line, sizeof (line), fin) != NULL) {
387  char *s;
388 
389  if (strspn(line, "\r\n") == strlen(line))
390  break;
391 
392  if ((nl == 0) && (strncasecmp("From ", line, strlen("From ")) == 0))
393  continue;
394 
395  zeStrChomp(line);
396 
397  s = line + strspn(line, "\r\n");
398  if ((*s != ' ') && (*s != '\t')) {
399  nh += add_header(header, spam);
400  memset(header, 0, sizeof (header));
401  snprintf(header, sizeof (header), "%s", s);
402  } else {
403  char *p = header + strlen(header);
404 
405  strncpy(p, line, strlen(s));
406  }
407  nl++;
408  }
409  nh += add_header(header, spam);
410 
411  ZE_MessageInfo(19, "Header has %d lines and %d headers", nl, nh);
412 
413  fclose(fin);
414 
415  return TRUE;
416 }
417 
418 /* ****************************************************************************
419  * *
420  * *
421  **************************************************************************** */
422 static bool
423 free_msg_headers(spam)
424  spamchk_T *spam;
425 {
426  (void) clear_msgheader_list(spam->hdrs);
427 
428  return TRUE;
429 }
430 
431 
432 /* ****************************************************************************
433  * *
434  * *
435  **************************************************************************** */
436 static bool
437 cli_handle_message(fname, msgNb, arg)
438  char *fname;
439  int msgNb;
440  void *arg;
441 {
442  char *ip = "0.0.0.0";
443  char *id = "00000000.000";
444 
445  spamchk_T spam;
446  msg_flags_T flags;
447  msg_scores_T rScores;
448 
449  size_t maxsize = 0x20000;
450 
451  char bid[32];
452 
453  msgtbx_T *mstat = (msgtbx_T *) arg;
454 
456 
457  mstat->nb++;
458 
459  snprintf(bid, sizeof (bid), "%08X.000", msgNb);
460  id = bid;
461  id = STREMPTY(fname, id);
462 
463  memset(&spam, 0, sizeof (spam));
464  memset(&flags, 0, sizeof (flags));
465  memset(&rScores, 0, sizeof (rScores));
466 
467  rScores.bayes = 0.5;
468 
470 
471  spam.ip = ip;
472 
473  if (GET_BIT(mstat->checks, 0))
474  rScores.do_oracle = TRUE;
475  if (GET_BIT(mstat->checks, 1))
476  rScores.do_regex = TRUE;
477  if (GET_BIT(mstat->checks, 2))
478  rScores.do_urlbl = TRUE;
479  if (GET_BIT(mstat->checks, 3))
480  rScores.do_bayes = TRUE;
481 
482  fill_msg_scale(&rScores.scale);
483  if (rScores.do_bayes) {
484  sfilter_vsm_T bcheck;
485 
486  memset(&bcheck, 0, sizeof (bcheck));
487 
489  if (bcheck.nbt <= 0)
490  bcheck.nbt = 21;
491  rScores.bayes = sfilter_check_message(id, fname, &bcheck);
492 
493  if (rScores.bayes >= 0.)
494  ZE_MessageInfo(9, "%s Bayes filter score : %6.3f", id, rScores.bayes);
495  else
496  ZE_MessageInfo(9, "%s Bayes filter score : Unchecked", id);
497  }
498 
499  if (!get_msg_headers(fname, &spam)) {
500 
501  }
502 
503  if (rScores.do_oracle || rScores.do_regex || rScores.do_urlbl) {
504  /*
505  * check header contents
506  */
507  if (rScores.do_regex) {
508  header_T *h = spam.hdrs;
509 
510  int score = 0;
511 
512  for (h = spam.hdrs; h != NULL; h = h->next) {
513  int where = MAIL_HEADERS;
514 
515  if (strcasecmp(h->attr, "subject") == 0)
516  where |= MAIL_SUBJECT;
517  if (strcasecmp(h->attr, "from") == 0)
518  where |= MAIL_FROM;
519 
520  score = check_regex(id, ip, h->value, where);
521 
522  rScores.headers += score;
523  }
524  }
525 
526  spam.scores = rScores;
527  (void) scan_body_contents(id, ip, fname, maxsize, &spam, &flags, &rScores);
528  rScores = spam.scores;
529  }
530 
531  {
532  char sout[256];
533  double score = 0.;
534  header_T *h;
535  size_t size = 0;
536 
537  memset(mstat->header, 0, sizeof (mstat->header));
538  mstat->score = score;
539 
540  score = compute_msg_score(&rScores);
541  (void) create_msg_score_header(sout, sizeof (sout), fname, NULL, &rScores);
542  ZE_MessageInfo(8, "%s", sout);
543 
544  strlcpy(mstat->header, sout, sizeof (mstat->header));
545 
546  if ((h = get_msgheader(spam.hdrs, "Subject")) != NULL) {
547  snprintf(sout, 80, "%s", h->value);
548  ZE_MessageInfo(9, "MSGID : %s SUBJECT : %s", id, sout);
549  }
550  if ((h = get_msgheader(spam.hdrs, "From")) != NULL) {
551  snprintf(sout, 80, "%s", h->value);
552  ZE_MessageInfo(9, "MSGID : %s FROM : %s", id, sout);
553  }
554  size = zeGetFileSize(fname);
555  ZE_MessageInfo(9, "MSGID : %s SIZE : %7d", id, size);
556 
557  if (mstat->spam_judgement) {
558  char buf[512];
559  int i;
560  double lscore = 0.0;
561 
562  ZE_MessageInfo(8, "MSGID : %s CLASS : %-5s %7.3f %s", id,
563  STRBOOL(score > mstat->spam_threshold, "SPAM", "HAM"),
564  score, fname);
565 
566  for (i = 2; i < mstat->argc; i++) {
567  strlcat(buf, " ", sizeof (buf));
568  strlcat(buf, mstat->argv[i], sizeof (buf));
569  }
570  lscore = rScores.bayes;
571  ZE_MessageInfo(8, "%s %s score=%-9.6f prob=%-9.6f class=%-5s",
572  fname, buf, logit(lscore), lscore,
573  STRBOOL(lscore > mstat->spam_threshold, "spam", "ham"));
574  }
575  /*
576  * 1225493245 joe-0812/spam/msg.0000003 op=class judge=spam class=spam
577  * learn=false query=true miss=false noisy=false features=911
578  * score=0.303917 prob=0.575400
579  */
580  }
581 
582  ZE_MessageInfo(10, "");
583 
584  free_msg_headers(&spam);
585 
586  return TRUE;
587 }
588 
589 /* ****************************************************************************
590  * *
591  * *
592  **************************************************************************** */
593 typedef struct {
594  FILE *fin;
595  char *fname;
596  int i;
597  pthread_t tid;
599 } msg_worker_T;
600 
601 static bool
602 get_next_message_file(fin, buf, sz)
603  FILE *fin;
604  char *buf;
605  size_t sz;
606 {
607  static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
608  bool r = FALSE;
609 
610  if (fin == NULL) {
611  sleep(1);
612  return r;
613  }
614 
615  MUTEX_LOCK(&mutex);
616 
617  if (fgets(buf, sz, fin) != NULL) {
618  char *p;
619 
620  if ((p = strchr(buf, '\n')) != NULL)
621  *p = '\0';
622  r = TRUE;
623  }
624  MUTEX_UNLOCK(&mutex);
625 
626  return r;
627 }
628 
629 static void *
630 worker_check_file(arg)
631  void *arg;
632 {
633  char fname[256];
634  int nb = 0;
635  msg_worker_T *worker = (msg_worker_T *) arg;
636 
637  while (get_next_message_file(worker->fin, fname, sizeof (fname))) {
638  if (zeGetFileSize(fname) > 150000)
639  continue;
640 
641  nb += cli_handle_message(fname, nb, &worker->mstat);
642  }
643 
644  return NULL;
645 }
646 
647 static bool
648 launch_workers(n, fname, mstatp)
649  int n;
650  char *fname;
651  msgtbx_T *mstatp;
652 {
653  int i;
654  msg_worker_T worker[256];
655  FILE *fin = NULL;
656 
657  memset(&worker, 0, sizeof (worker));
658 
659  if ((fin = fopen(fname, "r")) == NULL) {
660  ZE_LogSysError("Error opening %s file", fname);
661  return FALSE;
662  }
663 
664  for (i = 0; i < n; i++) {
665  int r;
666 
667  worker[i].i = i;
668  worker[i].fname = fname;
669  worker[i].fin = fin;
670  worker[i].tid = (pthread_t) - 1;
671  if (mstatp != NULL)
672  worker[i].mstat = *mstatp;
673 
674  r = pthread_create(&worker[i].tid, NULL, worker_check_file, &worker[i]);
675  if (r != 0) {
676  worker[i].tid = (pthread_t) - 1;
677  ZE_LogSysError("Error launching worker");
678  break;
679  }
680  }
681  for (i = 0; i < n; i++) {
682  int r;
683 
684  if (worker[i].tid < 0)
685  continue;
686 
687  ZE_MessageInfo(10, "Waiting thread %d", i);
688 
689  r = pthread_join(worker[i].tid, NULL);
690  worker[i].tid = (pthread_t) - 1;
691  if (r != 0) {
692  ZE_LogSysError("Error launching worker");
693  }
694  }
695  return TRUE;
696 }
697 
698 /* ****************************************************************************
699  * *
700  * *
701  **************************************************************************** */
702 static bool
703 cli_toolbox(mstat)
704  msgtbx_T *mstat;
705 {
706 #define NARG 32
707  char line[1024];
708  int nb = 0;
709 
710  ze_logLevel = 8;
711  ZE_MessageInfo(7, "Beginning...");
712  while (fgets(line, sizeof (line), stdin) != NULL) {
713  int argc;
714  char *argv[NARG];
715 
716  zeStrChomp(line);
717  ZE_MessageInfo(12, "Read : %s !", line);
718 
719  argc = zeStr2Tokens(line, NARG, argv, " ");
720  if (argc == 0)
721  break;
722 
723  if (STRCASEEQUAL(argv[0], "QUIT")) {
724  ZE_MessageInfo(7, "200 Exiting...");
725  break;
726  }
727 
728  if (STRCASEEQUAL(argv[0], "REOPEN")) {
729  bool ok;
730 
731  ok = bfilter_db_reopen();
732 
733  ZE_MessageInfo(7, "200 Database reopened : %s", STRBOOL(ok, "OK", "KO"));
734  continue;
735  }
736 
737  if (STRCASEEQUAL(argv[0], "JUDGE")) {
738  if (argc < 2) {
739  ZE_MessageInfo(7, "%s : Error...", argv[0]);
740  continue;
741  }
742 
743  mstat->spam_judgement = FALSE;
744  if (STRCASEEQUAL(argv[1], "ON") || STRCASEEQUAL(argv[1], "YES"))
745  mstat->spam_judgement = TRUE;
746 
747  continue;
748  }
749 
750  if (STRCASEEQUAL(argv[0], "THRESHOLD")) {
751  if (argc < 2) {
752  ZE_MessageInfo(7, "%s : Error...", argv[0]);
753  continue;
754  }
755 
756  {
757  double v = 0.;
758 
759  errno = 0;
760  v = strtod(argv[1], NULL);
761  if (errno == 0)
762  mstat->spam_threshold = v;
763  }
764  continue;
765  }
766 
767  if (STRCASEEQUAL(argv[0], "LOGLEVEL")) {
768  int l;
769 
770  if (argc < 2) {
771  ZE_MessageInfo(7, "%s : Error...", argv[0]);
772  continue;
773  }
774 
775  {
776  int l;
777 
778  l = atoi(argv[1]);
779  if (l < 0 || l > 15) {
780  ZE_MessageInfo(7, "%s %s : Error...", argv[0], argv[1]);
781  continue;
782  }
783  ze_logLevel = l;
784  }
785 
786  continue;
787  }
788 
789  if (STRCASEEQUAL(argv[0], "TRAIN")) {
790  ZE_MessageInfo(7, "%s not yet implemented...", argv[0]);
791  continue;
792  }
793 
794  if (STRCASEEQUAL(argv[0], "CLASSIFY")) {
795  size_t size;
796 
797  if (argc < 2) {
798  ZE_MessageInfo(7, "%s : Error...", argv[0]);
799  continue;
800  }
801 
802  size = zeGetFileSize(argv[1]);
803  if (size == 0) {
804  ZE_MessageInfo(8, "%s File %s not found", argv[0], argv[1]);
805  continue;
806  }
807 
808  mstat->argc = argc;
809  mstat->argv = argv;
810  nb += cli_handle_message(argv[1], nb, mstat);
811  continue;
812  }
813 
814  }
815  return TRUE;
816 }
817 
818 /* ****************************************************************************
819  * *
820  * *
821  **************************************************************************** */
822 void
823 usage()
824 {
825  printf("Usage : ze-message-tbx options\n"
826  " -h \n"
827  " -c file\n"
828  " configuration file (default : %s)\n"
829  " -v verbose (increase level)\n"
830  " -r log to file matched regular expressions\n"
831  " -s score threshold for spam classification\n"
832  " -S spam \"ground truth\"\n"
833  " -N number of threads\n"
834  " -b bayes database path\n"
835  " -m checks\n"
836  " where checks is a list of comma separated checks :\n"
837  " oracle, regex, urlbl, bayes or all\n"
838  " -l ze_logLevel\n"
839  " -t file type\n"
840  " where file type tells how messages are arranged inside args\n"
841  " mbox - each argument is a mailbox file with many messages\n"
842  " file - each argument is a file with one message\n"
843  " maildir - each argument is a directory with files inside\n"
844  " dir - the same as maildir\n"
845  " list - each argument is a file with a list of file names\n"
846  " each file contains a single message\n",
847  ZE_CONF_FILE);
848 
849  printf("\n %s \n %s\n", COPYRIGHT, PACKAGE);
850  printf(" Compiled on %s %s\n\n", __DATE__, __TIME__);
851 }
int check_regex(char *, char *, char *, int)
Definition: ze-mailregex.c:295
#define SHOW_CURSOR(zero)
Definition: macros.h:249
bool bfilter_db_reopen()
Definition: ze-bfilter.c:614
double sfilter_check_message(char *id, char *fname, sfilter_vsm_T *bcheck)
Definition: ze-bcheck.c:328
char * ip
Definition: ze-chkcontent.h:57
#define STRBOOL(x, t, f)
Definition: macros.h:87
double score
bool set_bfilter_max_sizes(size_t msg, size_t mime)
Definition: ze-bfilter.c:486
#define CF_BAYES_MAX_PART_SIZE
Definition: cfh-defs.h:107
#define CF_CDBDIR
Definition: cfh-defs.h:78
#define CF_DB_BAYES
Definition: cfh-defs.h:112
header_T * get_msgheader(header_T *, char *)
Definition: ze-headers.c:144
#define FREE(x)
Definition: macros.h:37
#define ZE_CDBDIR
Definition: defs.h:34
#define COPYRIGHT
Definition: version.h:31
#define MUTEX_UNLOCK(mutex)
Definition: macros.h:101
#define STRNULL(x, r)
Definition: macros.h:81
bool configure_msg_eval_function(char *val)
Definition: ze-msg-score.c:450
#define STRNCASEEQUAL(a, b, n)
Definition: macros.h:75
bool ok
Definition: ze-connopen.c:59
#define MUTEX_LOCK(mutex)
Definition: macros.h:93
msgtbx_T mstat
#define CF_BAYES_NB_TOKENS
Definition: cfh-defs.h:109
pthread_mutex_t mutex
Definition: ze-connopen.c:63
void zeLog_SetOutput(bool, bool)
Definition: zeSyslog.c:490
char ** argv
#define FALSE
Definition: macros.h:160
size_t zeGetFileSize(char *)
Definition: zeFileTools.c:132
#define strlcpy
Definition: zeString.h:32
#define ADJUST_FILENAME(path, fname, cfdir, defval)
Definition: macros.h:236
#define ZE_CONF_FILE
Definition: defs.h:40
int ze_logLevel
Definition: zeSyslog.c:34
#define GET_BIT(p, i)
Definition: macros.h:168
#define CF_BAYES_MAX_MESSAGE_SIZE
Definition: cfh-defs.h:106
char * zeStrChomp(char *)
Definition: zeStrings.c:501
int cf_get_int(int id)
Definition: ze-cf.c:803
char * arg_c
Definition: ze-config.h:47
#define SET_BIT(p, i)
Definition: macros.h:166
int mbox_handle(char *fname, mbox_F func, void *arg)
Definition: ze-mbox.c:34
bool bfilter_init(char *dbname)
Definition: ze-bfilter.c:200
int zeStr2Tokens(char *, int, char **, char *)
Definition: zeStrings.c:610
int main(int argc, char **argv)
#define strlcat
Definition: zeString.h:28
#define strchr
Definition: ze-sys.h:218
bool mailregexlog2file
Definition: ze-log-regex.c:34
void init_default_file_extensions()
Definition: ze-fileexp.c:195
bool fill_msg_scale(scores_scale_T *scale)
Definition: ze-msg-score.c:810
#define M_FILE
scores_scale_T scale
Definition: ze-msg-score.h:93
#define M_INTERACTIVE
double oracle_get_score(int, int)
bool create_msg_score_header(char *buf, size_t size, char *id, char *hostname, msg_scores_T *scores)
Definition: ze-msg-score.c:737
pthread_t tid
char * value
Definition: ze-headers.h:36
int plain_flags[32]
bool spam_judgement
double spam_threshold
#define ZE_MessageInfo(level,...)
Definition: zeSyslog.h:90
int nb
Definition: ze-connopen.c:61
bool add_to_msgheader_list(header_T **, char *, char *)
Definition: ze-headers.c:36
bool set_bfilter_ham_spam_ratio(double ratio)
Definition: ze-bfilter.c:438
#define TRUE
Definition: macros.h:157
#define MAIL_SUBJECT
Definition: ze-mailregex.h:38
int msg_flags[32]
OPT_REC_T cf_opt
Definition: ze-config.c:40
#define ZE_LogSysError(...)
Definition: zeSyslog.h:129
#define NARG
char * cf_get_str(int id)
Definition: ze-cf.c:854
char * attr
Definition: ze-headers.h:35
char * conf_file
Definition: ze-cf.c:38
char * oracle_get_label(int, int)
header_T * hdrs
double bayes
Definition: ze-msg-score.h:88
#define STREMPTY(x, r)
Definition: macros.h:82
header_T * next
Definition: ze-headers.h:37
int maildir_handle(char *dirname, mbox_F func, void *arg)
Definition: ze-mbox.c:125
header_T * clear_msgheader_list(header_T *)
Definition: ze-headers.c:93
int configure(char *, char *, bool)
Definition: ze-cf.c:1203
int add_header(char *, spamchk_T *)
void usage(char *arg)
#define ORACLE_TYPE_PLAIN
#define PACKAGE
Definition: version.h:28
#define M_MAILDIR
#define M_LIST
#define STRCASEEQUAL(a, b)
Definition: macros.h:72
#define MAIL_HEADERS
Definition: ze-mailregex.h:39
#define MAIL_FROM
Definition: ze-mailregex.h:41
msg_scores_T scores
Definition: ze-chkcontent.h:72
double compute_msg_score(msg_scores_T *scores)
Definition: ze-msg-score.c:634
#define ORACLE_TYPE_MSG
char header[256]
int html_flags[32]
#define CF_SPAM_REGEX_MAX_MSG_SIZE
Definition: cfh-defs.h:119
#define M_MBOX
double logit(double p)
Definition: ze-logit.c:34
int scan_body_contents(char *, char *, char *, size_t, spamchk_T *, msg_flags_T *, msg_scores_T *)
#define CF_BAYES_HAM_SPAM_RATIO
Definition: cfh-defs.h:108