~ubuntu-branches/ubuntu/lucid/bogofilter/lucid-updates

« back to all changes in this revision

Viewing changes to src/bogoconfig.c

  • Committer: Bazaar Package Importer
  • Author(s): Bhavani Shankar
  • Date: 2009-05-06 05:41:52 UTC
  • mfrom: (1.1.11 upstream) (2.1.4 squeeze)
  • Revision ID: james.westby@ubuntu.com-20090506054152-tgameecssbuv4np6
Tags: 1.2.0-2ubuntu1
* Merge from debian unstable, remaining changes: LP: #372497
  - don't build qdbm.
  - Don't build tokyocabinet support as it's in universe.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* $Id: bogoconfig.c 6713 2008-04-19 03:20:54Z relson $ */
 
1
/* $Id: bogoconfig.c 6811 2009-02-21 20:32:50Z relson $ */
2
2
 
3
3
/*****************************************************************************
4
4
 
86
86
static void process_arglist(int argc, char **argv, priority_t precedence, int pass);
87
87
static bool get_parsed_value(char **arg, double *parm);
88
88
static void comma_parse(char opt, const char *arg, double *parm1, double *parm2, double *parm3);
 
89
static bool token_count_conflict(void);
89
90
 
90
91
/*---------------------------------------------------------------------------*/
91
92
 
94
95
    LONGOPTIONS_COMMON
95
96
    /* longoptions.h - bogofilter */
96
97
    LONGOPTIONS_MAIN
 
98
    LONGOPTIONS_MAIN_TUNE
97
99
    /* longoptions.h - bogofilter/bogolexer options */
98
100
    LONGOPTIONS_LEX
99
101
    /* longoptions.h - bogofilter/bogoutil options */
357
359
    "  --terse-format                    short form\n",
358
360
    "  --thresh-update                   no update if near 0 or 1\n",
359
361
    "  --timestamp                       enable/disable token timestamps\n",
 
362
    "  --token-count                     fixed token count for scoring\n",
 
363
    "  --token-count-min                 min token count for scoring\n",
 
364
    "  --token-count-max                 max token count for scoring\n",
360
365
#ifndef DISABLE_UNICODE
361
366
    "  --unicode                         enable/disable unicode based wordlist\n",
362
367
#endif
390
395
    (void)fprintf(stdout,
391
396
                  "%s version %s\n"
392
397
                  "    Database: %s\n"
393
 
                  "Copyright (C) 2002-2007 David Relson, Matthias Andree\n"
 
398
                  "Copyright (C) 2002-2009 David Relson, Matthias Andree\n"
394
399
                  "Copyright (C) 2002-2004 Greg Louis\n"
395
400
                  "Copyright (C) 2002-2003 Eric S. Raymond, Adrian Otto, Gyepi Sam\n\n"
396
401
                  "%s comes with ABSOLUTELY NO WARRANTY.  "
473
478
            verbose = max(1, verbose);  /* force printing */
474
479
            set_terse_mode_format(inv_terse_mode);
475
480
        }
 
481
        
 
482
        if (token_count_conflict()) {
 
483
            fprintf(stderr, "Conflicting token count arguments given.\n");
 
484
            exit(EX_ERROR);
 
485
        }
476
486
    }
477
487
 
478
488
    return;
725
735
    case O_TERSE_FORMAT:                terse_format = get_string(name, val);                   break;
726
736
    case O_THRESH_UPDATE:               get_double(name, val, &thresh_update);                  break;
727
737
    case O_TIMESTAMP:                   timestamp_tokens = get_bool(name, val);                 break;
 
738
    case O_TOKEN_COUNT_FIX:             token_count_fix = atoi(val);                            break;
 
739
    case O_TOKEN_COUNT_MIN:             token_count_min = atoi(val);                            break;
 
740
    case O_TOKEN_COUNT_MAX:             token_count_max = atoi(val);                            break;
728
741
    case O_UNSURE_SUBJECT_TAG:          unsure_subject_tag = get_string(name, val);             break;
729
742
    case O_UNICODE:                     encoding = get_bool(name, val) ? E_UNICODE : E_RAW;     break;
730
743
    case O_WORDLIST:                    configure_wordlist(val);                                break;
746
759
 
747
760
#define Q1      if (query >= 1)
748
761
#define Q2      if (query >= 2)
 
762
#define Q3      if (query >= 3)
749
763
 
750
764
#define YN(b) (b ? "Yes" : "No")
751
765
#define NB(b) ((b != NULL && *b != '\0') ? b : "''")
762
776
    Q1 fprintf(stdout, "%-11s = %0.6f  # (%8.2e)\n", "ns_esf", ns_esf, ns_esf);
763
777
    Q1 fprintf(stdout, "%-11s = %0.6f  # (%8.2e)\n", "sp_esf", sp_esf, sp_esf);
764
778
    Q1 fprintf(stdout, "\n");
 
779
    Q3 fprintf(stdout, "%-17s = %d\n",    "token-count",         token_count_fix);
 
780
    Q3 fprintf(stdout, "%-17s = %d\n",    "token-count-min",     token_count_min);
 
781
    Q3 fprintf(stdout, "%-17s = %d\n",    "token-count-max",     token_count_max);
 
782
    Q3 fprintf(stdout, "\n");
765
783
    Q1 fprintf(stdout, "%-17s = %s\n",    "block-on-subnets",    YN(block_on_subnets));
766
784
    Q1 fprintf(stdout, "%-17s = %s\n",    "encoding",            (encoding != E_UNICODE) ? "raw" : "utf-8");
767
785
    Q1 fprintf(stdout, "%-17s = %s\n",    "charset-default",     charset_default);
822
840
        fprintf(stdout, "%s %s", (i == 0) ? "" : ",", array[i]);
823
841
    fprintf(stdout, "\n");
824
842
}
 
843
 
 
844
static bool token_count_conflict(void)
 
845
{
 
846
    if (token_count_fix != 0) {
 
847
        if (token_count_fix < token_count_min)
 
848
            return true;
 
849
    }
 
850
 
 
851
    if (token_count_max != 0) {
 
852
        if (token_count_max < token_count_min)
 
853
            return true;
 
854
        if (token_count_max < token_count_fix)
 
855
            return true;
 
856
    }
 
857
 
 
858
    return false;
 
859
}