NeoMutt  2020-11-20
Teaching an old dog new tricks
Go to the documentation of this file.
42 #include "config.h"
43 #include <stddef.h>
44 #include <stdbool.h>
45 #include <stdint.h>
46 #include "mutt/lib.h"
47 #include "mutt.h"
49 struct AliasMenuData;
50 struct AliasView;
51 struct ConfigSet;
52 struct Email;
53 struct Envelope;
54 struct Mailbox;
55 struct Menu;
57 #define MUTT_ALIAS_SIMPLESEARCH "~f %s | ~t %s | ~c %s"
59 /* These Config Variables are only used in pattern.c */
60 extern bool C_ThoroughSearch;
62 typedef uint8_t PatternCompFlags;
63 #define MUTT_PC_NO_FLAGS 0
64 #define MUTT_PC_FULL_MSG (1<<0)
65 #define MUTT_PC_PATTERN_DYNAMIC (1<<1)
66 #define MUTT_PC_SEND_MODE_SEARCH (1<<2)
71 struct Pattern
72 {
73  short op;
74  bool pat_not : 1;
75  bool all_addr : 1;
76  bool string_match : 1;
77  bool group_match : 1;
78  bool ign_case : 1;
79  bool is_alias : 1;
80  bool dynamic : 1;
81  bool sendmode : 1;
82  bool is_multi : 1;
83  int min;
84  int max;
85  struct PatternList *child;
86  union {
87  regex_t *regex;
88  struct Group *group;
89  char *str;
90  struct ListHead multi_cases;
91  } p;
92  SLIST_ENTRY(Pattern) entries;
93 };
94 SLIST_HEAD(PatternList, Pattern);
96 typedef uint8_t PatternExecFlags;
98 #define MUTT_MATCH_FULL_ADDRESS (1 << 0)
109 {
110  int list_all;
111  int list_one;
112  int sub_all;
113  int sub_one;
118 };
128 {
170 #ifdef USE_NNTP
172 #endif
174 };
176 int mutt_pattern_exec(struct Pattern *pat, PatternExecFlags flags, struct Mailbox *m,
177  struct Email *e, struct PatternCache *cache);
178 int mutt_pattern_alias_exec(struct Pattern *pat, PatternExecFlags flags,
179  struct AliasView *av, struct PatternCache *cache);
181 struct PatternList *mutt_pattern_comp(const char *s, PatternCompFlags flags, struct Buffer *err);
182 void mutt_check_simple(struct Buffer *s, const char *simple);
183 void mutt_pattern_free(struct PatternList **pat);
184 bool dlg_select_pattern(char *buf, size_t buflen);
186 int mutt_which_case(const char *s);
187 int mutt_is_list_recipient(bool all_addr, struct Envelope *e);
189 int mutt_pattern_func(int op, char *prompt);
190 int mutt_pattern_alias_func(int op, char *prompt, char *title, struct AliasMenuData *mdata, struct Menu *menu);
191 int mutt_search_command(struct Mailbox *m, int cur, int op);
192 int mutt_search_alias_command(struct Menu *menu, int cur, int op);
194 bool mutt_limit_current_thread(struct Email *e);
195 bool config_init_pattern(struct ConfigSet *cs);
197 #endif /* MUTT_PATTERN_LIB_H */
Pattern matches message number.
Definition: lib.h:151
struct PatternList * child
Arguments to logical operation.
Definition: lib.h:85
regex_t * regex
Compiled regex, for non-pattern matching.
Definition: lib.h:87
Container for lots of config items.
Definition: set.h:228
Pattern matches email&#39;s Message-Id.
Definition: lib.h:144
Pattern matches email&#39;s body.
Definition: lib.h:146
bool group_match
Check a group of Addresses.
Definition: lib.h:77
The envelope/body of an email.
Definition: email.h:37
struct PatternList * mutt_pattern_comp(const char *s, PatternCompFlags flags, struct Buffer *err)
Create a Pattern.
Definition: compile.c:1056
Message is signed.
Definition: lib.h:161
GUI selectable list of items.
Definition: mutt_menu.h:52
int mutt_search_command(struct Mailbox *m, int cur, int op)
Perform a search.
Definition: pattern.c:482
int pers_recip_all
Definition: lib.h:114
AliasMenuData - AliasView array wrapper with Pattern information.
Definition: gui.h:53
bool config_init_pattern(struct ConfigSet *cs)
Register pattern config variables - Implements module_init_config_t.
Definition: config.c:59
Email is on mailing list.
Definition: lib.h:156
Pattern matches &#39;To:&#39; field.
Definition: lib.h:134
bool C_ThoroughSearch
Config: Decode headers and messages before searching them.
Definition: config.c:38
String manipulation buffer.
Definition: buffer.h:33
Pattern matches date received.
Definition: lib.h:140
Pattern matches &#39;References:&#39; or &#39;In-Reply-To:&#39; field.
Definition: lib.h:154
bool is_multi
Multiple case (only for ~I pattern now)
Definition: lib.h:82
GUI data wrapping an Alias.
Definition: gui.h:36
int mutt_pattern_func(int op, char *prompt)
Perform some Pattern matching.
Definition: pattern.c:336
void mutt_check_simple(struct Buffer *s, const char *simple)
Convert a simple search into a real request.
Definition: pattern.c:109
Message is unreferenced in the thread.
Definition: lib.h:142
int mutt_is_subscribed_list_recipient(bool all_addr, struct Envelope *e)
Matches subscribed mailing lists.
Definition: exec.c:427
A simple (non-regex) pattern.
Definition: lib.h:71
int sub_all
Definition: lib.h:112
Pattern matches &#39;From:&#39; field.
Definition: lib.h:138
Types of pattern to match.
Definition: lib.h:127
Pattern matches email&#39;s header.
Definition: lib.h:147
Server-side pattern matches.
Definition: lib.h:166
bool is_alias
Is there an alias for this Address?
Definition: lib.h:79
Message is encrypted.
Definition: lib.h:163
bool dynamic
Evaluate date ranges at run time.
Definition: lib.h:80
Message is crypographically verified.
Definition: lib.h:162
bool all_addr
All Addresses in the list must match.
Definition: lib.h:75
Many unsorted constants and some structs.
bool dlg_select_pattern(char *buf, size_t buflen)
Show menu to select a Pattern.
Definition: dlgpattern.c:262
Pattern matches sender.
Definition: lib.h:150
Pattern matches keyword/label.
Definition: lib.h:165
Email is addressed to the user.
Definition: lib.h:158
Email is from the user.
Definition: lib.h:159
Pattern matches newsgroup.
Definition: lib.h:171
bool string_match
Check a string for a match.
Definition: lib.h:76
bool pat_not
Pattern should be inverted (not)
Definition: lib.h:74
int min
Minimum for range checks.
Definition: lib.h:83
bool ign_case
Ignore case for local string_match searches.
Definition: lib.h:78
int mutt_is_list_recipient(bool all_addr, struct Envelope *e)
Matches known mailing lists.
Definition: exec.c:440
Pattern matches any address field.
Definition: lib.h:160
Message is part of a broken thread.
Definition: lib.h:143
Email is on subscribed mailing list.
Definition: lib.h:157
int pers_from_one
Definition: lib.h:117
bool mutt_limit_current_thread(struct Email *e)
Limit the email view to the current thread.
Definition: pattern.c:186
int pers_recip_one
Definition: lib.h:115
Pattern matches MIME type.
Definition: lib.h:169
A mailbox.
Definition: mailbox.h:81
Message-Id is among results from an external query.
Definition: lib.h:145
union Pattern::@1 p
int list_all
Definition: lib.h:110
Pattern matches number of attachments.
Definition: lib.h:168
int mutt_pattern_alias_exec(struct Pattern *pat, PatternExecFlags flags, struct AliasView *av, struct PatternCache *cache)
Match a pattern against an alias.
Definition: exec.c:1041
short op
Operation, e.g. MUTT_PAT_SCORE.
Definition: lib.h:73
int mutt_which_case(const char *s)
int pers_from_all
Definition: lib.h:116
Pattern matches &#39;Date:&#39; field.
Definition: lib.h:139
Thread is collapsed.
Definition: lib.h:136
Pattern matches &#39;Cc:&#39; field.
Definition: lib.h:135
Duplicate message.
Definition: lib.h:141
Both patterns must match.
Definition: lib.h:129
char * str
String, if string_match is set.
Definition: lib.h:89
Either pattern can match.
Definition: lib.h:130
bool sendmode
Evaluate searches in send-mode.
Definition: lib.h:81
struct Group * group
Address group if group_match is set.
Definition: lib.h:88
SLIST_ENTRY(Pattern) entries
Linked list.
A set of email addresses.
Definition: group.h:38
Pattern matches parent.
Definition: lib.h:132
Pattern matches email&#39;s spam score.
Definition: lib.h:148
User is a recipient of the email.
Definition: lib.h:155
void mutt_pattern_free(struct PatternList **pat)
Free a Pattern.
Definition: compile.c:1004
int max
Maximum for range checks.
Definition: lib.h:84
struct ListHead multi_cases
Multiple strings for ~I pattern.
Definition: lib.h:90
Pattern matches raw email text.
Definition: lib.h:149
Pattern matches a child email.
Definition: lib.h:133
Cache commonly-used patterns.
Definition: lib.h:108
Pattern matches message tags.
Definition: lib.h:167
Pattern matches email thread.
Definition: lib.h:131
Convenience wrapper for the library headers.
int mutt_pattern_alias_func(int op, char *prompt, char *title, struct AliasMenuData *mdata, struct Menu *menu)
Perform some Pattern matching for Alias.
Definition: pattern.c:236
int mutt_search_alias_command(struct Menu *menu, int cur, int op)
Perform a search.
Definition: pattern.c:631
int list_one
Definition: lib.h:111
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: exec.c:738
SLIST_HEAD(PatternList, Pattern)
Message has PGP key.
Definition: lib.h:164
Pattern matches email&#39;s score.
Definition: lib.h:152
uint8_t PatternExecFlags
Flags for mutt_pattern_exec(), e.g. MUTT_MATCH_FULL_ADDRESS.
Definition: lib.h:96
uint8_t PatternCompFlags
Flags for mutt_pattern_comp(), e.g. MUTT_PC_FULL_MSG.
Definition: lib.h:62
The header of an Email.
Definition: envelope.h:54
Pattern matches email&#39;s size.
Definition: lib.h:153
int sub_one
Definition: lib.h:113
Pattern matches &#39;Subject:&#39; field.
Definition: lib.h:137