Added Makefile option to build without libpcre

This commit is contained in:
Yves Rutschle 2015-07-09 15:31:42 +02:00
parent ba945f1a8f
commit 3aefaf3004
4 changed files with 24 additions and 0 deletions

View File

@ -1,3 +1,7 @@
vNEXT:
Added USELIBPCRE to make use of regex engine
optional.
v1.17: 09MAR2015
Support RFC5952-style IPv6 addresses, e.g. [::]:443.

View File

@ -2,6 +2,7 @@
VERSION=$(shell ./genver.sh -r)
USELIBCONFIG=1 # Use libconfig? (necessary to use configuration files)
USELIBPCRE=1 # Use libpcre? (necessary to use regex probe)
USELIBWRAP?= # Use libwrap?
USELIBCAP= # Use libcap?
COV_TEST= # Perform test coverage?
@ -29,6 +30,10 @@ ifneq ($(strip $(USELIBWRAP)),)
CPPFLAGS+=-DLIBWRAP
endif
ifneq ($(strip $(USELIBPCRE)),)
CPPFLAGS+=-DLIBPCRE
endif
ifneq ($(strip $(USELIBCONFIG)),)
LIBS:=$(LIBS) -lconfig
CPPFLAGS+=-DLIBCONFIG

View File

@ -21,7 +21,9 @@
#define _GNU_SOURCE
#include <stdio.h>
#ifdef LIBPCRE
#include <regex.h>
#endif
#include <ctype.h>
#include "probe.h"
@ -244,6 +246,7 @@ static int is_adb_protocol(const char *p, int len, struct proto *proto)
static int regex_probe(const char *p, int len, struct proto *proto)
{
#ifdef LIBPCRE
regex_t **probe = proto->data;
regmatch_t pos = { 0, len };
@ -251,6 +254,11 @@ static int regex_probe(const char *p, int len, struct proto *proto)
/* try them all */;
return (*probe != NULL);
#else
/* Should never happen as we check when loading config file */
fprintf(stderr, "FATAL: regex probe called but not built in\n");
exit(5);
#endif
}
/*

View File

@ -25,7 +25,9 @@
#ifdef LIBCONFIG
#include <libconfig.h>
#endif
#ifdef LIBPCRE
#include <regex.h>
#endif
#include "common.h"
#include "probe.h"
@ -174,6 +176,7 @@ static int config_listen(config_t *config, struct addrinfo **listen)
#ifdef LIBCONFIG
static void setup_regex_probe(struct proto *p, config_setting_t* probes)
{
#ifdef LIBPCRE
int num_probes, errsize, i, res;
char *err;
const char * expr;
@ -201,6 +204,10 @@ static void setup_regex_probe(struct proto *p, config_setting_t* probes)
exit(1);
}
}
#else
fprintf(stderr, "line %d: regex probe specified but not compiled in\n", config_setting_source_line(probes));
exit(5);
#endif
}
#endif