NeoMutt  2024-11-14-34-g5aaf0d
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
private.h
Go to the documentation of this file.
1
23#ifndef MUTT_PATTERN_PRIVATE_H
24#define MUTT_PATTERN_PRIVATE_H
25
26#include <stdbool.h>
27#include "mutt/lib.h"
28#include "email/lib.h"
29#include "lib.h"
30
31struct MailboxView;
32
39{
43};
44
51{
58};
59
64{
65 char tag;
66 int op;
68
70 char *desc;
71};
72
77{
78 const char *raw;
79 int lgrp;
80 int rgrp;
81 bool ready;
82 regex_t cooked;
83};
84
89{
95 /* add new ones HERE */
97};
98
99/* The regexes in a modern format */
100#define RANGE_NUM_RX "([[:digit:]]+|0x[[:xdigit:]]+)[MmKk]?"
101#define RANGE_REL_SLOT_RX "[[:blank:]]*([.^$]|-?" RANGE_NUM_RX ")?[[:blank:]]*"
102#define RANGE_REL_RX "^" RANGE_REL_SLOT_RX "," RANGE_REL_SLOT_RX
103
104/* Almost the same, but no negative numbers allowed */
105#define RANGE_ABS_SLOT_RX "[[:blank:]]*([.^$]|" RANGE_NUM_RX ")?[[:blank:]]*"
106#define RANGE_ABS_RX "^" RANGE_ABS_SLOT_RX "-" RANGE_ABS_SLOT_RX
107
108/* First group is intentionally empty */
109#define RANGE_LT_RX "^()[[:blank:]]*(<[[:blank:]]*" RANGE_NUM_RX ")[[:blank:]]*"
110#define RANGE_GT_RX "^()[[:blank:]]*(>[[:blank:]]*" RANGE_NUM_RX ")[[:blank:]]*"
111
112/* Single group for min and max */
113#define RANGE_BARE_RX "^[[:blank:]]*([.^$]|" RANGE_NUM_RX ")[[:blank:]]*"
114#define RANGE_RX_GROUPS 5
115
116#define RANGE_DOT '.'
117#define RANGE_CIRCUM '^'
118#define RANGE_DOLLAR '$'
119#define RANGE_LT '<'
120#define RANGE_GT '>'
121
126{
129};
130
136static inline int email_msgno(struct Email *e)
137{
138 return e->msgno + 1;
139}
140
141#define MUTT_MAXRANGE -1
142
143extern struct RangeRegex RangeRegexes[];
144extern const struct PatternFlags Flags[];
145
146const struct PatternFlags *lookup_op(int op);
147const struct PatternFlags *lookup_tag(char tag);
148bool eval_date_minmax(struct Pattern *pat, const char *s, struct Buffer *err);
149bool eat_message_range(struct Pattern *pat, PatternCompFlags flags, struct Buffer *s, struct Buffer *err, struct MailboxView *mv);
150
151#endif /* MUTT_PATTERN_PRIVATE_H */
Structs that make up an email.
bool eat_message_range(struct Pattern *pat, PatternCompFlags flags, struct Buffer *s, struct Buffer *err, struct MailboxView *mv)
Parse a range of message numbers - Implements eat_arg_t -.
Definition: message.c:282
Convenience wrapper for the library headers.
uint8_t PatternCompFlags
Flags for mutt_pattern_comp(), e.g. MUTT_PC_FULL_MSG.
Definition: lib.h:66
RangeSide
Which side of the range.
Definition: private.h:126
@ RANGE_S_LEFT
Left side of range.
Definition: private.h:127
@ RANGE_S_RIGHT
Right side of range.
Definition: private.h:128
bool eval_date_minmax(struct Pattern *pat, const char *s, struct Buffer *err)
Evaluate a date-range pattern against 'now'.
Definition: compile.c:496
ExpandoDataPattern
Expando UIDs for Patterns.
Definition: private.h:39
@ ED_PAT_DESCRIPTION
PatternEntry.desc.
Definition: private.h:40
@ ED_PAT_EXPRESION
PatternEntry.expr.
Definition: private.h:41
@ ED_PAT_NUMBER
PatternEntry.num.
Definition: private.h:42
PatternEat
Function to process pattern arguments.
Definition: private.h:51
@ EAT_NONE
No arguments required.
Definition: private.h:52
@ EAT_RANGE
Process a number (range)
Definition: private.h:55
@ EAT_MESSAGE_RANGE
Process a message number (range)
Definition: private.h:56
@ EAT_DATE
Process a date (range)
Definition: private.h:54
@ EAT_QUERY
Process a query string.
Definition: private.h:57
@ EAT_REGEX
Process a regex.
Definition: private.h:53
const struct PatternFlags Flags[]
Lookup table for all patterns.
Definition: flags.c:40
const struct PatternFlags * lookup_tag(char tag)
Lookup a pattern modifier.
Definition: flags.c:198
struct RangeRegex RangeRegexes[]
Set of Regexes for various range types.
Definition: pattern.c:65
const struct PatternFlags * lookup_op(int op)
Lookup the Pattern Flags for an op.
Definition: flags.c:211
static int email_msgno(struct Email *e)
Helper to get the Email's message number.
Definition: private.h:136
RangeType
Type of range.
Definition: private.h:89
@ RANGE_K_REL
Relative range.
Definition: private.h:90
@ RANGE_K_ABS
Absolute range.
Definition: private.h:91
@ RANGE_K_LT
Less-than range.
Definition: private.h:92
@ RANGE_K_INVALID
Range is invalid.
Definition: private.h:96
@ RANGE_K_BARE
Single symbol.
Definition: private.h:94
@ RANGE_K_GT
Greater-than range.
Definition: private.h:93
Key value store.
String manipulation buffer.
Definition: buffer.h:36
The envelope/body of an email.
Definition: email.h:39
int msgno
Number displayed to the user.
Definition: email.h:111
View of a Mailbox.
Definition: mview.h:40
Mapping between user character and internal constant.
Definition: private.h:64
enum PatternEat eat_arg
Type of function needed to parse flag, e.g. EAT_DATE.
Definition: private.h:69
char tag
Character used to represent this operation, e.g. 'A' for '~A'.
Definition: private.h:65
char * desc
Description of flag.
Definition: private.h:70
PatternCompFlags flags
Pattern flags, e.g. MUTT_PC_FULL_MSG.
Definition: private.h:67
int op
Operation to perform, e.g. MUTT_PAT_SCORE.
Definition: private.h:66
A simple (non-regex) pattern.
Definition: lib.h:76
Regular expression representing a range.
Definition: private.h:77
int lgrp
Paren group matching the left side.
Definition: private.h:79
int rgrp
Paren group matching the right side.
Definition: private.h:80
regex_t cooked
Compiled form.
Definition: private.h:82
bool ready
Compiled yet?
Definition: private.h:81
const char * raw
Regex as string.
Definition: private.h:78