Ticket #24: store-filtered.diff

File store-filtered.diff, 6.7 KB (added by eagle, 14 years ago)

Patch against INN 2.4.2

  • doc/man/storage.conf.5

    old new  
    3636        expires: <mintime>[,<maxtime>]
    3737        options: <options>
    3838        exactmatch: <bool>
     39        filtered: <bool>
    3940}
    4041
    4142.fi
     
    122123described above.)  This is a boolan value and ``true'', ``yes''
    123124and ``on'' are usable to enable this key.  The case of these values is not
    124125significant.  The default is false.
     126.TP
     127.B filtered
     128If this key is set to ``true'', the article must have been rejected by the
     129Perl/Python filter.  This also requires that ``dontfilterrejected'' is set
     130to ``true'' in
     131.IR inn.conf .
     132This is a boolan value and ``true'', ``yes'' and ``on'' are usable to enable
     133this key.  The case of these values is not significant.  The default is false.
    125134.PP
    126135If an article matches all of the constraints of an entry, it is stored via
    127136that storage method and is associated with that <storage_class>.  This
  • include/storage.h

    diff -bur testnews.OLD/include/storage.h testnews/include/storage.h
    old new  
    4444  void           *private;   /* A pointer to method specific data */
    4545  time_t         arrived;    /* The time when the article arrived */
    4646  time_t         expires;    /* The time when the article will be expired */
     47  bool           filtered;   /* Article was marked by the filter */
    4748  char           *groups;    /* Where Newsgroups header starts */
    4849  int            groupslen;  /* Length of Newsgroups header */
    4950  TOKEN          *token;     /* A pointer to the article's TOKEN */
  • innd/art.c

    diff -bur testnews.OLD/innd/art.c testnews/innd/art.c
    old new  
    518518  arth.arrived = (time_t)0;
    519519  arth.token = (TOKEN *)NULL;
    520520  arth.expires = data->Expires;
     521  arth.filtered = data->Filtered;
    521522  if (innconf->storeonxref) {
    522523    arth.groups = data->Replic;
    523524    arth.groupslen = data->ReplicLength;
     
    18861887  TMRstop(TMR_PYTHON);
    18871888  if (filterrc != NULL) {
    18881889    if (innconf->dontrejectfiltered) {
     1890      snprintf(cp->Error, sizeof(cp->Error), "%d %.200s", NNTP_REJECTIT_VAL,
     1891               filterrc);
     1892      syslog(L_NOTICE, "filtering[python] %s %s", HDR(HDR__MESSAGE_ID),
     1893             cp->Error);
    18891894      Filtered = true;
    18901895    } else {
    18911896      snprintf(cp->Error, sizeof(cp->Error), "%d %.200s", NNTP_REJECTIT_VAL,
     
    19131918  if (filterrc) {
    19141919    if (innconf->dontrejectfiltered) {
    19151920      Filtered = true;
     1921      snprintf(cp->Error, sizeof(cp->Error), "%d %.200s", NNTP_REJECTIT_VAL,
     1922               filterrc);
     1923      syslog(L_NOTICE, "filtering[perl] %s %s", HDR(HDR__MESSAGE_ID),
     1924             cp->Error);
    19161925    } else {
    19171926      snprintf(cp->Error, sizeof(cp->Error), "%d %.200s", NNTP_REJECTIT_VAL,
    19181927               filterrc);
     
    22952304  for (i = 0; (ngp = GroupPointers[i]) != NULL; i++)
    22962305    ngp->PostCount = 0;
    22972306
     2307  data->Filtered = Filtered;
    22982308  token = ARTstore(cp);
    22992309  /* change trailing '\r\n' to '\0\n' of all system header */
    23002310  for (i = 0 ; i < MAX_ARTHEADER ; i++) {
  • innd/innd.h

    diff -bur testnews.OLD/innd/innd.h testnews/innd/innd.h
    old new  
    197197  int             HeaderLines;          /* number of header lines */
    198198  long            BytesValue;           /* size of stored article, "\r\n" is
    199199                                           counted as 1 byte */
     200  bool            Filtered;             /* Marked by filter */
    200201  char            Bytes[16];            /* generated Bytes header */
    201202  int             BytesLength;          /* generated Bytes header length */
    202203  char        *   BytesHeader;          /* where Bytes header begins in
  • scripts/innreport_inn.pm

    diff -bur testnews.OLD/scripts/innreport_inn.pm testnews/scripts/innreport_inn.pm
    old new  
    244244      # SERVER cancelled +id
    245245      return 1 if $left =~ /^SERVER cancelled /o;
    246246    }
    247     # rejecting[perl]
    248     if ($left =~ /^rejecting\[perl\] <[^>]+> \d+ (.*)/o) {
     247    # rejecting[perl]/filtering[perl]
     248    if ($left =~ /^(?:rejecting|filtering)\[perl\] <[^>]+> \d+ (.*)/o) {
    249249      $innd_filter_perl{$1}++;
    250250      return 1;
    251251    }
  • storage/interface.c

    diff -bur testnews.OLD/storage/interface.c testnews/storage/interface.c
    old new  
    334334#define SMexpire  14
    335335#define SMoptions 15
    336336#define SMexactmatch 16
     337#define SMfiltered 17
    337338
    338339static CONFTOKEN smtoks[] = {
    339340  { SMlbrace,   "{" },
     
    345346  { SMexpire,   "expires:" },
    346347  { SMoptions,  "options:" },
    347348  { SMexactmatch,       "exactmatch:" },
     349  { SMfiltered, "filtered:" },
    348350  { 0, 0 }
    349351};
    350352
     
    371373    char                *options = 0;
    372374    int                 inbrace;
    373375    bool                exactmatch = false;
     376    bool                filtered = false;
    374377
    375378    /* if innconf isn't already read in, do so. */
    376379    if (innconf == NULL) {
     
    423426            minexpire = 0;
    424427            maxexpire = 0;
    425428            exactmatch = false;
     429            filtered = false;
    426430
    427431        } else {
    428432            type = tok->type;
     
    470474                        || strcasecmp(p, "on") == 0)
    471475                        exactmatch = true;
    472476                    break;
     477                  case SMfiltered:
     478                    if (strcasecmp(p, "true") == 0
     479                        || strcasecmp(p, "yes") == 0
     480                        || strcasecmp(p, "on") == 0)
     481                        filtered = true;
     482                    break;
    473483                  default:
    474484                    SMseterror(SMERR_CONFIG, "Unknown keyword in method declaration");
    475485                    syslog(L_ERROR, "SM Unknown keyword in method declaration, line %d: %s", f->lineno, tok->name);
     
    512522            sub->minexpire = minexpire;
    513523            sub->maxexpire = maxexpire;
    514524            sub->exactmatch = exactmatch;
     525            sub->filtered = filtered;
    515526
    516527            free(method);
    517528            method = 0;
     
    694705            (!sub->minexpire || article.expires >= sub->minexpire) &&
    695706            (!sub->maxexpire || (article.expires <= sub->maxexpire)) &&
    696707            MatchGroups(article.groups, article.groupslen, sub->pattern,
    697                         sub->exactmatch)) {
     708                        sub->exactmatch) &&
     709            (sub->filtered == article.filtered)) {
    698710            if (InitMethod(typetoindex[sub->type]))
    699711                return sub;
    700712        }
  • storage/interface.h

    diff -bur testnews.OLD/storage/interface.h testnews/storage/interface.h
    old new  
    4545                                        method */
    4646    bool                exactmatch;  /* all newsgroups to which article belongs
    4747                                        should match the patterns */
     48    bool                filtered;    /* article was marked by the filter */
    4849    struct __S_SUB__   *next;
    4950} STORAGE_SUB;