Add --use-latest-psl to tools/psl, now default

Fixes #76
This commit is contained in:
Tim Rühsen 2016-12-15 12:51:35 +01:00
parent 3c3320180e
commit d4ea513f27
2 changed files with 16 additions and 3 deletions

View File

@ -42,12 +42,15 @@ show library version information
\fB\-\-print\-info\fR
print info about library builtin data
.SH PUBLIC SUFFIX DATA
By default, `psl' will use built-in Public Suffix data.
By default, `psl' will use the latest available Public Suffix data.
.br
You can also direct it to use a different file:
.TP
\fB\-\-use\-latest\-data\fR
use the latest available PSL data [default]
.TP
\fB\-\-use\-builtin\-data\fR
use the builtin PSL data [default]
use the builtin PSL data
.TP
\fB\-\-load\-psl\-file\fR <filename>
load PSL data from file

View File

@ -45,7 +45,8 @@ static void usage(int err, FILE* f)
fprintf(f, "\n");
fprintf(f, "Options:\n");
fprintf(f, " --version show library version information\n");
fprintf(f, " --use-builtin-data use the builtin PSL data [default]\n");
fprintf(f, " --use-latest-data use the latest PSL data available [default]\n");
fprintf(f, " --use-builtin-data use the builtin PSL data\n");
fprintf(f, " --load-psl-file <filename> load PSL data from file\n");
fprintf(f, " --is-public-suffix check if domains are public suffixes [default]\n");
fprintf(f, " --is-cookie-domain-acceptable <cookie-domain>\n");
@ -92,6 +93,15 @@ int main(int argc, const char *const *argv)
mode = 4;
cookie_domain = *(++arg);
}
else if (!strcmp(*arg, "--use-latest-data")) {
psl_free(psl);
if (psl_file) {
fprintf(stderr, "Dropped data from %s\n", psl_file);
psl_file = NULL;
}
if (!(psl = (psl_ctx_t *) psl_latest(NULL)))
printf("No PSL data available\n");
}
else if (!strcmp(*arg, "--use-builtin-data")) {
psl_free(psl);
if (psl_file) {