Macros | Enumerations | Functions
FILTER: Regular expressions and scoring

Location of scorefile: $XDG_CONFIG_HOME/$CFG_NAME/scorefile. More...

Macros

#define MAIN_ERR_PREFIX   "FILTER: "
 Message prefix for FILTER module.
 
#define FILTER_PERM   (posix_mode_t) (POSIX_S_IRUSR | POSIX_S_IWUSR)
 Permissions for score file.
 

Enumerations

enum  filter_rule_type {
  SCORE_TYPE_UNKNOWN = 0, SCORE_TYPE_FROM = 1, SCORE_TYPE_FROM_ERE = 2, SCORE_TYPE_SUBJECT = 3,
  SCORE_TYPE_SUBJECT_ERE = 4, SCORE_TYPE_MSGID_ERE = 5, SCORE_TYPE_GROUP = 6, SCORE_END_OF_LIST = 7
}
 
enum  filter_cs { FILTER_CS_ASCII, FILTER_CS_ISO8859_1, FILTER_CS_UTF_8 }
 

Functions

int filter_init (int utf8)
 Initialize filter module. More...
 
void filter_exit (void)
 Shutdown filter module. More...
 
int filter_check_testgroup (const char *group)
 Check for test group. More...
 
int filter_match_own (const struct core_hierarchy_element *he)
 Check for own article. More...
 
int filter_match_reply_to_own (const struct core_hierarchy_element *he)
 Check for reply to own article. More...
 
int filter_get_score (const struct core_hierarchy_element *he)
 Get article score. More...
 
enum filter_cs filter_get_locale_ctype (void)
 Get codeset of locale category LC_CTYPE. More...
 

Score limits

Type must be int . Minimum and maximum values are INT_MIN and INT_MAX .

#define FILTER_SCORE_MAX   INT_MAX
 
#define FILTER_SCORE_MIN   INT_MIN
 

Detailed Description

Location of scorefile: $XDG_CONFIG_HOME/$CFG_NAME/scorefile.

Any line starting with # is treated as a comment (not parsed and ignored). All other lines are parsed as rules with 4 colon-separated fields:

Note
Because : (colon) is used as field separator, it is not allowed to use it in wildmats.

Rules with unknown type are ignored.

Attention
It is required that 'SSIZE_MAX' is at least 'INT_MAX' (must be checked by build system).

Function Documentation

◆ filter_check_testgroup()

int filter_check_testgroup ( const char *  group)

Check for test group.

Parameters
[in]groupSingle newsgroup name (not list)

The test group ERE from the configuration is used for matching.

Returns
  • 1 if group is a test group
  • 0 otherwise

Definition at line 1527 of file filter.c.

◆ filter_exit()

void filter_exit ( void  )

Shutdown filter module.

Step 1:

  • Open and lock scorefile
  • Save scoring rules in memory to score file
  • Delete scoring rules from memory

Step 2 (only if CONF_SCORERC is configured):

  • Copy scorefile to the location configured with CONF_SCORERC

Definition at line 1335 of file filter.c.

References CONF_SCORERC, config, data, conf_entry_val::s, and conf::val.

◆ filter_get_locale_ctype()

enum filter_cs filter_get_locale_ctype ( void  )

Get codeset of locale category LC_CTYPE.

Returns
  • Codeset ID of locale category LC_CTYPE

Definition at line 1805 of file filter.c.

Referenced by core_convert_pathname_to_locale().

◆ filter_get_score()

int filter_get_score ( const struct core_hierarchy_element he)

Get article score.

Parameters
[in]hePointer to article hierarchy element
Returns
  • Score of article
  • 0 if no score is defined for article corresponding to he .

Definition at line 1677 of file filter.c.

◆ filter_init()

int filter_init ( int  utf8)

Initialize filter module.

Parameters
[in]utf8Flag indicating that the locale use UTF-8 encoding
Attention
Remember that the locale must use either UTF-8 or ISO 8859-1 codeset or be the POSIX locale.

Step1 (only if CONF_SCORERC is configured):

  • Rename current scorefile to scorefile.old
  • Copy pathname configured with CONF_SCORERC to scorefile

Step 2:

  • Open and lock scorefile
  • Load rules from scorefile to memory
Returns
  • 0 on success
  • Negative value on error

Definition at line 1047 of file filter.c.

References CONF_SCORERC, config, data, PRINT_ERROR, conf_entry_val::s, and conf::val.

◆ filter_match_own()

int filter_match_own ( const struct core_hierarchy_element he)

Check for own article.

Parameters
[in]hePointer to article hierarchy element

The identity configuration is used as reference for matching.

Returns
  • 1 if he corresponds to own article
  • 0 otherwise

Definition at line 1587 of file filter.c.

References CONF_FROM, CONF_REPLYTO, config, core_article_header::from, core_hierarchy_element::header, conf_entry_val::s, and conf::val.

Referenced by filter_match_reply_to_own().

◆ filter_match_reply_to_own()

int filter_match_reply_to_own ( const struct core_hierarchy_element he)

Check for reply to own article.

Parameters
[in]hePointer to article hierarchy element
Returns
  • 1 if he corresponds to a reply to an own article
  • 0 otherwise

Definition at line 1635 of file filter.c.

References filter_match_own(), core_hierarchy_element::header, core_article_header::msgid, core_hierarchy_element::parent, and core_article_header::refs.


Generated at 2024-04-27 using  doxygen