NeoMutt  2020-11-20
Teaching an old dog new tricks
DOXYGEN
prex.h File Reference

Manage precompiled / predefined regular expressions. More...

#include "regex3.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, PREX_RFC5322_DATE_LAX, PREX_IMAP_DATE, PREX_MBOX_FROM,
  PREX_MBOX_FROM_LAX, 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  PrexRfc5322Date {
  PREX_RFC5322_DATE_MATCH_FULL, PREX_RFC5322_DATE_MATCH_MAYBE_DOW, PREX_RFC5322_DATE_MATCH_DOW, PREX_RFC5322_DATE_MATCH_DAY,
  PREX_RFC5322_DATE_MATCH_MONTH, PREX_RFC5322_DATE_MATCH_YEAR, PREX_RFC5322_DATE_MATCH_HOUR, PREX_RFC5322_DATE_MATCH_MINUTE,
  PREX_RFC5322_DATE_MATCH_COLONSECOND, PREX_RFC5322_DATE_MATCH_SECOND, PREX_RFC5322_DATE_MATCH_TZFULL, PREX_RFC5322_DATE_MATCH_TZ,
  PREX_RFC5322_DATE_MATCH_TZ_OBS, PREX_RFC5322_DATE_MATCH_MAX
}
 Regex Matches for a RFC5322 date. 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_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...
 

Functions

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

Detailed Description

Manage precompiled / predefined regular expressions.

Authors
  • 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 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 

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

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_MAX 

Definition at line 31 of file prex.h.

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

◆ 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 50 of file prex.h.

51 {
72 };
imaps://...[host.com]...
Definition: prex.h:61
imaps://host.com[:993]/...
Definition: prex.h:64
...Inbox[?foo=bar&baz=value]
Definition: prex.h:69
[imaps://user:pass@host.comInbox?foo=bar]
Definition: prex.h:52
imaps:[//...]
Definition: prex.h:54
...//user:[pass]@...
Definition: prex.h:60
imaps:[somepath]|[//me@example.com/Inbox]?foo=bar
Definition: prex.h:55
...:993/[Inbox]
Definition: prex.h:67
imaps://host.com:[993]/...
Definition: prex.h:65
imaps:[//me@example.com/Inbox]?foo=bar
Definition: prex.h:56
...//user[:pass]@...
Definition: prex.h:59
...Inbox?[foo=bar&baz=value]
Definition: prex.h:70
imaps://...[127.0.0.1]...
Definition: prex.h:63
...//[user]:pass@...
Definition: prex.h:58
...//[user:pass@]...
Definition: prex.h:57
...:993[/Inbox]
Definition: prex.h:66
[imaps]://...
Definition: prex.h:53
imaps://...[host.com]...
Definition: prex.h:62
mailto:[me@example.com]?foo=bar
Definition: prex.h:68

◆ 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 79 of file prex.h.

◆ 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 92 of file prex.h.

◆ 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 106 of file prex.h.

◆ PrexRfc5322Date

Regex Matches for a RFC5322 date.

Note
The []s show the matching path of the RFC5322 date
Enumerator
PREX_RFC5322_DATE_MATCH_FULL 

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

PREX_RFC5322_DATE_MATCH_MAYBE_DOW 

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

PREX_RFC5322_DATE_MATCH_DOW 

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

PREX_RFC5322_DATE_MATCH_DAY 

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

PREX_RFC5322_DATE_MATCH_MONTH 

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

PREX_RFC5322_DATE_MATCH_YEAR 

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

PREX_RFC5322_DATE_MATCH_HOUR 

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

PREX_RFC5322_DATE_MATCH_MINUTE 

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

PREX_RFC5322_DATE_MATCH_COLONSECOND 

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

PREX_RFC5322_DATE_MATCH_SECOND 

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

PREX_RFC5322_DATE_MATCH_TZFULL 

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

PREX_RFC5322_DATE_MATCH_TZ 

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

PREX_RFC5322_DATE_MATCH_TZ_OBS 

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

PREX_RFC5322_DATE_MATCH_MAX 

Definition at line 120 of file prex.h.

121 {
136 };
Tue, 3 Mar [2020] 14:32:55 +0200
Definition: prex.h:127
Tue, [3] Mar 2020 14:32:55 +0200
Definition: prex.h:125
Tue, 3 Mar 2020 14:[32]:55 +0200
Definition: prex.h:129
Tue, 3 Mar 2020 14:32:55 [+0200]
Definition: prex.h:133
Tue, 3 [Jan] 2020 14:32:55 +0200
Definition: prex.h:126
Tue, 3 Mar 2020 [14]:32:55 +0200
Definition: prex.h:128
Tue, 3 Mar 2020 14:32:55[CET]
Definition: prex.h:132
[Mon, 2 Mar 2020 14:32:55 +0200]
Definition: prex.h:122
[Mon], 2 Mar 2020 14:32:55 +0200
Definition: prex.h:124
Tue, 3 Mar 2020 14:32:[55] +0200
Definition: prex.h:131
Tue, 3 Mar 2020 14:32[:55] +0200
Definition: prex.h:130
[Mon, ]2 Mar 2020 14:32:55 +0200
Definition: prex.h:123
Tue, 3 Mar 2020 14:32:55[UT]
Definition: prex.h:134

◆ PrexRfc5322DateLax

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

The reason we provide an alternate regex for RFC5322 dates is that the non-obsolete one 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 148 of file prex.h.

149 {
174 };
[Mon], 2 Mar 2020 14:32:55 +0200
Definition: prex.h:153
[Mon, 2 Mar 2020 14:32:55 +0200]
Definition: prex.h:150
Tue, 3 Mar 2020 14:32[:55] +0200
Definition: prex.h:166
Tue, 3 Mar 2020 14:32:55[UT]
Definition: prex.h:172
Tue, 3 Mar 2020 14:32:[55] +0200
Definition: prex.h:168
Tue, [3] Mar 2020 14:32:55 +0200
Definition: prex.h:156
[Mon, ]2 Mar 2020 14:32:55 +0200
Definition: prex.h:152
Tue, 3 Mar [2020] 14:32:55 +0200
Definition: prex.h:160
Tue, 3 Mar 2020 14:[32]:55 +0200
Definition: prex.h:164
Tue, 3 Mar 2020 14:32:55 [+0200]
Definition: prex.h:171
Tue, 3 Mar 2020 14:32:55[CET]
Definition: prex.h:170
Tue, 3 [Jan] 2020 14:32:55 +0200
Definition: prex.h:158
Tue, 3 Mar 2020 [14]:32:55 +0200
Definition: prex.h:162

◆ 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 181 of file prex.h.

182 {
192 };
15-MAR-2020 15:09:35 [-0700]
Definition: prex.h:190
15-MAR-2020 [15:09:35] -0700
Definition: prex.h:189
[16-MAR-2020 15:09:35 -0700]
Definition: prex.h:183
15-MAR-[2020] 15:09:35 -0700
Definition: prex.h:188
[ 4]-MAR-2020 15:09:35 -0700
Definition: prex.h:184
[4]-MAR-2020 15:09:35 -0700
Definition: prex.h:185
15-[MAR]-2020 15:09:35 -0700
Definition: prex.h:187
[15]-MAR-2020 15:09:35 -0700
Definition: prex.h:186

◆ 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 199 of file prex.h.

200 {
211 };
[From god@heaven.af.mil Sat Jan 3 01:05:34 1996]
Definition: prex.h:201
From god@heaven.af.mil Sat [Jan] 3 01:05:34 1996
Definition: prex.h:204
From god@heaven.af.mil Sat Jan 10 [01:05:34] 1996
Definition: prex.h:208
From god@heaven.af.mil Sat Jan 10 01:05:34 [1996]
Definition: prex.h:209
From [god@heaven.af.mil] Sat Jan 3 01:05:34 1996
Definition: prex.h:202
From god@heaven.af.mil Sat Jan [10] 01:05:34 1996
Definition: prex.h:207
From god@heaven.af.mil Sat Jan [3] 01:05:34 1996
Definition: prex.h:206
From god@heaven.af.mil [Sat] Jan 3 01:05:34 1996
Definition: prex.h:203
From god@heaven.af.mil Sat Jan [ 3] 01:05:34 1996
Definition: prex.h:205

◆ 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_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 218 of file prex.h.

219 {
236 };
From god@heaven.af.mil Sat Jan [10] 01:05:34 1996
Definition: prex.h:227
From god@heaven.af.mil [Sat] Jan 3 01:05:34 1996
Definition: prex.h:223
From god@heaven.af.mil Sat Jan 10 01:05:34 [96]
Definition: prex.h:234
From [god at heaven.af.mil] Sat Jan 3 01:05:34 1996
Definition: prex.h:221
From god@heaven.af.mil Sat Jan [3] 01:05:34 1996
Definition: prex.h:226
From god@heaven.af.mil Sat Jan 10 01:05:34 [MET DST] 1996
Definition: prex.h:231
From god@heaven.af.mil Sat Jan 10 01:05:34 [1996]
Definition: prex.h:232
From god@heaven.af.mil Sat Jan 10 [01:05:34] 1996
Definition: prex.h:228
From god@heaven.af.mil Sat Jan 10 [01:05] 1996
Definition: prex.h:230
From god@heaven.af.mil Sat [Jan] 3 01:05:34 1996
Definition: prex.h:224
[From god@heaven.af.mil Sat Jan 3 01:05:34 1996]
Definition: prex.h:220
From god@heaven.af.mil Sat Jan [ 3] 01:05:34 1996
Definition: prex.h:225
From [god@heaven.af.mil] Sat Jan 3 01:05:34 1996
Definition: prex.h:222
From god@heaven.af.mil Sat Jan 10 [01:05:34] 1996
Definition: prex.h:229
From god@heaven.af.mil Sat Jan 10 01:05:34 [1996]
Definition: prex.h:233

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 306 of file prex.c.

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

◆ mutt_prex_free()

void mutt_prex_free ( void  )

Cleanup heap memory allocated by compiled regexes.

Definition at line 347 of file prex.c.

348 {
349  for (enum Prex which = 0; which < PREX_MAX; which++)
350  {
351  struct PrexStorage *h = prex(which);
352 #ifdef HAVE_PCRE2
353  pcre2_match_data_free(h->mdata);
354  pcre2_code_free(h->re);
355 #else
356  regfree(h->re);
357  FREE(&h->re);
358 #endif
359  FREE(&h->matches);
360  }
361 }
regex_t * re
Compiled regex.
Definition: prex.c:76
Definition: prex.h:42
Prex
Predefined list of regular expressions.
Definition: prex.h:31
regmatch_t * matches
Resulting matches.
Definition: prex.c:78
A predefined / precompiled regex.
Definition: prex.c:67
enum Prex which
Regex type, e.g. PREX_URL.
Definition: prex.c:69
static struct PrexStorage * prex(enum Prex which)
Compile on demand and get data for a predefined regex.
Definition: prex.c:97
#define FREE(x)
Definition: memory.h:40
+ Here is the call graph for this function:
+ Here is the caller graph for this function: