Match patterns to emails. More...
#include "config.h"
#include <stdbool.h>
#include <stdint.h>
#include "mutt/lib.h"
#include "mutt.h"
#include "search_state.h"
Go to the source code of this file.
Data Structures | |
struct | Pattern |
A simple (non-regex) pattern. More... | |
struct | PatternCache |
Cache commonly-used patterns. More... | |
Macros | |
#define | MUTT_ALIAS_SIMPLESEARCH "~f %s | ~t %s | ~c %s" |
#define | MUTT_PC_NO_FLAGS 0 |
No flags are set. | |
#define | MUTT_PC_FULL_MSG (1 << 0) |
Enable body and header matching. | |
#define | MUTT_PC_PATTERN_DYNAMIC (1 << 1) |
Enable runtime date range evaluation. | |
#define | MUTT_PC_SEND_MODE_SEARCH (1 << 2) |
Allow send-mode body searching. | |
#define | MUTT_PAT_EXEC_NO_FLAGS 0 |
No flags are set. | |
#define | MUTT_MATCH_FULL_ADDRESS (1 << 0) |
Match the full address. | |
Typedefs | |
typedef uint8_t | PatternCompFlags |
Flags for mutt_pattern_comp(), e.g. MUTT_PC_FULL_MSG. | |
typedef uint8_t | PatternExecFlags |
Flags for mutt_pattern_exec(), e.g. MUTT_MATCH_FULL_ADDRESS. | |
Functions | |
SLIST_HEAD (PatternList, Pattern) | |
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. | |
bool | mutt_pattern_alias_exec (struct Pattern *pat, PatternExecFlags flags, struct AliasView *av, struct PatternCache *cache) |
Match a pattern against an alias. | |
struct PatternList * | mutt_pattern_comp (struct MailboxView *mv, struct Menu *menu, const char *s, PatternCompFlags flags, struct Buffer *err) |
Create a Pattern. | |
void | mutt_check_simple (struct Buffer *s, const char *simple) |
Convert a simple search into a real request. | |
void | mutt_pattern_free (struct PatternList **pat) |
Free a Pattern. | |
bool | dlg_pattern (struct Buffer *buf) |
Show menu to select a Pattern -. | |
bool | mutt_is_list_recipient (bool all_addr, struct Envelope *env) |
Matches known mailing lists. | |
bool | mutt_is_subscribed_list_recipient (bool all_addr, struct Envelope *env) |
Matches subscribed mailing lists. | |
int | mutt_pattern_func (struct MailboxView *mv, int op, char *prompt) |
Perform some Pattern matching. | |
int | mutt_pattern_alias_func (char *prompt, struct AliasMenuData *mdata, enum PatternAlias action, struct Menu *menu) |
Perform some Pattern matching for Alias. | |
int | mutt_search_command (struct MailboxView *mv, struct Menu *menu, int cur, struct SearchState *state, SearchFlags flags) |
Perform a search. | |
int | mutt_search_alias_command (struct Menu *menu, int cur, struct SearchState *state, SearchFlags flags) |
Perform a search. | |
Variables | |
const struct CompleteOps | CompletePatternOps |
Auto-Completion of Patterns. | |
Match patterns to emails.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.
Definition in file lib.h.
#define MUTT_PC_FULL_MSG (1 << 0) |
#define MUTT_PC_PATTERN_DYNAMIC (1 << 1) |
#define MUTT_PC_SEND_MODE_SEARCH (1 << 2) |
#define MUTT_MATCH_FULL_ADDRESS (1 << 0) |
typedef uint8_t PatternCompFlags |
Flags for mutt_pattern_comp(), e.g. MUTT_PC_FULL_MSG.
typedef uint8_t PatternExecFlags |
Flags for mutt_pattern_exec(), e.g. MUTT_MATCH_FULL_ADDRESS.
enum PatternType |
Types of pattern to match.
Enumerator | |
---|---|
MUTT_PAT_AND | Both patterns must match. |
MUTT_PAT_OR | Either pattern can match. |
MUTT_PAT_THREAD | Pattern matches email thread. |
MUTT_PAT_PARENT | Pattern matches parent. |
MUTT_PAT_CHILDREN | Pattern matches a child email. |
MUTT_PAT_TO | Pattern matches 'To:' field. |
MUTT_PAT_CC | Pattern matches 'Cc:' field. |
MUTT_PAT_BCC | Pattern matches 'Bcc:' field. |
MUTT_PAT_COLLAPSED | Thread is collapsed. |
MUTT_PAT_SUBJECT | Pattern matches 'Subject:' field. |
MUTT_PAT_FROM | Pattern matches 'From:' field. |
MUTT_PAT_DATE | Pattern matches 'Date:' field. |
MUTT_PAT_DATE_RECEIVED | Pattern matches date received. |
MUTT_PAT_DUPLICATED | Duplicate message. |
MUTT_PAT_UNREFERENCED | Message is unreferenced in the thread. |
MUTT_PAT_BROKEN | Message is part of a broken thread. |
MUTT_PAT_ID | Pattern matches email's Message-Id. |
MUTT_PAT_ID_EXTERNAL | Message-Id is among results from an external query. |
MUTT_PAT_BODY | Pattern matches email's body. |
MUTT_PAT_HEADER | Pattern matches email's header. |
MUTT_PAT_HORMEL | Pattern matches email's spam score. |
MUTT_PAT_WHOLE_MSG | Pattern matches raw email text. |
MUTT_PAT_SENDER | Pattern matches sender. |
MUTT_PAT_MESSAGE | Pattern matches message number. |
MUTT_PAT_SCORE | Pattern matches email's score. |
MUTT_PAT_SIZE | Pattern matches email's size. |
MUTT_PAT_REFERENCE | Pattern matches 'References:' or 'In-Reply-To:' field. |
MUTT_PAT_RECIPIENT | User is a recipient of the email. |
MUTT_PAT_LIST | Email is on mailing list. |
MUTT_PAT_SUBSCRIBED_LIST | Email is on subscribed mailing list. |
MUTT_PAT_PERSONAL_RECIP | Email is addressed to the user. |
MUTT_PAT_PERSONAL_FROM | Email is from the user. |
MUTT_PAT_ADDRESS | Pattern matches any address field. |
MUTT_PAT_CRYPT_SIGN | Message is signed. |
MUTT_PAT_CRYPT_VERIFIED | Message is crypographically verified. |
MUTT_PAT_CRYPT_ENCRYPT | Message is encrypted. |
MUTT_PAT_PGP_KEY | Message has PGP key. |
MUTT_PAT_XLABEL | Pattern matches keyword/label. |
MUTT_PAT_SERVERSEARCH | Server-side pattern matches. |
MUTT_PAT_DRIVER_TAGS | Pattern matches message tags. |
MUTT_PAT_MIMEATTACH | Pattern matches number of attachments. |
MUTT_PAT_MIMETYPE | Pattern matches MIME type. |
MUTT_PAT_NEWSGROUPS | Pattern matches newsgroup. |
MUTT_PAT_MAX |
Definition at line 134 of file lib.h.
enum PatternAlias |
What to do with the matching Aliases.
Enumerator | |
---|---|
PAA_TAG | Set AliasView.is_tagged, but don't touch the others. |
PAA_UNTAG | Unset AliasView.is_tagged, but don't touch the others. |
PAA_VISIBLE | Set AliasView.is_visible and hide the rest. |
SLIST_HEAD | ( | PatternList | , |
Pattern | |||
) |
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.
pat | Pattern to match |
flags | Flags, e.g. MUTT_MATCH_FULL_ADDRESS |
m | Mailbox |
e | |
cache | Cache for common Patterns |
true | Success, pattern matched |
false | Pattern did not match |
flags: MUTT_MATCH_FULL_ADDRESS: match both personal and machine address cache: For repeated matches against the same Header, passing in non-NULL will store some of the cacheable pattern matches in this structure.
Definition at line 1147 of file exec.c.
bool mutt_pattern_alias_exec | ( | struct Pattern * | pat, |
PatternExecFlags | flags, | ||
struct AliasView * | av, | ||
struct PatternCache * | cache | ||
) |
Match a pattern against an alias.
pat | Pattern to match |
flags | Flags, e.g. MUTT_MATCH_FULL_ADDRESS |
av | AliasView |
cache | Cache for common Patterns |
true | Success, pattern matched |
false | Pattern did not match |
flags: MUTT_MATCH_FULL_ADDRESS: match both personal and machine address cache: For repeated matches against the same Alias, passing in non-NULL will store some of the cacheable pattern matches in this structure.
Definition at line 1174 of file exec.c.
struct PatternList * mutt_pattern_comp | ( | struct MailboxView * | mv, |
struct Menu * | menu, | ||
const char * | s, | ||
PatternCompFlags | flags, | ||
struct Buffer * | err | ||
) |
Create a Pattern.
mv | Mailbox view |
menu | Current Menu |
s | Pattern string |
flags | Flags, e.g. MUTT_PC_FULL_MSG |
err | Buffer for error messages |
ptr | Newly allocated Pattern |
Definition at line 906 of file compile.c.
void mutt_check_simple | ( | struct Buffer * | buf, |
const char * | simple | ||
) |
Convert a simple search into a real request.
buf | Buffer for the result |
simple | Search string to convert |
Definition at line 112 of file pattern.c.
void mutt_pattern_free | ( | struct PatternList ** | pat | ) |
Free a Pattern.
[out] | pat | Pattern to free |
Definition at line 778 of file compile.c.
bool mutt_is_list_recipient | ( | bool | all_addr, |
struct Envelope * | env | ||
) |
Matches known mailing lists.
all_addr | If true, ALL Addresses must be mailing lists |
env | Envelope |
true |
|
Definition at line 508 of file exec.c.
bool mutt_is_subscribed_list_recipient | ( | bool | all_addr, |
struct Envelope * | env | ||
) |
Matches subscribed mailing lists.
all_addr | If true, ALL Addresses must be on the subscribed list |
env | Envelope |
true |
|
Definition at line 495 of file exec.c.
int mutt_pattern_func | ( | struct MailboxView * | mv, |
int | op, | ||
char * | prompt | ||
) |
Perform some Pattern matching.
mv | Mailbox View |
op | Operation to perform, e.g. MUTT_LIMIT |
prompt | Prompt to show the user |
0 | Success |
-1 | Failure |
Definition at line 311 of file pattern.c.
int mutt_pattern_alias_func | ( | char * | prompt, |
struct AliasMenuData * | mdata, | ||
enum PatternAlias | action, | ||
struct Menu * | menu | ||
) |
Perform some Pattern matching for Alias.
prompt | Prompt to show the user |
mdata | Menu data holding Aliases |
action | What to do with the results, e.g. PAA_TAG |
menu | Current menu |
0 | Success |
-1 | Failure |
Definition at line 191 of file pattern.c.
int mutt_search_command | ( | struct MailboxView * | mv, |
struct Menu * | menu, | ||
int | cur, | ||
struct SearchState * | state, | ||
SearchFlags | flags | ||
) |
Perform a search.
mv | Mailbox view to search through |
menu | Current Menu |
cur | Index number of current email |
state | Current search state |
flags | Search flags, e.g. SEARCH_PROMPT |
>=0 | Index of matching email |
-1 | No match, or error |
Definition at line 478 of file pattern.c.
int mutt_search_alias_command | ( | struct Menu * | menu, |
int | cur, | ||
struct SearchState * | state, | ||
SearchFlags | flags | ||
) |
Perform a search.
menu | Menu to search through |
cur | Index number of current email |
state | Current search state |
flags | Search flags, e.g. SEARCH_PROMPT |
>=0 | Index of matching alias |
-1 | No match, or error |
Definition at line 636 of file pattern.c.
|
extern |
Auto-Completion of Patterns.
Definition at line 82 of file complete.c.