1
0
mirror of git://git.gnupg.org/gnupg.git synced 2024-12-22 10:19:57 +01:00

Various updates

This commit is contained in:
Werner Koch 2006-09-21 13:30:45 +00:00
parent c69dc436ce
commit 43ab905823
19 changed files with 138 additions and 66 deletions

View File

@ -1,3 +1,13 @@
2006-09-21 Werner Koch <wk@g10code.com>
* ttyio.c (tty_private_set_rl_hooks): New.
(tty_enable_completion, tty_disable_completion): Use a hook to
enable readline support. Now always available.
(tty_cleanup_rl_after_signal): New.
* ttyio.h: Removed readline specific stuff. Included util.h.
* common-defs.h: New.
2006-09-15 Werner Koch <wk@g10code.com>
* convert.c: New.

View File

@ -20,7 +20,7 @@
## Process this file with automake to produce Makefile.in
noinst_LIBRARIES = libcommon.a libsimple-pwquery.a
noinst_LIBRARIES = libcommon.a libsimple-pwquery.a libgpgrl.a
noinst_PROGRAMS = $(module_tests)
TESTS = $(module_tests)
@ -30,6 +30,7 @@ AM_CFLAGS = $(LIBGCRYPT_CFLAGS) $(LIBASSUAN_CFLAGS) $(KSBA_CFLAGS) \
$(PTH_CFLAGS)
libcommon_a_SOURCES = \
common-defs.h \
util.h i18n.h \
errors.h \
openpgpdefs.h \
@ -63,6 +64,8 @@ libcommon_a_SOURCES = \
libsimple_pwquery_a_SOURCES = \
simple-pwquery.c simple-pwquery.h asshelp.c asshelp.h
libgpgrl_a_SOURCES = \
gpgrlhelp.c
#
# Module tests

32
common/common-defs.h Normal file
View File

@ -0,0 +1,32 @@
/* common-defs.h - Private declarations for common/
* Copyright (C) 2006 Free Software Foundation, Inc.
*
* This file is part of GnuPG.
*
* GnuPG is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* GnuPG is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*/
#ifndef GNUPG_COMMON_COMMON_DEFS_H
#define GNUPG_COMMON_COMMON_DEFS_H
/*-- ttyio.c --*/
void tty_private_set_rl_hooks (void (*set_completer) (rl_completion_func_t*),
void (*inhibit_completion) (int),
void (*cleanup_after_signal) (void) );
#endif /*GNUPG_COMMON_COMMON_DEFS_H*/

View File

@ -39,7 +39,6 @@
#include <swis.h>
#endif /* __riscos__ */
#include "memory.h"
#include "util.h"
#include "iobuf.h"

View File

@ -47,15 +47,10 @@
#endif
#include <errno.h>
#include <ctype.h>
#ifdef HAVE_LIBREADLINE
#include <readline/readline.h>
#include <readline/history.h>
#endif
#include "util.h"
#include "memory.h"
#include "ttyio.h"
#include "common-defs.h"
#define CONTROL_D ('D' - 'A' + 1)
@ -82,6 +77,11 @@ static int no_terminal;
static int restore_termios;
#endif
/* Hooks set by gpgrlhelp.c if required. */
static void (*my_rl_set_completer) (rl_completion_func_t *);
static void (*my_rl_inhibit_completion) (int);
static void (*my_rl_cleanup_after_signal) (void);
/* This is a wrapper around ttyname so that we can use it even when
@ -181,34 +181,6 @@ init_ttyfp(void)
}
#ifdef HAVE_LIBREADLINE
void
tty_enable_completion(rl_completion_func_t *completer)
{
/* if( no_terminal ) */
/* return; */
/* if( !initialized ) */
/* init_ttyfp(); */
/* rl_attempted_completion_function=completer; */
/* rl_inhibit_completion=0; */
}
void
tty_disable_completion(void)
{
/* if( no_terminal ) */
/* return; */
/* if( !initialized ) */
/* init_ttyfp(); */
/* rl_inhibit_completion=1; */
}
#endif /*HAVE_LIBREADLINE*/
int
tty_batchmode( int onoff )
{
@ -597,3 +569,48 @@ tty_get_answer_is_yes( const char *prompt )
xfree(p);
return yes;
}
/* Called by gnupg_rl_initialize to setup the reradline support. */
void
tty_private_set_rl_hooks (void (*set_completer) (rl_completion_func_t*),
void (*inhibit_completion) (int),
void (*cleanup_after_signal) (void))
{
my_rl_set_completer = set_completer;
my_rl_inhibit_completion = inhibit_completion;
my_rl_cleanup_after_signal = cleanup_after_signal;
}
void
tty_enable_completion (rl_completion_func_t *completer)
{
if (no_terminal || !my_rl_set_completer )
return;
if (!initialized)
init_ttyfp();
my_rl_set_completer (completer);
}
void
tty_disable_completion (void)
{
if (no_terminal || !my_rl_inhibit_completion)
return;
if (!initialized)
init_ttyfp();
my_rl_inhibit_completion (1);
}
void
tty_cleanup_rl_after_signal (void)
{
if (my_rl_cleanup_after_signal)
my_rl_cleanup_after_signal ();
}

View File

@ -21,10 +21,8 @@
#ifndef GNUPG_COMMON_TTYIO_H
#define GNUPG_COMMON_TTYIO_H
#ifdef HAVE_LIBREADLINE
#include <stdio.h>
#include <readline/readline.h>
#endif
#include "util.h" /* Make sure our readline typedef is available. */
const char *tty_get_ttyname (void);
int tty_batchmode (int onoff);
@ -46,16 +44,9 @@ void tty_kill_prompt (void);
int tty_get_answer_is_yes (const char *prompt);
int tty_no_terminal (int onoff);
#ifdef HAVE_LIBREADLINE
void tty_enable_completion(rl_completion_func_t *completer);
void tty_disable_completion(void);
#else
/* Use a macro to stub out these functions since a macro has no need
to typedef a "rl_completion_func_t" which would be undefined
without readline. */
#define tty_enable_completion(x)
#define tty_disable_completion()
#endif
void tty_enable_completion (rl_completion_func_t *completer);
void tty_disable_completion (void);
void tty_cleanup_rl_after_signal (void);
#endif /*GNUPG_COMMON_TTYIO_H*/

View File

@ -45,6 +45,13 @@
#include "../jnlib/dotlock.h"
#include "../jnlib/utf8conv.h"
/* We need this type even if we are not using libreadline and or we
did not include libreadline in the current file. */
#ifndef GNUPG_LIBREADLINE_H_INCLUDED
typedef char **rl_completion_func_t (const char *, int, int);
#endif /*!GNUPG_LIBREADLINE_H_INCLUDED*/
/* Handy malloc macros - please use only them. */
#define xtrymalloc(a) gcry_malloc ((a))
#define xtrymalloc_secure(a) gcry_malloc_secure ((a))
@ -153,6 +160,8 @@ char *bin2hexcolon (const void *buffer, size_t length, char *stringbuf);
/*-- homedir.c --*/
const char *default_homedir (void);
/*-- gpgrlhelp.c --*/
void gnupg_rl_initialize (void);
/*-- miscellaneous.c --*/

View File

@ -189,7 +189,9 @@ utilizes the @code{dirmngr} service.
Same as @option{--list-keys} but also prints all keys making up the chain.
@item --dump-keys
@item --dump-cert
@itemx --dump-keys
@opindex dump-cert
@opindex dump-keys
List all available certificates stored in the local key database using a
format useful mainly for debugging.

View File

@ -822,7 +822,7 @@ parse_file (const char *fname, FILE *fp, char **section_name, int in_pause)
lnr++;
if (!n || line[n-1] != '\n')
{
err ("%s:$d: trailing linefeed missing, line too long or "
err ("%s:%d: trailing linefeed missing, line too long or "
"embedded Nul character", fname, lnr);
break;
}

View File

@ -1,3 +1,14 @@
2006-09-21 Werner Koch <wk@g10code.com>
* signal.c (got_fatal_signal): Replaced readline stuff by a tty
function.
* Makefile.am (LDADD): Include libgpgrl.a.
* gpg.c (main): Call gpg_rl_initialize.
* keyedit.c: Removed double inclusion of stdio.h.
2006-09-20 Werner Koch <wk@g10code.com>
* call-agent.c: Include asshelp.h.

View File

@ -108,12 +108,13 @@ gpgv2_SOURCES = gpgv.c \
# ks-db.h \
# $(common_source)
LDADD = $(needed_libs) $(ZLIBS) $(DNSLIBS) $(LIBREADLINE) \
LDADD = $(needed_libs) ../common/libgpgrl.a \
$(ZLIBS) $(DNSLIBS) $(LIBREADLINE) \
$(LIBINTL) $(CAPLIBS) $(W32LIBS)
gpg2_LDADD = $(LIBGCRYPT_LIBS) $(LDADD) $(LIBASSUAN_LIBS) $(GPG_ERROR_LIBS)
gpgv2_LDADD = $(LIBGCRYPT_LIBS) $(LDADD) $(LIBASSUAN_LIBS) $(GPG_ERROR_LIBS)
$(PROGRAMS): $(needed_libs)
$(PROGRAMS): $(needed_libs) ../common/libgpgrl.a
install-data-local:
$(mkinstalldirs) $(DESTDIR)$(pkgdatadir)

View File

@ -38,6 +38,7 @@
#include "keyserver-internal.h"
#if GNUPG_MAJOR_VERSION == 1
# ifdef HAVE_LIBREADLINE
# define GNUPG_LIBREADLINE_H_INCLUDED
# include <stdio.h>
# include <readline/readline.h>
# endif /*HAVE_LIBREADLINE*/

View File

@ -30,7 +30,6 @@
#include "packet.h"
#include "errors.h"
#include "iobuf.h"
#include "memory.h"
#include "util.h"
#include "main.h"
#include "keydb.h"

View File

@ -1771,7 +1771,8 @@ main (int argc, char **argv )
when adding any stuff between here and the call to
secmem_init() somewhere after the option parsing. */
reopen_std ();
trap_unaligned();
trap_unaligned ();
gnupg_rl_initialize ();
set_strusage (my_strusage);
gcry_control (GCRYCTL_SUSPEND_SECMEM_WARN);
/* We don't need any locking in libgcrypt unless we use any kind of

View File

@ -31,7 +31,7 @@
#include <fcntl.h> /* for setmode() */
#endif
#ifdef HAVE_LIBREADLINE
#include <stdio.h>
#define GNUPG_LIBREADLINE_H_INCLUDED
#include <readline/readline.h>
#endif

View File

@ -28,7 +28,7 @@
#include <assert.h>
#include <ctype.h>
#ifdef HAVE_LIBREADLINE
#include <stdio.h>
#define GNUPG_LIBREADLINE_H_INCLUDED
#include <readline/readline.h>
#endif

View File

@ -28,10 +28,6 @@
#include <string.h>
#include <errno.h>
#include <assert.h>
#ifdef HAVE_LIBREADLINE
#include <readline/readline.h>
#include <readline/history.h>
#endif
#include "gpg.h"
#include "options.h"
@ -86,10 +82,7 @@ got_fatal_signal( int sig )
gcry_control (GCRYCTL_TERM_SECMEM );
#ifdef HAVE_LIBREADLINE
rl_free_line_state ();
rl_cleanup_after_signal ();
#endif
tty_cleanup_rl_after_signal ();
/* Better don't translate these messages. */
write(2, "\n", 1 );

View File

@ -1,5 +1,7 @@
2006-09-20 Werner Koch <wk@g10code.com>
* gpgsm.c: Add alias command --dump-cert.
* Makefile.am: Changes to allow parallel make runs.
2006-09-18 Werner Koch <wk@g10code.com>

View File

@ -268,6 +268,7 @@ static ARGPARSE_OPTS opts[] = {
{ aPasswd, "passwd", 256, N_("change a passphrase")},
{ aGPGConfList, "gpgconf-list", 256, "@" },
{ aDumpKeys, "dump-cert", 256, "@"},
{ aDumpKeys, "dump-keys", 256, "@"},
{ aDumpChain, "dump-chain", 256, "@"},
{ aDumpExternalKeys, "dump-external-keys", 256, "@"},