NeoMutt  2024-12-12-19-ge4b57e
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
prex.h File Reference

Manage precompiled / predefined regular expressions. More...

#include <regex.h>
+ Include dependency graph for prex.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Enumerations

enum  Prex {
  PREX_URL , PREX_URL_QUERY_KEY_VAL , PREX_RFC2047_ENCODED_WORD , PREX_GNUTLS_CERT_HOST_HASH ,
  PREX_RFC5322_DATE_LAX , PREX_IMAP_DATE , PREX_MBOX_FROM , PREX_MBOX_FROM_LAX ,
  PREX_ACCOUNT_CMD , PREX_ALIAS_TAGS , PREX_MAX
}
 Predefined list of regular expressions. More...
 
enum  PrexUrlSchemeMatch {
  PREX_URL_MATCH_FULL , PREX_URL_MATCH_SCHEME , PREX_URL_MATCH_REST , PREX_URL_MATCH_AUTH_OR_PATH ,
  PREX_URL_MATCH_AUTHORITY_PATH , PREX_URL_MATCH_USERINFO , PREX_URL_MATCH_USER , PREX_URL_MATCH_COLONPASS ,
  PREX_URL_MATCH_PASS , PREX_URL_MATCH_HOST , PREX_URL_MATCH_HOSTNAME , PREX_URL_MATCH_HOSTIPVX ,
  PREX_URL_MATCH_COLONPORT , PREX_URL_MATCH_PORT , PREX_URL_MATCH_SLASHPATH , PREX_URL_MATCH_PATH ,
  PREX_URL_MATCH_PATH_ONLY , PREX_URL_MATCH_QUESTIONQUERY , PREX_URL_MATCH_QUERY , PREX_URL_MATCH_MAX
}
 Regex Matches for PREX_URL. More...
 
enum  PrexUrlQueryKeyValMatch { PREX_URL_QUERY_KEY_VAL_MATCH_FULL , PREX_URL_QUERY_KEY_VAL_MATCH_KEY , PREX_URL_QUERY_KEY_VAL_MATCH_VAL , PREX_URL_QUERY_KEY_VAL_MATCH_MAX }
 Regex Matches for PREX_URL_QUERY_KEY_VAL. More...
 
enum  PrexRfc2047EncodedWordMatch {
  PREX_RFC2047_ENCODED_WORD_MATCH_FULL , PREX_RFC2047_ENCODED_WORD_MATCH_CHARSET , PREX_RFC2047_ENCODED_WORD_MATCH_ENCODING , PREX_RFC2047_ENCODED_WORD_MATCH_TEXT ,
  PREX_RFC2047_ENCODED_WORD_MATCH_MAX
}
 Regex Matches for PREX_RFC2047_ENCODED_WORD. More...
 
enum  PrexGnuTlsCertHostnameMatch {
  PREX_GNUTLS_CERT_HOST_HASH_MATCH_FULL , PREX_GNUTLS_CERT_HOST_HASH_MATCH_HOST , PREX_GNUTLS_CERT_HOST_HASH_MATCH_HASH , PREX_GNUTLS_CERT_HOST_HASH_MATCH_HASH_LAST ,
  PREX_GNUTLS_CERT_HOST_HASH_MATCH_MAX
}
 Regex Matches for a TLS Certificate Hostname. More...
 
enum  PrexRfc5322DateLax {
  PREX_RFC5322_DATE_LAX_MATCH_FULL , PREX_RFC5322_DATE_LAX_MATCH_CFWS1 , PREX_RFC5322_DATE_LAX_MATCH_MAYBE_DOW , PREX_RFC5322_DATE_LAX_MATCH_DOW ,
  PREX_RFC5322_DATE_LAX_MATCH_CFWS2 , PREX_RFC5322_DATE_LAX_MATCH_CFWS3 , PREX_RFC5322_DATE_LAX_MATCH_DAY , PREX_RFC5322_DATE_LAX_MATCH_CFWS4 ,
  PREX_RFC5322_DATE_LAX_MATCH_MONTH , PREX_RFC5322_DATE_LAX_MATCH_CFWS5 , PREX_RFC5322_DATE_LAX_MATCH_YEAR , PREX_RFC5322_DATE_LAX_MATCH_CFWS6 ,
  PREX_RFC5322_DATE_LAX_MATCH_HOUR , PREX_RFC5322_DATE_LAX_MATCH_CFWS7 , PREX_RFC5322_DATE_LAX_MATCH_MINUTE , PREX_RFC5322_DATE_LAX_MATCH_CFWS8 ,
  PREX_RFC5322_DATE_LAX_MATCH_COLONSECOND , PREX_RFC5322_DATE_LAX_MATCH_CFWS9 , PREX_RFC5322_DATE_LAX_MATCH_SECOND , PREX_RFC5322_DATE_LAX_MATCH_CFWS10 ,
  PREX_RFC5322_DATE_LAX_MATCH_TZFULL , PREX_RFC5322_DATE_LAX_MATCH_TZ , PREX_RFC5322_DATE_LAX_MATCH_TZ_OBS , PREX_RFC5322_DATE_LAX_MATCH_MAX
}
 Regex Matches for a RFC5322 date, including obsolete comments in parentheses. More...
 
enum  PrexImapDate {
  PREX_IMAP_DATE_MATCH_FULL , PREX_IMAP_DATE_MATCH_DAY , PREX_IMAP_DATE_MATCH_DAY1 , PREX_IMAP_DATE_MATCH_DAY2 ,
  PREX_IMAP_DATE_MATCH_MONTH , PREX_IMAP_DATE_MATCH_YEAR , PREX_IMAP_DATE_MATCH_TIME , PREX_IMAP_DATE_MATCH_TZ ,
  PREX_IMAP_DATE_MATCH_MAX
}
 Regex matches for an IMAP INTERNALDATE More...
 
enum  PrexMboxFrom {
  PREX_MBOX_FROM_MATCH_FULL , PREX_MBOX_FROM_MATCH_ENVSENDER , PREX_MBOX_FROM_MATCH_DOW , PREX_MBOX_FROM_MATCH_MONTH ,
  PREX_MBOX_FROM_MATCH_DAY , PREX_MBOX_FROM_MATCH_DAY1 , PREX_MBOX_FROM_MATCH_DAY2 , PREX_MBOX_FROM_MATCH_TIME ,
  PREX_MBOX_FROM_MATCH_YEAR , PREX_MBOX_FROM_MATCH_MAX
}
 Regex matches for an mbox-style From line. More...
 
enum  PrexMboxFromLax {
  PREX_MBOX_FROM_LAX_MATCH_FULL , PREX_MBOX_FROM_LAX_MATCH_ENVSENDER , PREX_MBOX_FROM_LAX_MATCH_ENVSENDER_PIPER , PREX_MBOX_FROM_LAX_MATCH_DOW ,
  PREX_MBOX_FROM_LAX_MATCH_MONTH , PREX_MBOX_FROM_LAX_MATCH_DAY , PREX_MBOX_FROM_LAX_MATCH_DAY1 , PREX_MBOX_FROM_LAX_MATCH_DAY2 ,
  PREX_MBOX_FROM_LAX_MATCH_TIME , PREX_MBOX_FROM_LAX_MATCH_TIME_SEC , PREX_MBOX_FROM_LAX_MATCH_TIME_NOSEC , PREX_MBOX_FROM_LAX_MATCH_TZ ,
  PREX_MBOX_FROM_LAX_MATCH_TZ1 , PREX_MBOX_FROM_LAX_MATCH_TZ2 , PREX_MBOX_FROM_LAX_MATCH_YEAR , PREX_MBOX_FROM_LAX_MATCH_YEAR_4DIG ,
  PREX_MBOX_FROM_LAX_MATCH_YEAR_2DIG , PREX_MBOX_FROM_LAX_MATCH_MAX
}
 Regex matches for an mbox-style From line, lax mode. More...
 
enum  PrexAccountCmd { PREX_ACCOUNT_CMD_MATCH_FULL , PREX_ACCOUNT_CMD_MATCH_KEY , PREX_ACCOUNT_CMD_MATCH_VALUE , PREX_ACCOUNT_CMD_MATCH_MAX }
 Regex matches for the output lines of account_command. More...
 
enum  PrexAliasTags {
  PREX_ALIAS_TAGS_MATCH_FULL , PREX_ALIAS_TAGS_MATCH_PRE , PREX_ALIAS_TAGS_MATCH_KEY , PREX_ALIAS_TAGS_MATCH_TAGS ,
  PREX_ALIAS_TAGS_MATCH_POST , PREX_ALIAS_TAGS_MATCH_MAX
}
 Regex matches for the tags: field of an alias command. More...
 

Functions

regmatch_t * mutt_prex_capture (enum Prex which, const char *str)
 Match a precompiled regex against a string.
 
void mutt_prex_cleanup (void)
 Cleanup heap memory allocated by compiled regexes.
 

Detailed Description

Manage precompiled / predefined regular expressions.

Authors
  • Pietro Cerutti
  • Richard Russon

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 prex.h.

Enumeration Type Documentation

◆ Prex

enum Prex

Predefined list of regular expressions.

Enumerator
PREX_URL 

[imaps://user:pass@example.com/INBOX?foo=bar]

PREX_URL_QUERY_KEY_VAL 

https://example.com/?[q=foo]

PREX_RFC2047_ENCODED_WORD 

[=?utf-8?Q?=E8=81=AA=E6=98=8E=E7=9A=84?=]

PREX_GNUTLS_CERT_HOST_HASH 

[#H foo.com A76D 954B EB79 1F49 5B3A 0A0E 0681 65B1]

PREX_RFC5322_DATE_LAX 

[Mon, (Comment) 16 Mar 2020 15:09:35 -0700]

PREX_IMAP_DATE 

[16-MAR-2020 15:09:35 -0700]

PREX_MBOX_FROM 

[From god@heaven.af.mil Sat Jan 3 01:05:34 1996]

PREX_MBOX_FROM_LAX 

[From god@heaven.af.mil Sat Jan 3 01:05:34 1996]

PREX_ACCOUNT_CMD 

key: value

PREX_ALIAS_TAGS 

tags:a,b,c

PREX_MAX 

Definition at line 32 of file prex.h.

33{
34 PREX_URL,
45};
@ PREX_GNUTLS_CERT_HOST_HASH
[#H foo.com A76D 954B EB79 1F49 5B3A 0A0E 0681 65B1]
Definition: prex.h:37
@ PREX_MBOX_FROM_LAX
[From god@heaven.af.mil Sat Jan 3 01:05:34 1996]
Definition: prex.h:41
@ PREX_URL
[imaps://user:pass@example.com/INBOX?foo=bar]
Definition: prex.h:34
@ PREX_MBOX_FROM
[From god@heaven.af.mil Sat Jan 3 01:05:34 1996]
Definition: prex.h:40
@ PREX_ACCOUNT_CMD
key: value
Definition: prex.h:42
@ PREX_ALIAS_TAGS
tags:a,b,c
Definition: prex.h:43
@ PREX_IMAP_DATE
[16-MAR-2020 15:09:35 -0700]
Definition: prex.h:39
@ PREX_RFC5322_DATE_LAX
[Mon, (Comment) 16 Mar 2020 15:09:35 -0700]
Definition: prex.h:38
@ PREX_URL_QUERY_KEY_VAL
https://example.com/?[q=foo]
Definition: prex.h:35
@ PREX_MAX
Definition: prex.h:44
@ PREX_RFC2047_ENCODED_WORD
[=?utf-8?Q?=E8=81=AA=E6=98=8E=E7=9A=84?=]
Definition: prex.h:36

◆ PrexUrlSchemeMatch

Regex Matches for PREX_URL.

Note
The []s show the matching path of the URL
Enumerator
PREX_URL_MATCH_FULL 

[imaps://user:pass@host.comInbox?foo=bar]

PREX_URL_MATCH_SCHEME 

[imaps]://...

PREX_URL_MATCH_REST 

imaps:[//...]

PREX_URL_MATCH_AUTH_OR_PATH 

imaps:[somepath]|[//me@example.com/Inbox]?foo=bar

PREX_URL_MATCH_AUTHORITY_PATH 

imaps:[//me@example.com/Inbox]?foo=bar

PREX_URL_MATCH_USERINFO 

...//[user:pass@]...

PREX_URL_MATCH_USER 

...//[user]:pass@...

PREX_URL_MATCH_COLONPASS 

...//user[:pass]@...

PREX_URL_MATCH_PASS 

...//user:[pass]@...

PREX_URL_MATCH_HOST 

imaps://...[host.com]...

PREX_URL_MATCH_HOSTNAME 

imaps://...[host.com]...

PREX_URL_MATCH_HOSTIPVX 

imaps://...[127.0.0.1]...

PREX_URL_MATCH_COLONPORT 

imaps://host.com[:993]/...

PREX_URL_MATCH_PORT 

imaps://host.com:[993]/...

PREX_URL_MATCH_SLASHPATH 

...:993[/Inbox]

PREX_URL_MATCH_PATH 

...:993/[Inbox]

PREX_URL_MATCH_PATH_ONLY 

mailto:[me@example.com]?foo=bar

PREX_URL_MATCH_QUESTIONQUERY 

...Inbox[?foo=bar&baz=value]

PREX_URL_MATCH_QUERY 

...Inbox?[foo=bar&baz=value]

PREX_URL_MATCH_MAX 

Definition at line 52 of file prex.h.

53{
74};
@ PREX_URL_MATCH_HOST
imaps://...[host.com]...
Definition: prex.h:63
@ PREX_URL_MATCH_REST
imaps:[//...]
Definition: prex.h:56
@ PREX_URL_MATCH_USER
...//[user]:pass@...
Definition: prex.h:60
@ PREX_URL_MATCH_SLASHPATH
...:993[/Inbox]
Definition: prex.h:68
@ PREX_URL_MATCH_FULL
[imaps://user:pass@host.comInbox?foo=bar]
Definition: prex.h:54
@ PREX_URL_MATCH_COLONPASS
...//user[:pass]@...
Definition: prex.h:61
@ PREX_URL_MATCH_QUERY
...Inbox?[foo=bar&baz=value]
Definition: prex.h:72
@ PREX_URL_MATCH_QUESTIONQUERY
...Inbox[?foo=bar&baz=value]
Definition: prex.h:71
@ PREX_URL_MATCH_HOSTNAME
imaps://...[host.com]...
Definition: prex.h:64
@ PREX_URL_MATCH_AUTHORITY_PATH
imaps:[//me@example.com/Inbox]?foo=bar
Definition: prex.h:58
@ PREX_URL_MATCH_PORT
imaps://host.com:[993]/...
Definition: prex.h:67
@ PREX_URL_MATCH_PATH_ONLY
mailto:[me@example.com]?foo=bar
Definition: prex.h:70
@ PREX_URL_MATCH_SCHEME
[imaps]://...
Definition: prex.h:55
@ PREX_URL_MATCH_USERINFO
...//[user:pass@]...
Definition: prex.h:59
@ PREX_URL_MATCH_PATH
...:993/[Inbox]
Definition: prex.h:69
@ PREX_URL_MATCH_HOSTIPVX
imaps://...[127.0.0.1]...
Definition: prex.h:65
@ PREX_URL_MATCH_COLONPORT
imaps://host.com[:993]/...
Definition: prex.h:66
@ PREX_URL_MATCH_PASS
...//user:[pass]@...
Definition: prex.h:62
@ PREX_URL_MATCH_AUTH_OR_PATH
imaps:[somepath]|[//me@example.com/Inbox]?foo=bar
Definition: prex.h:57
@ PREX_URL_MATCH_MAX
Definition: prex.h:73

◆ PrexUrlQueryKeyValMatch

Regex Matches for PREX_URL_QUERY_KEY_VAL.

Note
The []s show the matching path of the URL Query
Enumerator
PREX_URL_QUERY_KEY_VAL_MATCH_FULL 

[key=val]

PREX_URL_QUERY_KEY_VAL_MATCH_KEY 

[key]=val

PREX_URL_QUERY_KEY_VAL_MATCH_VAL 

key=[val]

PREX_URL_QUERY_KEY_VAL_MATCH_MAX 

Definition at line 81 of file prex.h.

82{
87};
@ PREX_URL_QUERY_KEY_VAL_MATCH_VAL
key=[val]
Definition: prex.h:85
@ PREX_URL_QUERY_KEY_VAL_MATCH_FULL
[key=val]
Definition: prex.h:83
@ PREX_URL_QUERY_KEY_VAL_MATCH_MAX
Definition: prex.h:86
@ PREX_URL_QUERY_KEY_VAL_MATCH_KEY
[key]=val
Definition: prex.h:84

◆ PrexRfc2047EncodedWordMatch

Regex Matches for PREX_RFC2047_ENCODED_WORD.

Note
The []s show the matching path of the RFC2047-encoded word
Enumerator
PREX_RFC2047_ENCODED_WORD_MATCH_FULL 

[=?utf-8?Q?=E8=81...?=]

PREX_RFC2047_ENCODED_WORD_MATCH_CHARSET 

=?[utf-8]?Q?=E8=81...?=

PREX_RFC2047_ENCODED_WORD_MATCH_ENCODING 

=?utf-8?[Q]?=E8=81...?=

PREX_RFC2047_ENCODED_WORD_MATCH_TEXT 

=?utf-8?Q?[=E8=81...]?=

PREX_RFC2047_ENCODED_WORD_MATCH_MAX 

Definition at line 94 of file prex.h.

95{
101};
@ PREX_RFC2047_ENCODED_WORD_MATCH_ENCODING
=?utf-8?[Q]?=E8=81...?=
Definition: prex.h:98
@ PREX_RFC2047_ENCODED_WORD_MATCH_TEXT
=?utf-8?Q?[=E8=81...]?=
Definition: prex.h:99
@ PREX_RFC2047_ENCODED_WORD_MATCH_CHARSET
=?[utf-8]?Q?=E8=81...?=
Definition: prex.h:97
@ PREX_RFC2047_ENCODED_WORD_MATCH_FULL
[=?utf-8?Q?=E8=81...?=]
Definition: prex.h:96
@ PREX_RFC2047_ENCODED_WORD_MATCH_MAX
Definition: prex.h:100

◆ PrexGnuTlsCertHostnameMatch

Regex Matches for a TLS Certificate Hostname.

Note
The []s show the matching path of the TLS Certificate Hostname
Enumerator
PREX_GNUTLS_CERT_HOST_HASH_MATCH_FULL 

[#H foo.com A76D ... 65B1]

PREX_GNUTLS_CERT_HOST_HASH_MATCH_HOST 

#H [foo.com] A76D ... 65B1

PREX_GNUTLS_CERT_HOST_HASH_MATCH_HASH 

#H foo.com [A76D ... 65B1]

PREX_GNUTLS_CERT_HOST_HASH_MATCH_HASH_LAST 

#H foo.com A76D ... [65B1]

PREX_GNUTLS_CERT_HOST_HASH_MATCH_MAX 

Definition at line 108 of file prex.h.

109{
115};
@ PREX_GNUTLS_CERT_HOST_HASH_MATCH_HASH_LAST
#H foo.com A76D ... [65B1]
Definition: prex.h:113
@ PREX_GNUTLS_CERT_HOST_HASH_MATCH_MAX
Definition: prex.h:114
@ PREX_GNUTLS_CERT_HOST_HASH_MATCH_FULL
[#H foo.com A76D ... 65B1]
Definition: prex.h:110
@ PREX_GNUTLS_CERT_HOST_HASH_MATCH_HASH
#H foo.com [A76D ... 65B1]
Definition: prex.h:112
@ PREX_GNUTLS_CERT_HOST_HASH_MATCH_HOST
#H [foo.com] A76D ... 65B1
Definition: prex.h:111

◆ PrexRfc5322DateLax

Regex Matches for a RFC5322 date, including obsolete comments in parentheses.

The reason we provide a regex for RFC5322 dates is that the regular parser is faster, while this one is more complete.

Note
The []s show the matching path of the RFC5322 date
The *_CFWS* constants match ()d comments with whitespace
Enumerator
PREX_RFC5322_DATE_LAX_MATCH_FULL 

[Mon, 2 Mar 2020 14:32:55 +0200]

PREX_RFC5322_DATE_LAX_MATCH_CFWS1 
PREX_RFC5322_DATE_LAX_MATCH_MAYBE_DOW 

[Mon, ]2 Mar 2020 14:32:55 +0200

PREX_RFC5322_DATE_LAX_MATCH_DOW 

[Mon], 2 Mar 2020 14:32:55 +0200

PREX_RFC5322_DATE_LAX_MATCH_CFWS2 
PREX_RFC5322_DATE_LAX_MATCH_CFWS3 
PREX_RFC5322_DATE_LAX_MATCH_DAY 

Tue, [3] Mar 2020 14:32:55 +0200

PREX_RFC5322_DATE_LAX_MATCH_CFWS4 
PREX_RFC5322_DATE_LAX_MATCH_MONTH 

Tue, 3 [Jan] 2020 14:32:55 +0200

PREX_RFC5322_DATE_LAX_MATCH_CFWS5 
PREX_RFC5322_DATE_LAX_MATCH_YEAR 

Tue, 3 Mar [2020] 14:32:55 +0200

PREX_RFC5322_DATE_LAX_MATCH_CFWS6 
PREX_RFC5322_DATE_LAX_MATCH_HOUR 

Tue, 3 Mar 2020 [14]:32:55 +0200

PREX_RFC5322_DATE_LAX_MATCH_CFWS7 
PREX_RFC5322_DATE_LAX_MATCH_MINUTE 

Tue, 3 Mar 2020 14:[32]:55 +0200

PREX_RFC5322_DATE_LAX_MATCH_CFWS8 
PREX_RFC5322_DATE_LAX_MATCH_COLONSECOND 

Tue, 3 Mar 2020 14:32[:55] +0200

PREX_RFC5322_DATE_LAX_MATCH_CFWS9 
PREX_RFC5322_DATE_LAX_MATCH_SECOND 

Tue, 3 Mar 2020 14:32:[55] +0200

PREX_RFC5322_DATE_LAX_MATCH_CFWS10 
PREX_RFC5322_DATE_LAX_MATCH_TZFULL 

Tue, 3 Mar 2020 14:32:55[CET]

PREX_RFC5322_DATE_LAX_MATCH_TZ 

Tue, 3 Mar 2020 14:32:55 [+0200]

PREX_RFC5322_DATE_LAX_MATCH_TZ_OBS 

Tue, 3 Mar 2020 14:32:55[UT]

PREX_RFC5322_DATE_LAX_MATCH_MAX 

Definition at line 127 of file prex.h.

128{
153};
@ PREX_RFC5322_DATE_LAX_MATCH_CFWS7
Definition: prex.h:142
@ PREX_RFC5322_DATE_LAX_MATCH_SECOND
Tue, 3 Mar 2020 14:32:[55] +0200
Definition: prex.h:147
@ PREX_RFC5322_DATE_LAX_MATCH_CFWS5
Definition: prex.h:138
@ PREX_RFC5322_DATE_LAX_MATCH_MAYBE_DOW
[Mon, ]2 Mar 2020 14:32:55 +0200
Definition: prex.h:131
@ PREX_RFC5322_DATE_LAX_MATCH_CFWS3
Definition: prex.h:134
@ PREX_RFC5322_DATE_LAX_MATCH_TZFULL
Tue, 3 Mar 2020 14:32:55[CET]
Definition: prex.h:149
@ PREX_RFC5322_DATE_LAX_MATCH_CFWS1
Definition: prex.h:130
@ PREX_RFC5322_DATE_LAX_MATCH_TZ
Tue, 3 Mar 2020 14:32:55 [+0200]
Definition: prex.h:150
@ PREX_RFC5322_DATE_LAX_MATCH_CFWS4
Definition: prex.h:136
@ PREX_RFC5322_DATE_LAX_MATCH_CFWS9
Definition: prex.h:146
@ PREX_RFC5322_DATE_LAX_MATCH_COLONSECOND
Tue, 3 Mar 2020 14:32[:55] +0200
Definition: prex.h:145
@ PREX_RFC5322_DATE_LAX_MATCH_YEAR
Tue, 3 Mar [2020] 14:32:55 +0200
Definition: prex.h:139
@ PREX_RFC5322_DATE_LAX_MATCH_HOUR
Tue, 3 Mar 2020 [14]:32:55 +0200
Definition: prex.h:141
@ PREX_RFC5322_DATE_LAX_MATCH_CFWS2
Definition: prex.h:133
@ PREX_RFC5322_DATE_LAX_MATCH_DOW
[Mon], 2 Mar 2020 14:32:55 +0200
Definition: prex.h:132
@ PREX_RFC5322_DATE_LAX_MATCH_FULL
[Mon, 2 Mar 2020 14:32:55 +0200]
Definition: prex.h:129
@ PREX_RFC5322_DATE_LAX_MATCH_MINUTE
Tue, 3 Mar 2020 14:[32]:55 +0200
Definition: prex.h:143
@ PREX_RFC5322_DATE_LAX_MATCH_MAX
Definition: prex.h:152
@ PREX_RFC5322_DATE_LAX_MATCH_CFWS8
Definition: prex.h:144
@ PREX_RFC5322_DATE_LAX_MATCH_CFWS10
Definition: prex.h:148
@ PREX_RFC5322_DATE_LAX_MATCH_TZ_OBS
Tue, 3 Mar 2020 14:32:55[UT]
Definition: prex.h:151
@ PREX_RFC5322_DATE_LAX_MATCH_CFWS6
Definition: prex.h:140
@ PREX_RFC5322_DATE_LAX_MATCH_MONTH
Tue, 3 [Jan] 2020 14:32:55 +0200
Definition: prex.h:137
@ PREX_RFC5322_DATE_LAX_MATCH_DAY
Tue, [3] Mar 2020 14:32:55 +0200
Definition: prex.h:135

◆ PrexImapDate

Regex matches for an IMAP INTERNALDATE

Note
The []s show the matching path of the IMAP date
Enumerator
PREX_IMAP_DATE_MATCH_FULL 

[16-MAR-2020 15:09:35 -0700]

PREX_IMAP_DATE_MATCH_DAY 

[ 4]-MAR-2020 15:09:35 -0700

PREX_IMAP_DATE_MATCH_DAY1 

[4]-MAR-2020 15:09:35 -0700

PREX_IMAP_DATE_MATCH_DAY2 

[15]-MAR-2020 15:09:35 -0700

PREX_IMAP_DATE_MATCH_MONTH 

15-[MAR]-2020 15:09:35 -0700

PREX_IMAP_DATE_MATCH_YEAR 

15-MAR-[2020] 15:09:35 -0700

PREX_IMAP_DATE_MATCH_TIME 

15-MAR-2020 [15:09:35] -0700

PREX_IMAP_DATE_MATCH_TZ 

15-MAR-2020 15:09:35 [-0700]

PREX_IMAP_DATE_MATCH_MAX 

Definition at line 160 of file prex.h.

161{
171};
@ PREX_IMAP_DATE_MATCH_TIME
15-MAR-2020 [15:09:35] -0700
Definition: prex.h:168
@ PREX_IMAP_DATE_MATCH_MAX
Definition: prex.h:170
@ PREX_IMAP_DATE_MATCH_YEAR
15-MAR-[2020] 15:09:35 -0700
Definition: prex.h:167
@ PREX_IMAP_DATE_MATCH_DAY
[ 4]-MAR-2020 15:09:35 -0700
Definition: prex.h:163
@ PREX_IMAP_DATE_MATCH_TZ
15-MAR-2020 15:09:35 [-0700]
Definition: prex.h:169
@ PREX_IMAP_DATE_MATCH_FULL
[16-MAR-2020 15:09:35 -0700]
Definition: prex.h:162
@ PREX_IMAP_DATE_MATCH_MONTH
15-[MAR]-2020 15:09:35 -0700
Definition: prex.h:166
@ PREX_IMAP_DATE_MATCH_DAY1
[4]-MAR-2020 15:09:35 -0700
Definition: prex.h:164
@ PREX_IMAP_DATE_MATCH_DAY2
[15]-MAR-2020 15:09:35 -0700
Definition: prex.h:165

◆ PrexMboxFrom

Regex matches for an mbox-style From line.

Note
The []s show the matching path of the IMAP date
Enumerator
PREX_MBOX_FROM_MATCH_FULL 

[From god@heaven.af.mil Sat Jan 3 01:05:34 1996]

PREX_MBOX_FROM_MATCH_ENVSENDER 

From [god@heaven.af.mil] Sat Jan 3 01:05:34 1996

PREX_MBOX_FROM_MATCH_DOW 

From god@heaven.af.mil [Sat] Jan 3 01:05:34 1996

PREX_MBOX_FROM_MATCH_MONTH 

From god@heaven.af.mil Sat [Jan] 3 01:05:34 1996

PREX_MBOX_FROM_MATCH_DAY 

From god@heaven.af.mil Sat Jan [ 3] 01:05:34 1996

PREX_MBOX_FROM_MATCH_DAY1 

From god@heaven.af.mil Sat Jan [3] 01:05:34 1996

PREX_MBOX_FROM_MATCH_DAY2 

From god@heaven.af.mil Sat Jan [10] 01:05:34 1996

PREX_MBOX_FROM_MATCH_TIME 

From god@heaven.af.mil Sat Jan 10 [01:05:34] 1996

PREX_MBOX_FROM_MATCH_YEAR 

From god@heaven.af.mil Sat Jan 10 01:05:34 [1996]

PREX_MBOX_FROM_MATCH_MAX 

Definition at line 178 of file prex.h.

179{
190};
@ PREX_MBOX_FROM_MATCH_MAX
Definition: prex.h:189
@ PREX_MBOX_FROM_MATCH_DAY2
From god@heaven.af.mil Sat Jan [10] 01:05:34 1996
Definition: prex.h:186
@ PREX_MBOX_FROM_MATCH_DAY
From god@heaven.af.mil Sat Jan [ 3] 01:05:34 1996
Definition: prex.h:184
@ PREX_MBOX_FROM_MATCH_MONTH
From god@heaven.af.mil Sat [Jan] 3 01:05:34 1996
Definition: prex.h:183
@ PREX_MBOX_FROM_MATCH_YEAR
From god@heaven.af.mil Sat Jan 10 01:05:34 [1996]
Definition: prex.h:188
@ PREX_MBOX_FROM_MATCH_DAY1
From god@heaven.af.mil Sat Jan [3] 01:05:34 1996
Definition: prex.h:185
@ PREX_MBOX_FROM_MATCH_DOW
From god@heaven.af.mil [Sat] Jan 3 01:05:34 1996
Definition: prex.h:182
@ PREX_MBOX_FROM_MATCH_FULL
[From god@heaven.af.mil Sat Jan 3 01:05:34 1996]
Definition: prex.h:180
@ PREX_MBOX_FROM_MATCH_ENVSENDER
From [god@heaven.af.mil] Sat Jan 3 01:05:34 1996
Definition: prex.h:181
@ PREX_MBOX_FROM_MATCH_TIME
From god@heaven.af.mil Sat Jan 10 [01:05:34] 1996
Definition: prex.h:187

◆ PrexMboxFromLax

Regex matches for an mbox-style From line, lax mode.

Note
The []s show the matching path of the IMAP date
Enumerator
PREX_MBOX_FROM_LAX_MATCH_FULL 

[From god@heaven.af.mil Sat Jan 3 01:05:34 1996]

PREX_MBOX_FROM_LAX_MATCH_ENVSENDER 

From [god at heaven.af.mil] Sat Jan 3 01:05:34 1996

PREX_MBOX_FROM_LAX_MATCH_ENVSENDER_PIPER 

From [god@heaven.af.mil] Sat Jan 3 01:05:34 1996

PREX_MBOX_FROM_LAX_MATCH_DOW 

From god@heaven.af.mil [Sat] Jan 3 01:05:34 1996

PREX_MBOX_FROM_LAX_MATCH_MONTH 

From god@heaven.af.mil Sat [Jan] 3 01:05:34 1996

PREX_MBOX_FROM_LAX_MATCH_DAY 

From god@heaven.af.mil Sat Jan [ 3] 01:05:34 1996

PREX_MBOX_FROM_LAX_MATCH_DAY1 

From god@heaven.af.mil Sat Jan [3] 01:05:34 1996

PREX_MBOX_FROM_LAX_MATCH_DAY2 

From god@heaven.af.mil Sat Jan [10] 01:05:34 1996

PREX_MBOX_FROM_LAX_MATCH_TIME 

From god@heaven.af.mil Sat Jan 10 [01:05:34] 1996

PREX_MBOX_FROM_LAX_MATCH_TIME_SEC 

From god@heaven.af.mil Sat Jan 10 [01:05:34] 1996

PREX_MBOX_FROM_LAX_MATCH_TIME_NOSEC 

From god@heaven.af.mil Sat Jan 10 [01:05] 1996

PREX_MBOX_FROM_LAX_MATCH_TZ 

From god@heaven.af.mil Sat Jan 10 01:05:34 [MET DST] 1996

PREX_MBOX_FROM_LAX_MATCH_TZ1 

From god@heaven.af.mil Sat Jan 10 01:05:34 [MET DST] 1996

PREX_MBOX_FROM_LAX_MATCH_TZ2 

From god@heaven.af.mil Sat Jan 10 01:05:34 [+0000] 1996

PREX_MBOX_FROM_LAX_MATCH_YEAR 

From god@heaven.af.mil Sat Jan 10 01:05:34 [1996]

PREX_MBOX_FROM_LAX_MATCH_YEAR_4DIG 

From god@heaven.af.mil Sat Jan 10 01:05:34 [1996]

PREX_MBOX_FROM_LAX_MATCH_YEAR_2DIG 

From god@heaven.af.mil Sat Jan 10 01:05:34 [96]

PREX_MBOX_FROM_LAX_MATCH_MAX 

Definition at line 197 of file prex.h.

198{
217};
@ PREX_MBOX_FROM_LAX_MATCH_DAY2
From god@heaven.af.mil Sat Jan [10] 01:05:34 1996
Definition: prex.h:206
@ PREX_MBOX_FROM_LAX_MATCH_MONTH
From god@heaven.af.mil Sat [Jan] 3 01:05:34 1996
Definition: prex.h:203
@ PREX_MBOX_FROM_LAX_MATCH_TIME_SEC
From god@heaven.af.mil Sat Jan 10 [01:05:34] 1996
Definition: prex.h:208
@ PREX_MBOX_FROM_LAX_MATCH_ENVSENDER
From [god at heaven.af.mil] Sat Jan 3 01:05:34 1996
Definition: prex.h:200
@ PREX_MBOX_FROM_LAX_MATCH_DOW
From god@heaven.af.mil [Sat] Jan 3 01:05:34 1996
Definition: prex.h:202
@ PREX_MBOX_FROM_LAX_MATCH_TZ2
From god@heaven.af.mil Sat Jan 10 01:05:34 [+0000] 1996
Definition: prex.h:212
@ PREX_MBOX_FROM_LAX_MATCH_TIME_NOSEC
From god@heaven.af.mil Sat Jan 10 [01:05] 1996
Definition: prex.h:209
@ PREX_MBOX_FROM_LAX_MATCH_ENVSENDER_PIPER
From [god@heaven.af.mil] Sat Jan 3 01:05:34 1996
Definition: prex.h:201
@ PREX_MBOX_FROM_LAX_MATCH_DAY1
From god@heaven.af.mil Sat Jan [3] 01:05:34 1996
Definition: prex.h:205
@ PREX_MBOX_FROM_LAX_MATCH_YEAR_2DIG
From god@heaven.af.mil Sat Jan 10 01:05:34 [96]
Definition: prex.h:215
@ PREX_MBOX_FROM_LAX_MATCH_TIME
From god@heaven.af.mil Sat Jan 10 [01:05:34] 1996
Definition: prex.h:207
@ PREX_MBOX_FROM_LAX_MATCH_DAY
From god@heaven.af.mil Sat Jan [ 3] 01:05:34 1996
Definition: prex.h:204
@ PREX_MBOX_FROM_LAX_MATCH_YEAR
From god@heaven.af.mil Sat Jan 10 01:05:34 [1996]
Definition: prex.h:213
@ PREX_MBOX_FROM_LAX_MATCH_TZ1
From god@heaven.af.mil Sat Jan 10 01:05:34 [MET DST] 1996
Definition: prex.h:211
@ PREX_MBOX_FROM_LAX_MATCH_TZ
From god@heaven.af.mil Sat Jan 10 01:05:34 [MET DST] 1996
Definition: prex.h:210
@ PREX_MBOX_FROM_LAX_MATCH_FULL
[From god@heaven.af.mil Sat Jan 3 01:05:34 1996]
Definition: prex.h:199
@ PREX_MBOX_FROM_LAX_MATCH_MAX
Definition: prex.h:216
@ PREX_MBOX_FROM_LAX_MATCH_YEAR_4DIG
From god@heaven.af.mil Sat Jan 10 01:05:34 [1996]
Definition: prex.h:214

◆ PrexAccountCmd

Regex matches for the output lines of account_command.

Enumerator
PREX_ACCOUNT_CMD_MATCH_FULL 

[key: value]

PREX_ACCOUNT_CMD_MATCH_KEY 

[key]: value

PREX_ACCOUNT_CMD_MATCH_VALUE 

key: [value]

PREX_ACCOUNT_CMD_MATCH_MAX 

Definition at line 222 of file prex.h.

223{
228};
@ PREX_ACCOUNT_CMD_MATCH_FULL
[key: value]
Definition: prex.h:224
@ PREX_ACCOUNT_CMD_MATCH_MAX
Definition: prex.h:227
@ PREX_ACCOUNT_CMD_MATCH_KEY
[key]: value
Definition: prex.h:225
@ PREX_ACCOUNT_CMD_MATCH_VALUE
key: [value]
Definition: prex.h:226

◆ PrexAliasTags

Regex matches for the tags: field of an alias command.

Enumerator
PREX_ALIAS_TAGS_MATCH_FULL 

[... tags:a,b,c ...]

PREX_ALIAS_TAGS_MATCH_PRE 

[... ]tags:a,b,c ...

PREX_ALIAS_TAGS_MATCH_KEY 

... [tags:]a,b,c ...

PREX_ALIAS_TAGS_MATCH_TAGS 

... tags:[a,b,c] ...

PREX_ALIAS_TAGS_MATCH_POST 

... tags:a,b,c[ ...]

PREX_ALIAS_TAGS_MATCH_MAX 

Definition at line 234 of file prex.h.

235{
242};
@ PREX_ALIAS_TAGS_MATCH_FULL
[... tags:a,b,c ...]
Definition: prex.h:236
@ PREX_ALIAS_TAGS_MATCH_POST
... tags:a,b,c[ ...]
Definition: prex.h:240
@ PREX_ALIAS_TAGS_MATCH_PRE
[... ]tags:a,b,c ...
Definition: prex.h:237
@ PREX_ALIAS_TAGS_MATCH_KEY
... [tags:]a,b,c ...
Definition: prex.h:238
@ PREX_ALIAS_TAGS_MATCH_MAX
Definition: prex.h:241
@ PREX_ALIAS_TAGS_MATCH_TAGS
... tags:[a,b,c] ...
Definition: prex.h:239

Function Documentation

◆ mutt_prex_capture()

regmatch_t * mutt_prex_capture ( enum Prex  which,
const char *  str 
)

Match a precompiled regex against a string.

Parameters
whichWhich regex to return
strString to apply regex on
Return values
ptrPointer to an array of matched captures
NULLRegex didn't match

Definition at line 298 of file prex.c.

299{
300 if (!str)
301 return NULL;
302
303 struct PrexStorage *h = prex(which);
304#ifdef HAVE_PCRE2
305 size_t len = strlen(str);
306 int rc = pcre2_match(h->re, (PCRE2_SPTR8) str, len, 0, 0, h->mdata, NULL);
307 if (rc < 0)
308 {
309 PCRE2_UCHAR errmsg[1024];
310 pcre2_get_error_message(rc, errmsg, sizeof(errmsg));
311 mutt_debug(LL_DEBUG2, "pcre2_match - <%s> -> <%s> = %s\n", h->str, str, errmsg);
312 return NULL;
313 }
314 PCRE2_SIZE *ovector = pcre2_get_ovector_pointer(h->mdata);
315 int i = 0;
316 for (; i < rc; i++)
317 {
318 h->matches[i].rm_so = ovector[i * 2];
319 h->matches[i].rm_eo = ovector[i * 2 + 1];
320 }
321 for (; i < h->nmatches; i++)
322 {
323 h->matches[i].rm_so = -1;
324 h->matches[i].rm_eo = -1;
325 }
326#else
327 if (regexec(h->re, str, h->nmatches, h->matches, 0))
328 return NULL;
329
330 ASSERT((h->re->re_nsub == (h->nmatches - 1)) &&
331 "Regular expression and matches enum are out of sync");
332#endif
333 return h->matches;
334}
#define mutt_debug(LEVEL,...)
Definition: logging2.h:89
@ LL_DEBUG2
Log at debug level 2.
Definition: logging2.h:44
static struct PrexStorage * prex(enum Prex which)
Compile on demand and get data for a predefined regex.
Definition: prex.c:100
#define ASSERT(COND)
Definition: signal2.h:58
A predefined / precompiled regex.
Definition: prex.c:70
const char * str
Regex string.
Definition: prex.c:73
enum Prex which
Regex type, e.g. PREX_URL.
Definition: prex.c:71
size_t nmatches
Number of regex matches.
Definition: prex.c:72
regex_t * re
Compiled regex.
Definition: prex.c:78
regmatch_t * matches
Resulting matches.
Definition: prex.c:80
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_prex_cleanup()

void mutt_prex_cleanup ( void  )

Cleanup heap memory allocated by compiled regexes.

Definition at line 339 of file prex.c.

340{
341 for (enum Prex which = 0; which < PREX_MAX; which++)
342 {
343 struct PrexStorage *h = prex(which);
344#ifdef HAVE_PCRE2
345 pcre2_match_data_free(h->mdata);
346 pcre2_code_free(h->re);
347#else
348 regfree(h->re);
349 FREE(&h->re);
350#endif
351 FREE(&h->matches);
352 }
353}
#define FREE(x)
Definition: memory.h:55
Prex
Predefined list of regular expressions.
Definition: prex.h:33
+ Here is the call graph for this function:
+ Here is the caller graph for this function: