NeoMutt  2018-07-16 +2481-68dcde
Teaching an old dog new tricks
Go to the documentation of this file.
24 #ifndef MUTT_PATTERN_H
25 #define MUTT_PATTERN_H
27 #include "config.h"
28 #include <regex.h>
29 #include <stdbool.h>
30 #include <stdint.h>
31 #include "mutt/mutt.h"
32 #include "mutt.h"
34 struct Email;
35 struct Envelope;
36 struct Mailbox;
38 /* These Config Variables are only used in pattern.c */
39 extern bool C_ThoroughSearch;
41 typedef uint8_t PatternCompFlags;
42 #define MUTT_PC_NO_FLAGS 0
43 #define MUTT_PC_FULL_MSG (1<<0)
44 #define MUTT_PC_PATTERN_DYNAMIC (1<<1)
49 struct Pattern
50 {
51  short op;
52  bool pat_not : 1;
53  bool all_addr : 1;
54  bool string_match : 1;
55  bool group_match : 1;
56  bool ign_case : 1;
57  bool is_alias : 1;
58  bool dynamic : 1;
59  bool is_multi : 1;
60  int min;
61  int max;
62  struct PatternList *child;
63  union {
64  regex_t *regex;
65  struct Group *group;
66  char *str;
67  struct ListHead multi_cases;
68  } p;
69  SLIST_ENTRY(Pattern) entries;
70 };
71 SLIST_HEAD(PatternList, Pattern);
73 typedef uint8_t PatternExecFlags;
75 #define MUTT_MATCH_FULL_ADDRESS (1 << 0)
86 {
87  int list_all;
88  int list_one;
89  int sub_all;
90  int sub_one;
95 };
105 {
147 #ifdef USE_NNTP
149 #endif
151 };
153 int mutt_pattern_exec(struct Pattern *pat, PatternExecFlags flags,
154  struct Mailbox *m, struct Email *e, struct PatternCache *cache);
155 struct PatternList *mutt_pattern_comp(const char *s, PatternCompFlags flags, struct Buffer *err);
156 void mutt_check_simple(struct Buffer *s, const char *simple);
157 void mutt_pattern_free(struct PatternList **pat);
159 int mutt_which_case(const char *s);
160 int mutt_is_list_recipient(bool all_addr, struct Envelope *e);
162 int mutt_pattern_func(int op, char *prompt);
163 int mutt_search_command(int cur, int op);
165 bool mutt_limit_current_thread(struct Email *e);
167 #endif /* MUTT_PATTERN_H */
Pattern matches date received.
Definition: pattern.h:117
struct PatternList * child
Arguments to logical operation.
Definition: pattern.h:62
Pattern matches email&#39;s header.
Definition: pattern.h:124
regex_t * regex
Compiled regex, for non-pattern matching.
Definition: pattern.h:64
Pattern matches MIME type.
Definition: pattern.h:146
Pattern matches &#39;Date:&#39; field.
Definition: pattern.h:116
bool group_match
Check a group of Addresses.
Definition: pattern.h:55
The envelope/body of an email.
Definition: email.h:39
Pattern matches newsgroup.
Definition: pattern.h:148
Pattern matches email&#39;s score.
Definition: pattern.h:129
int mutt_is_subscribed_list_recipient(bool all_addr, struct Envelope *e)
Matches subscribed mailing lists.
Definition: pattern.c:1768
int pers_recip_all
Definition: pattern.h:91
Message is part of a broken thread.
Definition: pattern.h:120
Pattern matches email&#39;s size.
Definition: pattern.h:130
struct PatternList * mutt_pattern_comp(const char *s, PatternCompFlags flags, struct Buffer *err)
Create a Pattern.
Definition: pattern.c:1386
String manipulation buffer.
Definition: buffer.h:33
Pattern matches &#39;From:&#39; field.
Definition: pattern.h:115
Email is from the user.
Definition: pattern.h:136
Email is on mailing list.
Definition: pattern.h:133
int mutt_search_command(int cur, int op)
Perform a search.
Definition: pattern.c:2557
bool is_multi
Multiple case (only for ~I pattern now)
Definition: pattern.h:59
Pattern matches a child email.
Definition: pattern.h:110
void mutt_pattern_free(struct PatternList **pat)
Free a Pattern.
Definition: pattern.c:1334
Pattern matches email&#39;s Message-Id.
Definition: pattern.h:121
A simple (non-regex) pattern.
Definition: pattern.h:49
Pattern matches message number.
Definition: pattern.h:128
int sub_all
Definition: pattern.h:89
Email is on subscribed mailing list.
Definition: pattern.h:134
int mutt_pattern_func(int op, char *prompt)
Perform some Pattern matching.
Definition: pattern.c:2415
bool is_alias
Is there an alias for this Address?
Definition: pattern.h:57
bool dynamic
Evaluate date ranges at run time.
Definition: pattern.h:58
bool all_addr
All Addresses in the list must match.
Definition: pattern.h:53
Duplicate message.
Definition: pattern.h:118
int mutt_which_case(const char *s)
int mutt_is_list_recipient(bool all_addr, struct Envelope *e)
Matches known mailing lists.
Definition: pattern.c:1780
bool string_match
Check a string for a match.
Definition: pattern.h:54
bool pat_not
Pattern should be inverted (not)
Definition: pattern.h:52
int min
Minimum for range checks.
Definition: pattern.h:60
bool ign_case
Ignore case for local string_match searches.
Definition: pattern.h:56
int pers_from_one
Definition: pattern.h:94
Server-side pattern matches.
Definition: pattern.h:143
Pattern matches &#39;Cc:&#39; field.
Definition: pattern.h:112
int pers_recip_one
Definition: pattern.h:92
Message is unreferenced in the thread.
Definition: pattern.h:119
A mailbox.
Definition: mailbox.h:92
Pattern matches keyword/label.
Definition: pattern.h:142
Either pattern can match.
Definition: pattern.h:107
Pattern matches email&#39;s spam score.
Definition: pattern.h:125
Message is encrypted.
Definition: pattern.h:140
Pattern matches &#39;Subject:&#39; field.
Definition: pattern.h:114
int list_all
Definition: pattern.h:87
Email is addressed to the user.
Definition: pattern.h:135
Message has PGP key.
Definition: pattern.h:141
short op
Operation, e.g. MUTT_PAT_SCORE.
Definition: pattern.h:51
Pattern matches parent.
Definition: pattern.h:109
bool mutt_limit_current_thread(struct Email *e)
Limit the email view to the current thread.
Definition: pattern.c:2374
SLIST_HEAD(PatternList, Pattern)
int pers_from_all
Definition: pattern.h:93
Pattern matches email&#39;s body.
Definition: pattern.h:123
bool C_ThoroughSearch
Config: Decode headers and messages before searching them.
Definition: pattern.c:70
union Pattern::@2 p
char * str
String, if string_match is set.
Definition: pattern.h:66
Message is signed.
Definition: pattern.h:138
uint8_t PatternExecFlags
Flags for mutt_pattern_exec(), e.g. MUTT_MATCH_FULL_ADDRESS.
Definition: pattern.h:73
struct Group * group
Address group if group_match is set.
Definition: pattern.h:65
SLIST_ENTRY(Pattern) entries
Linked list.
A set of email addresses.
Definition: group.h:38
Thread is collapsed.
Definition: pattern.h:113
Pattern matches sender.
Definition: pattern.h:127
Both patterns must match.
Definition: pattern.h:106
void mutt_check_simple(struct Buffer *s, const char *simple)
Convert a simple search into a real request.
Definition: pattern.c:2296
Message is crypographically verified.
Definition: pattern.h:139
int max
Maximum for range checks.
Definition: pattern.h:61
Pattern matches &#39;References:&#39; or &#39;In-Reply-To:&#39; field.
Definition: pattern.h:131
Pattern matches message tags.
Definition: pattern.h:144
Pattern matches any address field.
Definition: pattern.h:137
User is a recipient of the email.
Definition: pattern.h:132
struct ListHead multi_cases
Multiple strings for ~I pattern.
Definition: pattern.h:67
Types of pattern to match.
Definition: pattern.h:104
Pattern matches email thread.
Definition: pattern.h:108
uint8_t PatternCompFlags
Flags for mutt_pattern_comp(), e.g. MUTT_PC_FULL_MSG.
Definition: pattern.h:41
Pattern matches &#39;To:&#39; field.
Definition: pattern.h:111
Cache commonly-used patterns.
Definition: pattern.h:85
Pattern matches raw email text.
Definition: pattern.h:126
Pattern matches number of attachments.
Definition: pattern.h:145
Convenience wrapper for the library headers.
int list_one
Definition: pattern.h:88
Message-Id is among results from an external query.
Definition: pattern.h:122
The header of an Email.
Definition: envelope.h:54
int sub_one
Definition: pattern.h:90
int mutt_pattern_exec(struct Pattern *pat, PatternExecFlags flags, struct Mailbox *m, struct Email *e, struct PatternCache *cache)
Match a pattern against an email header.
Definition: pattern.c:2002