NeoMutt  2021-02-05
Teaching an old dog new tricks
DOXYGEN
lib.h File Reference

Match patterns to emails. More...

#include "config.h"
#include <stddef.h>
#include <stdbool.h>
#include <stdint.h>
#include "mutt/lib.h"
#include "mutt.h"
+ Include dependency graph for lib.h:
+ This graph shows which files directly or indirectly include this file:

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. More...
 
#define MUTT_PC_FULL_MSG   (1<<0)
 Enable body and header matching. More...
 
#define MUTT_PC_PATTERN_DYNAMIC   (1<<1)
 Enable runtime date range evaluation. More...
 
#define MUTT_PC_SEND_MODE_SEARCH   (1<<2)
 Allow send-mode body searching. More...
 
#define MUTT_PAT_EXEC_NO_FLAGS   0
 No flags are set. More...
 
#define MUTT_MATCH_FULL_ADDRESS   (1 << 0)
 Match the full address. More...
 

Typedefs

typedef uint8_t PatternCompFlags
 Flags for mutt_pattern_comp(), e.g. MUTT_PC_FULL_MSG. More...
 
typedef uint8_t PatternExecFlags
 Flags for mutt_pattern_exec(), e.g. MUTT_MATCH_FULL_ADDRESS. More...
 

Enumerations

enum  PatternType {
  MUTT_PAT_AND = MUTT_MT_MAX, MUTT_PAT_OR, MUTT_PAT_THREAD, MUTT_PAT_PARENT,
  MUTT_PAT_CHILDREN, MUTT_PAT_TO, MUTT_PAT_CC, MUTT_PAT_COLLAPSED,
  MUTT_PAT_SUBJECT, MUTT_PAT_FROM, MUTT_PAT_DATE, MUTT_PAT_DATE_RECEIVED,
  MUTT_PAT_DUPLICATED, MUTT_PAT_UNREFERENCED, MUTT_PAT_BROKEN, MUTT_PAT_ID,
  MUTT_PAT_ID_EXTERNAL, MUTT_PAT_BODY, MUTT_PAT_HEADER, MUTT_PAT_HORMEL,
  MUTT_PAT_WHOLE_MSG, MUTT_PAT_SENDER, MUTT_PAT_MESSAGE, MUTT_PAT_SCORE,
  MUTT_PAT_SIZE, MUTT_PAT_REFERENCE, MUTT_PAT_RECIPIENT, MUTT_PAT_LIST,
  MUTT_PAT_SUBSCRIBED_LIST, MUTT_PAT_PERSONAL_RECIP, MUTT_PAT_PERSONAL_FROM, MUTT_PAT_ADDRESS,
  MUTT_PAT_CRYPT_SIGN, MUTT_PAT_CRYPT_VERIFIED, MUTT_PAT_CRYPT_ENCRYPT, MUTT_PAT_PGP_KEY,
  MUTT_PAT_XLABEL, MUTT_PAT_SERVERSEARCH, MUTT_PAT_DRIVER_TAGS, MUTT_PAT_MIMEATTACH,
  MUTT_PAT_MIMETYPE, MUTT_PAT_NEWSGROUPS, MUTT_PAT_MAX
}
 Types of pattern to match. More...
 

Functions

 SLIST_HEAD (PatternList, Pattern)
 
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. More...
 
int mutt_pattern_alias_exec (struct Pattern *pat, PatternExecFlags flags, struct AliasView *av, struct PatternCache *cache)
 Match a pattern against an alias. More...
 
struct PatternList * mutt_pattern_comp (const char *s, PatternCompFlags flags, struct Buffer *err)
 Create a Pattern. More...
 
void mutt_check_simple (struct Buffer *s, const char *simple)
 Convert a simple search into a real request. More...
 
void mutt_pattern_free (struct PatternList **pat)
 Free a Pattern. More...
 
bool dlg_select_pattern (char *buf, size_t buflen)
 Show menu to select a Pattern. More...
 
int mutt_which_case (const char *s)
 
int mutt_is_list_recipient (bool all_addr, struct Envelope *e)
 Matches known mailing lists. More...
 
int mutt_is_subscribed_list_recipient (bool all_addr, struct Envelope *e)
 Matches subscribed mailing lists. More...
 
int mutt_pattern_func (int op, char *prompt)
 Perform some Pattern matching. More...
 
int mutt_pattern_alias_func (int op, char *prompt, char *title, struct AliasMenuData *mdata, struct Menu *menu)
 Perform some Pattern matching for Alias. More...
 
int mutt_search_command (struct Mailbox *m, int cur, int op)
 Perform a search. More...
 
int mutt_search_alias_command (struct Menu *menu, int cur, int op)
 Perform a search. More...
 
bool mutt_limit_current_thread (struct Email *e)
 Limit the email view to the current thread. More...
 
bool config_init_pattern (struct ConfigSet *cs)
 Register pattern config variables - Implements module_init_config_t. More...
 

Variables

bool C_ThoroughSearch
 Config: Decode headers and messages before searching them. More...
 

Detailed Description

Match patterns to emails.

Authors
  • Richard Russon
  • Pietro Cerutti

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.

Macro Definition Documentation

◆ MUTT_ALIAS_SIMPLESEARCH

#define MUTT_ALIAS_SIMPLESEARCH   "~f %s | ~t %s | ~c %s"

Definition at line 57 of file lib.h.

◆ MUTT_PC_NO_FLAGS

#define MUTT_PC_NO_FLAGS   0

No flags are set.

Definition at line 63 of file lib.h.

◆ MUTT_PC_FULL_MSG

#define MUTT_PC_FULL_MSG   (1<<0)

Enable body and header matching.

Definition at line 64 of file lib.h.

◆ MUTT_PC_PATTERN_DYNAMIC

#define MUTT_PC_PATTERN_DYNAMIC   (1<<1)

Enable runtime date range evaluation.

Definition at line 65 of file lib.h.

◆ MUTT_PC_SEND_MODE_SEARCH

#define MUTT_PC_SEND_MODE_SEARCH   (1<<2)

Allow send-mode body searching.

Definition at line 66 of file lib.h.

◆ MUTT_PAT_EXEC_NO_FLAGS

#define MUTT_PAT_EXEC_NO_FLAGS   0

No flags are set.

Definition at line 97 of file lib.h.

◆ MUTT_MATCH_FULL_ADDRESS

#define MUTT_MATCH_FULL_ADDRESS   (1 << 0)

Match the full address.

Definition at line 98 of file lib.h.

Typedef Documentation

◆ PatternCompFlags

typedef uint8_t PatternCompFlags

Flags for mutt_pattern_comp(), e.g. MUTT_PC_FULL_MSG.

Definition at line 62 of file lib.h.

◆ PatternExecFlags

typedef uint8_t PatternExecFlags

Flags for mutt_pattern_exec(), e.g. MUTT_MATCH_FULL_ADDRESS.

Definition at line 96 of file lib.h.

Enumeration Type Documentation

◆ PatternType

Types of pattern to match.

Note
This enum piggy-backs on top of MessageType
See also
mutt_pattern_comp(), mutt_pattern_exec()
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_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 127 of file lib.h.

128 {
130  MUTT_PAT_OR,
134  MUTT_PAT_TO,
135  MUTT_PAT_CC,
138  MUTT_PAT_FROM,
139  MUTT_PAT_DATE,
144  MUTT_PAT_ID,
146  MUTT_PAT_BODY,
153  MUTT_PAT_SIZE,
156  MUTT_PAT_LIST,
170 #ifdef USE_NNTP
172 #endif
173  MUTT_PAT_MAX,
174 };
Pattern matches message number.
Definition: lib.h:151
Pattern matches email&#39;s Message-Id.
Definition: lib.h:144
Pattern matches email&#39;s body.
Definition: lib.h:146
Message is signed.
Definition: lib.h:161
Email is on mailing list.
Definition: lib.h:156
Pattern matches &#39;To:&#39; field.
Definition: lib.h:134
Pattern matches date received.
Definition: lib.h:140
Pattern matches &#39;References:&#39; or &#39;In-Reply-To:&#39; field.
Definition: lib.h:154
Message is unreferenced in the thread.
Definition: lib.h:142
Pattern matches &#39;From:&#39; field.
Definition: lib.h:138
Pattern matches email&#39;s header.
Definition: lib.h:147
Server-side pattern matches.
Definition: lib.h:166
Message is encrypted.
Definition: lib.h:163
Message is crypographically verified.
Definition: lib.h:162
Pattern matches sender.
Definition: lib.h:150
Pattern matches keyword/label.
Definition: lib.h:165
Email is addressed to the user.
Definition: lib.h:158
Email is from the user.
Definition: lib.h:159
Pattern matches newsgroup.
Definition: lib.h:171
Pattern matches any address field.
Definition: lib.h:160
Message is part of a broken thread.
Definition: lib.h:143
Email is on subscribed mailing list.
Definition: lib.h:157
Pattern matches MIME type.
Definition: lib.h:169
Message-Id is among results from an external query.
Definition: lib.h:145
Pattern matches number of attachments.
Definition: lib.h:168
Pattern matches &#39;Date:&#39; field.
Definition: lib.h:139
Thread is collapsed.
Definition: lib.h:136
Pattern matches &#39;Cc:&#39; field.
Definition: lib.h:135
Duplicate message.
Definition: lib.h:141
Both patterns must match.
Definition: lib.h:129
Either pattern can match.
Definition: lib.h:130
Pattern matches parent.
Definition: lib.h:132
Pattern matches email&#39;s spam score.
Definition: lib.h:148
User is a recipient of the email.
Definition: lib.h:155
Pattern matches raw email text.
Definition: lib.h:149
Pattern matches a child email.
Definition: lib.h:133
Pattern matches message tags.
Definition: lib.h:167
Pattern matches email thread.
Definition: lib.h:131
Message has PGP key.
Definition: lib.h:164
Pattern matches email&#39;s score.
Definition: lib.h:152
Pattern matches email&#39;s size.
Definition: lib.h:153
Pattern matches &#39;Subject:&#39; field.
Definition: lib.h:137

Function Documentation

◆ SLIST_HEAD()

SLIST_HEAD ( PatternList  ,
Pattern   
)

◆ mutt_pattern_exec()

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.

Parameters
patPattern to match
flagsFlags, e.g. MUTT_MATCH_FULL_ADDRESS
mMailbox
eEmail
cacheCache for common Patterns
Return values
1Success, pattern matched
0Pattern did not match
-1Error

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 738 of file exec.c.

740 {
741  switch (pat->op)
742  {
743  case MUTT_PAT_AND:
744  return pat->pat_not ^ (perform_and(pat->child, flags, m, e, cache) > 0);
745  case MUTT_PAT_OR:
746  return pat->pat_not ^ (perform_or(pat->child, flags, m, e, cache) > 0);
747  case MUTT_PAT_THREAD:
748  return pat->pat_not ^
749  match_threadcomplete(pat->child, flags, m, e->thread, 1, 1, 1, 1);
750  case MUTT_PAT_PARENT:
751  return pat->pat_not ^ match_threadparent(pat->child, flags, m, e->thread);
752  case MUTT_PAT_CHILDREN:
753  return pat->pat_not ^ match_threadchildren(pat->child, flags, m, e->thread);
754  case MUTT_ALL:
755  return !pat->pat_not;
756  case MUTT_EXPIRED:
757  return pat->pat_not ^ e->expired;
758  case MUTT_SUPERSEDED:
759  return pat->pat_not ^ e->superseded;
760  case MUTT_FLAG:
761  return pat->pat_not ^ e->flagged;
762  case MUTT_TAG:
763  return pat->pat_not ^ e->tagged;
764  case MUTT_NEW:
765  return pat->pat_not ? e->old || e->read : !(e->old || e->read);
766  case MUTT_UNREAD:
767  return pat->pat_not ? e->read : !e->read;
768  case MUTT_REPLIED:
769  return pat->pat_not ^ e->replied;
770  case MUTT_OLD:
771  return pat->pat_not ? (!e->old || e->read) : (e->old && !e->read);
772  case MUTT_READ:
773  return pat->pat_not ^ e->read;
774  case MUTT_DELETED:
775  return pat->pat_not ^ e->deleted;
776  case MUTT_PAT_MESSAGE:
777  return pat->pat_not ^ ((EMSG(e) >= pat->min) && (EMSG(e) <= pat->max));
778  case MUTT_PAT_DATE:
779  if (pat->dynamic)
781  return pat->pat_not ^ (e->date_sent >= pat->min && e->date_sent <= pat->max);
783  if (pat->dynamic)
785  return pat->pat_not ^ (e->received >= pat->min && e->received <= pat->max);
786  case MUTT_PAT_BODY:
787  case MUTT_PAT_HEADER:
788  case MUTT_PAT_WHOLE_MSG:
789  if (pat->sendmode)
790  {
791  if (!e->body || !e->body->filename)
792  return 0;
793  return pat->pat_not ^ msg_search_sendmode(e, pat);
794  }
795  /* m can be NULL in certain cases, such as when replying to a message
796  * from the attachment menu and the user has a reply-hook using "~e".
797  * This is also the case when message scoring. */
798  if (!m)
799  return 0;
800 #ifdef USE_IMAP
801  /* IMAP search sets e->matched at search compile time */
802  if ((m->type == MUTT_IMAP) && pat->string_match)
803  return e->matched;
804 #endif
805  return pat->pat_not ^ msg_search(m, pat, e->msgno);
807 #ifdef USE_IMAP
808  if (!m)
809  return 0;
810  if (m->type == MUTT_IMAP)
811  {
812  if (pat->string_match)
813  return e->matched;
814  return 0;
815  }
816  mutt_error(_("error: server custom search only supported with IMAP"));
817  return 0;
818 #else
819  mutt_error(_("error: server custom search only supported with IMAP"));
820  return -1;
821 #endif
822  case MUTT_PAT_SENDER:
823  if (!e->env)
824  return 0;
825  return pat->pat_not ^ match_addrlist(pat, (flags & MUTT_MATCH_FULL_ADDRESS),
826  1, &e->env->sender);
827  case MUTT_PAT_FROM:
828  if (!e->env)
829  return 0;
830  return pat->pat_not ^
832  case MUTT_PAT_TO:
833  if (!e->env)
834  return 0;
835  return pat->pat_not ^
837  case MUTT_PAT_CC:
838  if (!e->env)
839  return 0;
840  return pat->pat_not ^
842  case MUTT_PAT_SUBJECT:
843  if (!e->env)
844  return 0;
845  return pat->pat_not ^ (e->env->subject && patmatch(pat, e->env->subject));
846  case MUTT_PAT_ID:
848  if (!e->env)
849  return 0;
850  return pat->pat_not ^ (e->env->message_id && patmatch(pat, e->env->message_id));
851  case MUTT_PAT_SCORE:
852  return pat->pat_not ^ (e->score >= pat->min &&
853  (pat->max == MUTT_MAXRANGE || e->score <= pat->max));
854  case MUTT_PAT_SIZE:
855  return pat->pat_not ^ (e->body->length >= pat->min &&
856  (pat->max == MUTT_MAXRANGE || e->body->length <= pat->max));
857  case MUTT_PAT_REFERENCE:
858  if (!e->env)
859  return 0;
860  return pat->pat_not ^ (match_reference(pat, &e->env->references) ||
861  match_reference(pat, &e->env->in_reply_to));
862  case MUTT_PAT_ADDRESS:
863  if (!e->env)
864  return 0;
865  return pat->pat_not ^ match_addrlist(pat, (flags & MUTT_MATCH_FULL_ADDRESS),
866  4, &e->env->from, &e->env->sender,
867  &e->env->to, &e->env->cc);
868  case MUTT_PAT_RECIPIENT:
869  if (!e->env)
870  return 0;
871  return pat->pat_not ^ match_addrlist(pat, (flags & MUTT_MATCH_FULL_ADDRESS),
872  2, &e->env->to, &e->env->cc);
873  case MUTT_PAT_LIST: /* known list, subscribed or not */
874  {
875  if (!e->env)
876  return 0;
877 
878  int result;
879  if (cache)
880  {
881  int *cache_entry = pat->all_addr ? &cache->list_all : &cache->list_one;
882  if (!is_pattern_cache_set(*cache_entry))
883  {
884  set_pattern_cache_value(cache_entry,
886  }
887  result = get_pattern_cache_value(*cache_entry);
888  }
889  else
890  result = mutt_is_list_recipient(pat->all_addr, e->env);
891  return pat->pat_not ^ result;
892  }
894  {
895  if (!e->env)
896  return 0;
897 
898  int result;
899  if (cache)
900  {
901  int *cache_entry = pat->all_addr ? &cache->sub_all : &cache->sub_one;
902  if (!is_pattern_cache_set(*cache_entry))
903  {
905  cache_entry, mutt_is_subscribed_list_recipient(pat->all_addr, e->env));
906  }
907  result = get_pattern_cache_value(*cache_entry);
908  }
909  else
911  return pat->pat_not ^ result;
912  }
914  {
915  if (!e->env)
916  return 0;
917 
918  int result;
919  if (cache)
920  {
921  int *cache_entry = pat->all_addr ? &cache->pers_recip_all : &cache->pers_recip_one;
922  if (!is_pattern_cache_set(*cache_entry))
923  {
925  cache_entry, match_user(pat->all_addr, &e->env->to, &e->env->cc));
926  }
927  result = get_pattern_cache_value(*cache_entry);
928  }
929  else
930  result = match_user(pat->all_addr, &e->env->to, &e->env->cc);
931  return pat->pat_not ^ result;
932  }
934  {
935  if (!e->env)
936  return 0;
937 
938  int result;
939  if (cache)
940  {
941  int *cache_entry = pat->all_addr ? &cache->pers_from_all : &cache->pers_from_one;
942  if (!is_pattern_cache_set(*cache_entry))
943  {
944  set_pattern_cache_value(cache_entry,
945  match_user(pat->all_addr, &e->env->from, NULL));
946  }
947  result = get_pattern_cache_value(*cache_entry);
948  }
949  else
950  result = match_user(pat->all_addr, &e->env->from, NULL);
951  return pat->pat_not ^ result;
952  }
953  case MUTT_PAT_COLLAPSED:
954  return pat->pat_not ^ (e->collapsed && e->num_hidden > 1);
955  case MUTT_PAT_CRYPT_SIGN:
956  if (!WithCrypto)
957  {
959  return 0;
960  }
961  return pat->pat_not ^ ((e->security & SEC_SIGN) ? 1 : 0);
963  if (!WithCrypto)
964  {
966  return 0;
967  }
968  return pat->pat_not ^ ((e->security & SEC_GOODSIGN) ? 1 : 0);
970  if (!WithCrypto)
971  {
973  return 0;
974  }
975  return pat->pat_not ^ ((e->security & SEC_ENCRYPT) ? 1 : 0);
976  case MUTT_PAT_PGP_KEY:
977  if (!(WithCrypto & APPLICATION_PGP))
978  {
980  return 0;
981  }
982  return pat->pat_not ^ ((e->security & PGP_KEY) == PGP_KEY);
983  case MUTT_PAT_XLABEL:
984  if (!e->env)
985  return 0;
986  return pat->pat_not ^ (e->env->x_label && patmatch(pat, e->env->x_label));
988  {
989  char *tags = driver_tags_get(&e->tags);
990  bool rc = (pat->pat_not ^ (tags && patmatch(pat, tags)));
991  FREE(&tags);
992  return rc;
993  }
994  case MUTT_PAT_HORMEL:
995  if (!e->env)
996  return 0;
997  return pat->pat_not ^ (e->env->spam.data && patmatch(pat, e->env->spam.data));
998  case MUTT_PAT_DUPLICATED:
999  return pat->pat_not ^ (e->thread && e->thread->duplicate_thread);
1000  case MUTT_PAT_MIMEATTACH:
1001  if (!m)
1002  return 0;
1003  {
1004  int count = mutt_count_body_parts(m, e);
1005  return pat->pat_not ^ (count >= pat->min &&
1006  (pat->max == MUTT_MAXRANGE || count <= pat->max));
1007  }
1008  case MUTT_PAT_MIMETYPE:
1009  if (!m)
1010  return 0;
1011  return pat->pat_not ^ match_mime_content_type(pat, m, e);
1012  case MUTT_PAT_UNREFERENCED:
1013  return pat->pat_not ^ (e->thread && !e->thread->child);
1014  case MUTT_PAT_BROKEN:
1015  return pat->pat_not ^ (e->thread && e->thread->fake_thread);
1016 #ifdef USE_NNTP
1017  case MUTT_PAT_NEWSGROUPS:
1018  if (!e->env)
1019  return 0;
1020  return pat->pat_not ^ (e->env->newsgroups && patmatch(pat, e->env->newsgroups));
1021 #endif
1022  }
1023  mutt_error(_("error: unknown op %d (report this error)"), pat->op);
1024  return 0;
1025 }
Pattern matches message number.
Definition: lib.h:151
struct PatternList * child
Arguments to logical operation.
Definition: lib.h:85
Deleted messages.
Definition: mutt.h:101
static int match_threadparent(struct PatternList *pat, PatternExecFlags flags, struct Mailbox *m, struct MuttThread *t)
Match Pattern against an email&#39;s parent.
Definition: exec.c:528
char * filename
when sending a message, this is the file to which this structure refers
Definition: body.h:46
enum MailboxType type
Mailbox type.
Definition: mailbox.h:105
Pattern matches email&#39;s Message-Id.
Definition: lib.h:144
#define WithCrypto
Definition: lib.h:123
Pattern matches email&#39;s body.
Definition: lib.h:146
static int get_pattern_cache_value(int cache_entry)
Get pattern cache value.
Definition: exec.c:633
Message is signed.
Definition: lib.h:161
struct Body * body
List of MIME parts.
Definition: email.h:91
static int msg_search_sendmode(struct Email *e, struct Pattern *pat)
Search in send-mode.
Definition: exec.c:656
static int match_user(int all_addr, struct AddressList *al1, struct AddressList *al2)
Matches the user&#39;s email Address.
Definition: exec.c:454
int pers_recip_all
^~p
Definition: lib.h:114
struct MuttThread * thread
Thread of Emails.
Definition: email.h:95
Email is on mailing list.
Definition: lib.h:156
#define SEC_ENCRYPT
Email is encrypted.
Definition: lib.h:85
Pattern matches &#39;To:&#39; field.
Definition: lib.h:134
static void set_pattern_cache_value(int *cache_entry, int value)
Sets a value in the PatternCache cache entry.
Definition: exec.c:622
Flagged messages.
Definition: mutt.h:102
#define EMSG(e)
Definition: private.h:120
Pattern matches date received.
Definition: lib.h:140
#define _(a)
Definition: message.h:28
Pattern matches &#39;References:&#39; or &#39;In-Reply-To:&#39; field.
Definition: lib.h:154
bool expired
Already expired?
Definition: email.h:52
static int match_threadcomplete(struct PatternList *pat, PatternExecFlags flags, struct Mailbox *m, struct MuttThread *t, int left, int up, int right, int down)
Match a Pattern against an email thread.
Definition: exec.c:490
int mutt_is_subscribed_list_recipient(bool all_addr, struct Envelope *e)
Matches subscribed mailing lists.
Definition: exec.c:427
Message is unreferenced in the thread.
Definition: lib.h:142
static int match_addrlist(struct Pattern *pat, bool match_personal, int n,...)
Match a Pattern against an Address list.
Definition: exec.c:351
Messages that have been replied to.
Definition: mutt.h:95
int sub_all
^~u
Definition: lib.h:112
Pattern matches &#39;From:&#39; field.
Definition: lib.h:138
Pattern matches email&#39;s header.
Definition: lib.h:147
Server-side pattern matches.
Definition: lib.h:166
Message is encrypted.
Definition: lib.h:163
static bool msg_search(struct Mailbox *m, struct Pattern *pat, int msgno)
Search an email.
Definition: exec.c:106
static bool match_update_dynamic_date(struct Pattern *pat)
Update a dynamic date pattern.
Definition: exec.c:605
All messages.
Definition: mutt.h:91
bool tagged
Email is tagged.
Definition: email.h:44
bool read
Email is read.
Definition: email.h:51
bool dynamic
Evaluate date ranges at run time.
Definition: lib.h:80
Message is crypographically verified.
Definition: lib.h:162
struct ListHead in_reply_to
in-reply-to header content
Definition: envelope.h:82
char * message_id
Message ID.
Definition: envelope.h:69
bool all_addr
All Addresses in the list must match.
Definition: lib.h:75
bool old
Email is seen, but unread.
Definition: email.h:50
struct AddressList from
Email&#39;s &#39;From&#39; list.
Definition: envelope.h:57
static int match_threadchildren(struct PatternList *pat, PatternExecFlags flags, struct Mailbox *m, struct MuttThread *t)
Match Pattern against an email&#39;s children.
Definition: exec.c:547
Pattern matches sender.
Definition: lib.h:150
static bool patmatch(const struct Pattern *pat, const char *buf)
Compare a string to a Pattern.
Definition: exec.c:65
Pattern matches keyword/label.
Definition: lib.h:165
Email is addressed to the user.
Definition: lib.h:158
struct Envelope * env
Envelope information.
Definition: email.h:90
Email is from the user.
Definition: lib.h:159
Pattern matches newsgroup.
Definition: lib.h:171
struct AddressList cc
Email&#39;s &#39;Cc&#39; list.
Definition: envelope.h:59
bool string_match
Check a string for a match.
Definition: lib.h:76
bool pat_not
Pattern should be inverted (not)
Definition: lib.h:74
bool superseded
Got superseded?
Definition: email.h:53
int min
Minimum for range checks.
Definition: lib.h:83
Pattern matches any address field.
Definition: lib.h:160
struct TagList tags
For drivers that support server tagging.
Definition: email.h:109
Message is part of a broken thread.
Definition: lib.h:143
Email is on subscribed mailing list.
Definition: lib.h:157
int score
Message score.
Definition: email.h:89
time_t date_sent
Time when the message was sent (UTC)
Definition: email.h:82
Old messages.
Definition: mutt.h:94
int pers_from_one
~P
Definition: lib.h:117
struct MuttThread * child
Child of this Thread.
Definition: thread.h:46
bool duplicate_thread
Duplicated Email in Thread.
Definition: thread.h:37
int pers_recip_one
~p
Definition: lib.h:115
#define APPLICATION_PGP
Use PGP to encrypt/sign.
Definition: lib.h:97
LOFF_T length
length (in bytes) of attachment
Definition: body.h:45
Pattern matches MIME type.
Definition: lib.h:169
bool fake_thread
Emails grouped by Subject.
Definition: thread.h:36
int mutt_is_list_recipient(bool all_addr, struct Envelope *e)
Matches known mailing lists.
Definition: exec.c:440
Message-Id is among results from an external query.
Definition: lib.h:145
static bool perform_and(struct PatternList *pat, PatternExecFlags flags, struct Mailbox *m, struct Email *e, struct PatternCache *cache)
Perform a logical AND on a set of Patterns.
Definition: exec.c:264
char * driver_tags_get(struct TagList *list)
Get tags.
Definition: tags.c:142
size_t num_hidden
Number of hidden messages in this view (only valid when collapsed is set)
Definition: email.h:75
Superseded messages.
Definition: mutt.h:107
Tagged messages.
Definition: mutt.h:103
char * data
Pointer to data.
Definition: buffer.h:35
int list_all
^~l
Definition: lib.h:110
New messages.
Definition: mutt.h:93
Messages that have been read.
Definition: mutt.h:96
Pattern matches number of attachments.
Definition: lib.h:168
static int is_pattern_cache_set(int cache_entry)
Is a given Pattern cached?
Definition: exec.c:643
bool collapsed
Is this message part of a collapsed thread?
Definition: email.h:73
short op
Operation, e.g. MUTT_PAT_SCORE.
Definition: lib.h:73
#define MUTT_MAXRANGE
Definition: private.h:122
SecurityFlags security
bit 0-10: flags, bit 11,12: application, bit 13: traditional pgp See: ncrypt/lib.h pgplib...
Definition: email.h:39
Expired messages.
Definition: mutt.h:106
int pers_from_all
^~P
Definition: lib.h:116
#define SEC_SIGN
Email is signed.
Definition: lib.h:86
uint8_t flags
e.g. MB_NORMAL
Definition: mailbox.h:134
Unread messages.
Definition: mutt.h:97
Pattern matches &#39;Date:&#39; field.
Definition: lib.h:139
Thread is collapsed.
Definition: lib.h:136
char * subject
Email&#39;s subject.
Definition: envelope.h:66
Pattern matches &#39;Cc:&#39; field.
Definition: lib.h:135
Duplicate message.
Definition: lib.h:141
Both patterns must match.
Definition: lib.h:129
#define PGP_KEY
Definition: lib.h:106
bool flagged
Marked important?
Definition: email.h:43
char * newsgroups
List of newsgroups.
Definition: envelope.h:75
bool deleted
Email is deleted.
Definition: email.h:45
Either pattern can match.
Definition: lib.h:130
bool sendmode
Evaluate searches in send-mode.
Definition: lib.h:81
#define mutt_error(...)
Definition: logging.h:84
bool replied
Email has been replied to.
Definition: email.h:54
static void print_crypt_pattern_op_error(int op)
Print an error for a disabled crypto pattern.
Definition: exec.c:80
Pattern matches parent.
Definition: lib.h:132
Pattern matches email&#39;s spam score.
Definition: lib.h:148
User is a recipient of the email.
Definition: lib.h:155
static bool match_reference(struct Pattern *pat, struct ListHead *refs)
Match references against a Pattern.
Definition: exec.c:381
#define FREE(x)
Definition: memory.h:40
int max
Maximum for range checks.
Definition: lib.h:84
struct AddressList to
Email&#39;s &#39;To&#39; list.
Definition: envelope.h:58
struct AddressList sender
Email&#39;s sender.
Definition: envelope.h:61
Pattern matches raw email text.
Definition: lib.h:149
Pattern matches a child email.
Definition: lib.h:133
int mutt_count_body_parts(struct Mailbox *m, struct Email *e)
Count the MIME Body parts.
Definition: mutt_parse.c:208
static int perform_or(struct PatternList *pat, PatternExecFlags flags, struct Mailbox *m, struct Email *e, struct PatternCache *cache)
Perform a logical OR on a set of Patterns.
Definition: exec.c:307
Pattern matches message tags.
Definition: lib.h:167
Pattern matches email thread.
Definition: lib.h:131
struct ListHead references
message references (in reverse order)
Definition: envelope.h:81
&#39;IMAP&#39; Mailbox type
Definition: mailbox.h:53
char * x_label
X-Label.
Definition: envelope.h:72
#define SEC_GOODSIGN
Email has a valid signature.
Definition: lib.h:87
int list_one
~l
Definition: lib.h:111
#define MUTT_MATCH_FULL_ADDRESS
Match the full address.
Definition: lib.h:98
Message has PGP key.
Definition: lib.h:164
time_t received
Time when the message was placed in the mailbox.
Definition: email.h:83
Pattern matches email&#39;s score.
Definition: lib.h:152
Pattern matches email&#39;s size.
Definition: lib.h:153
struct Buffer spam
Spam header.
Definition: envelope.h:80
bool matched
Search matches this Email.
Definition: email.h:68
int msgno
Number displayed to the user.
Definition: email.h:87
int sub_one
~u
Definition: lib.h:113
Pattern matches &#39;Subject:&#39; field.
Definition: lib.h:137
static bool match_mime_content_type(const struct Pattern *pat, struct Mailbox *m, struct Email *e)
Match a Pattern against an email&#39;s Content-Type.
Definition: exec.c:592
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_pattern_alias_exec()

int mutt_pattern_alias_exec ( struct Pattern pat,
PatternExecFlags  flags,
struct AliasView av,
struct PatternCache cache 
)

Match a pattern against an alias.

Parameters
patPattern to match
flagsFlags, e.g. MUTT_MATCH_FULL_ADDRESS
avAliasView
cacheCache for common Patterns
Return values
1Success, pattern matched
0Pattern did not match
-1Error

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 1041 of file exec.c.

1043 {
1044  switch (pat->op)
1045  {
1046  case MUTT_PAT_FROM: /* alias */
1047  if (!av->alias)
1048  return 0;
1049  return pat->pat_not ^ (av->alias->name && patmatch(pat, av->alias->name));
1050  case MUTT_PAT_CC: /* comment */
1051  if (!av->alias)
1052  return 0;
1053  return pat->pat_not ^ (av->alias->comment && patmatch(pat, av->alias->comment));
1054  case MUTT_PAT_TO: /* alias address list */
1055  if (!av->alias)
1056  return 0;
1057  return pat->pat_not ^ match_addrlist(pat, (flags & MUTT_MATCH_FULL_ADDRESS),
1058  1, &av->alias->addr);
1059  case MUTT_PAT_AND:
1060  return pat->pat_not ^ (perform_alias_and(pat->child, flags, av, cache) > 0);
1061  case MUTT_PAT_OR:
1062  return pat->pat_not ^ (perform_alias_or(pat->child, flags, av, cache) > 0);
1063  }
1064 
1065  return 0;
1066 }
struct PatternList * child
Arguments to logical operation.
Definition: lib.h:85
char * name
Short name.
Definition: alias.h:35
Pattern matches &#39;To:&#39; field.
Definition: lib.h:134
static int match_addrlist(struct Pattern *pat, bool match_personal, int n,...)
Match a Pattern against an Address list.
Definition: exec.c:351
Pattern matches &#39;From:&#39; field.
Definition: lib.h:138
static bool patmatch(const struct Pattern *pat, const char *buf)
Compare a string to a Pattern.
Definition: exec.c:65
bool pat_not
Pattern should be inverted (not)
Definition: lib.h:74
struct Alias * alias
Alias.
Definition: gui.h:45
char * comment
Free-form comment string.
Definition: alias.h:37
short op
Operation, e.g. MUTT_PAT_SCORE.
Definition: lib.h:73
static int perform_alias_or(struct PatternList *pat, PatternExecFlags flags, struct AliasView *av, struct PatternCache *cache)
Perform a logical OR on a set of Patterns.
Definition: exec.c:328
uint8_t flags
e.g. MB_NORMAL
Definition: mailbox.h:134
Pattern matches &#39;Cc:&#39; field.
Definition: lib.h:135
Both patterns must match.
Definition: lib.h:129
static bool perform_alias_and(struct PatternList *pat, PatternExecFlags flags, struct AliasView *av, struct PatternCache *cache)
Perform a logical AND on a set of Patterns.
Definition: exec.c:285
Either pattern can match.
Definition: lib.h:130
struct AddressList addr
List of Addresses the Alias expands to.
Definition: alias.h:36
#define MUTT_MATCH_FULL_ADDRESS
Match the full address.
Definition: lib.h:98
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_pattern_comp()

struct PatternList* mutt_pattern_comp ( const char *  s,
PatternCompFlags  flags,
struct Buffer err 
)

Create a Pattern.

Parameters
sPattern string
flagsFlags, e.g. MUTT_PC_FULL_MSG
errBuffer for error messages
Return values
ptrNewly allocated Pattern

Definition at line 1063 of file compile.c.

1064 {
1065  /* curlist when assigned will always point to a list containing at least one node
1066  * with a Pattern value. */
1067  struct PatternList *curlist = NULL;
1068  struct PatternList *tmp = NULL, *tmp2 = NULL;
1069  struct PatternList *last = NULL;
1070  bool pat_not = false;
1071  bool all_addr = false;
1072  bool pat_or = false;
1073  bool implicit = true; /* used to detect logical AND operator */
1074  bool is_alias = false;
1075  short thread_op;
1076  const struct PatternFlags *entry = NULL;
1077  char *p = NULL;
1078  char *buf = NULL;
1079  struct Buffer ps;
1080 
1081  if (!s || !*s)
1082  {
1083  mutt_buffer_strcpy(err, _("empty pattern"));
1084  return NULL;
1085  }
1086 
1087  mutt_buffer_init(&ps);
1088  ps.dptr = (char *) s;
1089  ps.dsize = mutt_str_len(s);
1090 
1091  while (*ps.dptr)
1092  {
1093  SKIPWS(ps.dptr);
1094  switch (*ps.dptr)
1095  {
1096  case '^':
1097  ps.dptr++;
1098  all_addr = !all_addr;
1099  break;
1100  case '!':
1101  ps.dptr++;
1102  pat_not = !pat_not;
1103  break;
1104  case '@':
1105  ps.dptr++;
1106  is_alias = !is_alias;
1107  break;
1108  case '|':
1109  if (!pat_or)
1110  {
1111  if (!curlist)
1112  {
1113  mutt_buffer_printf(err, _("error in pattern at: %s"), ps.dptr);
1114  return NULL;
1115  }
1116 
1117  struct Pattern *pat = SLIST_FIRST(curlist);
1118 
1119  if (SLIST_NEXT(pat, entries))
1120  {
1121  /* A & B | C == (A & B) | C */
1122  tmp = mutt_pattern_node_new();
1123  pat = SLIST_FIRST(tmp);
1124  pat->op = MUTT_PAT_AND;
1125  pat->child = curlist;
1126 
1127  curlist = tmp;
1128  last = curlist;
1129  }
1130 
1131  pat_or = true;
1132  }
1133  ps.dptr++;
1134  implicit = false;
1135  pat_not = false;
1136  all_addr = false;
1137  is_alias = false;
1138  break;
1139  case '%':
1140  case '=':
1141  case '~':
1142  {
1143  struct Pattern *pat = NULL;
1144  if (ps.dptr[1] == '\0')
1145  {
1146  mutt_buffer_printf(err, _("missing pattern: %s"), ps.dptr);
1147  goto cleanup;
1148  }
1149  thread_op = 0;
1150  if (ps.dptr[1] == '(')
1151  thread_op = MUTT_PAT_THREAD;
1152  else if ((ps.dptr[1] == '<') && (ps.dptr[2] == '('))
1153  thread_op = MUTT_PAT_PARENT;
1154  else if ((ps.dptr[1] == '>') && (ps.dptr[2] == '('))
1155  thread_op = MUTT_PAT_CHILDREN;
1156  if (thread_op)
1157  {
1158  ps.dptr++; /* skip ~ */
1159  if ((thread_op == MUTT_PAT_PARENT) || (thread_op == MUTT_PAT_CHILDREN))
1160  ps.dptr++;
1161  p = find_matching_paren(ps.dptr + 1);
1162  if (p[0] != ')')
1163  {
1164  mutt_buffer_printf(err, _("mismatched parentheses: %s"), ps.dptr);
1165  goto cleanup;
1166  }
1167  tmp = mutt_pattern_node_new();
1168  pat = SLIST_FIRST(tmp);
1169  pat->op = thread_op;
1170  if (last)
1171  SLIST_NEXT(SLIST_FIRST(last), entries) = pat;
1172  else
1173  curlist = tmp;
1174  last = tmp;
1175  pat->pat_not ^= pat_not;
1176  pat->all_addr |= all_addr;
1177  pat->is_alias |= is_alias;
1178  pat_not = false;
1179  all_addr = false;
1180  is_alias = false;
1181  /* compile the sub-expression */
1182  buf = mutt_strn_dup(ps.dptr + 1, p - (ps.dptr + 1));
1183  tmp2 = mutt_pattern_comp(buf, flags, err);
1184  if (!tmp2)
1185  {
1186  FREE(&buf);
1187  goto cleanup;
1188  }
1189  FREE(&buf);
1190  pat->child = tmp2;
1191  ps.dptr = p + 1; /* restore location */
1192  break;
1193  }
1194  if (implicit && pat_or)
1195  {
1196  /* A | B & C == (A | B) & C */
1197  tmp = mutt_pattern_node_new();
1198  pat = SLIST_FIRST(tmp);
1199  pat->op = MUTT_PAT_OR;
1200  pat->child = curlist;
1201  curlist = tmp;
1202  last = tmp;
1203  pat_or = false;
1204  }
1205 
1206  tmp = mutt_pattern_node_new();
1207  pat = SLIST_FIRST(tmp);
1208  pat->pat_not = pat_not;
1209  pat->all_addr = all_addr;
1210  pat->is_alias = is_alias;
1211  pat->string_match = (ps.dptr[0] == '=');
1212  pat->group_match = (ps.dptr[0] == '%');
1213  pat_not = false;
1214  all_addr = false;
1215  is_alias = false;
1216 
1217  if (last)
1218  SLIST_NEXT(SLIST_FIRST(last), entries) = pat;
1219  else
1220  curlist = tmp;
1221  if (curlist != last)
1222  FREE(&last);
1223  last = tmp;
1224 
1225  ps.dptr++; /* move past the ~ */
1226  entry = lookup_tag(*ps.dptr);
1227  if (!entry)
1228  {
1229  mutt_buffer_printf(err, _("%c: invalid pattern modifier"), *ps.dptr);
1230  goto cleanup;
1231  }
1232  if (entry->flags && ((flags & entry->flags) == 0))
1233  {
1234  mutt_buffer_printf(err, _("%c: not supported in this mode"), *ps.dptr);
1235  goto cleanup;
1236  }
1237  if (flags & MUTT_PC_SEND_MODE_SEARCH)
1238  pat->sendmode = true;
1239 
1240  pat->op = entry->op;
1241 
1242  ps.dptr++; /* eat the operator and any optional whitespace */
1243  SKIPWS(ps.dptr);
1244 
1245  if (entry->eat_arg)
1246  {
1247  if (ps.dptr[0] == '\0')
1248  {
1249  mutt_buffer_printf(err, "%s", _("missing parameter"));
1250  goto cleanup;
1251  }
1252  switch (entry->eat_arg)
1253  {
1254  case EAT_REGEX:
1255  if (!eat_regex(pat, flags, &ps, err))
1256  goto cleanup;
1257  break;
1258  case EAT_DATE:
1259  if (!eat_date(pat, flags, &ps, err))
1260  goto cleanup;
1261  break;
1262  case EAT_RANGE:
1263  if (!eat_range(pat, flags, &ps, err))
1264  goto cleanup;
1265  break;
1266  case EAT_MESSAGE_RANGE:
1267  if (!eat_message_range(pat, flags, &ps, err))
1268  goto cleanup;
1269  break;
1270  case EAT_QUERY:
1271  if (!eat_query(pat, flags, &ps, err))
1272  goto cleanup;
1273  break;
1274  default:
1275  break;
1276  }
1277  }
1278  implicit = true;
1279  break;
1280  }
1281 
1282  case '(':
1283  {
1284  p = find_matching_paren(ps.dptr + 1);
1285  if (p[0] != ')')
1286  {
1287  mutt_buffer_printf(err, _("mismatched parentheses: %s"), ps.dptr);
1288  goto cleanup;
1289  }
1290  /* compile the sub-expression */
1291  buf = mutt_strn_dup(ps.dptr + 1, p - (ps.dptr + 1));
1292  tmp = mutt_pattern_comp(buf, flags, err);
1293  FREE(&buf);
1294  if (!tmp)
1295  goto cleanup;
1296  struct Pattern *pat = SLIST_FIRST(tmp);
1297  if (last)
1298  SLIST_NEXT(SLIST_FIRST(last), entries) = pat;
1299  else
1300  curlist = tmp;
1301  last = tmp;
1302  pat = SLIST_FIRST(tmp);
1303  pat->pat_not ^= pat_not;
1304  pat->all_addr |= all_addr;
1305  pat->is_alias |= is_alias;
1306  pat_not = false;
1307  all_addr = false;
1308  is_alias = false;
1309  ps.dptr = p + 1; /* restore location */
1310  break;
1311  }
1312 
1313  default:
1314  mutt_buffer_printf(err, _("error in pattern at: %s"), ps.dptr);
1315  goto cleanup;
1316  }
1317  }
1318  if (!curlist)
1319  {
1320  mutt_buffer_strcpy(err, _("empty pattern"));
1321  return NULL;
1322  }
1323  if (curlist != tmp)
1324  FREE(&tmp);
1325  if (SLIST_NEXT(SLIST_FIRST(curlist), entries))
1326  {
1327  tmp = mutt_pattern_node_new();
1328  struct Pattern *pat = SLIST_FIRST(tmp);
1329  pat->op = pat_or ? MUTT_PAT_OR : MUTT_PAT_AND;
1330  pat->child = curlist;
1331  curlist = tmp;
1332  }
1333 
1334  return curlist;
1335 
1336 cleanup:
1337  mutt_pattern_free(&curlist);
1338  return NULL;
1339 }
struct PatternList * child
Arguments to logical operation.
Definition: lib.h:85
enum PatternEat eat_arg
Definition: private.h:58
bool group_match
Check a group of Addresses.
Definition: lib.h:77
Process a number (range)
Definition: private.h:44
static struct PatternList * mutt_pattern_node_new(void)
Create a new list containing a Pattern.
Definition: compile.c:1047
static bool eat_date(struct Pattern *pat, PatternCompFlags flags, struct Buffer *s, struct Buffer *err)
Parse a date pattern - Implements eat_arg_t.
Definition: compile.c:949
static bool eat_regex(struct Pattern *pat, PatternCompFlags flags, struct Buffer *s, struct Buffer *err)
Parse a regex - Implements eat_arg_t.
Definition: compile.c:80
String manipulation buffer.
Definition: buffer.h:33
#define _(a)
Definition: message.h:28
struct PatternList * mutt_pattern_comp(const char *s, PatternCompFlags flags, struct Buffer *err)
Create a Pattern.
Definition: compile.c:1063
int mutt_buffer_printf(struct Buffer *buf, const char *fmt,...)
Format a string overwriting a Buffer.
Definition: buffer.c:160
Process a regex.
Definition: private.h:42
static char * find_matching_paren(char *s)
Find the matching parenthesis.
Definition: compile.c:989
A simple (non-regex) pattern.
Definition: lib.h:71
bool is_alias
Is there an alias for this Address?
Definition: lib.h:79
int op
Operation to perform, e.g. MUTT_PAT_SCORE.
Definition: private.h:55
bool all_addr
All Addresses in the list must match.
Definition: lib.h:75
static bool eat_query(struct Pattern *pat, PatternCompFlags flags, struct Buffer *s, struct Buffer *err)
Parse a query for an external search program - Implements eat_arg_t.
Definition: compile.c:149
char * mutt_strn_dup(const char *begin, size_t len)
Duplicate a sub-string.
Definition: string.c:548
#define SKIPWS(ch)
Definition: string2.h:46
#define MUTT_PC_SEND_MODE_SEARCH
Allow send-mode body searching.
Definition: lib.h:66
bool string_match
Check a string for a match.
Definition: lib.h:76
bool pat_not
Pattern should be inverted (not)
Definition: lib.h:74
#define SLIST_NEXT(elm, field)
Definition: queue.h:269
Process a message number (range)
Definition: private.h:45
#define SLIST_FIRST(head)
Definition: queue.h:228
short op
Operation, e.g. MUTT_PAT_SCORE.
Definition: lib.h:73
const struct PatternFlags * lookup_tag(char tag)
Lookup a pattern modifier.
Definition: flags.c:197
size_t mutt_buffer_strcpy(struct Buffer *buf, const char *s)
Copy a string into a Buffer.
Definition: buffer.c:312
size_t mutt_str_len(const char *a)
Calculate the length of a string, safely.
Definition: string.c:631
static bool eat_range(struct Pattern *pat, PatternCompFlags flags, struct Buffer *s, struct Buffer *err)
Parse a number range - Implements eat_arg_t.
Definition: compile.c:620
Both patterns must match.
Definition: lib.h:129
Either pattern can match.
Definition: lib.h:130
bool sendmode
Evaluate searches in send-mode.
Definition: lib.h:81
Pattern matches parent.
Definition: lib.h:132
#define FREE(x)
Definition: memory.h:40
Pattern matches a child email.
Definition: lib.h:133
static bool eat_message_range(struct Pattern *pat, PatternCompFlags flags, struct Buffer *s, struct Buffer *err)
Parse a range of message numbers - Implements eat_arg_t.
Definition: compile.c:905
Mapping between user character and internal constant.
Definition: private.h:52
struct Buffer * mutt_buffer_init(struct Buffer *buf)
Initialise a new Buffer.
Definition: buffer.c:46
void mutt_pattern_free(struct PatternList **pat)
Free a Pattern.
Definition: compile.c:1011
Pattern matches email thread.
Definition: lib.h:131
PatternCompFlags flags
Pattern flags, e.g. MUTT_PC_FULL_MSG.
Definition: private.h:56
Process a date (range)
Definition: private.h:43
Process a query string.
Definition: private.h:46
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_check_simple()

void mutt_check_simple ( struct Buffer buf,
const char *  simple 
)

Convert a simple search into a real request.

Parameters
bufBuffer for the result
simpleSearch string to convert

Definition at line 111 of file pattern.c.

112 {
113  bool do_simple = true;
114 
115  for (const char *p = mutt_buffer_string(buf); p && (p[0] != '\0'); p++)
116  {
117  if ((p[0] == '\\') && (p[1] != '\0'))
118  p++;
119  else if ((p[0] == '~') || (p[0] == '=') || (p[0] == '%'))
120  {
121  do_simple = false;
122  break;
123  }
124  }
125 
126  /* XXX - is mutt_istr_cmp() right here, or should we use locale's
127  * equivalences? */
128 
129  if (do_simple) /* yup, so spoof a real request */
130  {
131  /* convert old tokens into the new format */
132  if (mutt_istr_equal("all", mutt_buffer_string(buf)) ||
133  mutt_str_equal("^", mutt_buffer_string(buf)) ||
134  mutt_str_equal(".", mutt_buffer_string(buf))) /* ~A is more efficient */
135  {
136  mutt_buffer_strcpy(buf, "~A");
137  }
138  else if (mutt_istr_equal("del", mutt_buffer_string(buf)))
139  mutt_buffer_strcpy(buf, "~D");
140  else if (mutt_istr_equal("flag", mutt_buffer_string(buf)))
141  mutt_buffer_strcpy(buf, "~F");
142  else if (mutt_istr_equal("new", mutt_buffer_string(buf)))
143  mutt_buffer_strcpy(buf, "~N");
144  else if (mutt_istr_equal("old", mutt_buffer_string(buf)))
145  mutt_buffer_strcpy(buf, "~O");
146  else if (mutt_istr_equal("repl", mutt_buffer_string(buf)))
147  mutt_buffer_strcpy(buf, "~Q");
148  else if (mutt_istr_equal("read", mutt_buffer_string(buf)))
149  mutt_buffer_strcpy(buf, "~R");
150  else if (mutt_istr_equal("tag", mutt_buffer_string(buf)))
151  mutt_buffer_strcpy(buf, "~T");
152  else if (mutt_istr_equal("unread", mutt_buffer_string(buf)))
153  mutt_buffer_strcpy(buf, "~U");
154  else
155  {
156  struct Buffer *tmp = mutt_buffer_pool_get();
157  quote_simple(mutt_buffer_string(buf), tmp);
158  mutt_file_expand_fmt(buf, simple, mutt_buffer_string(tmp));
160  }
161  }
162 }
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
Definition: string.c:871
struct Buffer * mutt_buffer_pool_get(void)
Get a Buffer from the pool.
Definition: pool.c:101
static void quote_simple(const char *str, struct Buffer *buf)
Apply simple quoting to a string.
Definition: pattern.c:93
void mutt_buffer_pool_release(struct Buffer **pbuf)
Free a Buffer from the pool.
Definition: pool.c:112
String manipulation buffer.
Definition: buffer.h:33
static const char * mutt_buffer_string(const struct Buffer *buf)
Convert a buffer to a const char * "string".
Definition: buffer.h:77
bool mutt_istr_equal(const char *a, const char *b)
Compare two strings, ignoring case.
Definition: string.c:883
union Pattern::@1 p
void mutt_file_expand_fmt(struct Buffer *dest, const char *fmt, const char *src)
Replace s in a string with a filename.
Definition: file.c:1447
size_t mutt_buffer_strcpy(struct Buffer *buf, const char *s)
Copy a string into a Buffer.
Definition: buffer.c:312
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_pattern_free()

void mutt_pattern_free ( struct PatternList **  pat)

Free a Pattern.

Parameters
[out]patPattern to free

Definition at line 1011 of file compile.c.

1012 {
1013  if (!pat || !*pat)
1014  return;
1015 
1016  struct Pattern *np = SLIST_FIRST(*pat), *next = NULL;
1017 
1018  while (np)
1019  {
1020  next = SLIST_NEXT(np, entries);
1021 
1022  if (np->is_multi)
1024  else if (np->string_match || np->dynamic)
1025  FREE(&np->p.str);
1026  else if (np->group_match)
1027  np->p.group = NULL;
1028  else if (np->p.regex)
1029  {
1030  regfree(np->p.regex);
1031  FREE(&np->p.regex);
1032  }
1033 
1034  mutt_pattern_free(&np->child);
1035  FREE(&np);
1036 
1037  np = next;
1038  }
1039 
1040  FREE(pat);
1041 }
struct PatternList * child
Arguments to logical operation.
Definition: lib.h:85
regex_t * regex
Compiled regex, for non-pattern matching.
Definition: lib.h:87
bool group_match
Check a group of Addresses.
Definition: lib.h:77
bool is_multi
Multiple case (only for ~I pattern now)
Definition: lib.h:82
void mutt_list_free(struct ListHead *h)
Free a List AND its strings.
Definition: list.c:122
A simple (non-regex) pattern.
Definition: lib.h:71
bool dynamic
Evaluate date ranges at run time.
Definition: lib.h:80
bool string_match
Check a string for a match.
Definition: lib.h:76
#define SLIST_NEXT(elm, field)
Definition: queue.h:269
#define SLIST_FIRST(head)
Definition: queue.h:228
union Pattern::@1 p
char * str
String, if string_match is set.
Definition: lib.h:89
struct Group * group
Address group if group_match is set.
Definition: lib.h:88
#define FREE(x)
Definition: memory.h:40
struct ListHead multi_cases
Multiple strings for ~I pattern.
Definition: lib.h:90
void mutt_pattern_free(struct PatternList **pat)
Free a Pattern.
Definition: compile.c:1011
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ dlg_select_pattern()

bool dlg_select_pattern ( char *  buf,
size_t  buflen 
)

Show menu to select a Pattern.

Parameters
bufBuffer for the selected Pattern
buflenLength of buffer
Return values
booltrue, if a selection was made

Definition at line 262 of file dlgpattern.c.

263 {
264  struct Menu *menu = create_pattern_menu();
266  dlg->help_data = PatternHelp;
267  dlg->help_menu = MENU_GENERIC;
268 
269  bool rc = false;
270  bool done = false;
271  while (!done)
272  {
273  switch (mutt_menu_loop(menu))
274  {
275  case OP_GENERIC_SELECT_ENTRY:
276  {
277  struct PatternEntry *entry = (struct PatternEntry *) menu->mdata + menu->current;
278  mutt_str_copy(buf, entry->tag, buflen);
279  rc = true;
280  done = true;
281  break;
282  }
283 
284  case OP_EXIT:
285  done = true;
286  break;
287  }
288  }
289 
290  free_pattern_menu(&menu);
292  return rc;
293 }
GUI selectable list of items.
Definition: mutt_menu.h:52
int help_menu
Menu for key bindings, e.g. MENU_PAGER.
Definition: mutt_window.h:134
static const struct Mapping PatternHelp[]
Help Bar for the Pattern selection dialog.
Definition: dlgpattern.c:61
A division of the screen.
Definition: mutt_window.h:115
struct MuttWindow * dialog_create_simple_index(struct Menu *menu, enum WindowType type)
Create a simple index Dialog.
Definition: dialog.c:165
void * mdata
Extra data for the current menu.
Definition: mutt_menu.h:55
const struct Mapping * help_data
Data for the Help Bar.
Definition: mutt_window.h:135
void dialog_destroy_simple_index(struct MuttWindow **ptr)
Destroy a simple index Dialog.
Definition: dialog.c:209
static void free_pattern_menu(struct Menu **ptr)
Free the Pattern Completion menu.
Definition: dlgpattern.c:235
const char * tag
Copied to buffer if selected.
Definition: dlgpattern.c:55
size_t mutt_str_copy(char *dest, const char *src, size_t dsize)
Copy a string into a buffer (guaranteeing NUL-termination)
Definition: string.c:716
Pattern Dialog, create_pattern_menu()
Definition: mutt_window.h:84
int current
Current entry.
Definition: mutt_menu.h:56
static struct Menu * create_pattern_menu(void)
Create the Pattern Completion menu.
Definition: dlgpattern.c:122
A line in the Pattern Completion menu.
Definition: dlgpattern.c:52
Generic selection list.
Definition: keymap.h:79
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_which_case()

int mutt_which_case ( const char *  s)

◆ mutt_is_list_recipient()

int mutt_is_list_recipient ( bool  all_addr,
struct Envelope e 
)

Matches known mailing lists.

Parameters
all_addrIf true, ALL Addresses must be mailing lists
eEnvelope
Return values
true
  • One Address is a mailing list (all_addr is false)
  • All the Addresses are mailing lists (all_addr is true)

Definition at line 440 of file exec.c.

441 {
442  return mutt_is_predicate_recipient(all_addr, e, &mutt_is_mail_list);
443 }
bool mutt_is_mail_list(const struct Address *addr)
Is this the email address of a mailing list? - Implements addr_predicate_t.
Definition: maillist.c:45
static int mutt_is_predicate_recipient(bool all_addr, struct Envelope *e, addr_predicate_t p)
Test an Envelopes Addresses using a predicate function.
Definition: exec.c:403
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_is_subscribed_list_recipient()

int mutt_is_subscribed_list_recipient ( bool  all_addr,
struct Envelope e 
)

Matches subscribed mailing lists.

Parameters
all_addrIf true, ALL Addresses must be on the subscribed list
eEnvelope
Return values
true
  • One Address is subscribed (all_addr is false)
  • All the Addresses are subscribed (all_addr is true)

Definition at line 427 of file exec.c.

428 {
430 }
bool mutt_is_subscribed_list(const struct Address *addr)
Is this the email address of a user-subscribed mailing list? - Implements addr_predicate_t.
Definition: maillist.c:57
static int mutt_is_predicate_recipient(bool all_addr, struct Envelope *e, addr_predicate_t p)
Test an Envelopes Addresses using a predicate function.
Definition: exec.c:403
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_pattern_func()

int mutt_pattern_func ( int  op,
char *  prompt 
)

Perform some Pattern matching.

Parameters
opOperation to perform, e.g. MUTT_LIMIT
promptPrompt to show the user
Return values
0Success
-1Failure

Definition at line 338 of file pattern.c.

339 {
340  struct Mailbox *m = ctx_mailbox(Context);
341  if (!m)
342  return -1;
343 
344  struct Buffer err;
345  int rc = -1;
346  struct Progress progress;
347  struct Buffer *buf = mutt_buffer_pool_get();
348 
350  if (prompt || (op != MUTT_LIMIT))
351  {
352  if ((mutt_buffer_get_field(prompt, buf, MUTT_PATTERN | MUTT_CLEAR) != 0) ||
354  {
356  return -1;
357  }
358  }
359 
360  mutt_message(_("Compiling search pattern..."));
361 
362  char *simple = mutt_buffer_strdup(buf);
364  const char *pbuf = buf->data;
365  while (*pbuf == ' ')
366  pbuf++;
367  const bool match_all = mutt_str_equal(pbuf, "~A");
368 
369  mutt_buffer_init(&err);
370  err.dsize = 256;
371  err.data = mutt_mem_malloc(err.dsize);
372  struct PatternList *pat = mutt_pattern_comp(buf->data, MUTT_PC_FULL_MSG, &err);
373  if (!pat)
374  {
375  mutt_error("%s", err.data);
376  goto bail;
377  }
378 
379 #ifdef USE_IMAP
380  if ((m->type == MUTT_IMAP) && (!imap_search(m, pat)))
381  goto bail;
382 #endif
383 
384  mutt_progress_init(&progress, _("Executing command on matching messages..."),
385  MUTT_PROGRESS_READ, (op == MUTT_LIMIT) ? m->msg_count : m->vcount);
386 
387  if (op == MUTT_LIMIT)
388  {
389  m->vcount = 0;
390  Context->vsize = 0;
391  Context->collapsed = false;
392  int padding = mx_msg_padding_size(m);
393 
394  for (int i = 0; i < m->msg_count; i++)
395  {
396  struct Email *e = m->emails[i];
397  if (!e)
398  break;
399 
400  mutt_progress_update(&progress, i, -1);
401  /* new limit pattern implicitly uncollapses all threads */
402  e->vnum = -1;
403  e->visible = false;
404  e->collapsed = false;
405  e->num_hidden = 0;
406  if (match_all ||
408  {
409  e->vnum = m->vcount;
410  e->visible = true;
411  m->v2r[m->vcount] = i;
412  m->vcount++;
413  struct Body *b = e->body;
414  Context->vsize += b->length + b->offset - b->hdr_offset + padding;
415  }
416  }
417  }
418  else
419  {
420  for (int i = 0; i < m->vcount; i++)
421  {
422  struct Email *e = mutt_get_virt_email(m, i);
423  if (!e)
424  continue;
425  mutt_progress_update(&progress, i, -1);
427  {
428  switch (op)
429  {
430  case MUTT_UNDELETE:
431  mutt_set_flag(m, e, MUTT_PURGE, false);
432  /* fallthrough */
433  case MUTT_DELETE:
434  mutt_set_flag(m, e, MUTT_DELETE, (op == MUTT_DELETE));
435  break;
436  case MUTT_TAG:
437  case MUTT_UNTAG:
438  mutt_set_flag(m, e, MUTT_TAG, (op == MUTT_TAG));
439  break;
440  }
441  }
442  }
443  }
444 
446 
447  if (op == MUTT_LIMIT)
448  {
449  /* drop previous limit pattern */
450  FREE(&Context->pattern);
452 
453  if (m->msg_count && !m->vcount)
454  mutt_error(_("No messages matched criteria"));
455 
456  /* record new limit pattern, unless match all */
457  if (!match_all)
458  {
459  Context->pattern = simple;
460  simple = NULL; /* don't clobber it */
462  }
463  }
464 
465  rc = 0;
466 
467 bail:
469  FREE(&simple);
470  mutt_pattern_free(&pat);
471  FREE(&err.data);
472 
473  return rc;
474 }
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
Definition: string.c:871
struct Email ** emails
Array of Emails.
Definition: mailbox.h:99
bool imap_search(struct Mailbox *m, const struct PatternList *pat)
Find messages in mailbox matching a pattern.
Definition: search.c:228
The "current" mailbox.
Definition: context.h:38
enum MailboxType type
Mailbox type.
Definition: mailbox.h:105
#define NONULL(x)
Definition: string2.h:37
int msg_count
Total number of messages.
Definition: mailbox.h:91
#define mutt_set_flag(m, e, flag, bf)
Definition: protos.h:67
The envelope/body of an email.
Definition: email.h:37
#define MUTT_CLEAR
Clear input if printable character is pressed.
Definition: mutt.h:62
struct Buffer * mutt_buffer_pool_get(void)
Get a Buffer from the pool.
Definition: pool.c:101
struct Email * mutt_get_virt_email(struct Mailbox *m, int vnum)
Get a virtual Email.
Definition: context.c:396
struct Body * body
List of MIME parts.
Definition: email.h:91
struct Mailbox * ctx_mailbox(struct Context *ctx)
wrapper to get the mailbox in a Context, or NULL
Definition: context.c:428
char * mutt_buffer_strdup(const struct Buffer *buf)
Copy a Buffer&#39;s string.
Definition: buffer.c:432
#define mutt_message(...)
Definition: logging.h:83
void mutt_check_simple(struct Buffer *buf, const char *simple)
Convert a simple search into a real request.
Definition: pattern.c:111
Messages in limited view.
Definition: mutt.h:105
void mutt_buffer_pool_release(struct Buffer **pbuf)
Free a Buffer from the pool.
Definition: pool.c:112
String manipulation buffer.
Definition: buffer.h:33
Messages to be un-deleted.
Definition: mutt.h:99
LOFF_T offset
offset where the actual data begins
Definition: body.h:44
#define _(a)
Definition: message.h:28
struct PatternList * mutt_pattern_comp(const char *s, PatternCompFlags flags, struct Buffer *err)
Create a Pattern.
Definition: compile.c:1063
Messages to be purged (bypass trash)
Definition: mutt.h:100
A progress bar.
Definition: progress.h:50
#define MUTT_PATTERN
Pattern mode - only used for history classes.
Definition: mutt.h:64
int vcount
The number of virtual messages.
Definition: mailbox.h:102
The body of an email.
Definition: body.h:34
void mutt_progress_update(struct Progress *progress, size_t pos, int percent)
Update the state of the progress bar.
Definition: progress.c:212
Progress tracks elements, according to $read_inc
Definition: progress.h:42
void mutt_clear_error(void)
Clear the message line (bottom line of screen)
Definition: mutt_logging.c:113
off_t vsize
Size (in bytes) of the messages shown.
Definition: context.h:40
bool visible
Is this message part of the view?
Definition: email.h:74
#define SLIST_FIRST(head)
Definition: queue.h:228
LOFF_T length
length (in bytes) of attachment
Definition: body.h:45
Messages to be deleted.
Definition: mutt.h:98
A mailbox.
Definition: mailbox.h:81
void * mutt_mem_malloc(size_t size)
Allocate memory on the heap.
Definition: memory.c:90
size_t num_hidden
Number of hidden messages in this view (only valid when collapsed is set)
Definition: email.h:75
struct PatternList * limit_pattern
Compiled limit pattern.
Definition: context.h:42
Tagged messages.
Definition: mutt.h:103
char * data
Pointer to data.
Definition: buffer.h:35
bool collapsed
Is this message part of a collapsed thread?
Definition: email.h:73
int vnum
Virtual message number.
Definition: email.h:88
void mutt_progress_init(struct Progress *progress, const char *msg, enum ProgressType type, size_t size)
Set up a progress bar.
Definition: progress.c:153
size_t mutt_buffer_strcpy(struct Buffer *buf, const char *s)
Copy a string into a Buffer.
Definition: buffer.c:312
WHERE char * C_SimpleSearch
Config: Pattern to search for when search doesn&#39;t contain ~&#39;s.
Definition: mutt_globals.h:107
#define mutt_buffer_get_field(field, buf, complete)
Definition: curs_lib.h:85
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: exec.c:738
int * v2r
Mapping from virtual to real msgno.
Definition: mailbox.h:101
bool collapsed
Are all threads collapsed?
Definition: context.h:48
#define mutt_error(...)
Definition: logging.h:84
#define FREE(x)
Definition: memory.h:40
Messages to be un-tagged.
Definition: mutt.h:104
int mx_msg_padding_size(struct Mailbox *m)
Bytes of padding between messages - Wrapper for MxOps::msg_padding_size()
Definition: mx.c:1555
long hdr_offset
Offset in stream where the headers begin.
Definition: body.h:42
struct Buffer * mutt_buffer_init(struct Buffer *buf)
Initialise a new Buffer.
Definition: buffer.c:46
void mutt_pattern_free(struct PatternList **pat)
Free a Pattern.
Definition: compile.c:1011
#define MUTT_PC_FULL_MSG
Enable body and header matching.
Definition: lib.h:64
bool mutt_buffer_is_empty(const struct Buffer *buf)
Is the Buffer empty?
Definition: buffer.c:252
&#39;IMAP&#39; Mailbox type
Definition: mailbox.h:53
char * pattern
Limit pattern string.
Definition: context.h:41
static unsigned char * pbuf
Cache PGP data packet.
Definition: pgppacket.c:38
#define MUTT_MATCH_FULL_ADDRESS
Match the full address.
Definition: lib.h:98
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_pattern_alias_func()

int mutt_pattern_alias_func ( int  op,
char *  prompt,
char *  menu_name,
struct AliasMenuData mdata,
struct Menu menu 
)

Perform some Pattern matching for Alias.

Parameters
opOperation to perform, e.g. MUTT_LIMIT
promptPrompt to show the user
menu_nameName of the current menu, e.g. Aliases, Query
mdataMenu data holding Aliases
menuCurrent menu
Return values
0Success
-1Failure

Definition at line 238 of file pattern.c.

240 {
241  int rc = -1;
242  struct Progress progress;
243  struct Buffer *buf = mutt_buffer_pool_get();
244 
245  mutt_buffer_strcpy(buf, mdata->str);
246  if (prompt)
247  {
248  if ((mutt_buffer_get_field(prompt, buf, MUTT_PATTERN | MUTT_CLEAR) != 0) ||
250  {
252  return -1;
253  }
254  }
255 
256  mutt_message(_("Compiling search pattern..."));
257 
258  bool match_all = false;
259  struct PatternList *pat = NULL;
260  char *simple = mutt_buffer_strdup(buf);
261  if (simple)
262  {
264  const char *pbuf = buf->data;
265  while (*pbuf == ' ')
266  pbuf++;
267  match_all = mutt_str_equal(pbuf, "~A");
268 
269  struct Buffer err = mutt_buffer_make(0);
270  pat = mutt_pattern_comp(buf->data, MUTT_PC_FULL_MSG, &err);
271  if (!pat)
272  {
273  mutt_error("%s", mutt_buffer_string(&err));
274  mutt_buffer_dealloc(&err);
275  goto bail;
276  }
277  }
278  else
279  {
280  match_all = true;
281  }
282 
283  mutt_progress_init(&progress, _("Executing command on matching messages..."),
284  MUTT_PROGRESS_READ, ARRAY_SIZE(&mdata->ava));
285 
286  int vcounter = 0;
287  struct AliasView *avp = NULL;
288  ARRAY_FOREACH(avp, &mdata->ava)
289  {
290  mutt_progress_update(&progress, ARRAY_FOREACH_IDX, -1);
291 
292  if (match_all ||
294  {
295  avp->is_visible = true;
296  vcounter++;
297  }
298  else
299  {
300  avp->is_visible = false;
301  }
302  }
303 
304  mutt_str_replace(&mdata->str, simple);
305 
306  if (menu)
307  {
308  menu->max = vcounter;
309  menu->current = 0;
310 
311  FREE(&menu->title);
312 
313  if (match_all)
314  menu->title = menu_create_alias_title(menu_name, NULL);
315  else
316  menu->title = menu_create_alias_title(menu_name, simple);
317  }
318 
320 
321  rc = 0;
322 
323 bail:
325  FREE(&simple);
326  mutt_pattern_free(&pat);
327 
328  return rc;
329 }
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
Definition: string.c:871
#define MUTT_CLEAR
Clear input if printable character is pressed.
Definition: mutt.h:62
struct Buffer * mutt_buffer_pool_get(void)
Get a Buffer from the pool.
Definition: pool.c:101
char * mutt_buffer_strdup(const struct Buffer *buf)
Copy a Buffer&#39;s string.
Definition: buffer.c:432
#define mutt_message(...)
Definition: logging.h:83
char * menu_create_alias_title(char *menu_name, char *limit)
Create a title string for the Menu.
Definition: gui.c:84
void mutt_check_simple(struct Buffer *buf, const char *simple)
Convert a simple search into a real request.
Definition: pattern.c:111
#define ARRAY_FOREACH(elem, head)
Iterate over all elements of the array.
Definition: array.h:206
void mutt_buffer_pool_release(struct Buffer **pbuf)
Free a Buffer from the pool.
Definition: pool.c:112
struct Buffer mutt_buffer_make(size_t size)
Make a new buffer on the stack.
Definition: buffer.c:61
String manipulation buffer.
Definition: buffer.h:33
#define _(a)
Definition: message.h:28
struct PatternList * mutt_pattern_comp(const char *s, PatternCompFlags flags, struct Buffer *err)
Create a Pattern.
Definition: compile.c:1063
GUI data wrapping an Alias.
Definition: gui.h:36
A progress bar.
Definition: progress.h:50
#define MUTT_PATTERN
Pattern mode - only used for history classes.
Definition: mutt.h:64
static const char * mutt_buffer_string(const struct Buffer *buf)
Convert a buffer to a const char * "string".
Definition: buffer.h:77
void mutt_progress_update(struct Progress *progress, size_t pos, int percent)
Update the state of the progress bar.
Definition: progress.c:212
const char * title
Title of this menu.
Definition: mutt_menu.h:54
Progress tracks elements, according to $read_inc
Definition: progress.h:42
void mutt_buffer_dealloc(struct Buffer *buf)
Release the memory allocated by a buffer.
Definition: buffer.c:294
char * str
String representing the limit being used.
Definition: gui.h:55
void mutt_clear_error(void)
Clear the message line (bottom line of screen)
Definition: mutt_logging.c:113
bool is_visible
Is visible?
Definition: gui.h:44
#define SLIST_FIRST(head)
Definition: queue.h:228
int mutt_pattern_alias_exec(struct Pattern *pat, PatternExecFlags flags, struct AliasView *av, struct PatternCache *cache)
Match a pattern against an alias.
Definition: exec.c:1041
char * data
Pointer to data.
Definition: buffer.h:35
void mutt_progress_init(struct Progress *progress, const char *msg, enum ProgressType type, size_t size)
Set up a progress bar.
Definition: progress.c:153
size_t mutt_buffer_strcpy(struct Buffer *buf, const char *s)
Copy a string into a Buffer.
Definition: buffer.c:312
int max
Number of entries in the menu.
Definition: mutt_menu.h:57
#define mutt_buffer_get_field(field, buf, complete)
Definition: curs_lib.h:85
#define MUTT_ALIAS_SIMPLESEARCH
Definition: lib.h:57
char * mutt_str_replace(char **p, const char *s)
Replace one string with another.
Definition: string.c:446
#define mutt_error(...)
Definition: logging.h:84
#define FREE(x)
Definition: memory.h:40
struct AliasViewArray ava
Array of AliasView.
Definition: gui.h:57
void mutt_pattern_free(struct PatternList **pat)
Free a Pattern.
Definition: compile.c:1011
int current
Current entry.
Definition: mutt_menu.h:56
#define MUTT_PC_FULL_MSG
Enable body and header matching.
Definition: lib.h:64
bool mutt_buffer_is_empty(const struct Buffer *buf)
Is the Buffer empty?
Definition: buffer.c:252
static unsigned char * pbuf
Cache PGP data packet.
Definition: pgppacket.c:38
#define MUTT_MATCH_FULL_ADDRESS
Match the full address.
Definition: lib.h:98
#define ARRAY_SIZE(head)
The number of elements stored.
Definition: array.h:83
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_search_command()

int mutt_search_command ( struct Mailbox m,
int  cur,
int  op 
)

Perform a search.

Parameters
mMailbox to search through
curIndex number of current email
opOperation to perform, e.g. OP_SEARCH_NEXT
Return values
>=0 Index of matching email
-1No match, or error

Definition at line 484 of file pattern.c.

485 {
486  struct Progress progress;
487 
488  if ((*LastSearch == '\0') || ((op != OP_SEARCH_NEXT) && (op != OP_SEARCH_OPPOSITE)))
489  {
490  char buf[256];
491  mutt_str_copy(buf, (LastSearch[0] != '\0') ? LastSearch : "", sizeof(buf));
492  if ((mutt_get_field(((op == OP_SEARCH) || (op == OP_SEARCH_NEXT)) ?
493  _("Search for: ") :
494  _("Reverse search for: "),
495  buf, sizeof(buf), MUTT_CLEAR | MUTT_PATTERN) != 0) ||
496  (buf[0] == '\0'))
497  {
498  return -1;
499  }
500 
501  if ((op == OP_SEARCH) || (op == OP_SEARCH_NEXT))
502  OptSearchReverse = false;
503  else
504  OptSearchReverse = true;
505 
506  /* compare the *expanded* version of the search pattern in case
507  * $simple_search has changed while we were searching */
508  struct Buffer *tmp = mutt_buffer_pool_get();
509  mutt_buffer_strcpy(tmp, buf);
511 
513  {
514  struct Buffer err;
515  mutt_buffer_init(&err);
516  OptSearchInvalid = true;
517  mutt_str_copy(LastSearch, buf, sizeof(LastSearch));
519  mutt_message(_("Compiling search pattern..."));
521  err.dsize = 256;
522  err.data = mutt_mem_malloc(err.dsize);
524  if (!SearchPattern)
525  {
527  mutt_error("%s", err.data);
528  FREE(&err.data);
529  LastSearch[0] = '\0';
530  LastSearchExpn[0] = '\0';
531  return -1;
532  }
533  FREE(&err.data);
535  }
536 
538  }
539 
540  if (OptSearchInvalid)
541  {
542  for (int i = 0; i < m->msg_count; i++)
543  m->emails[i]->searched = false;
544 #ifdef USE_IMAP
545  if ((m->type == MUTT_IMAP) && (!imap_search(m, SearchPattern)))
546  return -1;
547 #endif
548  OptSearchInvalid = false;
549  }
550 
551  int incr = OptSearchReverse ? -1 : 1;
552  if (op == OP_SEARCH_OPPOSITE)
553  incr = -incr;
554 
555  mutt_progress_init(&progress, _("Searching..."), MUTT_PROGRESS_READ, m->vcount);
556 
557  for (int i = cur + incr, j = 0; j != m->vcount; j++)
558  {
559  const char *msg = NULL;
560  mutt_progress_update(&progress, j, -1);
561  if (i > m->vcount - 1)
562  {
563  i = 0;
564  if (C_WrapSearch)
565  msg = _("Search wrapped to top");
566  else
567  {
568  mutt_message(_("Search hit bottom without finding match"));
569  return -1;
570  }
571  }
572  else if (i < 0)
573  {
574  i = m->vcount - 1;
575  if (C_WrapSearch)
576  msg = _("Search wrapped to bottom");
577  else
578  {
579  mutt_message(_("Search hit top without finding match"));
580  return -1;
581  }
582  }
583 
584  struct Email *e = mutt_get_virt_email(m, i);
585  if (e->searched)
586  {
587  /* if we've already evaluated this message, use the cached value */
588  if (e->matched)
589  {
591  if (msg && *msg)
592  mutt_message(msg);
593  return i;
594  }
595  }
596  else
597  {
598  /* remember that we've already searched this message */
599  e->searched = true;
601  MUTT_MATCH_FULL_ADDRESS, m, e, NULL);
602  if (e->matched > 0)
603  {
605  if (msg && *msg)
606  mutt_message(msg);
607  return i;
608  }
609  }
610 
611  if (SigInt)
612  {
613  mutt_error(_("Search interrupted"));
614  SigInt = 0;
615  return -1;
616  }
617 
618  i += incr;
619  }
620 
621  mutt_error(_("Not found"));
622  return -1;
623 }
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
Definition: string.c:871
struct Email ** emails
Array of Emails.
Definition: mailbox.h:99
bool imap_search(struct Mailbox *m, const struct PatternList *pat)
Find messages in mailbox matching a pattern.
Definition: search.c:228
enum MailboxType type
Mailbox type.
Definition: mailbox.h:105
#define NONULL(x)
Definition: string2.h:37
int msg_count
Total number of messages.
Definition: mailbox.h:91
The envelope/body of an email.
Definition: email.h:37
#define MUTT_CLEAR
Clear input if printable character is pressed.
Definition: mutt.h:62
struct Buffer * mutt_buffer_pool_get(void)
Get a Buffer from the pool.
Definition: pool.c:101
struct Email * mutt_get_virt_email(struct Mailbox *m, int vnum)
Get a virtual Email.
Definition: context.c:396
#define mutt_message(...)
Definition: logging.h:83
WHERE SIG_ATOMIC_VOLATILE_T SigInt
true after SIGINT is received
Definition: mutt_globals.h:74
void mutt_check_simple(struct Buffer *buf, const char *simple)
Convert a simple search into a real request.
Definition: pattern.c:111
void mutt_buffer_pool_release(struct Buffer **pbuf)
Free a Buffer from the pool.
Definition: pool.c:112
String manipulation buffer.
Definition: buffer.h:33
#define _(a)
Definition: message.h:28
static char LastSearch[256]
last pattern searched for
Definition: pattern.c:85
struct PatternList * mutt_pattern_comp(const char *s, PatternCompFlags flags, struct Buffer *err)
Create a Pattern.
Definition: compile.c:1063
bool searched
Email has been searched.
Definition: email.h:67
A progress bar.
Definition: progress.h:50
#define MUTT_PATTERN
Pattern mode - only used for history classes.
Definition: mutt.h:64
#define mutt_get_field(field, buf, buflen, complete)
Definition: curs_lib.h:91
int vcount
The number of virtual messages.
Definition: mailbox.h:102
static const char * mutt_buffer_string(const struct Buffer *buf)
Convert a buffer to a const char * "string".
Definition: buffer.h:77
void mutt_progress_update(struct Progress *progress, size_t pos, int percent)
Update the state of the progress bar.
Definition: progress.c:212
Progress tracks elements, according to $read_inc
Definition: progress.h:42
void mutt_clear_error(void)
Clear the message line (bottom line of screen)
Definition: mutt_logging.c:113
static char LastSearchExpn[1024]
expanded version of LastSearch
Definition: pattern.c:86
#define SLIST_FIRST(head)
Definition: queue.h:228
void * mutt_mem_malloc(size_t size)
Allocate memory on the heap.
Definition: memory.c:90
char * data
Pointer to data.
Definition: buffer.h:35
WHERE bool OptSearchInvalid
(pseudo) used to invalidate the search pattern
Definition: options.h:52
void mutt_progress_init(struct Progress *progress, const char *msg, enum ProgressType type, size_t size)
Set up a progress bar.
Definition: progress.c:153
WHERE bool C_WrapSearch
Config: Wrap around when the search hits the end.
Definition: mutt_globals.h:170
size_t mutt_buffer_strcpy(struct Buffer *buf, const char *s)
Copy a string into a Buffer.
Definition: buffer.c:312
WHERE char * C_SimpleSearch
Config: Pattern to search for when search doesn&#39;t contain ~&#39;s.
Definition: mutt_globals.h:107
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: exec.c:738
static struct PatternList * SearchPattern
current search pattern
Definition: pattern.c:84
size_t mutt_str_copy(char *dest, const char *src, size_t dsize)
Copy a string into a buffer (guaranteeing NUL-termination)
Definition: string.c:716
#define mutt_error(...)
Definition: logging.h:84
#define FREE(x)
Definition: memory.h:40
struct Buffer * mutt_buffer_init(struct Buffer *buf)
Initialise a new Buffer.
Definition: buffer.c:46
void mutt_pattern_free(struct PatternList **pat)
Free a Pattern.
Definition: compile.c:1011
#define MUTT_PC_FULL_MSG
Enable body and header matching.
Definition: lib.h:64
&#39;IMAP&#39; Mailbox type
Definition: mailbox.h:53
#define MUTT_MATCH_FULL_ADDRESS
Match the full address.
Definition: lib.h:98
WHERE bool OptSearchReverse
(pseudo) used by ci_search_command
Definition: options.h:53
bool matched
Search matches this Email.
Definition: email.h:68
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_search_alias_command()

int mutt_search_alias_command ( struct Menu menu,
int  cur,
int  op 
)

Perform a search.

Parameters
menuMenu to search through
curIndex number of current alias
opOperation to perform, e.g. OP_SEARCH_NEXT
Return values
>=0Index of matching alias
-1No match, or error

Definition at line 633 of file pattern.c.

634 {
635  struct Progress progress;
636 
637  struct AliasViewArray *ava = &((struct AliasMenuData *) menu->mdata)->ava;
638 
639  if ((*LastSearch == '\0') || ((op != OP_SEARCH_NEXT) && (op != OP_SEARCH_OPPOSITE)))
640  {
641  char buf[256];
642  mutt_str_copy(buf, (LastSearch[0] != '\0') ? LastSearch : "", sizeof(buf));
643  if ((mutt_get_field(((op == OP_SEARCH) || (op == OP_SEARCH_NEXT)) ?
644  _("Search for: ") :
645  _("Reverse search for: "),
646  buf, sizeof(buf), MUTT_CLEAR | MUTT_PATTERN) != 0) ||
647  (buf[0] == '\0'))
648  {
649  return -1;
650  }
651 
652  if ((op == OP_SEARCH) || (op == OP_SEARCH_NEXT))
653  OptSearchReverse = false;
654  else
655  OptSearchReverse = true;
656 
657  /* compare the *expanded* version of the search pattern in case
658  * $simple_search has changed while we were searching */
659  struct Buffer *tmp = mutt_buffer_pool_get();
660  mutt_buffer_strcpy(tmp, buf);
662 
664  {
665  struct Buffer err;
666  mutt_buffer_init(&err);
667  OptSearchInvalid = true;
668  mutt_str_copy(LastSearch, buf, sizeof(LastSearch));
670  mutt_message(_("Compiling search pattern..."));
672  err.dsize = 256;
673  err.data = mutt_mem_malloc(err.dsize);
675  if (!SearchPattern)
676  {
678  mutt_error("%s", err.data);
679  FREE(&err.data);
680  LastSearch[0] = '\0';
681  LastSearchExpn[0] = '\0';
682  return -1;
683  }
684  FREE(&err.data);
686  }
687 
689  }
690 
691  if (OptSearchInvalid)
692  {
693  struct AliasView *av = NULL;
694  ARRAY_FOREACH(av, ava)
695  {
696  av->is_searched = false;
697  }
698 
699  OptSearchInvalid = false;
700  }
701 
702  int incr = OptSearchReverse ? -1 : 1;
703  if (op == OP_SEARCH_OPPOSITE)
704  incr = -incr;
705 
706  mutt_progress_init(&progress, _("Searching..."), MUTT_PROGRESS_READ, ARRAY_SIZE(ava));
707 
708  for (int i = cur + incr, j = 0; j != ARRAY_SIZE(ava); j++)
709  {
710  const char *msg = NULL;
711  mutt_progress_update(&progress, j, -1);
712  if (i > ARRAY_SIZE(ava) - 1)
713  {
714  i = 0;
715  if (C_WrapSearch)
716  msg = _("Search wrapped to top");
717  else
718  {
719  mutt_message(_("Search hit bottom without finding match"));
720  return -1;
721  }
722  }
723  else if (i < 0)
724  {
725  i = ARRAY_SIZE(ava) - 1;
726  if (C_WrapSearch)
727  msg = _("Search wrapped to bottom");
728  else
729  {
730  mutt_message(_("Search hit top without finding match"));
731  return -1;
732  }
733  }
734 
735  struct AliasView *av = ARRAY_GET(ava, i);
736  if (av->is_searched)
737  {
738  /* if we've already evaluated this message, use the cached value */
739  if (av->is_matched)
740  {
742  if (msg && *msg)
743  mutt_message(msg);
744  return i;
745  }
746  }
747  else
748  {
749  /* remember that we've already searched this message */
750  av->is_searched = true;
752  MUTT_MATCH_FULL_ADDRESS, av, NULL);
753  if (av->is_matched > 0)
754  {
756  if (msg && *msg)
757  mutt_message(msg);
758  return i;
759  }
760  }
761 
762  if (SigInt)
763  {
764  mutt_error(_("Search interrupted"));
765  SigInt = 0;
766  return -1;
767  }
768 
769  i += incr;
770  }
771 
772  mutt_error(_("Not found"));
773  return -1;
774 }
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
Definition: string.c:871
#define MUTT_CLEAR
Clear input if printable character is pressed.
Definition: mutt.h:62
struct Buffer * mutt_buffer_pool_get(void)
Get a Buffer from the pool.
Definition: pool.c:101
#define mutt_message(...)
Definition: logging.h:83
WHERE SIG_ATOMIC_VOLATILE_T SigInt
true after SIGINT is received
Definition: mutt_globals.h:74
AliasMenuData - AliasView array wrapper with Pattern information.
Definition: gui.h:53
void mutt_check_simple(struct Buffer *buf, const char *simple)
Convert a simple search into a real request.
Definition: pattern.c:111
#define ARRAY_FOREACH(elem, head)
Iterate over all elements of the array.
Definition: array.h:206
void mutt_buffer_pool_release(struct Buffer **pbuf)
Free a Buffer from the pool.
Definition: pool.c:112
#define ARRAY_GET(head, idx)
Return the element at index.
Definition: array.h:105
String manipulation buffer.
Definition: buffer.h:33
#define _(a)
Definition: message.h:28
static char LastSearch[256]
last pattern searched for
Definition: pattern.c:85
struct PatternList * mutt_pattern_comp(const char *s, PatternCompFlags flags, struct Buffer *err)
Create a Pattern.
Definition: compile.c:1063
bool is_matched
Search matches this Alias.
Definition: gui.h:41
GUI data wrapping an Alias.
Definition: gui.h:36
A progress bar.
Definition: progress.h:50
#define MUTT_PATTERN
Pattern mode - only used for history classes.
Definition: mutt.h:64
#define mutt_get_field(field, buf, buflen, complete)
Definition: curs_lib.h:91
static const char * mutt_buffer_string(const struct Buffer *buf)
Convert a buffer to a const char * "string".
Definition: buffer.h:77
void mutt_progress_update(struct Progress *progress, size_t pos, int percent)
Update the state of the progress bar.
Definition: progress.c:212
Progress tracks elements, according to $read_inc
Definition: progress.h:42
void mutt_clear_error(void)
Clear the message line (bottom line of screen)
Definition: mutt_logging.c:113
static char LastSearchExpn[1024]
expanded version of LastSearch
Definition: pattern.c:86
void * mdata
Extra data for the current menu.
Definition: mutt_menu.h:55
#define SLIST_FIRST(head)
Definition: queue.h:228
int mutt_pattern_alias_exec(struct Pattern *pat, PatternExecFlags flags, struct AliasView *av, struct PatternCache *cache)
Match a pattern against an alias.
Definition: exec.c:1041
void * mutt_mem_malloc(size_t size)
Allocate memory on the heap.
Definition: memory.c:90
char * data
Pointer to data.
Definition: buffer.h:35
bool is_searched
Alias has been searched.
Definition: gui.h:40
WHERE bool OptSearchInvalid
(pseudo) used to invalidate the search pattern
Definition: options.h:52
void mutt_progress_init(struct Progress *progress, const char *msg, enum ProgressType type, size_t size)
Set up a progress bar.
Definition: progress.c:153
WHERE bool C_WrapSearch
Config: Wrap around when the search hits the end.
Definition: mutt_globals.h:170
size_t mutt_buffer_strcpy(struct Buffer *buf, const char *s)
Copy a string into a Buffer.
Definition: buffer.c:312
static struct PatternList * SearchPattern
current search pattern
Definition: pattern.c:84
#define MUTT_ALIAS_SIMPLESEARCH
Definition: lib.h:57
size_t mutt_str_copy(char *dest, const char *src, size_t dsize)
Copy a string into a buffer (guaranteeing NUL-termination)
Definition: string.c:716
#define mutt_error(...)
Definition: logging.h:84
#define FREE(x)
Definition: memory.h:40
struct Buffer * mutt_buffer_init(struct Buffer *buf)
Initialise a new Buffer.
Definition: buffer.c:46
void mutt_pattern_free(struct PatternList **pat)
Free a Pattern.
Definition: compile.c:1011
#define MUTT_PC_FULL_MSG
Enable body and header matching.
Definition: lib.h:64
#define MUTT_MATCH_FULL_ADDRESS
Match the full address.
Definition: lib.h:98
WHERE bool OptSearchReverse
(pseudo) used by ci_search_command
Definition: options.h:53
#define ARRAY_SIZE(head)
The number of elements stored.
Definition: array.h:83
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_limit_current_thread()

bool mutt_limit_current_thread ( struct Email e)

Limit the email view to the current thread.

Parameters
eCurrent Email
Return values
trueSuccess
falseFailure

Definition at line 189 of file pattern.c.

190 {
191  struct Mailbox *m = ctx_mailbox(Context);
192  if (!e || !m)
193  return false;
194 
195  struct MuttThread *me = top_of_thread(e);
196  if (!me)
197  return false;
198 
199  m->vcount = 0;
200  Context->vsize = 0;
201  Context->collapsed = false;
202 
203  for (int i = 0; i < m->msg_count; i++)
204  {
205  e = m->emails[i];
206  if (!e)
207  break;
208 
209  e->vnum = -1;
210  e->visible = false;
211  e->collapsed = false;
212  e->num_hidden = 0;
213 
214  if (top_of_thread(e) == me)
215  {
216  struct Body *body = e->body;
217 
218  e->vnum = m->vcount;
219  e->visible = true;
220  m->v2r[m->vcount] = i;
221  m->vcount++;
222  Context->vsize += (body->length + body->offset - body->hdr_offset);
223  }
224  }
225  return true;
226 }
struct Email ** emails
Array of Emails.
Definition: mailbox.h:99
The "current" mailbox.
Definition: context.h:38
int msg_count
Total number of messages.
Definition: mailbox.h:91
struct Body * body
List of MIME parts.
Definition: email.h:91
struct Mailbox * ctx_mailbox(struct Context *ctx)
wrapper to get the mailbox in a Context, or NULL
Definition: context.c:428
LOFF_T offset
offset where the actual data begins
Definition: body.h:44
int vcount
The number of virtual messages.
Definition: mailbox.h:102
The body of an email.
Definition: body.h:34
off_t vsize
Size (in bytes) of the messages shown.
Definition: context.h:40
bool visible
Is this message part of the view?
Definition: email.h:74
LOFF_T length
length (in bytes) of attachment
Definition: body.h:45
A mailbox.
Definition: mailbox.h:81
static struct MuttThread * top_of_thread(struct Email *e)
Find the first email in the current thread.
Definition: pattern.c:170
size_t num_hidden
Number of hidden messages in this view (only valid when collapsed is set)
Definition: email.h:75
bool collapsed
Is this message part of a collapsed thread?
Definition: email.h:73
int vnum
Virtual message number.
Definition: email.h:88
An Email conversation.
Definition: thread.h:34
int * v2r
Mapping from virtual to real msgno.
Definition: mailbox.h:101
bool collapsed
Are all threads collapsed?
Definition: context.h:48
long hdr_offset
Offset in stream where the headers begin.
Definition: body.h:42
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ config_init_pattern()

bool config_init_pattern ( struct ConfigSet cs)

Register pattern config variables - Implements module_init_config_t.

Definition at line 59 of file config.c.

60 {
61  return cs_register_variables(cs, PatternVars, 0);
62 }
bool cs_register_variables(const struct ConfigSet *cs, struct ConfigDef vars[], uint32_t flags)
Register a set of config items.
Definition: set.c:286
struct ConfigDef PatternVars[]
Definition: config.c:41
+ Here is the call graph for this function:

Variable Documentation

◆ C_ThoroughSearch

bool C_ThoroughSearch

Config: Decode headers and messages before searching them.

Definition at line 38 of file config.c.