Merge pull request #6 from dkg/develop

Develop
This commit is contained in:
rockdaboot 2014-06-06 12:04:51 +02:00
commit 21af3c9fd4
3 changed files with 30 additions and 24 deletions

View File

@ -446,7 +446,7 @@ int main(int argc, const char **argv)
fprintf(fpout, "static time_t _psl_file_time = %lu;\n", st.st_mtime);
fprintf(fpout, "static time_t _psl_compile_time = %lu;\n", time(NULL));
fprintf(fpout, "static const char _psl_sha1_checksum[] = \"%s\";\n", checksum);
fprintf(fpout, "static const char _psl_filename[] = \"%s\";\n", checksum);
fprintf(fpout, "static const char _psl_filename[] = \"%s\";\n", argv[1]);
if (fclose(fpout) != 0)
ret = 4;

View File

@ -1,5 +1,4 @@
bin_PROGRAMS = psl
AM_CPPFLAGS = -I$(top_srcdir)/include
AM_LDFLAGS = -static
LDADD = ../src/libpsl.la
AM_LDFLAGS = -lpsl -L$(top_srcdir)/src

View File

@ -36,22 +36,22 @@
#include <string.h>
#include <libpsl.h>
static void usage(int err)
static void usage(int err, FILE* f)
{
fprintf(stderr, "\n");
fprintf(stderr, "Usage: psl [options] <domains...>\n");
fprintf(stderr, "\n");
fprintf(stderr, "Options:\n");
fprintf(stderr, " --version show library version information\n");
fprintf(stderr, " --use-builtin-data use the builtin PSL data. [default]\n");
fprintf(stderr, " --load-psl-file <filename> load PSL data from file.\n");
fprintf(stderr, " --is-public-suffix check if domains are public suffixes or not. [default]\n");
fprintf(stderr, " --is-cookie-domain-acceptable <cookie-domain>\n");
fprintf(stderr, " check if cookie-domain is acceptable for domains.\n");
fprintf(stderr, " --print-unreg-domain print the longest publix suffix part\n");
fprintf(stderr, " --print-reg-domain print the shortest private suffix part\n");
fprintf(stderr, " --print-info print info about library builtin data\n");
fprintf(stderr, "\n");
fprintf(f, "Usage: psl [options] <domains...>\n");
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, " --load-psl-file <filename> load PSL data from file.\n");
fprintf(f, " --is-public-suffix check if domains are public suffixes or not. [default]\n");
fprintf(f, " --is-cookie-domain-acceptable <cookie-domain>\n");
fprintf(f, " check if cookie-domain is acceptable for domains.\n");
fprintf(f, " --print-unreg-domain print the longest publix suffix part\n");
fprintf(f, " --print-reg-domain print the shortest private suffix part\n");
fprintf(f, " --print-info print info about library builtin data\n");
fprintf(f, "\n");
fprintf(f, "\n");
exit(err);
}
@ -102,12 +102,13 @@ int main(int argc, const char *const *argv)
psl_file = NULL;
}
if (!(psl = psl_load_file(psl_file = *(++arg)))) {
fprintf(stderr, "Failed to load PSL data from %s\n", psl_file);
fprintf(stderr, "Failed to load PSL data from %s\n\n", psl_file);
psl_file = NULL;
}
}
else if (!strcmp(*arg, "--help")) {
usage(0);
fprintf(stdout, "`psl' explores the Public Suffix List\n\n");
usage(0, stdout);
}
else if (!strcmp(*arg, "--version")) {
printf("psl %s\n", PACKAGE_VERSION);
@ -123,16 +124,22 @@ int main(int argc, const char *const *argv)
}
else {
fprintf(stderr, "Unknown option '%s'\n", *arg);
usage(1);
usage(1, stderr);
}
} else
break;
}
if (!psl && mode != 99) {
printf("No PSL data available - aborting\n");
if (mode != 99) {
if (!psl) {
fprintf(stderr, "No PSL data available - aborting\n");
exit(2);
}
if (arg >= argv + argc) {
fprintf(stderr, "No domains given - aborting\n");
exit(3);
}
}
if (mode == 1) {
for (; arg < argv + argc; arg++)