From 9b9c3a35c13ad8a9096891846ced86ac95586d52 Mon Sep 17 00:00:00 2001 From: Daniel Kahn Gillmor Date: Fri, 6 Jun 2014 01:10:21 -0400 Subject: [PATCH] clean up help output --- tools/psl.c | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/tools/psl.c b/tools/psl.c index 9d684e6..7af00ca 100644 --- a/tools/psl.c +++ b/tools/psl.c @@ -36,22 +36,22 @@ #include #include -static void usage(int err) +static void usage(int err, FILE* f) { - fprintf(stderr, "\n"); - fprintf(stderr, "Usage: psl [options] \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 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 \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] \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 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 \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,7 +124,7 @@ int main(int argc, const char *const *argv) } else { fprintf(stderr, "Unknown option '%s'\n", *arg); - usage(1); + usage(1, stderr); } } else break;