From 7080c6553fbebbf058999c5f5a50960257a693a4 Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Thu, 12 Feb 2004 10:02:22 +0000 Subject: [PATCH] * watchgnupg.c (main): Implement option "--". (print_version): New. * Makefile.am: Include cmacros.am for common flags. --- tools/ChangeLog | 7 ++++++ tools/Makefile.am | 9 ++++--- tools/watchgnupg.c | 61 ++++++++++++++++++++++++++++++++++------------ 3 files changed, 58 insertions(+), 19 deletions(-) diff --git a/tools/ChangeLog b/tools/ChangeLog index e764d7b6a..bd99271d6 100644 --- a/tools/ChangeLog +++ b/tools/ChangeLog @@ -1,3 +1,10 @@ +2004-02-12 Werner Koch + + * watchgnupg.c (main): Implement option "--". + (print_version): New. + + * Makefile.am: Include cmacros.am for common flags. + 2004-02-03 Werner Koch * addgnupghome: Try to use getent, so that it also works for NIS diff --git a/tools/Makefile.am b/tools/Makefile.am index 32dd709fa..71a77356f 100644 --- a/tools/Makefile.am +++ b/tools/Makefile.am @@ -21,18 +21,19 @@ EXTRA_DIST = Manifest watchgnupg.c \ rfc822parse.c rfc822parse.h gpgparsemail.c \ addgnupghome -localedir = $(datadir)/locale -INCLUDES = -I../intl -DLOCALEDIR=\"$(localedir)\" +AM_CPPFLAGS = -I$(top_srcdir)/intl -I$(top_srcdir)/common +include $(top_srcdir)/am/cmacros.am # Note, that we require GPG_ERROR_CFLAGS only because some share header files # require that file. It is not actually used in gpgconf. -AM_CFLAGS = -I$(top_srcdir)/common -I$(top_srcdir)/intl @GPG_ERROR_CFLAGS@ +AM_CFLAGS = @GPG_ERROR_CFLAGS@ sbin_SCRIPTS = addgnupghome -bin_PROGRAMS = gpgconf +bin_PROGRAMS = gpgconf watchgnupg gpgconf_SOURCES = gpgconf.c gpgconf.h gpgconf-comp.c no-libgcrypt.c gpgconf_LDADD = ../jnlib/libjnlib.a ../common/libcommon.a @INTLLIBS@ +watchgnupg_SOURCES = watchgnupg.c 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 +#endif #include #include #include @@ -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 .\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,24 +223,20 @@ 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); + argc--; argv++; + break; } - if (!strcmp (*argv, "--verbose")) + else if (!strcmp (*argv, "--version")) + print_version (0); + else if (!strcmp (*argv, "--help")) + print_version (1); + else if (!strcmp (*argv, "--verbose")) { verbose = 1; argc--; argv++; } - else if (!strcmp (*argv, "--debug")) - { - verbose = debug = 1; - argc--; argv++; - } else if (!strcmp (*argv, "--force")) { force = 1; @@ -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); }