NeoMutt  2020-11-20
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:119
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
int flags
e.g. MB_NORMAL
Definition: mailbox.h:134
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:121
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
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:206
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
int flags
e.g. MB_NORMAL
Definition: mailbox.h:134
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
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 1056 of file compile.c.

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

110 {
111  bool do_simple = true;
112 
113  for (const char *p = mutt_b2s(buf); p && (p[0] != '\0'); p++)
114  {
115  if ((p[0] == '\\') && (p[1] != '\0'))
116  p++;
117  else if ((p[0] == '~') || (p[0] == '=') || (p[0] == '%'))
118  {
119  do_simple = false;
120  break;
121  }
122  }
123 
124  /* XXX - is mutt_istr_cmp() right here, or should we use locale's
125  * equivalences? */
126 
127  if (do_simple) /* yup, so spoof a real request */
128  {
129  /* convert old tokens into the new format */
130  if (mutt_istr_equal("all", mutt_b2s(buf)) || mutt_str_equal("^", mutt_b2s(buf)) ||
131  mutt_str_equal(".", mutt_b2s(buf))) /* ~A is more efficient */
132  {
133  mutt_buffer_strcpy(buf, "~A");
134  }
135  else if (mutt_istr_equal("del", mutt_b2s(buf)))
136  mutt_buffer_strcpy(buf, "~D");
137  else if (mutt_istr_equal("flag", mutt_b2s(buf)))
138  mutt_buffer_strcpy(buf, "~F");
139  else if (mutt_istr_equal("new", mutt_b2s(buf)))
140  mutt_buffer_strcpy(buf, "~N");
141  else if (mutt_istr_equal("old", mutt_b2s(buf)))
142  mutt_buffer_strcpy(buf, "~O");
143  else if (mutt_istr_equal("repl", mutt_b2s(buf)))
144  mutt_buffer_strcpy(buf, "~Q");
145  else if (mutt_istr_equal("read", mutt_b2s(buf)))
146  mutt_buffer_strcpy(buf, "~R");
147  else if (mutt_istr_equal("tag", mutt_b2s(buf)))
148  mutt_buffer_strcpy(buf, "~T");
149  else if (mutt_istr_equal("unread", mutt_b2s(buf)))
150  mutt_buffer_strcpy(buf, "~U");
151  else
152  {
153  struct Buffer *tmp = mutt_buffer_pool_get();
154  quote_simple(mutt_b2s(buf), tmp);
155  mutt_file_expand_fmt(buf, simple, mutt_b2s(tmp));
157  }
158  }
159 }
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:91
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
bool mutt_istr_equal(const char *a, const char *b)
Compare two strings, ignoring case.
Definition: string.c:883
#define mutt_b2s(buf)
Definition: buffer.h:41
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 1004 of file compile.c.

1005 {
1006  if (!pat || !*pat)
1007  return;
1008 
1009  struct Pattern *np = SLIST_FIRST(*pat), *next = NULL;
1010 
1011  while (np)
1012  {
1013  next = SLIST_NEXT(np, entries);
1014 
1015  if (np->is_multi)
1017  else if (np->string_match || np->dynamic)
1018  FREE(&np->p.str);
1019  else if (np->group_match)
1020  np->p.group = NULL;
1021  else if (np->p.regex)
1022  {
1023  regfree(np->p.regex);
1024  FREE(&np->p.regex);
1025  }
1026 
1027  mutt_pattern_free(&np->child);
1028  FREE(&np);
1029 
1030  np = next;
1031  }
1032 
1033  FREE(pat);
1034 }
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:1004
+ 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 336 of file pattern.c.

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

238 {
239  int rc = -1;
240  struct Progress progress;
241  struct Buffer *buf = mutt_buffer_pool_get();
242 
243  mutt_buffer_strcpy(buf, mdata->str);
244  if (prompt)
245  {
246  if ((mutt_buffer_get_field(prompt, buf, MUTT_PATTERN | MUTT_CLEAR) != 0) ||
248  {
250  return -1;
251  }
252  }
253 
254  mutt_message(_("Compiling search pattern..."));
255 
256  bool match_all = false;
257  struct PatternList *pat = NULL;
258  char *simple = mutt_buffer_strdup(buf);
259  if (simple)
260  {
262  const char *pbuf = buf->data;
263  while (*pbuf == ' ')
264  pbuf++;
265  match_all = mutt_str_equal(pbuf, "~A");
266 
267  struct Buffer err = mutt_buffer_make(0);
268  pat = mutt_pattern_comp(buf->data, MUTT_PC_FULL_MSG, &err);
269  if (!pat)
270  {
271  mutt_error("%s", mutt_b2s(&err));
272  mutt_buffer_dealloc(&err);
273  goto bail;
274  }
275  }
276  else
277  {
278  match_all = true;
279  }
280 
281  mutt_progress_init(&progress, _("Executing command on matching messages..."),
282  MUTT_PROGRESS_READ, ARRAY_SIZE(&mdata->ava));
283 
284  int vcounter = 0;
285  struct AliasView *avp = NULL;
286  ARRAY_FOREACH(avp, &mdata->ava)
287  {
288  mutt_progress_update(&progress, ARRAY_FOREACH_IDX, -1);
289 
290  if (match_all ||
292  {
293  avp->is_visible = true;
294  vcounter++;
295  }
296  else
297  {
298  avp->is_visible = false;
299  }
300  }
301 
302  mutt_str_replace(&mdata->str, simple);
303 
304  if (menu)
305  {
306  menu->max = vcounter;
307  menu->current = 0;
308 
309  FREE(&menu->title);
310 
311  if (match_all)
312  menu->title = menu_create_alias_title(menu_name, NULL);
313  else
314  menu->title = menu_create_alias_title(menu_name, simple);
315  }
316 
318 
319  rc = 0;
320 
321 bail:
323  FREE(&simple);
324  mutt_pattern_free(&pat);
325 
326  return rc;
327 }
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:109
#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:1056
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
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
#define mutt_b2s(buf)
Definition: buffer.h:41
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:1004
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 482 of file pattern.c.

483 {
484  struct Progress progress;
485 
486  if ((*LastSearch == '\0') || ((op != OP_SEARCH_NEXT) && (op != OP_SEARCH_OPPOSITE)))
487  {
488  char buf[256];
489  mutt_str_copy(buf, (LastSearch[0] != '\0') ? LastSearch : "", sizeof(buf));
490  if ((mutt_get_field(((op == OP_SEARCH) || (op == OP_SEARCH_NEXT)) ?
491  _("Search for: ") :
492  _("Reverse search for: "),
493  buf, sizeof(buf), MUTT_CLEAR | MUTT_PATTERN) != 0) ||
494  (buf[0] == '\0'))
495  {
496  return -1;
497  }
498 
499  if ((op == OP_SEARCH) || (op == OP_SEARCH_NEXT))
500  OptSearchReverse = false;
501  else
502  OptSearchReverse = true;
503 
504  /* compare the *expanded* version of the search pattern in case
505  * $simple_search has changed while we were searching */
506  struct Buffer *tmp = mutt_buffer_pool_get();
507  mutt_buffer_strcpy(tmp, buf);
509 
511  {
512  struct Buffer err;
513  mutt_buffer_init(&err);
514  OptSearchInvalid = true;
515  mutt_str_copy(LastSearch, buf, sizeof(LastSearch));
517  mutt_message(_("Compiling search pattern..."));
519  err.dsize = 256;
520  err.data = mutt_mem_malloc(err.dsize);
522  if (!SearchPattern)
523  {
525  mutt_error("%s", err.data);
526  FREE(&err.data);
527  LastSearch[0] = '\0';
528  LastSearchExpn[0] = '\0';
529  return -1;
530  }
531  FREE(&err.data);
533  }
534 
536  }
537 
538  if (OptSearchInvalid)
539  {
540  for (int i = 0; i < m->msg_count; i++)
541  m->emails[i]->searched = false;
542 #ifdef USE_IMAP
543  if ((m->type == MUTT_IMAP) && (!imap_search(m, SearchPattern)))
544  return -1;
545 #endif
546  OptSearchInvalid = false;
547  }
548 
549  int incr = OptSearchReverse ? -1 : 1;
550  if (op == OP_SEARCH_OPPOSITE)
551  incr = -incr;
552 
553  mutt_progress_init(&progress, _("Searching..."), MUTT_PROGRESS_READ, m->vcount);
554 
555  for (int i = cur + incr, j = 0; j != m->vcount; j++)
556  {
557  const char *msg = NULL;
558  mutt_progress_update(&progress, j, -1);
559  if (i > m->vcount - 1)
560  {
561  i = 0;
562  if (C_WrapSearch)
563  msg = _("Search wrapped to top");
564  else
565  {
566  mutt_message(_("Search hit bottom without finding match"));
567  return -1;
568  }
569  }
570  else if (i < 0)
571  {
572  i = m->vcount - 1;
573  if (C_WrapSearch)
574  msg = _("Search wrapped to bottom");
575  else
576  {
577  mutt_message(_("Search hit top without finding match"));
578  return -1;
579  }
580  }
581 
582  struct Email *e = mutt_get_virt_email(m, i);
583  if (e->searched)
584  {
585  /* if we've already evaluated this message, use the cached value */
586  if (e->matched)
587  {
589  if (msg && *msg)
590  mutt_message(msg);
591  return i;
592  }
593  }
594  else
595  {
596  /* remember that we've already searched this message */
597  e->searched = true;
599  MUTT_MATCH_FULL_ADDRESS, m, e, NULL);
600  if (e->matched > 0)
601  {
603  if (msg && *msg)
604  mutt_message(msg);
605  return i;
606  }
607  }
608 
609  if (SigInt)
610  {
611  mutt_error(_("Search interrupted"));
612  SigInt = 0;
613  return -1;
614  }
615 
616  i += incr;
617  }
618 
619  mutt_error(_("Not found"));
620  return -1;
621 }
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:109
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:83
struct PatternList * mutt_pattern_comp(const char *s, PatternCompFlags flags, struct Buffer *err)
Create a Pattern.
Definition: compile.c:1056
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
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
#define mutt_b2s(buf)
Definition: buffer.h:41
static char LastSearchExpn[1024]
expanded version of LastSearch
Definition: pattern.c:84
#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:82
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:1004
#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 631 of file pattern.c.

632 {
633  struct Progress progress;
634 
635  struct AliasViewArray *ava = &((struct AliasMenuData *) menu->mdata)->ava;
636 
637  if ((*LastSearch == '\0') || ((op != OP_SEARCH_NEXT) && (op != OP_SEARCH_OPPOSITE)))
638  {
639  char buf[256];
640  mutt_str_copy(buf, (LastSearch[0] != '\0') ? LastSearch : "", sizeof(buf));
641  if ((mutt_get_field(((op == OP_SEARCH) || (op == OP_SEARCH_NEXT)) ?
642  _("Search for: ") :
643  _("Reverse search for: "),
644  buf, sizeof(buf), MUTT_CLEAR | MUTT_PATTERN) != 0) ||
645  (buf[0] == '\0'))
646  {
647  return -1;
648  }
649 
650  if ((op == OP_SEARCH) || (op == OP_SEARCH_NEXT))
651  OptSearchReverse = false;
652  else
653  OptSearchReverse = true;
654 
655  /* compare the *expanded* version of the search pattern in case
656  * $simple_search has changed while we were searching */
657  struct Buffer *tmp = mutt_buffer_pool_get();
658  mutt_buffer_strcpy(tmp, buf);
660 
662  {
663  struct Buffer err;
664  mutt_buffer_init(&err);
665  OptSearchInvalid = true;
666  mutt_str_copy(LastSearch, buf, sizeof(LastSearch));
668  mutt_message(_("Compiling search pattern..."));
670  err.dsize = 256;
671  err.data = mutt_mem_malloc(err.dsize);
673  if (!SearchPattern)
674  {
676  mutt_error("%s", err.data);
677  FREE(&err.data);
678  LastSearch[0] = '\0';
679  LastSearchExpn[0] = '\0';
680  return -1;
681  }
682  FREE(&err.data);
684  }
685 
687  }
688 
689  if (OptSearchInvalid)
690  {
691  struct AliasView *av = NULL;
692  ARRAY_FOREACH(av, ava)
693  {
694  av->is_searched = false;
695  }
696 
697  OptSearchInvalid = false;
698  }
699 
700  int incr = OptSearchReverse ? -1 : 1;
701  if (op == OP_SEARCH_OPPOSITE)
702  incr = -incr;
703 
704  mutt_progress_init(&progress, _("Searching..."), MUTT_PROGRESS_READ, ARRAY_SIZE(ava));
705 
706  for (int i = cur + incr, j = 0; j != ARRAY_SIZE(ava); j++)
707  {
708  const char *msg = NULL;
709  mutt_progress_update(&progress, j, -1);
710  if (i > ARRAY_SIZE(ava) - 1)
711  {
712  i = 0;
713  if (C_WrapSearch)
714  msg = _("Search wrapped to top");
715  else
716  {
717  mutt_message(_("Search hit bottom without finding match"));
718  return -1;
719  }
720  }
721  else if (i < 0)
722  {
723  i = ARRAY_SIZE(ava) - 1;
724  if (C_WrapSearch)
725  msg = _("Search wrapped to bottom");
726  else
727  {
728  mutt_message(_("Search hit top without finding match"));
729  return -1;
730  }
731  }
732 
733  struct AliasView *av = ARRAY_GET(ava, i);
734  if (av->is_searched)
735  {
736  /* if we've already evaluated this message, use the cached value */
737  if (av->is_matched)
738  {
740  if (msg && *msg)
741  mutt_message(msg);
742  return i;
743  }
744  }
745  else
746  {
747  /* remember that we've already searched this message */
748  av->is_searched = true;
750  MUTT_MATCH_FULL_ADDRESS, av, NULL);
751  if (av->is_matched > 0)
752  {
754  if (msg && *msg)
755  mutt_message(msg);
756  return i;
757  }
758  }
759 
760  if (SigInt)
761  {
762  mutt_error(_("Search interrupted"));
763  SigInt = 0;
764  return -1;
765  }
766 
767  i += incr;
768  }
769 
770  mutt_error(_("Not found"));
771  return -1;
772 }
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:109
#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:83
struct PatternList * mutt_pattern_comp(const char *s, PatternCompFlags flags, struct Buffer *err)
Create a Pattern.
Definition: compile.c:1056
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
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
#define mutt_b2s(buf)
Definition: buffer.h:41
static char LastSearchExpn[1024]
expanded version of LastSearch
Definition: pattern.c:84
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:82
#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:1004
#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 186 of file pattern.c.

187 {
188  if (!e || !Context || !Context->mailbox)
189  return false;
190 
191  struct MuttThread *me = top_of_thread(e);
192  if (!me)
193  return false;
194 
195  struct Mailbox *m = Context->mailbox;
196 
197  m->vcount = 0;
198  Context->vsize = 0;
199  Context->collapsed = false;
200 
201  for (int i = 0; i < m->msg_count; i++)
202  {
203  e = m->emails[i];
204  if (!e)
205  break;
206 
207  e->vnum = -1;
208  e->visible = false;
209  e->collapsed = false;
210  e->num_hidden = 0;
211 
212  if (top_of_thread(e) == me)
213  {
214  struct Body *body = e->body;
215 
216  e->vnum = m->vcount;
217  e->visible = true;
218  m->v2r[m->vcount] = i;
219  m->vcount++;
220  Context->vsize += (body->length + body->offset - body->hdr_offset);
221  }
222  }
223  return true;
224 }
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
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
struct Mailbox * mailbox
Definition: context.h:50
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:167
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[], int 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.