NeoMutt  2024-11-14-34-g5aaf0d
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
lib.h
Go to the documentation of this file.
1
44#ifndef MUTT_PATTERN_LIB_H
45#define MUTT_PATTERN_LIB_H
46
47#include "config.h"
48#include <stdbool.h>
49#include <stdint.h>
50#include "mutt/lib.h"
51#include "mutt.h"
52#include "search_state.h"
53
54struct AliasMenuData;
55struct AliasView;
56struct Email;
57struct Envelope;
58struct Mailbox;
59struct MailboxView;
60struct Menu;
61
62#define MUTT_ALIAS_SIMPLESEARCH "~f %s | ~t %s | ~c %s"
63
64extern const struct CompleteOps CompletePatternOps;
65
66typedef uint8_t PatternCompFlags;
67#define MUTT_PC_NO_FLAGS 0
68#define MUTT_PC_FULL_MSG (1 << 0)
69#define MUTT_PC_PATTERN_DYNAMIC (1 << 1)
70#define MUTT_PC_SEND_MODE_SEARCH (1 << 2)
71
75struct Pattern
76{
77 short op;
78 bool pat_not : 1;
79 bool all_addr : 1;
80 bool string_match : 1;
81 bool group_match : 1;
82 bool ign_case : 1;
83 bool is_alias : 1;
84 bool dynamic : 1;
85 bool sendmode : 1;
86 bool is_multi : 1;
87 long min;
88 long max;
89 struct PatternList *child;
90 union {
91 regex_t *regex;
92 struct Group *group;
93 char *str;
94 struct ListHead multi_cases;
95 } p;
96#ifdef USE_DEBUG_GRAPHVIZ
97 const char *raw_pattern;
98#endif
100};
101SLIST_HEAD(PatternList, Pattern);
102
103typedef uint8_t PatternExecFlags;
104#define MUTT_PAT_EXEC_NO_FLAGS 0
105#define MUTT_MATCH_FULL_ADDRESS (1 << 0)
106
116{
125};
126
135{
180};
181
186{
190};
191
192bool mutt_pattern_exec(struct Pattern *pat, PatternExecFlags flags, struct Mailbox *m,
193 struct Email *e, struct PatternCache *cache);
194bool mutt_pattern_alias_exec(struct Pattern *pat, PatternExecFlags flags,
195 struct AliasView *av, struct PatternCache *cache);
196
197struct PatternList *mutt_pattern_comp(struct MailboxView *mv, struct Menu *menu, const char *s, PatternCompFlags flags, struct Buffer *err);
198void mutt_check_simple(struct Buffer *s, const char *simple);
199void mutt_pattern_free(struct PatternList **pat);
200bool dlg_pattern(struct Buffer *buf);
201
202bool mutt_is_list_recipient(bool all_addr, struct Envelope *env);
203bool mutt_is_subscribed_list_recipient(bool all_addr, struct Envelope *env);
204int mutt_pattern_func(struct MailboxView *mv, int op, char *prompt);
205int mutt_pattern_alias_func(char *prompt, struct AliasMenuData *mdata, enum PatternAlias action, struct Menu *menu);
206int mutt_search_command(struct MailboxView *mv, struct Menu *menu, int cur,
207 struct SearchState *state, SearchFlags flags);
208int mutt_search_alias_command(struct Menu *menu, int cur,
209 struct SearchState *state, SearchFlags flags);
210
211#endif /* MUTT_PATTERN_LIB_H */
bool dlg_pattern(struct Buffer *buf)
Show menu to select a Pattern -.
Definition: dlg_pattern.c:317
Convenience wrapper for the library headers.
Many unsorted constants and some structs.
@ MUTT_MT_MAX
Definition: mutt.h:87
uint8_t PatternCompFlags
Flags for mutt_pattern_comp(), e.g. MUTT_PC_FULL_MSG.
Definition: lib.h:66
PatternAlias
What to do with the matching Aliases.
Definition: lib.h:186
@ PAA_VISIBLE
Set AliasView.is_visible and hide the rest.
Definition: lib.h:189
@ PAA_TAG
Set AliasView.is_tagged, but don't touch the others.
Definition: lib.h:187
@ PAA_UNTAG
Unset AliasView.is_tagged, but don't touch the others.
Definition: lib.h:188
PatternType
Types of pattern to match.
Definition: lib.h:135
@ MUTT_PAT_HEADER
Pattern matches email's header.
Definition: lib.h:155
@ MUTT_PAT_WHOLE_MSG
Pattern matches raw email text.
Definition: lib.h:157
@ MUTT_PAT_BROKEN
Message is part of a broken thread.
Definition: lib.h:151
@ MUTT_PAT_ID_EXTERNAL
Message-Id is among results from an external query.
Definition: lib.h:153
@ MUTT_PAT_OR
Either pattern can match.
Definition: lib.h:137
@ MUTT_PAT_CHILDREN
Pattern matches a child email.
Definition: lib.h:140
@ MUTT_PAT_PARENT
Pattern matches parent.
Definition: lib.h:139
@ MUTT_PAT_REFERENCE
Pattern matches 'References:' or 'In-Reply-To:' field.
Definition: lib.h:162
@ MUTT_PAT_FROM
Pattern matches 'From:' field.
Definition: lib.h:146
@ MUTT_PAT_DRIVER_TAGS
Pattern matches message tags.
Definition: lib.h:175
@ MUTT_PAT_COLLAPSED
Thread is collapsed.
Definition: lib.h:144
@ MUTT_PAT_CRYPT_VERIFIED
Message is crypographically verified.
Definition: lib.h:170
@ MUTT_PAT_HORMEL
Pattern matches email's spam score.
Definition: lib.h:156
@ MUTT_PAT_SUBJECT
Pattern matches 'Subject:' field.
Definition: lib.h:145
@ MUTT_PAT_LIST
Email is on mailing list.
Definition: lib.h:164
@ MUTT_PAT_NEWSGROUPS
Pattern matches newsgroup.
Definition: lib.h:178
@ MUTT_PAT_PERSONAL_RECIP
Email is addressed to the user.
Definition: lib.h:166
@ MUTT_PAT_CC
Pattern matches 'Cc:' field.
Definition: lib.h:142
@ MUTT_PAT_SUBSCRIBED_LIST
Email is on subscribed mailing list.
Definition: lib.h:165
@ MUTT_PAT_SERVERSEARCH
Server-side pattern matches.
Definition: lib.h:174
@ MUTT_PAT_RECIPIENT
User is a recipient of the email.
Definition: lib.h:163
@ MUTT_PAT_CRYPT_ENCRYPT
Message is encrypted.
Definition: lib.h:171
@ MUTT_PAT_UNREFERENCED
Message is unreferenced in the thread.
Definition: lib.h:150
@ MUTT_PAT_CRYPT_SIGN
Message is signed.
Definition: lib.h:169
@ MUTT_PAT_MESSAGE
Pattern matches message number.
Definition: lib.h:159
@ MUTT_PAT_AND
Both patterns must match.
Definition: lib.h:136
@ MUTT_PAT_DATE
Pattern matches 'Date:' field.
Definition: lib.h:147
@ MUTT_PAT_XLABEL
Pattern matches keyword/label.
Definition: lib.h:173
@ MUTT_PAT_SCORE
Pattern matches email's score.
Definition: lib.h:160
@ MUTT_PAT_MIMEATTACH
Pattern matches number of attachments.
Definition: lib.h:176
@ MUTT_PAT_DUPLICATED
Duplicate message.
Definition: lib.h:149
@ MUTT_PAT_PERSONAL_FROM
Email is from the user.
Definition: lib.h:167
@ MUTT_PAT_TO
Pattern matches 'To:' field.
Definition: lib.h:141
@ MUTT_PAT_BCC
Pattern matches 'Bcc:' field.
Definition: lib.h:143
@ MUTT_PAT_SENDER
Pattern matches sender.
Definition: lib.h:158
@ MUTT_PAT_DATE_RECEIVED
Pattern matches date received.
Definition: lib.h:148
@ MUTT_PAT_ADDRESS
Pattern matches any address field.
Definition: lib.h:168
@ MUTT_PAT_MAX
Definition: lib.h:179
@ MUTT_PAT_MIMETYPE
Pattern matches MIME type.
Definition: lib.h:177
@ MUTT_PAT_PGP_KEY
Message has PGP key.
Definition: lib.h:172
@ MUTT_PAT_ID
Pattern matches email's Message-Id.
Definition: lib.h:152
@ MUTT_PAT_THREAD
Pattern matches email thread.
Definition: lib.h:138
@ MUTT_PAT_SIZE
Pattern matches email's size.
Definition: lib.h:161
@ MUTT_PAT_BODY
Pattern matches email's body.
Definition: lib.h:154
int mutt_pattern_alias_func(char *prompt, struct AliasMenuData *mdata, enum PatternAlias action, struct Menu *menu)
Perform some Pattern matching for Alias.
Definition: pattern.c:191
bool mutt_pattern_alias_exec(struct Pattern *pat, PatternExecFlags flags, struct AliasView *av, struct PatternCache *cache)
Match a pattern against an alias.
Definition: exec.c:1174
void mutt_check_simple(struct Buffer *s, const char *simple)
Convert a simple search into a real request.
Definition: pattern.c:112
int mutt_search_command(struct MailboxView *mv, struct Menu *menu, int cur, struct SearchState *state, SearchFlags flags)
Perform a search.
Definition: pattern.c:478
bool mutt_is_subscribed_list_recipient(bool all_addr, struct Envelope *env)
Matches subscribed mailing lists.
Definition: exec.c:495
int mutt_search_alias_command(struct Menu *menu, int cur, struct SearchState *state, SearchFlags flags)
Perform a search.
Definition: pattern.c:636
bool mutt_is_list_recipient(bool all_addr, struct Envelope *env)
Matches known mailing lists.
Definition: exec.c:508
struct PatternList * mutt_pattern_comp(struct MailboxView *mv, struct Menu *menu, const char *s, PatternCompFlags flags, struct Buffer *err)
Create a Pattern.
Definition: compile.c:906
void mutt_pattern_free(struct PatternList **pat)
Free a Pattern.
Definition: compile.c:778
int mutt_pattern_func(struct MailboxView *mv, int op, char *prompt)
Perform some Pattern matching.
Definition: pattern.c:311
bool 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:1147
uint8_t PatternExecFlags
Flags for mutt_pattern_exec(), e.g. MUTT_MATCH_FULL_ADDRESS.
Definition: lib.h:103
const struct CompleteOps CompletePatternOps
Auto-Completion of Patterns.
Definition: complete.c:82
#define SLIST_HEAD(name, type)
Definition: queue.h:178
Holds state of a search.
uint8_t SearchFlags
Flags for a specific search, e.g. SEARCH_PROMPT.
Definition: search_state.h:43
AliasView array wrapper with Pattern information -.
Definition: gui.h:54
GUI data wrapping an Alias.
Definition: gui.h:38
String manipulation buffer.
Definition: buffer.h:36
The envelope/body of an email.
Definition: email.h:39
The header of an Email.
Definition: envelope.h:57
A set of email addresses.
Definition: group.h:39
View of a Mailbox.
Definition: mview.h:40
A mailbox.
Definition: mailbox.h:79
Definition: lib.h:79
Cache commonly-used patterns.
Definition: lib.h:116
int pers_recip_all
^~p
Definition: lib.h:121
int list_one
~l
Definition: lib.h:118
int pers_from_one
~P
Definition: lib.h:124
int list_all
^~l
Definition: lib.h:117
int sub_all
^~u
Definition: lib.h:119
int pers_recip_one
~p
Definition: lib.h:122
int pers_from_all
^~P
Definition: lib.h:123
int sub_one
~u
Definition: lib.h:120
A simple (non-regex) pattern.
Definition: lib.h:76
bool group_match
Check a group of Addresses.
Definition: lib.h:81
union Pattern::@1 p
bool all_addr
All Addresses in the list must match.
Definition: lib.h:79
struct Group * group
Address group if group_match is set.
Definition: lib.h:92
struct PatternList * child
Arguments to logical operation.
Definition: lib.h:89
long min
Minimum for range checks.
Definition: lib.h:87
bool string_match
Check a string for a match.
Definition: lib.h:80
regex_t * regex
Compiled regex, for non-pattern matching.
Definition: lib.h:91
SLIST_ENTRY(Pattern) entries
Linked list.
char * str
String, if string_match is set.
Definition: lib.h:93
bool is_alias
Is there an alias for this Address?
Definition: lib.h:83
bool ign_case
Ignore case for local string_match searches.
Definition: lib.h:82
long max
Maximum for range checks.
Definition: lib.h:88
bool dynamic
Evaluate date ranges at run time.
Definition: lib.h:84
short op
Operation, e.g. MUTT_PAT_SCORE.
Definition: lib.h:77
bool sendmode
Evaluate searches in send-mode.
Definition: lib.h:85
bool is_multi
Multiple case (only for ~I pattern now)
Definition: lib.h:86
bool pat_not
Pattern should be inverted (not)
Definition: lib.h:78
Holds state of a search.
Definition: search_state.h:36