Add vre_pcre2.h to contain the backend specifics of VRE

For now, this is only VRE_unpack() to get the pcre2_code handle.

If we ever change the regex backend again, we will remove
vre_pcre2.h and add something else.

Suggested by Dridi, thus authorship attributed to Dridi.
parent 1bc7abb8
......@@ -67,6 +67,7 @@ nobase_pkginclude_HEADERS += \
vmod_abi.h \
vqueue.h \
vre.h \
vre_pcre2.h \
vdef.h \
vrt.h \
vrt_obj.h \
......
/*-
* Copyright (c) 2021 Varnish Software AS
* All rights reserved.
*
* Author: Dridi Boukelmoune <dridi.boukelmoune@gmail.com>
*
* SPDX-License-Identifier: BSD-2-Clause
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* Access to the PCRE2 backend in VRE
*
*/
#ifndef VRE_H_INCLUDED
#error Include vre.h before vre_pcre2.h
#endif
#ifndef VRE_PCRE2_H_INCLUDED
#define VRE_PCRE2_H_INCLUDED
#include <pcre2.h>
pcre2_code *VRE_unpack(const vre_t *code);
#endif /* VRE_PCRE2_H_INCLUDED */
......@@ -34,8 +34,6 @@
#include <string.h>
#include <unistd.h>
#include <pcre2.h>
#include "vdef.h"
#include "vas.h" // XXX Flexelint "not used" - but req'ed for assert()
......@@ -43,6 +41,7 @@
#include "miniobj.h"
#include "vre.h"
#include "vre_pcre2.h"
#if !HAVE_PCRE2_SET_DEPTH_LIMIT
# define pcre2_set_depth_limit(r, d) pcre2_set_recursion_limit(r, d)
......@@ -132,8 +131,8 @@ VRE_error(struct vsb *vsb, int err)
return (0);
}
static pcre2_code *
vre_unpack(const vre_t *code)
pcre2_code *
VRE_unpack(const vre_t *code)
{
CHECK_OBJ_NOTNULL(code, VRE_MAGIC);
......@@ -168,7 +167,7 @@ VRE_export(const vre_t *code, size_t *sz)
vre_t *exp;
CHECK_OBJ_NOTNULL(code, VRE_MAGIC);
re = vre_unpack(code);
re = VRE_unpack(code);
AZ(pcre2_pattern_info(re, PCRE2_INFO_SIZE, sz));
exp = malloc(sizeof(*exp) + *sz);
......@@ -190,7 +189,7 @@ vre_match(const vre_t *code, const char *subject, size_t length, size_t offset,
pcre2_code *re;
int matches;
re = vre_unpack(code);
re = VRE_unpack(code);
if (datap != NULL && *datap != NULL) {
data = *datap;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment