NeoMutt  2021-10-29-33-g41675a
Teaching an old dog new tricks
DOXYGEN
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 "config.h"
27 #include <stdbool.h>
28 #include "mutt/lib.h"
29 #include "lib.h"
30 
37 {
44 };
45 
50 {
51  int tag;
52  int op;
54 
55  enum PatternEat eat_arg;
56  char *desc;
57 };
58 
62 struct RangeRegex
63 {
64  const char *raw;
65  int lgrp;
66  int rgrp;
67  bool ready;
68  regex_t cooked;
69 };
70 
75 {
81  /* add new ones HERE */
83 };
84 
85 /* The regexes in a modern format */
86 #define RANGE_NUM_RX "([[:digit:]]+|0x[[:xdigit:]]+)[MmKk]?"
87 #define RANGE_REL_SLOT_RX "[[:blank:]]*([.^$]|-?" RANGE_NUM_RX ")?[[:blank:]]*"
88 #define RANGE_REL_RX "^" RANGE_REL_SLOT_RX "," RANGE_REL_SLOT_RX
89 
90 /* Almost the same, but no negative numbers allowed */
91 #define RANGE_ABS_SLOT_RX "[[:blank:]]*([.^$]|" RANGE_NUM_RX ")?[[:blank:]]*"
92 #define RANGE_ABS_RX "^" RANGE_ABS_SLOT_RX "-" RANGE_ABS_SLOT_RX
93 
94 /* First group is intentionally empty */
95 #define RANGE_LT_RX "^()[[:blank:]]*(<[[:blank:]]*" RANGE_NUM_RX ")[[:blank:]]*"
96 #define RANGE_GT_RX "^()[[:blank:]]*(>[[:blank:]]*" RANGE_NUM_RX ")[[:blank:]]*"
97 
98 /* Single group for min and max */
99 #define RANGE_BARE_RX "^[[:blank:]]*([.^$]|" RANGE_NUM_RX ")[[:blank:]]*"
100 #define RANGE_RX_GROUPS 5
101 
102 #define RANGE_DOT '.'
103 #define RANGE_CIRCUM '^'
104 #define RANGE_DOLLAR '$'
105 #define RANGE_LT '<'
106 #define RANGE_GT '>'
107 
112 {
115 };
116 
117 #define EMSG(e) (((e)->msgno) + 1)
118 
119 #define MUTT_MAXRANGE -1
120 
121 extern struct RangeRegex RangeRegexes[];
122 extern const struct PatternFlags Flags[];
123 
124 const struct PatternFlags *lookup_op(int op);
125 const struct PatternFlags *lookup_tag(char tag);
126 bool eval_date_minmax(struct Pattern *pat, const char *s, struct Buffer *err);
127 
128 #endif /* MUTT_PATTERN_PRIVATE_H */
Convenience wrapper for the library headers.
uint8_t PatternCompFlags
Flags for mutt_pattern_comp(), e.g. MUTT_PC_FULL_MSG.
Definition: lib.h:59
RangeSide
Which side of the range.
Definition: private.h:112
@ RANGE_S_LEFT
Left side of range.
Definition: private.h:113
@ RANGE_S_RIGHT
Right side of range.
Definition: private.h:114
bool eval_date_minmax(struct Pattern *pat, const char *s, struct Buffer *err)
Evaluate a date-range pattern against 'now'.
Definition: compile.c:499
PatternEat
Function to process pattern arguments.
Definition: private.h:37
@ EAT_NONE
No arguments required.
Definition: private.h:38
@ EAT_RANGE
Process a number (range)
Definition: private.h:41
@ EAT_MESSAGE_RANGE
Process a message number (range)
Definition: private.h:42
@ EAT_DATE
Process a date (range)
Definition: private.h:40
@ EAT_QUERY
Process a query string.
Definition: private.h:43
@ EAT_REGEX
Process a regex.
Definition: private.h:39
const struct PatternFlags Flags[]
Lookup table for all patterns.
Definition: flags.c:40
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:210
const struct PatternFlags * lookup_tag(char tag)
Lookup a pattern modifier.
Definition: flags.c:197
RangeType
Type of range.
Definition: private.h:75
@ RANGE_K_REL
Relative range.
Definition: private.h:76
@ RANGE_K_ABS
Absolute range.
Definition: private.h:77
@ RANGE_K_LT
Less-than range.
Definition: private.h:78
@ RANGE_K_INVALID
Range is invalid.
Definition: private.h:82
@ RANGE_K_BARE
Single symbol.
Definition: private.h:80
@ RANGE_K_GT
Greater-than range.
Definition: private.h:79
Key value store.
String manipulation buffer.
Definition: buffer.h:34
Mapping between user character and internal constant.
Definition: private.h:50
enum PatternEat eat_arg
Type of function needed to parse flag, e.g. EAT_DATE.
Definition: private.h:55
int tag
Character used to represent this operation, e.g. 'A' for '~A'.
Definition: private.h:51
char * desc
Description of flag.
Definition: private.h:56
PatternCompFlags flags
Pattern flags, e.g. MUTT_PC_FULL_MSG.
Definition: private.h:53
int op
Operation to perform, e.g. MUTT_PAT_SCORE.
Definition: private.h:52
A simple (non-regex) pattern.
Definition: lib.h:69
Regular expression representing a range.
Definition: private.h:63
int lgrp
Paren group matching the left side.
Definition: private.h:65
int rgrp
Paren group matching the right side.
Definition: private.h:66
regex_t cooked
Compiled form.
Definition: private.h:68
bool ready
Compiled yet?
Definition: private.h:67
const char * raw
Regex as string.
Definition: private.h:64