summaryrefslogtreecommitdiffstats
path: root/tools/watchgnupg.c
diff options
context:
space:
mode:
authorWerner Koch <wk@gnupg.org>2004-02-12 11:02:22 +0100
committerWerner Koch <wk@gnupg.org>2004-02-12 11:02:22 +0100
commit7080c6553fbebbf058999c5f5a50960257a693a4 (patch)
tree94a44603fc4e7e55996c7cf6264dda6ed9049916 /tools/watchgnupg.c
parentMore stuff for testing (diff)
downloadgnupg2-7080c6553fbebbf058999c5f5a50960257a693a4.tar.xz
gnupg2-7080c6553fbebbf058999c5f5a50960257a693a4.zip
* watchgnupg.c (main): Implement option "--".
(print_version): New. * Makefile.am: Include cmacros.am for common flags.
Diffstat (limited to 'tools/watchgnupg.c')
-rw-r--r--tools/watchgnupg.c61
1 files changed, 46 insertions, 15 deletions
diff --git a/tools/watchgnupg.c b/tools/watchgnupg.c
index dfb11f2de..7f79f2f18 100644
--- a/tools/watchgnupg.c
+++ b/tools/watchgnupg.c
@@ -1,5 +1,5 @@
/* watchgnupg.c - Socket server for GnuPG logs
- * Copyright (C) 2003 Free Software Foundation, Inc.
+ * Copyright (C) 2003, 2004 Free Software Foundation, Inc.
*
* This file is part of GnuPG.
*
@@ -18,6 +18,9 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
#include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
@@ -33,8 +36,16 @@
#define PGM "watchgnupg"
+/* Allow for a standalone build. */
+#ifdef VERSION
+#define MYVERSION_LINE PGM " (GnuPG) " VERSION
+#define BUGREPORT_LINE "\nReport bugs to <bug-gnupg@gnu.org>.\n"
+#else
+#define MYVERSION_LINE PGM
+#define BUGREPORT_LINE ""
+#endif
+
static int verbose;
-static int debug;
static void
@@ -169,6 +180,29 @@ print_line (client_t c, const char *line)
}
+static void
+print_version (int with_help)
+{
+ fputs (MYVERSION_LINE "\n"
+ "Copyright (C) 2004 Free Software Foundation, Inc.\n"
+ "This program comes with ABSOLUTELY NO WARRANTY.\n"
+ "This is free software, and you are welcome to redistribute it\n"
+ "under certain conditions. See the file COPYING for details.\n",
+ stdout);
+
+ if (with_help)
+ fputs ("\n"
+ "Usage: " PGM " [OPTIONS] SOCKETNAME\n"
+ "Open the local socket SOCKETNAME and display log messages\n"
+ "\n"
+ " --force delete an already existing socket file\n"
+ " --verbose enable extra informational output\n"
+ " --version print version of the program and exit\n"
+ " --help display this help and exit\n"
+ BUGREPORT_LINE, stdout );
+
+ exit (0);
+}
int
main (int argc, char **argv)
@@ -189,22 +223,18 @@ main (int argc, char **argv)
while (argc && last_argc != argc )
{
last_argc = argc;
- if (!strcmp (*argv, "--help"))
+ if (!strcmp (*argv, "--"))
{
- puts (
- "usage: " PGM " [options] socketname\n"
- "\n"
- " Options are --verbose, --debug and --force");
- exit (0);
- }
- if (!strcmp (*argv, "--verbose"))
- {
- verbose = 1;
argc--; argv++;
+ break;
}
- else if (!strcmp (*argv, "--debug"))
+ else if (!strcmp (*argv, "--version"))
+ print_version (0);
+ else if (!strcmp (*argv, "--help"))
+ print_version (1);
+ else if (!strcmp (*argv, "--verbose"))
{
- verbose = debug = 1;
+ verbose = 1;
argc--; argv++;
}
else if (!strcmp (*argv, "--force"))
@@ -216,7 +246,8 @@ main (int argc, char **argv)
if (argc != 1)
{
- die ("usage: " PGM " socketname\n");
+ fprintf (stderr, "usage: " PGM " socketname\n");
+ exit (1);
}