1
0
mirror of https://github.com/moparisthebest/sslh synced 2024-11-24 01:52:24 -05:00

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 v1.17: 09MAR2015
Support RFC5952-style IPv6 addresses, e.g. [::]:443. Support RFC5952-style IPv6 addresses, e.g. [::]:443.

View File

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

View File

@ -21,7 +21,9 @@
#define _GNU_SOURCE #define _GNU_SOURCE
#include <stdio.h> #include <stdio.h>
#ifdef LIBPCRE
#include <regex.h> #include <regex.h>
#endif
#include <ctype.h> #include <ctype.h>
#include "probe.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) static int regex_probe(const char *p, int len, struct proto *proto)
{ {
#ifdef LIBPCRE
regex_t **probe = proto->data; regex_t **probe = proto->data;
regmatch_t pos = { 0, len }; regmatch_t pos = { 0, len };
@ -251,6 +254,11 @@ static int regex_probe(const char *p, int len, struct proto *proto)
/* try them all */; /* try them all */;
return (*probe != NULL); 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 #ifdef LIBCONFIG
#include <libconfig.h> #include <libconfig.h>
#endif #endif
#ifdef LIBPCRE
#include <regex.h> #include <regex.h>
#endif
#include "common.h" #include "common.h"
#include "probe.h" #include "probe.h"
@ -174,6 +176,7 @@ static int config_listen(config_t *config, struct addrinfo **listen)
#ifdef LIBCONFIG #ifdef LIBCONFIG
static void setup_regex_probe(struct proto *p, config_setting_t* probes) static void setup_regex_probe(struct proto *p, config_setting_t* probes)
{ {
#ifdef LIBPCRE
int num_probes, errsize, i, res; int num_probes, errsize, i, res;
char *err; char *err;
const char * expr; const char * expr;
@ -201,6 +204,10 @@ static void setup_regex_probe(struct proto *p, config_setting_t* probes)
exit(1); exit(1);
} }
} }
#else
fprintf(stderr, "line %d: regex probe specified but not compiled in\n", config_setting_source_line(probes));
exit(5);
#endif
} }
#endif #endif