Improved detection of bad/invalid signer keys.
[gnupg.git] / common / gpgrlhelp.c
blob28459aac2664225a4b5c5053750baec01537b09b
1 /* gpgrlhelp.c - A readline wrapper.
2 * Copyright (C) 2006 Free Software Foundation, Inc.
4 * This file is part of GnuPG.
6 * GnuPG is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
11 * GnuPG is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, see <http://www.gnu.org/licenses/>.
20 /* This module may by used by applications to initializes readline
21 support. It is required so that we can have hooks in other parts
22 of libcommon without actually requiring to link against
23 libreadline. It works along with ttyio.c which is a proper part of
24 libcommon. */
26 #include <config.h>
27 #include <stdlib.h>
28 #include <stddef.h>
30 #ifdef HAVE_LIBREADLINE
31 #define GNUPG_LIBREADLINE_H_INCLUDED
32 #include <stdio.h>
33 #include <readline/readline.h>
34 #include <readline/history.h>
35 #endif
37 #include "util.h"
38 #include "common-defs.h"
41 #ifdef HAVE_LIBREADLINE
42 static void
43 set_completer (rl_completion_func_t *completer)
45 rl_attempted_completion_function = completer;
46 rl_inhibit_completion = 0;
49 static void
50 inhibit_completion (int value)
52 rl_inhibit_completion = value;
55 static void
56 cleanup_after_signal (void)
58 rl_free_line_state ();
59 rl_cleanup_after_signal ();
62 static void
63 init_stream (FILE *fp)
65 rl_catch_signals = 0;
66 rl_instream = rl_outstream = fp;
67 rl_inhibit_completion = 1;
70 #endif /*HAVE_LIBREADLINE*/
73 /* Initialize our readline code. This should be called as early as
74 possible as it is actually a constructur. */
75 void
76 gnupg_rl_initialize (void)
78 #ifdef HAVE_LIBREADLINE
79 tty_private_set_rl_hooks (init_stream,
80 set_completer,
81 inhibit_completion,
82 cleanup_after_signal,
83 readline,
84 add_history);
85 rl_readline_name = "GnuPG";
86 #endif