NeoMutt  2021-02-05-666-ge300cd
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 Context;
52 struct Email;
53 struct Envelope;
54 struct Mailbox;
55 struct Menu;
57 #define MUTT_ALIAS_SIMPLESEARCH "~f %s | ~t %s | ~c %s"
59 typedef uint8_t PatternCompFlags;
60 #define MUTT_PC_NO_FLAGS 0
61 #define MUTT_PC_FULL_MSG (1 << 0)
62 #define MUTT_PC_PATTERN_DYNAMIC (1 << 1)
63 #define MUTT_PC_SEND_MODE_SEARCH (1 << 2)
68 struct Pattern
69 {
70  short op;
71  bool pat_not : 1;
72  bool all_addr : 1;
73  bool string_match : 1;
74  bool group_match : 1;
75  bool ign_case : 1;
76  bool is_alias : 1;
77  bool dynamic : 1;
78  bool sendmode : 1;
79  bool is_multi : 1;
80  int min;
81  int max;
82  struct PatternList *child;
83  union {
84  regex_t *regex;
85  struct Group *group;
86  char *str;
87  struct ListHead multi_cases;
88  } p;
89  SLIST_ENTRY(Pattern) entries;
90 };
91 SLIST_HEAD(PatternList, Pattern);
93 typedef uint8_t PatternExecFlags;
95 #define MUTT_MATCH_FULL_ADDRESS (1 << 0)
106 {
107  int list_all;
108  int list_one;
109  int sub_all;
110  int sub_one;
115 };
125 {
167 #ifdef USE_NNTP
169 #endif
171 };
173 int mutt_pattern_exec(struct Pattern *pat, PatternExecFlags flags, struct Mailbox *m,
174  struct Email *e, struct PatternCache *cache);
175 int mutt_pattern_alias_exec(struct Pattern *pat, PatternExecFlags flags,
176  struct AliasView *av, struct PatternCache *cache);
178 struct PatternList *mutt_pattern_comp(struct Mailbox *m, struct Menu *menu, const char *s, PatternCompFlags flags, struct Buffer *err);
179 void mutt_check_simple(struct Buffer *s, const char *simple);
180 void mutt_pattern_free(struct PatternList **pat);
181 bool dlg_select_pattern(char *buf, size_t buflen);
183 int mutt_which_case(const char *s);
184 int mutt_is_list_recipient(bool all_addr, struct Envelope *e);
186 int mutt_pattern_func(struct Context *ctx, int op, char *prompt);
187 int mutt_pattern_alias_func(int op, char *prompt, struct AliasMenuData *mdata, struct Menu *menu);
188 int mutt_search_command(struct Mailbox *m, struct Menu *menu, int cur, int op);
189 int mutt_search_alias_command(struct Menu *menu, int cur, int op);
191 bool mutt_limit_current_thread(struct Context *ctx, struct Email *e);
193 #endif /* MUTT_PATTERN_LIB_H */
Pattern matches message number.
Definition: lib.h:148
struct PatternList * child
Arguments to logical operation.
Definition: lib.h:82
The "current" mailbox.
Definition: context.h:37
regex_t * regex
Compiled regex, for non-pattern matching.
Definition: lib.h:84
Pattern matches email&#39;s Message-Id.
Definition: lib.h:141
Pattern matches email&#39;s body.
Definition: lib.h:143
bool group_match
Check a group of Addresses.
Definition: lib.h:74
The envelope/body of an email.
Definition: email.h:37
Message is signed.
Definition: lib.h:158
Definition: lib.h:67
int pers_recip_all
Definition: lib.h:111
AliasView array wrapper with Pattern information -.
Definition: gui.h:52
Email is on mailing list.
Definition: lib.h:153
Pattern matches &#39;To:&#39; field.
Definition: lib.h:131
union Pattern::@3 p
bool mutt_limit_current_thread(struct Context *ctx, struct Email *e)
Limit the email view to the current thread.
Definition: pattern.c:192
String manipulation buffer.
Definition: buffer.h:33
Pattern matches date received.
Definition: lib.h:137
Pattern matches &#39;References:&#39; or &#39;In-Reply-To:&#39; field.
Definition: lib.h:151
bool is_multi
Multiple case (only for ~I pattern now)
Definition: lib.h:79
GUI data wrapping an Alias.
Definition: gui.h:35
void mutt_check_simple(struct Buffer *s, const char *simple)
Convert a simple search into a real request.
Definition: pattern.c:113
int mutt_pattern_alias_func(int op, char *prompt, struct AliasMenuData *mdata, struct Menu *menu)
Perform some Pattern matching for Alias.
Definition: pattern.c:241
Message is unreferenced in the thread.
Definition: lib.h:139
int mutt_is_subscribed_list_recipient(bool all_addr, struct Envelope *e)
Matches subscribed mailing lists.
Definition: exec.c:441
struct PatternList * mutt_pattern_comp(struct Mailbox *m, struct Menu *menu, const char *s, PatternCompFlags flags, struct Buffer *err)
Create a Pattern.
Definition: compile.c:1092
A simple (non-regex) pattern.
Definition: lib.h:68
int sub_all
Definition: lib.h:109
Pattern matches &#39;From:&#39; field.
Definition: lib.h:135
Types of pattern to match.
Definition: lib.h:124
Pattern matches email&#39;s header.
Definition: lib.h:144
Server-side pattern matches.
Definition: lib.h:163
bool is_alias
Is there an alias for this Address?
Definition: lib.h:76
Message is encrypted.
Definition: lib.h:160
bool dynamic
Evaluate date ranges at run time.
Definition: lib.h:77
Message is crypographically verified.
Definition: lib.h:159
bool all_addr
All Addresses in the list must match.
Definition: lib.h:72
Many unsorted constants and some structs.
bool dlg_select_pattern(char *buf, size_t buflen)
Show menu to select a Pattern.
Definition: dlgpattern.c:345
Pattern matches sender.
Definition: lib.h:147
Pattern matches keyword/label.
Definition: lib.h:162
Email is addressed to the user.
Definition: lib.h:155
Email is from the user.
Definition: lib.h:156
Pattern matches newsgroup.
Definition: lib.h:168
bool string_match
Check a string for a match.
Definition: lib.h:73
bool pat_not
Pattern should be inverted (not)
Definition: lib.h:71
int mutt_pattern_func(struct Context *ctx, int op, char *prompt)
Perform some Pattern matching.
Definition: pattern.c:342
int min
Minimum for range checks.
Definition: lib.h:80
bool ign_case
Ignore case for local string_match searches.
Definition: lib.h:75
int mutt_is_list_recipient(bool all_addr, struct Envelope *e)
Matches known mailing lists.
Definition: exec.c:454
Pattern matches any address field.
Definition: lib.h:157
Message is part of a broken thread.
Definition: lib.h:140
Email is on subscribed mailing list.
Definition: lib.h:154
int pers_from_one
Definition: lib.h:114
int pers_recip_one
Definition: lib.h:112
Pattern matches MIME type.
Definition: lib.h:166
A mailbox.
Definition: mailbox.h:81
Message-Id is among results from an external query.
Definition: lib.h:142
int list_all
Definition: lib.h:107
Pattern matches number of attachments.
Definition: lib.h:165
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:1120
short op
Operation, e.g. MUTT_PAT_SCORE.
Definition: lib.h:70
int mutt_which_case(const char *s)
int pers_from_all
Definition: lib.h:113
Pattern matches &#39;Date:&#39; field.
Definition: lib.h:136
Thread is collapsed.
Definition: lib.h:133
Pattern matches &#39;Cc:&#39; field.
Definition: lib.h:132
Duplicate message.
Definition: lib.h:138
Both patterns must match.
Definition: lib.h:126
char * str
String, if string_match is set.
Definition: lib.h:86
Either pattern can match.
Definition: lib.h:127
bool sendmode
Evaluate searches in send-mode.
Definition: lib.h:78
struct Group * group
Address group if group_match is set.
Definition: lib.h:85
SLIST_ENTRY(Pattern) entries
Linked list.
A set of email addresses.
Definition: group.h:39
Pattern matches parent.
Definition: lib.h:129
Pattern matches email&#39;s spam score.
Definition: lib.h:145
User is a recipient of the email.
Definition: lib.h:152
void mutt_pattern_free(struct PatternList **pat)
Free a Pattern.
Definition: compile.c:1038
int max
Maximum for range checks.
Definition: lib.h:81
struct ListHead multi_cases
Multiple strings for ~I pattern.
Definition: lib.h:87
Pattern matches raw email text.
Definition: lib.h:146
Pattern matches a child email.
Definition: lib.h:130
Cache commonly-used patterns.
Definition: lib.h:105
Pattern matches message tags.
Definition: lib.h:164
Pattern matches email thread.
Definition: lib.h:128
Convenience wrapper for the library headers.
int mutt_search_alias_command(struct Menu *menu, int cur, int op)
Perform a search.
Definition: pattern.c:652
int list_one
Definition: lib.h:108
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:1097
SLIST_HEAD(PatternList, Pattern)
Message has PGP key.
Definition: lib.h:161
Pattern matches email&#39;s score.
Definition: lib.h:149
uint8_t PatternExecFlags
Flags for mutt_pattern_exec(), e.g. MUTT_MATCH_FULL_ADDRESS.
Definition: lib.h:93
uint8_t PatternCompFlags
Flags for mutt_pattern_comp(), e.g. MUTT_PC_FULL_MSG.
Definition: lib.h:59
The header of an Email.
Definition: envelope.h:54
Pattern matches email&#39;s size.
Definition: lib.h:150
int sub_one
Definition: lib.h:110
Pattern matches &#39;Subject:&#39; field.
Definition: lib.h:134
int mutt_search_command(struct Mailbox *m, struct Menu *menu, int cur, int op)
Perform a search.
Definition: pattern.c:496