* watchgnupg.c (main): Implement option "--".

(print_version): New.

* Makefile.am: Include cmacros.am for common flags.
This commit is contained in:
Werner Koch 2004-02-12 10:02:22 +00:00
parent 270576cf17
commit 7080c6553f
3 changed files with 58 additions and 19 deletions

View File

@ -1,3 +1,10 @@
2004-02-12 Werner Koch <wk@gnupg.org>
* watchgnupg.c (main): Implement option "--".
(print_version): New.
* Makefile.am: Include cmacros.am for common flags.
2004-02-03 Werner Koch <wk@gnupg.org>
* addgnupghome: Try to use getent, so that it also works for NIS

View File

@ -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

View File

@ -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,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);
}