NeoMutt  2020-06-26-89-g172cd3
Teaching an old dog new tricks
DOXYGEN
pattern.h
Go to the documentation of this file.
1 
24 #ifndef MUTT_PATTERN_H
25 #define MUTT_PATTERN_H
26 
27 #include "config.h"
28 #include <stdbool.h>
29 #include <stdint.h>
30 #include "mutt/lib.h"
31 #include "mutt.h"
32 
33 struct Email;
34 struct Envelope;
35 struct Mailbox;
36 
37 /* These Config Variables are only used in pattern.c */
38 extern bool C_ThoroughSearch;
39 
40 typedef uint8_t PatternCompFlags;
41 #define MUTT_PC_NO_FLAGS 0
42 #define MUTT_PC_FULL_MSG (1<<0)
43 #define MUTT_PC_PATTERN_DYNAMIC (1<<1)
44 #define MUTT_PC_SEND_MODE_SEARCH (1<<2)
45 
46 
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 sendmode : 1;
60  bool is_multi : 1;
61  int min;
62  int max;
63  struct PatternList *child;
64  union {
65  regex_t *regex;
66  struct Group *group;
67  char *str;
68  struct ListHead multi_cases;
69  } p;
70  SLIST_ENTRY(Pattern) entries;
71 };
72 SLIST_HEAD(PatternList, Pattern);
73 
74 typedef uint8_t PatternExecFlags;
75 #define MUTT_PAT_EXEC_NO_FLAGS 0
76 #define MUTT_MATCH_FULL_ADDRESS (1 << 0)
77 
78 
87 {
88  int list_all;
89  int list_one;
90  int sub_all;
91  int sub_one;
96 };
97 
106 {
148 #ifdef USE_NNTP
150 #endif
152 };
153 
154 int mutt_pattern_exec(struct Pattern *pat, PatternExecFlags flags,
155  struct Mailbox *m, struct Email *e, struct PatternCache *cache);
156 struct PatternList *mutt_pattern_comp(const char *s, PatternCompFlags flags, struct Buffer *err);
157 void mutt_check_simple(struct Buffer *s, const char *simple);
158 void mutt_pattern_free(struct PatternList **pat);
159 
160 int mutt_which_case(const char *s);
161 int mutt_is_list_recipient(bool all_addr, struct Envelope *e);
163 int mutt_pattern_func(int op, char *prompt);
164 int mutt_search_command(int cur, int op);
165 
166 bool mutt_limit_current_thread(struct Email *e);
167 
168 #endif /* MUTT_PATTERN_H */
Pattern matches date received.
Definition: pattern.h:118
struct PatternList * child
Arguments to logical operation.
Definition: pattern.h:63
Pattern matches email&#39;s header.
Definition: pattern.h:125
regex_t * regex
Compiled regex, for non-pattern matching.
Definition: pattern.h:65
Pattern matches MIME type.
Definition: pattern.h:147
Pattern matches &#39;Date:&#39; field.
Definition: pattern.h:117
bool group_match
Check a group of Addresses.
Definition: pattern.h:55
The envelope/body of an email.
Definition: email.h:37
Pattern matches newsgroup.
Definition: pattern.h:149
Pattern matches email&#39;s score.
Definition: pattern.h:130
int mutt_is_subscribed_list_recipient(bool all_addr, struct Envelope *e)
Matches subscribed mailing lists.
Definition: pattern.c:1818
int pers_recip_all
^~p
Definition: pattern.h:92
Message is part of a broken thread.
Definition: pattern.h:121
Pattern matches email&#39;s size.
Definition: pattern.h:131
struct PatternList * mutt_pattern_comp(const char *s, PatternCompFlags flags, struct Buffer *err)
Create a Pattern.
Definition: pattern.c:1437
String manipulation buffer.
Definition: buffer.h:33
Pattern matches &#39;From:&#39; field.
Definition: pattern.h:116
Email is from the user.
Definition: pattern.h:137
Email is on mailing list.
Definition: pattern.h:134
int mutt_search_command(int cur, int op)
Perform a search.
Definition: pattern.c:2697
bool is_multi
Multiple case (only for ~I pattern now)
Definition: pattern.h:60
Pattern matches a child email.
Definition: pattern.h:111
void mutt_pattern_free(struct PatternList **pat)
Free a Pattern.
Definition: pattern.c:1385
Pattern matches email&#39;s Message-Id.
Definition: pattern.h:122
A simple (non-regex) pattern.
Definition: pattern.h:49
Pattern matches message number.
Definition: pattern.h:129
int sub_all
^~u
Definition: pattern.h:90
Email is on subscribed mailing list.
Definition: pattern.h:135
int mutt_pattern_func(int op, char *prompt)
Perform some Pattern matching.
Definition: pattern.c:2554
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
Many unsorted constants and some structs.
Duplicate message.
Definition: pattern.h:119
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:1831
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:61
bool ign_case
Ignore case for local string_match searches.
Definition: pattern.h:56
int pers_from_one
~P
Definition: pattern.h:95
Server-side pattern matches.
Definition: pattern.h:144
Pattern matches &#39;Cc:&#39; field.
Definition: pattern.h:113
int pers_recip_one
~p
Definition: pattern.h:93
Message is unreferenced in the thread.
Definition: pattern.h:120
A mailbox.
Definition: mailbox.h:81
Pattern matches keyword/label.
Definition: pattern.h:143
Either pattern can match.
Definition: pattern.h:108
union Pattern::@1 p
Pattern matches email&#39;s spam score.
Definition: pattern.h:126
Message is encrypted.
Definition: pattern.h:141
Pattern matches &#39;Subject:&#39; field.
Definition: pattern.h:115
int list_all
^~l
Definition: pattern.h:88
Email is addressed to the user.
Definition: pattern.h:136
Message has PGP key.
Definition: pattern.h:142
short op
Operation, e.g. MUTT_PAT_SCORE.
Definition: pattern.h:51
Pattern matches parent.
Definition: pattern.h:110
bool mutt_limit_current_thread(struct Email *e)
Limit the email view to the current thread.
Definition: pattern.c:2507
SLIST_HEAD(PatternList, Pattern)
int pers_from_all
^~P
Definition: pattern.h:94
Pattern matches email&#39;s body.
Definition: pattern.h:124
bool C_ThoroughSearch
Config: Decode headers and messages before searching them.
Definition: pattern.c:75
char * str
String, if string_match is set.
Definition: pattern.h:67
Message is signed.
Definition: pattern.h:139
bool sendmode
Evaluate searches in send-mode.
Definition: pattern.h:59
uint8_t PatternExecFlags
Flags for mutt_pattern_exec(), e.g. MUTT_MATCH_FULL_ADDRESS.
Definition: pattern.h:74
struct Group * group
Address group if group_match is set.
Definition: pattern.h:66
SLIST_ENTRY(Pattern) entries
Linked list.
A set of email addresses.
Definition: group.h:38
Thread is collapsed.
Definition: pattern.h:114
Pattern matches sender.
Definition: pattern.h:128
Both patterns must match.
Definition: pattern.h:107
void mutt_check_simple(struct Buffer *s, const char *simple)
Convert a simple search into a real request.
Definition: pattern.c:2430
Message is crypographically verified.
Definition: pattern.h:140
int max
Maximum for range checks.
Definition: pattern.h:62
Pattern matches &#39;References:&#39; or &#39;In-Reply-To:&#39; field.
Definition: pattern.h:132
Pattern matches message tags.
Definition: pattern.h:145
Pattern matches any address field.
Definition: pattern.h:138
User is a recipient of the email.
Definition: pattern.h:133
struct ListHead multi_cases
Multiple strings for ~I pattern.
Definition: pattern.h:68
PatternType
Types of pattern to match.
Definition: pattern.h:105
Pattern matches email thread.
Definition: pattern.h:109
uint8_t PatternCompFlags
Flags for mutt_pattern_comp(), e.g. MUTT_PC_FULL_MSG.
Definition: pattern.h:40
Pattern matches &#39;To:&#39; field.
Definition: pattern.h:112
Cache commonly-used patterns.
Definition: pattern.h:86
Pattern matches raw email text.
Definition: pattern.h:127
Convenience wrapper for the library headers.
Pattern matches number of attachments.
Definition: pattern.h:146
int list_one
~l
Definition: pattern.h:89
Message-Id is among results from an external query.
Definition: pattern.h:123
The header of an Email.
Definition: envelope.h:54
int sub_one
~u
Definition: pattern.h:91
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:2129