summaryrefslogtreecommitdiff
path: root/src/exim_monitor
diff options
context:
space:
mode:
authorJeremy Harris <jgh146exb@wizmail.org>2021-09-12 15:42:51 +0100
committerJeremy Harris <jgh146exb@wizmail.org>2021-09-12 15:42:51 +0100
commit22ed7a5295f196fce32563f6e9c669110dd36f4d (patch)
tree19169afbc1f8c69890ee140c353b20200939d072 /src/exim_monitor
parent8271f864edaf7fb2db0eb3aaa0c4789f55125978 (diff)
downloadexim4-22ed7a5295f196fce32563f6e9c669110dd36f4d.tar.gz
pcre2
Diffstat (limited to 'src/exim_monitor')
-rw-r--r--src/exim_monitor/em_globals.c4
-rw-r--r--src/exim_monitor/em_hdr.h7
-rw-r--r--src/exim_monitor/em_init.c26
-rw-r--r--src/exim_monitor/em_log.c23
4 files changed, 32 insertions, 28 deletions
diff --git a/src/exim_monitor/em_globals.c b/src/exim_monitor/em_globals.c
index 88d5103fc..e311aef1c 100644
--- a/src/exim_monitor/em_globals.c
+++ b/src/exim_monitor/em_globals.c
@@ -81,7 +81,7 @@ uschar *queue_stripchart_name = NULL;
int queue_update = 60;
int queue_width = 600;
-pcre *yyyymmdd_regex;
+pcre2_code *yyyymmdd_regex;
uschar *size_stripchart = NULL;
uschar *size_stripchart_name = NULL;
@@ -89,7 +89,7 @@ int spool_is_split = FALSE;
int start_small = FALSE;
int stripchart_height = 90;
int stripchart_number = 1;
-pcre **stripchart_regex;
+pcre2_code **stripchart_regex;
uschar **stripchart_title;
int *stripchart_total;
int stripchart_update = 60;
diff --git a/src/exim_monitor/em_hdr.h b/src/exim_monitor/em_hdr.h
index c45f9fca7..6d8b7e2ea 100644
--- a/src/exim_monitor/em_hdr.h
+++ b/src/exim_monitor/em_hdr.h
@@ -85,7 +85,8 @@ anything. */
/* Regular expression include */
-#include <pcre.h>
+#define PCRE2_CODE_UNIT_WIDTH 8
+#include <pcre2.h>
/* Includes from the main source of Exim. One of these days I should tidy up
this interface so that this kind of kludge isn't needed. */
@@ -273,7 +274,7 @@ extern uschar *queue_stripchart_name; /* sic */
extern int queue_update; /* update interval */
extern int queue_width; /* width of queue window */
-extern pcre *yyyymmdd_regex; /* for matching yyyy-mm-dd */
+extern pcre2_code *yyyymmdd_regex; /* for matching yyyy-mm-dd */
extern uschar *size_stripchart; /* path for size monitoring */
extern uschar *size_stripchart_name; /* name for size stripchart */
@@ -282,7 +283,7 @@ extern int spool_is_split; /* True if detected split spool */
extern int start_small; /* True to start with small window */
extern int stripchart_height; /* height of stripcharts */
extern int stripchart_number; /* number of stripcharts */
-extern pcre **stripchart_regex; /* vector of regexps */
+extern pcre2_code **stripchart_regex; /* vector of regexps */
extern uschar **stripchart_title; /* vector of titles */
extern int *stripchart_total; /* vector of accumulating values */
extern int stripchart_update; /* update interval */
diff --git a/src/exim_monitor/em_init.c b/src/exim_monitor/em_init.c
index 56cb29886..f85f858d4 100644
--- a/src/exim_monitor/em_init.c
+++ b/src/exim_monitor/em_init.c
@@ -32,7 +32,6 @@ int i;
work. */
for (i = 0; i <= 1; i++)
-
{
int first = 1;
int count = 0;
@@ -69,13 +68,18 @@ for (i = 0; i <= 1; i++)
buffer[p-pp] = 0;
if (first)
{
- int offset;
- const uschar *error;
- if (!(stripchart_regex[indx] = pcre_compile(CS buffer, PCRE_COPT,
- CCSS &error, &offset, NULL)))
+ size_t offset;
+ int err;
+
+ if (!(stripchart_regex[indx] =
+ pcre2_compile((PCRE2_SPTR)buffer,
+ PCRE2_ZERO_TERMINATED, PCRE_COPT,
+ &err, &offset, NULL)))
{
- printf("regular expression error: %s at offset %d "
- "while compiling %s\n", error, offset, buffer);
+ uschar errbuf[128];
+ pcre2_get_error_message(err, errbuf, sizeof(errbuf));
+ printf("regular expression error: %s at offset %l "
+ "while compiling %s\n", errbuf, (long)offset, buffer);
exit(99);
}
}
@@ -95,7 +99,7 @@ for (i = 0; i <= 1; i++)
if (i == 0)
{
stripchart_number += count;
- stripchart_regex = (pcre **)store_malloc(stripchart_number * sizeof(pcre *));
+ stripchart_regex = (pcre2_code **)store_malloc(stripchart_number * sizeof(pcre2_code *));
stripchart_title = (uschar **)store_malloc(stripchart_number * sizeof(uschar *));
}
}
@@ -109,7 +113,7 @@ for (i = 0; i <= 1; i++)
void init(int argc, uschar **argv)
{
int x;
-int erroroffset;
+size_t erroroffset;
uschar *s;
const uschar *error;
@@ -230,8 +234,8 @@ queue_stripchart_name = (s != NULL)? string_copy(s) : US"queue";
/* Compile the regex for matching yyyy-mm-dd at the start of a string. */
-yyyymmdd_regex = pcre_compile("^\\d{4}-\\d\\d-\\d\\d\\s", PCRE_COPT,
- CCSS &error, &erroroffset, NULL);
+yyyymmdd_regex = pcre2_compile((PCRE2_SPTR)"^\\d{4}-\\d\\d-\\d\\d\\s",
+ PCRE2_ZERO_TERMINATED, PCRE_COPT, &x, &erroroffset, NULL);
}
/* End of em_init.c */
diff --git a/src/exim_monitor/em_log.c b/src/exim_monitor/em_log.c
index 1e1dc7c04..662595b12 100644
--- a/src/exim_monitor/em_log.c
+++ b/src/exim_monitor/em_log.c
@@ -229,7 +229,7 @@ if (LOG != NULL)
uschar *p = buffer;
rmark reset_point;
int length = Ustrlen(buffer);
- int i;
+ pcre2_match_data * md = pcre2_match_data_create(1, NULL);
/* Skip totally blank lines (paranoia: there shouldn't be any) */
@@ -246,27 +246,25 @@ if (LOG != NULL)
stripchart is the queue length, which is handled elsewhere, and the
1st may the a size monitor. */
- for (i = stripchart_varstart; i < stripchart_number; i++)
- {
- if (pcre_exec(stripchart_regex[i], NULL, CS buffer, length, 0, PCRE_EOPT,
- NULL, 0) >= 0)
+ for (int i = stripchart_varstart; i < stripchart_number; i++)
+ if (pcre2_match(stripchart_regex[i], (PCRE2_SPTR)buffer, length,
+ 0, PCRE_EOPT, md, NULL) >= 0)
stripchart_total[i]++;
- }
/* Munge the log entry and display shortened form on one line.
We omit the date and show only the time. Remove any time zone offset.
Take note of the presence of [pid]. */
- if (pcre_exec(yyyymmdd_regex,NULL,CS buffer,length,0,PCRE_EOPT,NULL,0) >= 0)
+ if (pcre2_match(yyyymmdd_regex, (PCRE2_SPTR) buffer, length, 0, PCRE_EOPT,
+ md, NULL) >= 0)
{
int pidlength = 0;
- if ((buffer[20] == '+' || buffer[20] == '-') &&
- isdigit(buffer[21]) && buffer[25] == ' ')
+ if ( (buffer[20] == '+' || buffer[20] == '-')
+ && isdigit(buffer[21]) && buffer[25] == ' ')
memmove(buffer + 20, buffer + 26, Ustrlen(buffer + 26) + 1);
if (buffer[20] == '[')
- {
- while (Ustrchr("[]0123456789", buffer[20+pidlength++]) != NULL);
- }
+ while (Ustrchr("[]0123456789", buffer[20+pidlength++]) != NULL)
+ ;
id = string_copyn(buffer + 20 + pidlength, MESSAGE_ID_LENGTH);
show_log("%s", buffer+11);
}
@@ -275,6 +273,7 @@ if (LOG != NULL)
id = US"";
show_log("%s", buffer);
}
+ pcre2_match_data_free(md);
/* Deal with frozen and unfrozen messages */