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
30 #ifdef HAVE_LIBREADLINE
31 #define GNUPG_LIBREADLINE_H_INCLUDED
33 #include <readline/readline.h>
34 #include <readline/history.h>
38 #include "common-defs.h"
41 #ifdef HAVE_LIBREADLINE
43 set_completer (rl_completion_func_t
*completer
)
45 rl_attempted_completion_function
= completer
;
46 rl_inhibit_completion
= 0;
50 inhibit_completion (int value
)
52 rl_inhibit_completion
= value
;
56 cleanup_after_signal (void)
58 rl_free_line_state ();
59 rl_cleanup_after_signal ();
63 init_stream (FILE *fp
)
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. */
76 gnupg_rl_initialize (void)
78 #ifdef HAVE_LIBREADLINE
79 tty_private_set_rl_hooks (init_stream
,
85 rl_readline_name
= "GnuPG";