NeoMutt  2021-02-05-89-gabe350
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 
31 struct Buffer;
32 struct Pattern;
33 
40 {
47 };
48 
53 {
54  int tag;
55  int op;
57 
59  char *desc;
60 };
61 
65 struct RangeRegex
66 {
67  const char *raw;
68  int lgrp;
69  int rgrp;
70  bool ready;
71  regex_t cooked;
72 };
73 
78 {
84  /* add new ones HERE */
86 };
87 
88 /* The regexes in a modern format */
89 #define RANGE_NUM_RX "([[:digit:]]+|0x[[:xdigit:]]+)[MmKk]?"
90 #define RANGE_REL_SLOT_RX "[[:blank:]]*([.^$]|-?" RANGE_NUM_RX ")?[[:blank:]]*"
91 #define RANGE_REL_RX "^" RANGE_REL_SLOT_RX "," RANGE_REL_SLOT_RX
92 
93 /* Almost the same, but no negative numbers allowed */
94 #define RANGE_ABS_SLOT_RX "[[:blank:]]*([.^$]|" RANGE_NUM_RX ")?[[:blank:]]*"
95 #define RANGE_ABS_RX "^" RANGE_ABS_SLOT_RX "-" RANGE_ABS_SLOT_RX
96 
97 /* First group is intentionally empty */
98 #define RANGE_LT_RX "^()[[:blank:]]*(<[[:blank:]]*" RANGE_NUM_RX ")[[:blank:]]*"
99 #define RANGE_GT_RX "^()[[:blank:]]*(>[[:blank:]]*" RANGE_NUM_RX ")[[:blank:]]*"
100 
101 /* Single group for min and max */
102 #define RANGE_BARE_RX "^[[:blank:]]*([.^$]|" RANGE_NUM_RX ")[[:blank:]]*"
103 #define RANGE_RX_GROUPS 5
104 
105 #define RANGE_DOT '.'
106 #define RANGE_CIRCUM '^'
107 #define RANGE_DOLLAR '$'
108 #define RANGE_LT '<'
109 #define RANGE_GT '>'
110 
115 {
118 };
119 
120 #define EMSG(e) (((e)->msgno) + 1)
121 
122 #define MUTT_MAXRANGE -1
123 
124 extern struct RangeRegex range_regexes[];
125 extern const struct PatternFlags Flags[];
126 
127 extern char *C_ExternalSearchCommand;
128 extern char *C_PatternFormat;
129 
130 const struct PatternFlags *lookup_op(int op);
131 const struct PatternFlags *lookup_tag(char tag);
132 bool eval_date_minmax(struct Pattern *pat, const char *s, struct Buffer *err);
133 
134 #endif /* MUTT_PATTERN_PRIVATE_H */
RangeRegex::cooked
regex_t cooked
Compiled form.
Definition: private.h:71
RangeRegex::lgrp
int lgrp
Paren group matching the left side.
Definition: private.h:68
EAT_DATE
@ EAT_DATE
Process a date (range)
Definition: private.h:43
RANGE_K_INVALID
@ RANGE_K_INVALID
Range is invalid.
Definition: private.h:85
PatternEat
PatternEat
Function to process pattern arguments.
Definition: private.h:39
EAT_NONE
@ EAT_NONE
No arguments required.
Definition: private.h:41
Flags
const struct PatternFlags Flags[]
Lookup table for all patterns.
Definition: flags.c:41
PatternFlags::tag
int tag
Character used to represent this operation, e.g. 'A' for '~A'.
Definition: private.h:54
Buffer
String manipulation buffer.
Definition: buffer.h:33
RangeRegex
Regular expression representing a range.
Definition: private.h:65
C_ExternalSearchCommand
char * C_ExternalSearchCommand
Config: External search command.
Definition: config.c:36
lookup_tag
const struct PatternFlags * lookup_tag(char tag)
Lookup a pattern modifier.
Definition: flags.c:197
RangeSide
RangeSide
Which side of the range.
Definition: private.h:114
C_PatternFormat
char * C_PatternFormat
Config: printf-like format string for the pattern completion menu.
Definition: config.c:37
RANGE_K_REL
@ RANGE_K_REL
Relative range.
Definition: private.h:79
PatternCompFlags
uint8_t PatternCompFlags
Flags for mutt_pattern_comp(), e.g. MUTT_PC_FULL_MSG.
Definition: lib.h:63
EAT_RANGE
@ EAT_RANGE
Process a number (range)
Definition: private.h:44
range_regexes
struct RangeRegex range_regexes[]
Set of Regexes for various range types.
Definition: pattern.c:64
PatternFlags::desc
char * desc
Definition: private.h:59
lib.h
RANGE_K_ABS
@ RANGE_K_ABS
Absolute range.
Definition: private.h:80
PatternFlags::eat_arg
enum PatternEat eat_arg
Definition: private.h:58
RANGE_K_BARE
@ RANGE_K_BARE
Single symbol.
Definition: private.h:83
EAT_REGEX
@ EAT_REGEX
Process a regex.
Definition: private.h:42
RangeRegex::raw
const char * raw
Regex as string.
Definition: private.h:67
lookup_op
const struct PatternFlags * lookup_op(int op)
Lookup the Pattern Flags for an op.
Definition: flags.c:210
eval_date_minmax
bool eval_date_minmax(struct Pattern *pat, const char *s, struct Buffer *err)
Evaluate a date-range pattern against 'now'.
Definition: compile.c:498
PatternFlags::op
int op
Operation to perform, e.g. MUTT_PAT_SCORE.
Definition: private.h:55
PatternFlags::flags
PatternCompFlags flags
Pattern flags, e.g. MUTT_PC_FULL_MSG.
Definition: private.h:56
EAT_MESSAGE_RANGE
@ EAT_MESSAGE_RANGE
Process a message number (range)
Definition: private.h:45
EAT_QUERY
@ EAT_QUERY
Process a query string.
Definition: private.h:46
RANGE_K_LT
@ RANGE_K_LT
Less-than range.
Definition: private.h:81
RangeType
RangeType
Type of range.
Definition: private.h:77
RANGE_K_GT
@ RANGE_K_GT
Greater-than range.
Definition: private.h:82
RangeRegex::ready
bool ready
Compiled yet?
Definition: private.h:70
RangeRegex::rgrp
int rgrp
Paren group matching the right side.
Definition: private.h:69
PatternFlags
Mapping between user character and internal constant.
Definition: private.h:52
Pattern
A simple (non-regex) pattern.
Definition: lib.h:72
RANGE_S_RIGHT
@ RANGE_S_RIGHT
Right side of range.
Definition: private.h:117
RANGE_S_LEFT
@ RANGE_S_LEFT
Left side of range.
Definition: private.h:116