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