added ./configure --with-psl-file to set PSL file path
This commit is contained in:
parent
3fd48b9328
commit
c93268ce25
|
@ -89,6 +89,14 @@ else
|
||||||
TESTS_INFO="Valgrind testing not enabled"
|
TESTS_INFO="Valgrind testing not enabled"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Check for custom PSL file
|
||||||
|
AC_ARG_WITH(psl-file,
|
||||||
|
AC_HELP_STRING([--with-psl-file=[PATH]],
|
||||||
|
[path to PSL file]),
|
||||||
|
PSL_FILE=$withval,
|
||||||
|
PSL_FILE="\$(top_srcdir)/data/effective_tld_names.dat")
|
||||||
|
AC_SUBST(PSL_FILE)
|
||||||
|
|
||||||
# Override the template file name of the generated .pc file, so that there
|
# Override the template file name of the generated .pc file, so that there
|
||||||
# is no need to rename the template file when the API version changes.
|
# is no need to rename the template file when the API version changes.
|
||||||
AC_CONFIG_FILES([Makefile
|
AC_CONFIG_FILES([Makefile
|
||||||
|
@ -111,5 +119,6 @@ AC_MSG_NOTICE([Summary of build options:
|
||||||
CFlags: ${CFLAGS} ${CPPFLAGS}
|
CFlags: ${CFLAGS} ${CPPFLAGS}
|
||||||
LDFlags: ${LDFLAGS}
|
LDFlags: ${LDFLAGS}
|
||||||
Builtin PSL: ${enable_builtin}
|
Builtin PSL: ${enable_builtin}
|
||||||
|
PSL File: ${PSL_FILE}
|
||||||
Tests: ${TESTS_INFO}
|
Tests: ${TESTS_INFO}
|
||||||
])
|
])
|
||||||
|
|
|
@ -19,5 +19,6 @@ psl2c_CPPFLAGS = -I$(top_srcdir)/include -D _GNU_SOURCE
|
||||||
#psl2c_LDADD = -lidn2
|
#psl2c_LDADD = -lidn2
|
||||||
|
|
||||||
# Build rule for suffix.c
|
# Build rule for suffix.c
|
||||||
suffixes.c: $(top_srcdir)/data/effective_tld_names.dat psl2c$(EXEEXT)
|
# PSL_FILE can be set by ./configure --with-psl-file=[PATH]
|
||||||
./psl2c$(EXEEXT) $(top_srcdir)/data/effective_tld_names.dat suffixes.c
|
suffixes.c: $(PSL_FILE) psl2c$(EXEEXT)
|
||||||
|
./psl2c$(EXEEXT) "$(PSL_FILE)" suffixes.c
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
DEFS = @DEFS@ -DDATADIR=\"$(top_srcdir)/data\" -DSRCDIR=\"$(srcdir)\"
|
DEFS = @DEFS@ -DDATADIR=\"$(top_srcdir)/data\" -DSRCDIR=\"$(srcdir)\" -DPSL_FILE=\"$(PSL_FILE)\"
|
||||||
AM_CPPFLAGS = -I$(top_srcdir)/include
|
AM_CPPFLAGS = -I$(top_srcdir)/include
|
||||||
LDADD = ../src/libpsl-@LIBPSL_API_VERSION@.la
|
LDADD = ../src/libpsl-@LIBPSL_API_VERSION@.la
|
||||||
|
|
||||||
|
|
|
@ -50,11 +50,11 @@ static void test_psl(void)
|
||||||
int result;
|
int result;
|
||||||
char buf[256], domain[64], *linep, *p;
|
char buf[256], domain[64], *linep, *p;
|
||||||
|
|
||||||
psl = psl_load_file(DATADIR "/effective_tld_names.dat");
|
psl = psl_load_file(PSL_FILE); // PSL_FILE can be set by ./configure --with-psl-file=[PATH]
|
||||||
|
|
||||||
printf("loaded %d suffixes and %d exceptions\n", psl_suffix_count(psl), psl_suffix_exception_count(psl));
|
printf("loaded %d suffixes and %d exceptions\n", psl_suffix_count(psl), psl_suffix_exception_count(psl));
|
||||||
|
|
||||||
if ((fp = fopen(DATADIR "/effective_tld_names.dat", "r"))) {
|
if ((fp = fopen(PSL_FILE, "r"))) {
|
||||||
while ((linep = fgets(buf, sizeof(buf), fp))) {
|
while ((linep = fgets(buf, sizeof(buf), fp))) {
|
||||||
while (isspace(*linep)) linep++; // ignore leading whitespace
|
while (isspace(*linep)) linep++; // ignore leading whitespace
|
||||||
if (!*linep) continue; // skip empty lines
|
if (!*linep) continue; // skip empty lines
|
||||||
|
@ -105,7 +105,7 @@ static void test_psl(void)
|
||||||
|
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
} else {
|
} else {
|
||||||
printf("Failed to open %s\n", DATADIR "/effective_tld_names.dat");
|
printf("Failed to open %s\n", PSL_FILE);
|
||||||
failed++;
|
failed++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -70,7 +70,7 @@ static void test_psl(void)
|
||||||
unsigned it;
|
unsigned it;
|
||||||
psl_ctx_t *psl;
|
psl_ctx_t *psl;
|
||||||
|
|
||||||
psl = psl_load_file(DATADIR "/effective_tld_names.dat");
|
psl = psl_load_file(PSL_FILE);
|
||||||
|
|
||||||
printf("loaded %d suffixes and %d exceptions\n", psl_suffix_count(psl), psl_suffix_exception_count(psl));
|
printf("loaded %d suffixes and %d exceptions\n", psl_suffix_count(psl), psl_suffix_exception_count(psl));
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue