PageRenderTime 46ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/tags/release-1-1-2/noffle/src/filter.h

#
C Header | 98 lines | 62 code | 18 blank | 18 comment | 0 complexity | 93d8b3f2542b913b46f8bb2c29377789 MD5 | raw file
Possible License(s): GPL-2.0
  1. /*
  2. filter.h
  3. Article filtering.
  4. $Id: filter.h 331 2001-11-22 12:04:45Z mirkol $
  5. */
  6. #ifndef FILTER_H
  7. #define FILTER_H
  8. #include <sys/types.h>
  9. #include <regex.h>
  10. #include "fetchlist.h"
  11. #include "over.h"
  12. /* The possible actions in a filter. */
  13. typedef enum {
  14. FILTER_FULL,
  15. FILTER_XOVER,
  16. FILTER_THREAD,
  17. FILTER_DISCARD,
  18. FILTER_DEFAULT
  19. } FilterAction;
  20. /* Representation of a rule. */
  21. typedef enum {
  22. RULE_NEWSGROUP, /* Wildmat data */
  23. RULE_SUBJECT, /* Regex data */
  24. RULE_FROM,
  25. RULE_MSGID,
  26. RULE_BYTES_LT, RULE_BYTES_EQ, RULE_BYTES_GT, /* Number data */
  27. RULE_LINES_LT, RULE_LINES_EQ, RULE_LINES_GT,
  28. RULE_NOREFS_LT, RULE_NOREFS_EQ, RULE_NOREFS_GT,
  29. RULE_XPOSTS_LT, RULE_XPOSTS_EQ, RULE_XPOSTS_GT,
  30. RULE_POST_STATUS /* 'y','n','m' */
  31. } FilterRuleType;
  32. typedef union {
  33. regex_t regex;
  34. unsigned long amount;
  35. char *grp;
  36. char postAllow; /* 'y','n','m' */
  37. } FilterRuleData;
  38. typedef struct {
  39. FilterRuleType type;
  40. FilterRuleData data;
  41. } FilterRule;
  42. /* A single filter is a collection of rules with an action. */
  43. typedef struct {
  44. int nRules;
  45. int maxRules;
  46. FilterRule *rules;
  47. FilterAction action;
  48. } Filter;
  49. /* Add a filter to the list of filters. */
  50. void
  51. Flt_addFilter( const Filter *f );
  52. /*
  53. * Run the rules over the supplied overview. If a specific rule fires,
  54. * returns its action. If no rule fires, return the default read mode.
  55. */
  56. FilterAction
  57. Flt_checkFilters( const char *thisGrp, const char *newsgroups,
  58. const Over *ov, FetchMode mode );
  59. /*
  60. * Build and access a filter
  61. */
  62. Filter *
  63. new_Filter( void );
  64. void
  65. del_Filter( Filter *f );
  66. FilterAction
  67. Flt_action( const Filter *f );
  68. int
  69. Flt_nRules( const Filter *f );
  70. Bool
  71. Flt_getNewsgroups( void );
  72. FilterRule
  73. Flt_rule( const Filter *f, int ruleNo );
  74. void
  75. Flt_setAction( Filter *f, FilterAction action );
  76. void
  77. Flt_addRule( Filter *f, FilterRule rule );
  78. #endif /* FILTER_H */