NeoMutt  2021-02-05-89-gabe350
Teaching an old dog new tricks
DOXYGEN
lib.h File Reference
#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 (struct Context *ctx, 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 (struct Context *ctx, int op, char *prompt)
 Perform some Pattern matching. More...
 
int mutt_pattern_alias_func (int op, char *prompt, char *title, struct AliasMenuData *mdata, struct Context *ctx, struct Menu *menu)
 Perform some Pattern matching for Alias. More...
 
int mutt_search_command (struct Context *ctx, struct Mailbox *m, int cur, int op)
 Perform a search. More...
 
int mutt_search_alias_command (struct Context *ctx, struct Menu *menu, int cur, int op)
 Perform a search. More...
 
bool mutt_limit_current_thread (struct Context *ctx, struct Email *e)
 Limit the email view to the current thread. 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 58 of file lib.h.

◆ MUTT_PC_NO_FLAGS

#define MUTT_PC_NO_FLAGS   0

No flags are set.

Definition at line 64 of file lib.h.

◆ MUTT_PC_FULL_MSG

#define MUTT_PC_FULL_MSG   (1<<0)

Enable body and header matching.

Definition at line 65 of file lib.h.

◆ MUTT_PC_PATTERN_DYNAMIC

#define MUTT_PC_PATTERN_DYNAMIC   (1<<1)

Enable runtime date range evaluation.

Definition at line 66 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 67 of file lib.h.

◆ MUTT_PAT_EXEC_NO_FLAGS

#define MUTT_PAT_EXEC_NO_FLAGS   0

No flags are set.

Definition at line 98 of file lib.h.

◆ MUTT_MATCH_FULL_ADDRESS

#define MUTT_MATCH_FULL_ADDRESS   (1 << 0)

Match the full address.

Definition at line 99 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 63 of file lib.h.

◆ PatternExecFlags

typedef uint8_t PatternExecFlags

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

Definition at line 97 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 128 of file lib.h.

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 ^
831  match_addrlist(pat, (flags & MUTT_MATCH_FULL_ADDRESS), 1, &e->env->from);
832  case MUTT_PAT_TO:
833  if (!e->env)
834  return 0;
835  return pat->pat_not ^
836  match_addrlist(pat, (flags & MUTT_MATCH_FULL_ADDRESS), 1, &e->env->to);
837  case MUTT_PAT_CC:
838  if (!e->env)
839  return 0;
840  return pat->pat_not ^
841  match_addrlist(pat, (flags & MUTT_MATCH_FULL_ADDRESS), 1, &e->env->cc);
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 }
+ 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 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_pattern_comp()

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

Create a Pattern.

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

Definition at line 1082 of file compile.c.

1084 {
1085  /* curlist when assigned will always point to a list containing at least one node
1086  * with a Pattern value. */
1087  struct PatternList *curlist = NULL;
1088  struct PatternList *tmp = NULL, *tmp2 = NULL;
1089  struct PatternList *last = NULL;
1090  bool pat_not = false;
1091  bool all_addr = false;
1092  bool pat_or = false;
1093  bool implicit = true; /* used to detect logical AND operator */
1094  bool is_alias = false;
1095  short thread_op;
1096  const struct PatternFlags *entry = NULL;
1097  char *p = NULL;
1098  char *buf = NULL;
1099  struct Buffer ps;
1100 
1101  if (!s || !*s)
1102  {
1103  mutt_buffer_strcpy(err, _("empty pattern"));
1104  return NULL;
1105  }
1106 
1107  mutt_buffer_init(&ps);
1108  ps.dptr = (char *) s;
1109  ps.dsize = mutt_str_len(s);
1110 
1111  while (*ps.dptr)
1112  {
1113  SKIPWS(ps.dptr);
1114  switch (*ps.dptr)
1115  {
1116  case '^':
1117  ps.dptr++;
1118  all_addr = !all_addr;
1119  break;
1120  case '!':
1121  ps.dptr++;
1122  pat_not = !pat_not;
1123  break;
1124  case '@':
1125  ps.dptr++;
1126  is_alias = !is_alias;
1127  break;
1128  case '|':
1129  if (!pat_or)
1130  {
1131  if (!curlist)
1132  {
1133  mutt_buffer_printf(err, _("error in pattern at: %s"), ps.dptr);
1134  return NULL;
1135  }
1136 
1137  struct Pattern *pat = SLIST_FIRST(curlist);
1138 
1139  if (SLIST_NEXT(pat, entries))
1140  {
1141  /* A & B | C == (A & B) | C */
1142  tmp = mutt_pattern_node_new();
1143  pat = SLIST_FIRST(tmp);
1144  pat->op = MUTT_PAT_AND;
1145  pat->child = curlist;
1146 
1147  curlist = tmp;
1148  last = curlist;
1149  }
1150 
1151  pat_or = true;
1152  }
1153  ps.dptr++;
1154  implicit = false;
1155  pat_not = false;
1156  all_addr = false;
1157  is_alias = false;
1158  break;
1159  case '%':
1160  case '=':
1161  case '~':
1162  {
1163  struct Pattern *pat = NULL;
1164  if (ps.dptr[1] == '\0')
1165  {
1166  mutt_buffer_printf(err, _("missing pattern: %s"), ps.dptr);
1167  goto cleanup;
1168  }
1169  thread_op = 0;
1170  if (ps.dptr[1] == '(')
1171  thread_op = MUTT_PAT_THREAD;
1172  else if ((ps.dptr[1] == '<') && (ps.dptr[2] == '('))
1173  thread_op = MUTT_PAT_PARENT;
1174  else if ((ps.dptr[1] == '>') && (ps.dptr[2] == '('))
1175  thread_op = MUTT_PAT_CHILDREN;
1176  if (thread_op)
1177  {
1178  ps.dptr++; /* skip ~ */
1179  if ((thread_op == MUTT_PAT_PARENT) || (thread_op == MUTT_PAT_CHILDREN))
1180  ps.dptr++;
1181  p = find_matching_paren(ps.dptr + 1);
1182  if (p[0] != ')')
1183  {
1184  mutt_buffer_printf(err, _("mismatched parentheses: %s"), ps.dptr);
1185  goto cleanup;
1186  }
1187  tmp = mutt_pattern_node_new();
1188  pat = SLIST_FIRST(tmp);
1189  pat->op = thread_op;
1190  if (last)
1191  SLIST_NEXT(SLIST_FIRST(last), entries) = pat;
1192  else
1193  curlist = tmp;
1194  last = tmp;
1195  pat->pat_not ^= pat_not;
1196  pat->all_addr |= all_addr;
1197  pat->is_alias |= is_alias;
1198  pat_not = false;
1199  all_addr = false;
1200  is_alias = false;
1201  /* compile the sub-expression */
1202  buf = mutt_strn_dup(ps.dptr + 1, p - (ps.dptr + 1));
1203  tmp2 = mutt_pattern_comp(ctx, buf, flags, err);
1204  if (!tmp2)
1205  {
1206  FREE(&buf);
1207  goto cleanup;
1208  }
1209  FREE(&buf);
1210  pat->child = tmp2;
1211  ps.dptr = p + 1; /* restore location */
1212  break;
1213  }
1214  if (implicit && pat_or)
1215  {
1216  /* A | B & C == (A | B) & C */
1217  tmp = mutt_pattern_node_new();
1218  pat = SLIST_FIRST(tmp);
1219  pat->op = MUTT_PAT_OR;
1220  pat->child = curlist;
1221  curlist = tmp;
1222  last = tmp;
1223  pat_or = false;
1224  }
1225 
1226  tmp = mutt_pattern_node_new();
1227  pat = SLIST_FIRST(tmp);
1228  pat->pat_not = pat_not;
1229  pat->all_addr = all_addr;
1230  pat->is_alias = is_alias;
1231  pat->string_match = (ps.dptr[0] == '=');
1232  pat->group_match = (ps.dptr[0] == '%');
1233  pat_not = false;
1234  all_addr = false;
1235  is_alias = false;
1236 
1237  if (last)
1238  SLIST_NEXT(SLIST_FIRST(last), entries) = pat;
1239  else
1240  curlist = tmp;
1241  if (curlist != last)
1242  FREE(&last);
1243  last = tmp;
1244 
1245  ps.dptr++; /* move past the ~ */
1246  entry = lookup_tag(*ps.dptr);
1247  if (!entry)
1248  {
1249  mutt_buffer_printf(err, _("%c: invalid pattern modifier"), *ps.dptr);
1250  goto cleanup;
1251  }
1252  if (entry->flags && ((flags & entry->flags) == 0))
1253  {
1254  mutt_buffer_printf(err, _("%c: not supported in this mode"), *ps.dptr);
1255  goto cleanup;
1256  }
1257  if (flags & MUTT_PC_SEND_MODE_SEARCH)
1258  pat->sendmode = true;
1259 
1260  pat->op = entry->op;
1261 
1262  ps.dptr++; /* eat the operator and any optional whitespace */
1263  SKIPWS(ps.dptr);
1264 
1265  if (entry->eat_arg)
1266  {
1267  if (ps.dptr[0] == '\0')
1268  {
1269  mutt_buffer_printf(err, "%s", _("missing parameter"));
1270  goto cleanup;
1271  }
1272  switch (entry->eat_arg)
1273  {
1274  case EAT_REGEX:
1275  if (!eat_regex(pat, flags, &ps, err))
1276  goto cleanup;
1277  break;
1278  case EAT_DATE:
1279  if (!eat_date(pat, flags, &ps, err))
1280  goto cleanup;
1281  break;
1282  case EAT_RANGE:
1283  if (!eat_range(pat, flags, &ps, err))
1284  goto cleanup;
1285  break;
1286  case EAT_MESSAGE_RANGE:
1287  if (!eat_message_range(pat, flags, &ps, err, ctx))
1288  goto cleanup;
1289  break;
1290  case EAT_QUERY:
1291  if (!eat_query(pat, flags, &ps, err, ctx))
1292  goto cleanup;
1293  break;
1294  default:
1295  break;
1296  }
1297  }
1298  implicit = true;
1299  break;
1300  }
1301 
1302  case '(':
1303  {
1304  p = find_matching_paren(ps.dptr + 1);
1305  if (p[0] != ')')
1306  {
1307  mutt_buffer_printf(err, _("mismatched parentheses: %s"), ps.dptr);
1308  goto cleanup;
1309  }
1310  /* compile the sub-expression */
1311  buf = mutt_strn_dup(ps.dptr + 1, p - (ps.dptr + 1));
1312  tmp = mutt_pattern_comp(ctx, buf, flags, err);
1313  FREE(&buf);
1314  if (!tmp)
1315  goto cleanup;
1316  struct Pattern *pat = SLIST_FIRST(tmp);
1317  if (last)
1318  SLIST_NEXT(SLIST_FIRST(last), entries) = pat;
1319  else
1320  curlist = tmp;
1321  last = tmp;
1322  pat = SLIST_FIRST(tmp);
1323  pat->pat_not ^= pat_not;
1324  pat->all_addr |= all_addr;
1325  pat->is_alias |= is_alias;
1326  pat_not = false;
1327  all_addr = false;
1328  is_alias = false;
1329  ps.dptr = p + 1; /* restore location */
1330  break;
1331  }
1332 
1333  default:
1334  mutt_buffer_printf(err, _("error in pattern at: %s"), ps.dptr);
1335  goto cleanup;
1336  }
1337  }
1338  if (!curlist)
1339  {
1340  mutt_buffer_strcpy(err, _("empty pattern"));
1341  return NULL;
1342  }
1343  if (curlist != tmp)
1344  FREE(&tmp);
1345  if (SLIST_NEXT(SLIST_FIRST(curlist), entries))
1346  {
1347  tmp = mutt_pattern_node_new();
1348  struct Pattern *pat = SLIST_FIRST(tmp);
1349  pat->op = pat_or ? MUTT_PAT_OR : MUTT_PAT_AND;
1350  pat->child = curlist;
1351  curlist = tmp;
1352  }
1353 
1354  return curlist;
1355 
1356 cleanup:
1357  mutt_pattern_free(&curlist);
1358  return NULL;
1359 }
+ 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 }
+ 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 1029 of file compile.c.

1030 {
1031  if (!pat || !*pat)
1032  return;
1033 
1034  struct Pattern *np = SLIST_FIRST(*pat), *next = NULL;
1035 
1036  while (np)
1037  {
1038  next = SLIST_NEXT(np, entries);
1039 
1040  if (np->is_multi)
1042  else if (np->string_match || np->dynamic)
1043  FREE(&np->p.str);
1044  else if (np->group_match)
1045  np->p.group = NULL;
1046  else if (np->p.regex)
1047  {
1048  regfree(np->p.regex);
1049  FREE(&np->p.regex);
1050  }
1051 
1052  mutt_pattern_free(&np->child);
1053  FREE(&np);
1054 
1055  np = next;
1056  }
1057 
1058  FREE(pat);
1059 }
+ 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 }
+ 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 }
+ 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 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_pattern_func()

int mutt_pattern_func ( struct Context ctx,
int  op,
char *  prompt 
)

Perform some Pattern matching.

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

Definition at line 344 of file pattern.c.

345 {
346  if (!ctx || !ctx->mailbox)
347  return -1;
348 
349  struct Mailbox *m = ctx->mailbox;
350 
351  struct Buffer err;
352  int rc = -1;
353  struct Progress progress;
354  struct Buffer *buf = mutt_buffer_pool_get();
355 
356  mutt_buffer_strcpy(buf, NONULL(ctx->pattern));
357  if (prompt || (op != MUTT_LIMIT))
358  {
359  if ((mutt_buffer_get_field(prompt, buf, MUTT_PATTERN | MUTT_CLEAR, false,
360  NULL, NULL, NULL) != 0) ||
362  {
364  return -1;
365  }
366  }
367 
368  mutt_message(_("Compiling search pattern..."));
369 
370  char *simple = mutt_buffer_strdup(buf);
372  const char *pbuf = buf->data;
373  while (*pbuf == ' ')
374  pbuf++;
375  const bool match_all = mutt_str_equal(pbuf, "~A");
376 
377  mutt_buffer_init(&err);
378  err.dsize = 256;
379  err.data = mutt_mem_malloc(err.dsize);
380  struct PatternList *pat = mutt_pattern_comp(ctx, buf->data, MUTT_PC_FULL_MSG, &err);
381  if (!pat)
382  {
383  mutt_error("%s", err.data);
384  goto bail;
385  }
386 
387 #ifdef USE_IMAP
388  if ((m->type == MUTT_IMAP) && (!imap_search(m, pat)))
389  goto bail;
390 #endif
391 
392  mutt_progress_init(&progress, _("Executing command on matching messages..."),
393  MUTT_PROGRESS_READ, (op == MUTT_LIMIT) ? m->msg_count : m->vcount);
394 
395  if (op == MUTT_LIMIT)
396  {
397  m->vcount = 0;
398  ctx->vsize = 0;
399  ctx->collapsed = false;
400  int padding = mx_msg_padding_size(m);
401 
402  for (int i = 0; i < m->msg_count; i++)
403  {
404  struct Email *e = m->emails[i];
405  if (!e)
406  break;
407 
408  mutt_progress_update(&progress, i, -1);
409  /* new limit pattern implicitly uncollapses all threads */
410  e->vnum = -1;
411  e->visible = false;
412  e->collapsed = false;
413  e->num_hidden = 0;
414  if (match_all ||
416  {
417  e->vnum = m->vcount;
418  e->visible = true;
419  m->v2r[m->vcount] = i;
420  m->vcount++;
421  struct Body *b = e->body;
422  ctx->vsize += b->length + b->offset - b->hdr_offset + padding;
423  }
424  }
425  }
426  else
427  {
428  for (int i = 0; i < m->vcount; i++)
429  {
430  struct Email *e = mutt_get_virt_email(m, i);
431  if (!e)
432  continue;
433  mutt_progress_update(&progress, i, -1);
435  {
436  switch (op)
437  {
438  case MUTT_UNDELETE:
439  mutt_set_flag(m, e, MUTT_PURGE, false);
440  /* fallthrough */
441  case MUTT_DELETE:
442  mutt_set_flag(m, e, MUTT_DELETE, (op == MUTT_DELETE));
443  break;
444  case MUTT_TAG:
445  case MUTT_UNTAG:
446  mutt_set_flag(m, e, MUTT_TAG, (op == MUTT_TAG));
447  break;
448  }
449  }
450  }
451  }
452 
454 
455  if (op == MUTT_LIMIT)
456  {
457  /* drop previous limit pattern */
458  FREE(&ctx->pattern);
460 
461  if (m->msg_count && !m->vcount)
462  mutt_error(_("No messages matched criteria"));
463 
464  /* record new limit pattern, unless match all */
465  if (!match_all)
466  {
467  ctx->pattern = simple;
468  simple = NULL; /* don't clobber it */
469  ctx->limit_pattern = mutt_pattern_comp(ctx, buf->data, MUTT_PC_FULL_MSG, &err);
470  }
471  }
472 
473  rc = 0;
474 
475 bail:
477  FREE(&simple);
478  mutt_pattern_free(&pat);
479  FREE(&err.data);
480 
481  return rc;
482 }
+ 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 Context ctx,
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
ctxCurrent Mailbox
menuCurrent menu
Return values
0Success
-1Failure

Definition at line 241 of file pattern.c.

244 {
245  int rc = -1;
246  struct Progress progress;
247  struct Buffer *buf = mutt_buffer_pool_get();
248 
249  mutt_buffer_strcpy(buf, mdata->str);
250  if (prompt)
251  {
252  if ((mutt_buffer_get_field(prompt, buf, MUTT_PATTERN | MUTT_CLEAR, false,
253  NULL, NULL, NULL) != 0) ||
255  {
257  return -1;
258  }
259  }
260 
261  mutt_message(_("Compiling search pattern..."));
262 
263  bool match_all = false;
264  struct PatternList *pat = NULL;
265  char *simple = mutt_buffer_strdup(buf);
266  if (simple)
267  {
269  const char *pbuf = buf->data;
270  while (*pbuf == ' ')
271  pbuf++;
272  match_all = mutt_str_equal(pbuf, "~A");
273 
274  struct Buffer err = mutt_buffer_make(0);
275  pat = mutt_pattern_comp(ctx, buf->data, MUTT_PC_FULL_MSG, &err);
276  if (!pat)
277  {
278  mutt_error("%s", mutt_buffer_string(&err));
279  mutt_buffer_dealloc(&err);
280  goto bail;
281  }
282  }
283  else
284  {
285  match_all = true;
286  }
287 
288  mutt_progress_init(&progress, _("Executing command on matching messages..."),
289  MUTT_PROGRESS_READ, ARRAY_SIZE(&mdata->ava));
290 
291  int vcounter = 0;
292  struct AliasView *avp = NULL;
293  ARRAY_FOREACH(avp, &mdata->ava)
294  {
295  mutt_progress_update(&progress, ARRAY_FOREACH_IDX, -1);
296 
297  if (match_all ||
299  {
300  avp->is_visible = true;
301  vcounter++;
302  }
303  else
304  {
305  avp->is_visible = false;
306  }
307  }
308 
309  mutt_str_replace(&mdata->str, simple);
310 
311  if (menu)
312  {
313  menu->max = vcounter;
314  menu->current = 0;
315 
316  FREE(&menu->title);
317 
318  if (match_all)
319  menu->title = menu_create_alias_title(menu_name, NULL);
320  else
321  menu->title = menu_create_alias_title(menu_name, simple);
322  }
323 
325 
326  rc = 0;
327 
328 bail:
330  FREE(&simple);
331  mutt_pattern_free(&pat);
332 
333  return rc;
334 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_search_command()

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

Perform a search.

Parameters
ctxCurrent Mailbox
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 493 of file pattern.c.

494 {
495  struct Progress progress;
496 
497  if ((*LastSearch == '\0') || ((op != OP_SEARCH_NEXT) && (op != OP_SEARCH_OPPOSITE)))
498  {
499  char buf[256];
500  mutt_str_copy(buf, (LastSearch[0] != '\0') ? LastSearch : "", sizeof(buf));
501  if ((mutt_get_field(
502  ((op == OP_SEARCH) || (op == OP_SEARCH_NEXT)) ? _("Search for: ") : _("Reverse search for: "),
503  buf, sizeof(buf), MUTT_CLEAR | MUTT_PATTERN, false, NULL, NULL) != 0) ||
504  (buf[0] == '\0'))
505  {
506  return -1;
507  }
508 
509  if ((op == OP_SEARCH) || (op == OP_SEARCH_NEXT))
510  OptSearchReverse = false;
511  else
512  OptSearchReverse = true;
513 
514  /* compare the *expanded* version of the search pattern in case
515  * $simple_search has changed while we were searching */
516  struct Buffer *tmp = mutt_buffer_pool_get();
517  mutt_buffer_strcpy(tmp, buf);
519 
521  {
522  struct Buffer err;
523  mutt_buffer_init(&err);
524  OptSearchInvalid = true;
525  mutt_str_copy(LastSearch, buf, sizeof(LastSearch));
527  mutt_message(_("Compiling search pattern..."));
529  err.dsize = 256;
530  err.data = mutt_mem_malloc(err.dsize);
532  if (!SearchPattern)
533  {
535  mutt_error("%s", err.data);
536  FREE(&err.data);
537  LastSearch[0] = '\0';
538  LastSearchExpn[0] = '\0';
539  return -1;
540  }
541  FREE(&err.data);
543  }
544 
546  }
547 
548  if (OptSearchInvalid)
549  {
550  for (int i = 0; i < m->msg_count; i++)
551  m->emails[i]->searched = false;
552 #ifdef USE_IMAP
553  if ((m->type == MUTT_IMAP) && (!imap_search(m, SearchPattern)))
554  return -1;
555 #endif
556  OptSearchInvalid = false;
557  }
558 
559  int incr = OptSearchReverse ? -1 : 1;
560  if (op == OP_SEARCH_OPPOSITE)
561  incr = -incr;
562 
563  mutt_progress_init(&progress, _("Searching..."), MUTT_PROGRESS_READ, m->vcount);
564 
565  for (int i = cur + incr, j = 0; j != m->vcount; j++)
566  {
567  const char *msg = NULL;
568  mutt_progress_update(&progress, j, -1);
569  if (i > m->vcount - 1)
570  {
571  i = 0;
572  if (C_WrapSearch)
573  msg = _("Search wrapped to top");
574  else
575  {
576  mutt_message(_("Search hit bottom without finding match"));
577  return -1;
578  }
579  }
580  else if (i < 0)
581  {
582  i = m->vcount - 1;
583  if (C_WrapSearch)
584  msg = _("Search wrapped to bottom");
585  else
586  {
587  mutt_message(_("Search hit top without finding match"));
588  return -1;
589  }
590  }
591 
592  struct Email *e = mutt_get_virt_email(m, i);
593  if (e->searched)
594  {
595  /* if we've already evaluated this message, use the cached value */
596  if (e->matched)
597  {
599  if (msg && *msg)
600  mutt_message(msg);
601  return i;
602  }
603  }
604  else
605  {
606  /* remember that we've already searched this message */
607  e->searched = true;
609  MUTT_MATCH_FULL_ADDRESS, m, e, NULL);
610  if (e->matched > 0)
611  {
613  if (msg && *msg)
614  mutt_message(msg);
615  return i;
616  }
617  }
618 
619  if (SigInt)
620  {
621  mutt_error(_("Search interrupted"));
622  SigInt = 0;
623  return -1;
624  }
625 
626  i += incr;
627  }
628 
629  mutt_error(_("Not found"));
630  return -1;
631 }
+ 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 Context ctx,
struct Menu menu,
int  cur,
int  op 
)

Perform a search.

Parameters
ctxCurrent Mailbox
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 642 of file pattern.c.

643 {
644  struct Progress progress;
645 
646  struct AliasViewArray *ava = &((struct AliasMenuData *) menu->mdata)->ava;
647 
648  if ((*LastSearch == '\0') || ((op != OP_SEARCH_NEXT) && (op != OP_SEARCH_OPPOSITE)))
649  {
650  char buf[256];
651  mutt_str_copy(buf, (LastSearch[0] != '\0') ? LastSearch : "", sizeof(buf));
652  if ((mutt_get_field(
653  ((op == OP_SEARCH) || (op == OP_SEARCH_NEXT)) ? _("Search for: ") : _("Reverse search for: "),
654  buf, sizeof(buf), MUTT_CLEAR | MUTT_PATTERN, false, NULL, NULL) != 0) ||
655  (buf[0] == '\0'))
656  {
657  return -1;
658  }
659 
660  if ((op == OP_SEARCH) || (op == OP_SEARCH_NEXT))
661  OptSearchReverse = false;
662  else
663  OptSearchReverse = true;
664 
665  /* compare the *expanded* version of the search pattern in case
666  * $simple_search has changed while we were searching */
667  struct Buffer *tmp = mutt_buffer_pool_get();
668  mutt_buffer_strcpy(tmp, buf);
670 
672  {
673  struct Buffer err;
674  mutt_buffer_init(&err);
675  OptSearchInvalid = true;
676  mutt_str_copy(LastSearch, buf, sizeof(LastSearch));
678  mutt_message(_("Compiling search pattern..."));
680  err.dsize = 256;
681  err.data = mutt_mem_malloc(err.dsize);
683  if (!SearchPattern)
684  {
686  mutt_error("%s", err.data);
687  FREE(&err.data);
688  LastSearch[0] = '\0';
689  LastSearchExpn[0] = '\0';
690  return -1;
691  }
692  FREE(&err.data);
694  }
695 
697  }
698 
699  if (OptSearchInvalid)
700  {
701  struct AliasView *av = NULL;
702  ARRAY_FOREACH(av, ava)
703  {
704  av->is_searched = false;
705  }
706 
707  OptSearchInvalid = false;
708  }
709 
710  int incr = OptSearchReverse ? -1 : 1;
711  if (op == OP_SEARCH_OPPOSITE)
712  incr = -incr;
713 
714  mutt_progress_init(&progress, _("Searching..."), MUTT_PROGRESS_READ, ARRAY_SIZE(ava));
715 
716  for (int i = cur + incr, j = 0; j != ARRAY_SIZE(ava); j++)
717  {
718  const char *msg = NULL;
719  mutt_progress_update(&progress, j, -1);
720  if (i > ARRAY_SIZE(ava) - 1)
721  {
722  i = 0;
723  if (C_WrapSearch)
724  msg = _("Search wrapped to top");
725  else
726  {
727  mutt_message(_("Search hit bottom without finding match"));
728  return -1;
729  }
730  }
731  else if (i < 0)
732  {
733  i = ARRAY_SIZE(ava) - 1;
734  if (C_WrapSearch)
735  msg = _("Search wrapped to bottom");
736  else
737  {
738  mutt_message(_("Search hit top without finding match"));
739  return -1;
740  }
741  }
742 
743  struct AliasView *av = ARRAY_GET(ava, i);
744  if (av->is_searched)
745  {
746  /* if we've already evaluated this message, use the cached value */
747  if (av->is_matched)
748  {
750  if (msg && *msg)
751  mutt_message(msg);
752  return i;
753  }
754  }
755  else
756  {
757  /* remember that we've already searched this message */
758  av->is_searched = true;
760  MUTT_MATCH_FULL_ADDRESS, av, NULL);
761  if (av->is_matched > 0)
762  {
764  if (msg && *msg)
765  mutt_message(msg);
766  return i;
767  }
768  }
769 
770  if (SigInt)
771  {
772  mutt_error(_("Search interrupted"));
773  SigInt = 0;
774  return -1;
775  }
776 
777  i += incr;
778  }
779 
780  mutt_error(_("Not found"));
781  return -1;
782 }
+ 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 Context ctx,
struct Email e 
)

Limit the email view to the current thread.

Parameters
ctxCurrent Mailbox
eCurrent Email
Return values
trueSuccess
falseFailure

Definition at line 190 of file pattern.c.

191 {
192  if (!ctx || !ctx->mailbox || !e)
193  return false;
194 
195  struct Mailbox *m = ctx->mailbox;
196 
197  struct MuttThread *me = top_of_thread(e);
198  if (!me)
199  return false;
200 
201  m->vcount = 0;
202  ctx->vsize = 0;
203  ctx->collapsed = false;
204 
205  for (int i = 0; i < m->msg_count; i++)
206  {
207  e = m->emails[i];
208  if (!e)
209  break;
210 
211  e->vnum = -1;
212  e->visible = false;
213  e->collapsed = false;
214  e->num_hidden = 0;
215 
216  if (top_of_thread(e) == me)
217  {
218  struct Body *body = e->body;
219 
220  e->vnum = m->vcount;
221  e->visible = true;
222  m->v2r[m->vcount] = i;
223  m->vcount++;
224  ctx->vsize += (body->length + body->offset - body->hdr_offset);
225  }
226  }
227  return true;
228 }
+ Here is the call graph for this function:
+ Here is the caller 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.

MUTT_PAT_PARENT
@ MUTT_PAT_PARENT
Pattern matches parent.
Definition: lib.h:133
match_threadchildren
static int match_threadchildren(struct PatternList *pat, PatternExecFlags flags, struct Mailbox *m, struct MuttThread *t)
Match Pattern against an email's children.
Definition: exec.c:547
Body::hdr_offset
long hdr_offset
Offset in stream where the headers begin.
Definition: body.h:42
MUTT_PAT_CRYPT_ENCRYPT
@ MUTT_PAT_CRYPT_ENCRYPT
Message is encrypted.
Definition: lib.h:164
patmatch
static bool patmatch(const struct Pattern *pat, const char *buf)
Compare a string to a Pattern.
Definition: exec.c:65
MENU_GENERIC
@ MENU_GENERIC
Generic selection list.
Definition: keymap.h:79
mutt_get_virt_email
struct Email * mutt_get_virt_email(struct Mailbox *m, int vnum)
Get a virtual Email.
Definition: context.c:397
create_pattern_menu
static struct Menu * create_pattern_menu(void)
Create the Pattern Completion menu.
Definition: dlgpattern.c:122
Email::date_sent
time_t date_sent
Time when the message was sent (UTC)
Definition: email.h:82
Email::msgno
int msgno
Number displayed to the user.
Definition: email.h:87
Envelope::subject
char * subject
Email's subject.
Definition: envelope.h:66
mutt_pattern_comp
struct PatternList * mutt_pattern_comp(struct Context *ctx, const char *s, PatternCompFlags flags, struct Buffer *err)
Create a Pattern.
Definition: compile.c:1082
MUTT_PAT_DATE
@ MUTT_PAT_DATE
Pattern matches 'Date:' field.
Definition: lib.h:140
dialog_create_simple_index
struct MuttWindow * dialog_create_simple_index(struct Menu *menu, enum WindowType type)
Create a simple index Dialog.
Definition: dialog.c:165
SigInt
WHERE SIG_ATOMIC_VOLATILE_T SigInt
true after SIGINT is received
Definition: mutt_globals.h:74
imap_search
bool imap_search(struct Mailbox *m, const struct PatternList *pat)
Find messages in mailbox matching a pattern.
Definition: search.c:228
Pattern::regex
regex_t * regex
Compiled regex, for non-pattern matching.
Definition: lib.h:88
MUTT_FLAG
@ MUTT_FLAG
Flagged messages.
Definition: mutt.h:102
EAT_DATE
@ EAT_DATE
Process a date (range)
Definition: private.h:43
MUTT_PAT_PERSONAL_RECIP
@ MUTT_PAT_PERSONAL_RECIP
Email is addressed to the user.
Definition: lib.h:159
MUTT_PAT_SCORE
@ MUTT_PAT_SCORE
Pattern matches email's score.
Definition: lib.h:153
_
#define _(a)
Definition: message.h:28
NONULL
#define NONULL(x)
Definition: string2.h:37
AliasView::is_matched
bool is_matched
Search matches this Alias.
Definition: gui.h:41
Mailbox
A mailbox.
Definition: mailbox.h:81
MUTT_PAT_LIST
@ MUTT_PAT_LIST
Email is on mailing list.
Definition: lib.h:157
Envelope::in_reply_to
struct ListHead in_reply_to
in-reply-to header content
Definition: envelope.h:82
Envelope::message_id
char * message_id
Message ID.
Definition: envelope.h:69
PatternCache::pers_recip_one
int pers_recip_one
~p
Definition: lib.h:116
Mailbox::v2r
int * v2r
Mapping from virtual to real msgno.
Definition: mailbox.h:101
Mailbox::emails
struct Email ** emails
Array of Emails.
Definition: mailbox.h:99
Alias::addr
struct AddressList addr
List of Addresses the Alias expands to.
Definition: alias.h:36
MUTT_ALL
@ MUTT_ALL
All messages.
Definition: mutt.h:91
mutt_pattern_free
void mutt_pattern_free(struct PatternList **pat)
Free a Pattern.
Definition: compile.c:1029
set_pattern_cache_value
static void set_pattern_cache_value(int *cache_entry, int value)
Sets a value in the PatternCache cache entry.
Definition: exec.c:622
Email::matched
bool matched
Search matches this Email.
Definition: email.h:68
Pattern::is_multi
bool is_multi
Multiple case (only for ~I pattern now)
Definition: lib.h:83
Buffer
String manipulation buffer.
Definition: buffer.h:33
PatternCache::sub_one
int sub_one
~u
Definition: lib.h:114
Email::thread
struct MuttThread * thread
Thread of Emails.
Definition: email.h:95
MUTT_PAT_TO
@ MUTT_PAT_TO
Pattern matches 'To:' field.
Definition: lib.h:135
Body::offset
LOFF_T offset
offset where the actual data begins
Definition: body.h:44
MUTT_PAT_HORMEL
@ MUTT_PAT_HORMEL
Pattern matches email's spam score.
Definition: lib.h:149
quote_simple
static void quote_simple(const char *str, struct Buffer *buf)
Apply simple quoting to a string.
Definition: pattern.c:93
PatternHelp
static const struct Mapping PatternHelp[]
Help Bar for the Pattern selection dialog.
Definition: dlgpattern.c:61
AliasMenuData::str
char * str
String representing the limit being used.
Definition: gui.h:55
MUTT_PATTERN
#define MUTT_PATTERN
Pattern mode - only used for history classes.
Definition: mutt.h:64
MUTT_PAT_COLLAPSED
@ MUTT_PAT_COLLAPSED
Thread is collapsed.
Definition: lib.h:137
mutt_check_simple
void mutt_check_simple(struct Buffer *buf, const char *simple)
Convert a simple search into a real request.
Definition: pattern.c:111
mutt_buffer_is_empty
bool mutt_buffer_is_empty(const struct Buffer *buf)
Is the Buffer empty?
Definition: buffer.c:252
mutt_buffer_dealloc
void mutt_buffer_dealloc(struct Buffer *buf)
Release the memory allocated by a buffer.
Definition: buffer.c:294
Body
The body of an email.
Definition: body.h:34
SEC_ENCRYPT
#define SEC_ENCRYPT
Email is encrypted.
Definition: lib.h:85
MUTT_PAT_OR
@ MUTT_PAT_OR
Either pattern can match.
Definition: lib.h:131
SLIST_NEXT
#define SLIST_NEXT(elm, field)
Definition: queue.h:269
SEC_SIGN
#define SEC_SIGN
Email is signed.
Definition: lib.h:86
MUTT_PAT_PERSONAL_FROM
@ MUTT_PAT_PERSONAL_FROM
Email is from the user.
Definition: lib.h:160
match_mime_content_type
static bool match_mime_content_type(const struct Pattern *pat, struct Mailbox *m, struct Email *e)
Match a Pattern against an email's Content-Type.
Definition: exec.c:592
Envelope::x_label
char * x_label
X-Label.
Definition: envelope.h:72
Context::vsize
off_t vsize
Size (in bytes) of the messages shown.
Definition: context.h:40
MUTT_PAT_MIMETYPE
@ MUTT_PAT_MIMETYPE
Pattern matches MIME type.
Definition: lib.h:170
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.
Definition: exec.c:738
MuttWindow
A division of the screen.
Definition: mutt_window.h:115
Email::num_hidden
size_t num_hidden
Number of hidden messages in this view (only valid when collapsed is set)
Definition: email.h:75
mutt_buffer_init
struct Buffer * mutt_buffer_init(struct Buffer *buf)
Initialise a new Buffer.
Definition: buffer.c:46
get_pattern_cache_value
static int get_pattern_cache_value(int cache_entry)
Get pattern cache value.
Definition: exec.c:633
eat_range
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:626
PatternCache::pers_from_all
int pers_from_all
^~P
Definition: lib.h:117
perform_or
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
mutt_is_subscribed_list_recipient
int mutt_is_subscribed_list_recipient(bool all_addr, struct Envelope *e)
Matches subscribed mailing lists.
Definition: exec.c:427
AliasView::is_visible
bool is_visible
Is visible?
Definition: gui.h:44
AliasView::alias
struct Alias * alias
Alias.
Definition: gui.h:45
Pattern::dynamic
bool dynamic
Evaluate date ranges at run time.
Definition: lib.h:81
FREE
#define FREE(x)
Definition: memory.h:40
MUTT_PAT_FROM
@ MUTT_PAT_FROM
Pattern matches 'From:' field.
Definition: lib.h:139
MUTT_DELETED
@ MUTT_DELETED
Deleted messages.
Definition: mutt.h:101
PatternEntry::tag
const char * tag
Copied to buffer if selected.
Definition: dlgpattern.c:55
MUTT_MATCH_FULL_ADDRESS
#define MUTT_MATCH_FULL_ADDRESS
Match the full address.
Definition: lib.h:99
MuttWindow::help_menu
int help_menu
Menu for key bindings, e.g. MENU_PAGER.
Definition: mutt_window.h:134
MUTT_PAT_PGP_KEY
@ MUTT_PAT_PGP_KEY
Message has PGP key.
Definition: lib.h:165
mutt_file_expand_fmt
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
ARRAY_SIZE
#define ARRAY_SIZE(head)
The number of elements stored.
Definition: array.h:83
lookup_tag
const struct PatternFlags * lookup_tag(char tag)
Lookup a pattern modifier.
Definition: flags.c:197
MUTT_PAT_SERVERSEARCH
@ MUTT_PAT_SERVERSEARCH
Server-side pattern matches.
Definition: lib.h:167
mutt_buffer_pool_release
void mutt_buffer_pool_release(struct Buffer **pbuf)
Free a Buffer from the pool.
Definition: pool.c:112
MUTT_LIMIT
@ MUTT_LIMIT
Messages in limited view.
Definition: mutt.h:105
MUTT_PAT_SUBJECT
@ MUTT_PAT_SUBJECT
Pattern matches 'Subject:' field.
Definition: lib.h:138
MUTT_PAT_SUBSCRIBED_LIST
@ MUTT_PAT_SUBSCRIBED_LIST
Email is on subscribed mailing list.
Definition: lib.h:158
ARRAY_GET
#define ARRAY_GET(head, idx)
Return the element at index.
Definition: array.h:105
MUTT_SUPERSEDED
@ MUTT_SUPERSEDED
Superseded messages.
Definition: mutt.h:107
Mailbox::vcount
int vcount
The number of virtual messages.
Definition: mailbox.h:102
PatternCache::pers_recip_all
int pers_recip_all
^~p
Definition: lib.h:115
EAT_RANGE
@ EAT_RANGE
Process a number (range)
Definition: private.h:44
LastSearch
static char LastSearch[256]
last pattern searched for
Definition: pattern.c:85
AliasView
GUI data wrapping an Alias.
Definition: gui.h:36
MUTT_READ
@ MUTT_READ
Messages that have been read.
Definition: mutt.h:96
SKIPWS
#define SKIPWS(ch)
Definition: string2.h:46
mutt_istr_equal
bool mutt_istr_equal(const char *a, const char *b)
Compare two strings, ignoring case.
Definition: string.c:883
match_user
static int match_user(int all_addr, struct AddressList *al1, struct AddressList *al2)
Matches the user's email Address.
Definition: exec.c:454
perform_and
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
MUTT_PAT_BODY
@ MUTT_PAT_BODY
Pattern matches email's body.
Definition: lib.h:147
mutt_is_mail_list
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
mutt_str_equal
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
Definition: string.c:871
MuttThread::child
struct MuttThread * child
Child of this Thread.
Definition: thread.h:46
MUTT_PAT_DRIVER_TAGS
@ MUTT_PAT_DRIVER_TAGS
Pattern matches message tags.
Definition: lib.h:168
mutt_is_list_recipient
int mutt_is_list_recipient(bool all_addr, struct Envelope *e)
Matches known mailing lists.
Definition: exec.c:440
Email::old
bool old
Email is seen, but unread.
Definition: email.h:50
Email::received
time_t received
Time when the message was placed in the mailbox.
Definition: email.h:83
mutt_progress_init
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
MUTT_PURGE
@ MUTT_PURGE
Messages to be purged (bypass trash)
Definition: mutt.h:100
Envelope::cc
struct AddressList cc
Email's 'Cc' list.
Definition: envelope.h:59
AliasMenuData::ava
struct AliasViewArray ava
Array of AliasView.
Definition: gui.h:57
mutt_buffer_pool_get
struct Buffer * mutt_buffer_pool_get(void)
Get a Buffer from the pool.
Definition: pool.c:101
Mailbox::type
enum MailboxType type
Mailbox type.
Definition: mailbox.h:105
Pattern::min
int min
Minimum for range checks.
Definition: lib.h:84
eat_date
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:967
ARRAY_FOREACH
#define ARRAY_FOREACH(elem, head)
Iterate over all elements of the array.
Definition: array.h:206
Email::visible
bool visible
Is this message part of the view?
Definition: email.h:74
PatternCache::list_all
int list_all
^~l
Definition: lib.h:111
MUTT_PAT_DATE_RECEIVED
@ MUTT_PAT_DATE_RECEIVED
Pattern matches date received.
Definition: lib.h:141
MUTT_UNREAD
@ MUTT_UNREAD
Unread messages.
Definition: mutt.h:97
MUTT_PAT_ID
@ MUTT_PAT_ID
Pattern matches email's Message-Id.
Definition: lib.h:145
MUTT_NEW
@ MUTT_NEW
New messages.
Definition: mutt.h:93
MuttThread::fake_thread
bool fake_thread
Emails grouped by Subject.
Definition: thread.h:36
MUTT_UNDELETE
@ MUTT_UNDELETE
Messages to be un-deleted.
Definition: mutt.h:99
Email::tagged
bool tagged
Email is tagged.
Definition: email.h:44
mutt_count_body_parts
int mutt_count_body_parts(struct Mailbox *m, struct Email *e)
Count the MIME Body parts.
Definition: mutt_parse.c:208
MUTT_PAT_HEADER
@ MUTT_PAT_HEADER
Pattern matches email's header.
Definition: lib.h:148
Pattern::is_alias
bool is_alias
Is there an alias for this Address?
Definition: lib.h:80
Progress
A progress bar.
Definition: progress.h:50
Body::length
LOFF_T length
length (in bytes) of attachment
Definition: body.h:45
MUTT_PAT_REFERENCE
@ MUTT_PAT_REFERENCE
Pattern matches 'References:' or 'In-Reply-To:' field.
Definition: lib.h:155
APPLICATION_PGP
#define APPLICATION_PGP
Use PGP to encrypt/sign.
Definition: lib.h:97
MUTT_PAT_CC
@ MUTT_PAT_CC
Pattern matches 'Cc:' field.
Definition: lib.h:136
Email::expired
bool expired
Already expired?
Definition: email.h:52
Pattern::all_addr
bool all_addr
All Addresses in the list must match.
Definition: lib.h:76
print_crypt_pattern_op_error
static void print_crypt_pattern_op_error(int op)
Print an error for a disabled crypto pattern.
Definition: exec.c:80
Mailbox::msg_count
int msg_count
Total number of messages.
Definition: mailbox.h:91
AliasView::is_searched
bool is_searched
Alias has been searched.
Definition: gui.h:40
mutt_clear_error
void mutt_clear_error(void)
Clear the message line (bottom line of screen)
Definition: mutt_logging.c:113
MUTT_PAT_ID_EXTERNAL
@ MUTT_PAT_ID_EXTERNAL
Message-Id is among results from an external query.
Definition: lib.h:146
PatternFlags::eat_arg
enum PatternEat eat_arg
Definition: private.h:58
MuttThread::duplicate_thread
bool duplicate_thread
Duplicated Email in Thread.
Definition: thread.h:37
MUTT_PC_FULL_MSG
#define MUTT_PC_FULL_MSG
Enable body and header matching.
Definition: lib.h:65
MUTT_PAT_AND
@ MUTT_PAT_AND
Both patterns must match.
Definition: lib.h:130
MUTT_IMAP
@ MUTT_IMAP
'IMAP' Mailbox type
Definition: mailbox.h:53
MUTT_PAT_BROKEN
@ MUTT_PAT_BROKEN
Message is part of a broken thread.
Definition: lib.h:144
MUTT_PAT_WHOLE_MSG
@ MUTT_PAT_WHOLE_MSG
Pattern matches raw email text.
Definition: lib.h:150
Envelope::to
struct AddressList to
Email's 'To' list.
Definition: envelope.h:58
MUTT_PAT_SENDER
@ MUTT_PAT_SENDER
Pattern matches sender.
Definition: lib.h:151
MUTT_EXPIRED
@ MUTT_EXPIRED
Expired messages.
Definition: mutt.h:106
MUTT_PROGRESS_READ
@ MUTT_PROGRESS_READ
Progress tracks elements, according to $read_inc
Definition: progress.h:42
Pattern::string_match
bool string_match
Check a string for a match.
Definition: lib.h:77
Pattern::pat_not
bool pat_not
Pattern should be inverted (not)
Definition: lib.h:75
perform_alias_and
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
match_reference
static bool match_reference(struct Pattern *pat, struct ListHead *refs)
Match references against a Pattern.
Definition: exec.c:381
Context::mailbox
struct Mailbox * mailbox
Definition: context.h:50
EAT_REGEX
@ EAT_REGEX
Process a regex.
Definition: private.h:42
Email::env
struct Envelope * env
Envelope information.
Definition: email.h:90
eat_regex
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
MuttThread
An Email conversation.
Definition: thread.h:34
MUTT_REPLIED
@ MUTT_REPLIED
Messages that have been replied to.
Definition: mutt.h:95
Menu::title
const char * title
Title of this menu.
Definition: mutt_menu.h:54
mutt_pattern_node_new
static struct PatternList * mutt_pattern_node_new(void)
Create a new list containing a Pattern.
Definition: compile.c:1065
MUTT_PAT_THREAD
@ MUTT_PAT_THREAD
Pattern matches email thread.
Definition: lib.h:132
Context::collapsed
bool collapsed
Are all threads collapsed?
Definition: context.h:48
match_threadcomplete
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
top_of_thread
static struct MuttThread * top_of_thread(struct Email *e)
Find the first email in the current thread.
Definition: pattern.c:170
PatternCache::sub_all
int sub_all
^~u
Definition: lib.h:113
MUTT_UNTAG
@ MUTT_UNTAG
Messages to be un-tagged.
Definition: mutt.h:104
LastSearchExpn
static char LastSearchExpn[1024]
expanded version of LastSearch
Definition: pattern.c:86
Email::flagged
bool flagged
Marked important?
Definition: email.h:43
mutt_buffer_get_field
int mutt_buffer_get_field(const char *field, struct Buffer *buf, CompletionFlags complete, bool multiple, struct Mailbox *m, char ***files, int *numfiles)
Ask the user for a string.
Definition: curs_lib.c:260
pbuf
static unsigned char * pbuf
Cache PGP data packet.
Definition: pgppacket.c:38
mutt_str_len
size_t mutt_str_len(const char *a)
Calculate the length of a string, safely.
Definition: string.c:631
mutt_buffer_string
static const char * mutt_buffer_string(const struct Buffer *buf)
Convert a buffer to a const char * "string".
Definition: buffer.h:77
MUTT_PAT_MAX
@ MUTT_PAT_MAX
Definition: lib.h:174
MUTT_PAT_CHILDREN
@ MUTT_PAT_CHILDREN
Pattern matches a child email.
Definition: lib.h:134
MUTT_ALIAS_SIMPLESEARCH
#define MUTT_ALIAS_SIMPLESEARCH
Definition: lib.h:58
MUTT_PAT_DUPLICATED
@ MUTT_PAT_DUPLICATED
Duplicate message.
Definition: lib.h:142
Email::security
SecurityFlags security
bit 0-10: flags, bit 11,12: application, bit 13: traditional pgp See: ncrypt/lib.h pgplib....
Definition: email.h:39
Email::collapsed
bool collapsed
Is this message part of a collapsed thread?
Definition: email.h:73
SLIST_FIRST
#define SLIST_FIRST(head)
Definition: queue.h:228
C_SimpleSearch
WHERE char * C_SimpleSearch
Config: Pattern to search for when search doesn't contain ~'s.
Definition: mutt_globals.h:107
MuttWindow::help_data
const struct Mapping * help_data
Data for the Help Bar.
Definition: mutt_window.h:135
MUTT_PAT_NEWSGROUPS
@ MUTT_PAT_NEWSGROUPS
Pattern matches newsgroup.
Definition: lib.h:172
mutt_str_replace
char * mutt_str_replace(char **p, const char *s)
Replace one string with another.
Definition: string.c:446
Email::score
int score
Message score.
Definition: email.h:89
MUTT_OLD
@ MUTT_OLD
Old messages.
Definition: mutt.h:94
WT_DLG_PATTERN
@ WT_DLG_PATTERN
Pattern Dialog, create_pattern_menu()
Definition: mutt_window.h:84
WithCrypto
#define WithCrypto
Definition: lib.h:123
match_update_dynamic_date
static bool match_update_dynamic_date(struct Pattern *pat)
Update a dynamic date pattern.
Definition: exec.c:605
mutt_menu_loop
int mutt_menu_loop(struct Menu *menu)
Menu event loop.
Definition: menu.c:1309
Pattern::op
short op
Operation, e.g. MUTT_PAT_SCORE.
Definition: lib.h:74
Envelope::newsgroups
char * newsgroups
List of newsgroups.
Definition: envelope.h:75
Context::limit_pattern
struct PatternList * limit_pattern
Compiled limit pattern.
Definition: context.h:42
Alias::name
char * name
Short name.
Definition: alias.h:35
MUTT_MT_MAX
@ MUTT_MT_MAX
Definition: mutt.h:110
Email::deleted
bool deleted
Email is deleted.
Definition: email.h:45
EMSG
#define EMSG(e)
Definition: private.h:120
MUTT_PAT_CRYPT_SIGN
@ MUTT_PAT_CRYPT_SIGN
Message is signed.
Definition: lib.h:162
PatternFlags::op
int op
Operation to perform, e.g. MUTT_PAT_SCORE.
Definition: private.h:55
PatternFlags::flags
PatternCompFlags flags
Pattern flags, e.g. MUTT_PC_FULL_MSG.
Definition: private.h:56
Pattern::p
union Pattern::@2 p
Envelope::from
struct AddressList from
Email's 'From' list.
Definition: envelope.h:57
MUTT_PAT_ADDRESS
@ MUTT_PAT_ADDRESS
Pattern matches any address field.
Definition: lib.h:161
free_pattern_menu
static void free_pattern_menu(struct Menu **ptr)
Free the Pattern Completion menu.
Definition: dlgpattern.c:235
MUTT_DELETE
@ MUTT_DELETE
Messages to be deleted.
Definition: mutt.h:98
Menu::mdata
void * mdata
Extra data for the current menu.
Definition: mutt_menu.h:55
msg_search
static bool msg_search(struct Mailbox *m, struct Pattern *pat, int msgno)
Search an email.
Definition: exec.c:106
menu_create_alias_title
char * menu_create_alias_title(char *menu_name, char *limit)
Create a title string for the Menu.
Definition: gui.c:84
mutt_mem_malloc
void * mutt_mem_malloc(size_t size)
Allocate memory on the heap.
Definition: memory.c:90
OptSearchInvalid
WHERE bool OptSearchInvalid
(pseudo) used to invalidate the search pattern
Definition: options.h:52
Menu::max
int max
Number of entries in the menu.
Definition: mutt_menu.h:57
MUTT_PAT_UNREFERENCED
@ MUTT_PAT_UNREFERENCED
Message is unreferenced in the thread.
Definition: lib.h:143
driver_tags_get
char * driver_tags_get(struct TagList *list)
Get tags.
Definition: tags.c:144
Alias::comment
char * comment
Free-form comment string.
Definition: alias.h:37
Email::tags
struct TagList tags
For drivers that support server tagging.
Definition: email.h:109
MUTT_PAT_SIZE
@ MUTT_PAT_SIZE
Pattern matches email's size.
Definition: lib.h:154
PatternEntry
A line in the Pattern Completion menu.
Definition: dlgpattern.c:52
eat_query
static bool eat_query(struct Pattern *pat, PatternCompFlags flags, struct Buffer *s, struct Buffer *err, struct Context *ctx)
Parse a query for an external search program - Implements eat_arg_t.
Definition: compile.c:155
perform_alias_or
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
MUTT_PAT_XLABEL
@ MUTT_PAT_XLABEL
Pattern matches keyword/label.
Definition: lib.h:166
MUTT_TAG
@ MUTT_TAG
Tagged messages.
Definition: mutt.h:103
mutt_strn_dup
char * mutt_strn_dup(const char *begin, size_t len)
Duplicate a sub-string.
Definition: string.c:548
mutt_is_subscribed_list
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
C_WrapSearch
WHERE bool C_WrapSearch
Config: Wrap around when the search hits the end.
Definition: mutt_globals.h:170
Pattern::group
struct Group * group
Address group if group_match is set.
Definition: lib.h:89
PGP_KEY
#define PGP_KEY
Definition: lib.h:106
EAT_MESSAGE_RANGE
@ EAT_MESSAGE_RANGE
Process a message number (range)
Definition: private.h:45
MUTT_PAT_MESSAGE
@ MUTT_PAT_MESSAGE
Pattern matches message number.
Definition: lib.h:152
eat_message_range
static bool eat_message_range(struct Pattern *pat, PatternCompFlags flags, struct Buffer *s, struct Buffer *err, struct Context *ctx)
Parse a range of message numbers - Implements eat_arg_t.
Definition: compile.c:923
AliasMenuData
AliasMenuData - AliasView array wrapper with Pattern information.
Definition: gui.h:53
EAT_QUERY
@ EAT_QUERY
Process a query string.
Definition: private.h:46
MUTT_PC_SEND_MODE_SEARCH
#define MUTT_PC_SEND_MODE_SEARCH
Allow send-mode body searching.
Definition: lib.h:67
Email::searched
bool searched
Email has been searched.
Definition: email.h:67
Envelope::spam
struct Buffer spam
Spam header.
Definition: envelope.h:80
Email::vnum
int vnum
Virtual message number.
Definition: email.h:88
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.
Definition: exec.c:1041
MUTT_CLEAR
#define MUTT_CLEAR
Clear input if printable character is pressed.
Definition: mutt.h:62
match_addrlist
static int match_addrlist(struct Pattern *pat, bool match_personal, int n,...)
Match a Pattern against an Address list.
Definition: exec.c:351
mutt_progress_update
void mutt_progress_update(struct Progress *progress, size_t pos, int percent)
Update the state of the progress bar.
Definition: progress.c:212
Context::pattern
char * pattern
Limit pattern string.
Definition: context.h:41
Pattern::max
int max
Maximum for range checks.
Definition: lib.h:85
mutt_get_field
int mutt_get_field(const char *field, char *buf, size_t buflen, CompletionFlags complete, bool multiple, char ***files, int *numfiles)
Ask the user for a string.
Definition: curs_lib.c:311
MUTT_PAT_MIMEATTACH
@ MUTT_PAT_MIMEATTACH
Pattern matches number of attachments.
Definition: lib.h:169
msg_search_sendmode
static int msg_search_sendmode(struct Email *e, struct Pattern *pat)
Search in send-mode.
Definition: exec.c:656
mutt_buffer_strdup
char * mutt_buffer_strdup(const struct Buffer *buf)
Copy a Buffer's string.
Definition: buffer.c:432
dialog_destroy_simple_index
void dialog_destroy_simple_index(struct MuttWindow **ptr)
Destroy a simple index Dialog.
Definition: dialog.c:209
Menu::current
int current
Current entry.
Definition: mutt_menu.h:56
Pattern::multi_cases
struct ListHead multi_cases
Multiple strings for ~I pattern.
Definition: lib.h:91
mutt_is_predicate_recipient
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
Pattern::str
char * str
String, if string_match is set.
Definition: lib.h:90
Email::replied
bool replied
Email has been replied to.
Definition: email.h:54
Buffer::data
char * data
Pointer to data.
Definition: buffer.h:35
PatternCache::list_one
int list_one
~l
Definition: lib.h:112
Email
The envelope/body of an email.
Definition: email.h:37
Pattern::sendmode
bool sendmode
Evaluate searches in send-mode.
Definition: lib.h:82
MUTT_PAT_CRYPT_VERIFIED
@ MUTT_PAT_CRYPT_VERIFIED
Message is crypographically verified.
Definition: lib.h:163
mutt_message
#define mutt_message(...)
Definition: logging.h:83
PatternCache::pers_from_one
int pers_from_one
~P
Definition: lib.h:118
mutt_set_flag
#define mutt_set_flag(m, e, flag, bf)
Definition: protos.h:67
OptSearchReverse
WHERE bool OptSearchReverse
(pseudo) used by ci_search_command
Definition: options.h:53
SearchPattern
static struct PatternList * SearchPattern
current search pattern
Definition: pattern.c:84
mx_msg_padding_size
int mx_msg_padding_size(struct Mailbox *m)
Bytes of padding between messages - Wrapper for MxOps::msg_padding_size()
Definition: mx.c:1554
mutt_buffer_printf
int mutt_buffer_printf(struct Buffer *buf, const char *fmt,...)
Format a string overwriting a Buffer.
Definition: buffer.c:160
Envelope::references
struct ListHead references
message references (in reverse order)
Definition: envelope.h:81
mutt_buffer_make
struct Buffer mutt_buffer_make(size_t size)
Make a new buffer on the stack.
Definition: buffer.c:61
mutt_list_free
void mutt_list_free(struct ListHead *h)
Free a List AND its strings.
Definition: list.c:122
Menu
GUI selectable list of items.
Definition: mutt_menu.h:52
Email::superseded
bool superseded
Got superseded?
Definition: email.h:53
Email::read
bool read
Email is read.
Definition: email.h:51
MUTT_MAXRANGE
#define MUTT_MAXRANGE
Definition: private.h:122
Envelope::sender
struct AddressList sender
Email's sender.
Definition: envelope.h:61
find_matching_paren
static char * find_matching_paren(char *s)
Find the matching parenthesis.
Definition: compile.c:1007
SEC_GOODSIGN
#define SEC_GOODSIGN
Email has a valid signature.
Definition: lib.h:87
Pattern::group_match
bool group_match
Check a group of Addresses.
Definition: lib.h:78
mutt_buffer_strcpy
size_t mutt_buffer_strcpy(struct Buffer *buf, const char *s)
Copy a string into a Buffer.
Definition: buffer.c:312
PatternFlags
Mapping between user character and internal constant.
Definition: private.h:52
Pattern
A simple (non-regex) pattern.
Definition: lib.h:72
MUTT_PAT_RECIPIENT
@ MUTT_PAT_RECIPIENT
User is a recipient of the email.
Definition: lib.h:156
match_threadparent
static int match_threadparent(struct PatternList *pat, PatternExecFlags flags, struct Mailbox *m, struct MuttThread *t)
Match Pattern against an email's parent.
Definition: exec.c:528
is_pattern_cache_set
static int is_pattern_cache_set(int cache_entry)
Is a given Pattern cached?
Definition: exec.c:643
Body::filename
char * filename
when sending a message, this is the file to which this structure refers
Definition: body.h:46
Email::body
struct Body * body
List of MIME parts.
Definition: email.h:91
mutt_error
#define mutt_error(...)
Definition: logging.h:84
Pattern::child
struct PatternList * child
Arguments to logical operation.
Definition: lib.h:86
mutt_str_copy
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