1 /* gpgrlhelp.c - A readline wrapper.
2 * Copyright (C) 2006 Free Software Foundation, Inc.
4 * This file is part of GnuPG.
6 * This file is free software; you can redistribute it and/or modify
7 * it under the terms of either
9 * - the GNU Lesser General Public License as published by the Free
10 * Software Foundation; either version 3 of the License, or (at
11 * your option) any later version.
15 * - the GNU General Public License as published by the Free
16 * Software Foundation; either version 2 of the License, or (at
17 * your option) any later version.
19 * or both in parallel, as here.
21 * This file is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU General Public License for more details.
26 * You should have received a copy of the GNU General Public License
27 * along with this program; if not, see <https://www.gnu.org/licenses/>.
30 /* This module may by used by applications to initializes readline
31 support. It is required so that we can have hooks in other parts
32 of libcommon without actually requiring to link against
33 libreadline. It works along with ttyio.c which is a proper part of
40 #ifdef HAVE_LIBREADLINE
41 #define GNUPG_LIBREADLINE_H_INCLUDED
43 #include <readline/readline.h>
44 #include <readline/history.h>
48 #include "common-defs.h"
51 #ifdef HAVE_LIBREADLINE
53 set_completer (rl_completion_func_t *completer)
55 rl_attempted_completion_function = completer;
56 rl_inhibit_completion = 0;
60 inhibit_completion (int value)
62 rl_inhibit_completion = value;
66 cleanup_after_signal (void)
68 rl_free_line_state ();
69 rl_cleanup_after_signal ();
73 init_stream (FILE *fp)
76 rl_instream = rl_outstream = fp;
77 rl_inhibit_completion = 1;
80 #endif /*HAVE_LIBREADLINE*/
83 /* Initialize our readline code. This should be called as early as
84 possible as it is actually a constructur. */
86 gnupg_rl_initialize (void)
88 #ifdef HAVE_LIBREADLINE
89 tty_private_set_rl_hooks (init_stream,
95 rl_readline_name = GNUPG_NAME;