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