summaryrefslogtreecommitdiff
path: root/src/pcre2grep.c
diff options
context:
space:
mode:
authorph10 <ph10@6239d852-aaf2-0410-a92c-79f79f948069>2018-11-17 16:45:57 +0000
committerph10 <ph10@6239d852-aaf2-0410-a92c-79f79f948069>2018-11-17 16:45:57 +0000
commit3ca120a64fe50153fc78bfc1ddb28d1cd55bd96f (patch)
tree78cde16b1930fd9486396ecf050133b8fc8e137f /src/pcre2grep.c
parent08a605bfc307304534c41fe4b3b85f54a2422435 (diff)
downloadpcre2-3ca120a64fe50153fc78bfc1ddb28d1cd55bd96f.tar.gz
Add --disable-pcre2grep-callout-fork configuration setting.
git-svn-id: svn://vcs.exim.org/pcre2/code/trunk@1042 6239d852-aaf2-0410-a92c-79f79f948069
Diffstat (limited to 'src/pcre2grep.c')
-rw-r--r--src/pcre2grep.c33
1 files changed, 23 insertions, 10 deletions
diff --git a/src/pcre2grep.c b/src/pcre2grep.c
index 1027047..477e867 100644
--- a/src/pcre2grep.c
+++ b/src/pcre2grep.c
@@ -73,7 +73,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include <fcntl.h> /* For _O_BINARY */
#endif
-#ifdef SUPPORT_PCRE2GREP_CALLOUT
+#if defined(SUPPORT_PCRE2GREP_CALLOUT) && defined(SUPPORT_PCRE2GREP_CALLOUT_FORK)
#ifdef WIN32
#include <process.h>
#else
@@ -1133,7 +1133,11 @@ printf("Search for PATTERN in each FILE or standard input." STDOUT_NL);
printf("PATTERN must be present if neither -e nor -f is used." STDOUT_NL);
#ifdef SUPPORT_PCRE2GREP_CALLOUT
-printf("Callout scripts in patterns are supported." STDOUT_NL);
+#ifdef SUPPORT_PCRE2GREP_CALLOUT_FORK
+printf("All callout scripts in patterns are supported." STDOUT_NL);
+#else
+printf("Non-fork callout scripts in patterns are supported." STDOUT_NL);
+#endif
#else
printf("Callout scripts are not supported in this pcre2grep." STDOUT_NL);
#endif
@@ -2017,10 +2021,10 @@ return printed;
* Parse and execute callout scripts *
*************************************************/
-/* This function parses a callout string block and executes the
-program specified by the string. The string is a list of substrings
-separated by pipe characters. The first substring represents the
-executable name, and the following substrings specify the arguments:
+/* If SUPPORT_PCRE2GREP_CALLOUT_FORK is defined, this function parses a callout
+string block and executes the program specified by the string. The string is a
+list of substrings separated by pipe characters. The first substring represents
+the executable name, and the following substrings specify the arguments:
program_name|param1|param2|...
@@ -2037,8 +2041,9 @@ follows:
dollar or $| replaced by a pipe character.
Alternatively, if string starts with pipe, the remainder is taken as an output
-string, same as --output. In this case, --om-separator is used to separate each
-callout, defaulting to newline.
+string, same as --output. This is the only form that is supported if
+SUPPORT_PCRE2GREP_FORK is not defined. In this case, --om-separator is used to
+separate each callout, defaulting to newline.
Example:
@@ -2066,6 +2071,8 @@ PCRE2_SPTR string = calloutptr->callout_string;
PCRE2_SPTR subject = calloutptr->subject;
PCRE2_SIZE *ovector = calloutptr->offset_vector;
PCRE2_SIZE capture_top = calloutptr->capture_top;
+
+#ifdef SUPPORT_PCRE2GREP_CALLOUT_FORK
PCRE2_SIZE argsvectorlen = 2;
PCRE2_SIZE argslen = 1;
char *args;
@@ -2076,10 +2083,12 @@ char **argsvectorptr;
pid_t pid;
#endif
int result = 0;
+#endif /* SUPPORT_PCRE2GREP_CALLOUT_FORK */
(void)unused; /* Avoid compiler warning */
/* Only callout with strings are supported. */
+
if (string == NULL || length == 0) return 0;
/* If there's no command, output the remainder directly. */
@@ -2091,6 +2100,10 @@ if (*string == '|')
(void)display_output_text(string, TRUE, subject, ovector, capture_top);
return 0;
}
+
+#ifndef SUPPORT_PCRE2GREP_CALLOUT_FORK
+return 0;
+#else
/* Checking syntax and compute the number of string fragments. Callout strings
are ignored in case of a syntax error. */
@@ -2294,9 +2307,9 @@ free(argsvector);
continues) or non-zero (match fails). */
return result != 0;
+#endif /* SUPPORT_PCRE2GREP_CALLOUT_FORK */
}
-
-#endif
+#endif /* SUPPORT_PCRE2GREP_CALLOUT */