Sponsored by: Robert Klemme
/*
* Allow PCRE syntax in host patterns.
*/
/*
* Allow PCRE syntax in host patterns.
*/
-#undef FEATURE_EXTENDED_HOST_PATTERNS
+#undef FEATURE_PCRE_HOST_PATTERNS
/*
* Allow filtering with scripts and programs.
/*
* Allow filtering with scripts and programs.
AC_DEFINE(FEATURE_GRACEFUL_TERMINATION)
fi])
AC_DEFINE(FEATURE_GRACEFUL_TERMINATION)
fi])
-AC_ARG_ENABLE(extended-host-patterns,
-[ --enable-extended-host-patterns Enable and require PCRE syntax in host patterns. This feature hasn't
+AC_ARG_ENABLE(pcre-host-patterns,
+[ --enable-pcre-host-patterns Enable and require PCRE syntax in host patterns. This feature hasn't
been announced yet and it's not clear if it's a good idea. It's expected
to work, but undocumented. You should only enable it if you know what
PCRE is and are sure that you need it for your host patterns. You can
been announced yet and it's not clear if it's a good idea. It's expected
to work, but undocumented. You should only enable it if you know what
PCRE is and are sure that you need it for your host patterns. You can
use PCRE host patterns. Please don't enable this option when creating
packages for others that may not be expecting it.],
[if test $enableval = yes; then
use PCRE host patterns. Please don't enable this option when creating
packages for others that may not be expecting it.],
[if test $enableval = yes; then
- AC_DEFINE(FEATURE_EXTENDED_HOST_PATTERNS)
+ AC_DEFINE(FEATURE_PCRE_HOST_PATTERNS)
fi])
AC_ARG_ENABLE(external-filters,
fi])
AC_ARG_ENABLE(external-filters,
-#ifdef FEATURE_EXTENDED_HOST_PATTERNS
+#ifdef FEATURE_PCRE_HOST_PATTERNS
regex_t *host_regex;/**< Regex for host matching */
regex_t *host_regex;/**< Regex for host matching */
- enum host_regex_type { VANILLA_HOST_PATTERN, EXTENDED_HOST_PATTERN } host_regex_type;
-#endif /* defined FEATURE_EXTENDED_HOST_PATTERNS */
+ enum host_regex_type { VANILLA_HOST_PATTERN, PCRE_HOST_PATTERN } host_regex_type;
+#endif /* defined FEATURE_PCRE_HOST_PATTERNS */
char *dbuffer; /**< Buffer with '\0'-delimited domain name, or NULL to match all hosts. */
char **dvec; /**< List of pointers to the strings in dbuffer. */
int dcount; /**< How many parts to this domain? (length of dvec) */
char *dbuffer; /**< Buffer with '\0'-delimited domain name, or NULL to match all hosts. */
char **dvec; /**< List of pointers to the strings in dbuffer. */
int dcount; /**< How many parts to this domain? (length of dvec) */
RIGHT_ANCHORED_HOST
};
static jb_err compile_vanilla_host_pattern(struct pattern_spec *url, const char *host_pattern);
RIGHT_ANCHORED_HOST
};
static jb_err compile_vanilla_host_pattern(struct pattern_spec *url, const char *host_pattern);
-#ifdef FEATURE_EXTENDED_HOST_PATTERNS
+#ifdef FEATURE_PCRE_HOST_PATTERNS
static jb_err compile_pcre_host_pattern(struct pattern_spec *url, const char *host_pattern);
#endif
static jb_err compile_pcre_host_pattern(struct pattern_spec *url, const char *host_pattern);
#endif
-#ifdef FEATURE_EXTENDED_HOST_PATTERNS
+#ifdef FEATURE_PCRE_HOST_PATTERNS
const size_t prefix_length = 18;
if (strncmpic(buf, "PCRE-HOST-PATTERN:", prefix_length) == 0)
{
const size_t prefix_length = 18;
if (strncmpic(buf, "PCRE-HOST-PATTERN:", prefix_length) == 0)
{
- url->pattern.url_spec.host_regex_type = EXTENDED_HOST_PATTERN;
+ url->pattern.url_spec.host_regex_type = PCRE_HOST_PATTERN;
/* Overwrite the "PCRE-HOST-PATTERN:" prefix */
memmove(buf, buf+prefix_length, strlen(buf+prefix_length)+1);
}
/* Overwrite the "PCRE-HOST-PATTERN:" prefix */
memmove(buf, buf+prefix_length, strlen(buf+prefix_length)+1);
}
-#ifdef FEATURE_EXTENDED_HOST_PATTERNS
- if (url->pattern.url_spec.host_regex_type == EXTENDED_HOST_PATTERN)
+#ifdef FEATURE_PCRE_HOST_PATTERNS
+ if (url->pattern.url_spec.host_regex_type == PCRE_HOST_PATTERN)
{
return compile_pcre_host_pattern(url, buf);
}
{
return compile_pcre_host_pattern(url, buf);
}
-#ifdef FEATURE_EXTENDED_HOST_PATTERNS
+#ifdef FEATURE_PCRE_HOST_PATTERNS
/*********************************************************************
*
* Function : compile_pcre_host_pattern
/*********************************************************************
*
* Function : compile_pcre_host_pattern
{
return compile_pattern(host_pattern, RIGHT_ANCHORED_HOST, url, &url->pattern.url_spec.host_regex);
}
{
return compile_pattern(host_pattern, RIGHT_ANCHORED_HOST, url, &url->pattern.url_spec.host_regex);
}
-#endif /* def FEATURE_EXTENDED_HOST_PATTERNS */
+#endif /* def FEATURE_PCRE_HOST_PATTERNS */
/*********************************************************************
/*********************************************************************
if (pattern == NULL) return;
freez(pattern->spec);
if (pattern == NULL) return;
freez(pattern->spec);
-#ifdef FEATURE_EXTENDED_HOST_PATTERNS
+#ifdef FEATURE_PCRE_HOST_PATTERNS
if (pattern->pattern.url_spec.host_regex)
{
regfree(pattern->pattern.url_spec.host_regex);
freez(pattern->pattern.url_spec.host_regex);
}
if (pattern->pattern.url_spec.host_regex)
{
regfree(pattern->pattern.url_spec.host_regex);
freez(pattern->pattern.url_spec.host_regex);
}
-#endif /* def FEATURE_EXTENDED_HOST_PATTERNS */
+#endif /* def FEATURE_PCRE_HOST_PATTERNS */
freez(pattern->pattern.url_spec.dbuffer);
freez(pattern->pattern.url_spec.dvec);
pattern->pattern.url_spec.dcount = 0;
freez(pattern->pattern.url_spec.dbuffer);
freez(pattern->pattern.url_spec.dvec);
pattern->pattern.url_spec.dcount = 0;
const struct pattern_spec *pattern)
{
assert(http->host != NULL);
const struct pattern_spec *pattern)
{
assert(http->host != NULL);
-#ifdef FEATURE_EXTENDED_HOST_PATTERNS
- if (pattern->pattern.url_spec.host_regex_type == EXTENDED_HOST_PATTERN) {
+#ifdef FEATURE_PCRE_HOST_PATTERNS
+ if (pattern->pattern.url_spec.host_regex_type == PCRE_HOST_PATTERN) {
return ((NULL == pattern->pattern.url_spec.host_regex)
|| (0 == regexec(pattern->pattern.url_spec.host_regex,
http->host, 0, NULL, 0)));
return ((NULL == pattern->pattern.url_spec.host_regex)
|| (0 == regexec(pattern->pattern.url_spec.host_regex,
http->host, 0, NULL, 0)));