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