Bug fix: #48: Compilation failure with old libconfig/libpcre

- Fix compilation failure with <libpcre-8.20 and <libconfig-1.4. Tested
  with libpcre-8.12 and libconfig-1.3.2, but not extensively tested.
  libconfig-1.3* probably has more limitations on configuration file
  syntax (enforces comma at the end of a setting?) and does not support
  @include.

- Make it possible to turn off PCRE and libconfig support using
  environment variable "CFG". Not well tested. CMake might provide a
  better solution.
This commit is contained in:
Richard Grenville
2012-09-28 09:10:34 +08:00
parent 69513d6231
commit 9139d038c2
4 changed files with 50 additions and 21 deletions

View File

@ -20,12 +20,12 @@
// Whether to enable PCRE regular expression support in blacklists, enabled
// by default
#define CONFIG_REGEX_PCRE 1
// #define CONFIG_REGEX_PCRE 1
// Whether to enable JIT support of libpcre. This may cause problems on PaX
// kernels.
#define CONFIG_REGEX_PCRE_JIT 1
// #define CONFIG_REGEX_PCRE_JIT 1
// Whether to enable parsing of configuration files using libconfig
#define CONFIG_LIBCONFIG 1
// #define CONFIG_LIBCONFIG 1
// === Includes ===
@ -49,6 +49,12 @@
#ifdef CONFIG_REGEX_PCRE
#include <pcre.h>
// For compatiblity with <libpcre-8.20
#ifndef PCRE_STUDY_JIT_COMPILE
#define PCRE_STUDY_JIT_COMPILE 0
#endif
#endif
#ifdef CONFIG_LIBCONFIG
@ -923,7 +929,7 @@ static void
fork_after(void);
#ifdef CONFIG_LIBCONFIG
static void
static inline void
lcfg_lookup_bool(const config_t *config, const char *path, Bool *value) {
int ival;
@ -931,6 +937,21 @@ lcfg_lookup_bool(const config_t *config, const char *path, Bool *value) {
*value = ival;
}
static inline int
lcfg_lookup_int(const config_t *config, const char *path, int *value) {
#ifndef CONFIG_LIBCONFIG_LEGACY
return config_lookup_int(config, path, value);
#else
long lval;
int ret;
if ((ret = config_lookup_int(config, path, &lval)))
*value = lval;
return ret;
#endif
}
static FILE *
open_config_file(char *cpath, char **path);