~ubuntu-branches/ubuntu/feisty/gnupg2/feisty

« back to all changes in this revision

Viewing changes to common/gpgrlhelp.c

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt
  • Date: 2006-11-24 18:48:23 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20061124184823-17ir9m46tl09n9k4
Tags: 2.0.0-4ubuntu1
* Synchronize to Debian, reapply remaining Ubuntu changes to pristine Debian
  version:
  - Remove libpcsclite-dev, libopensc2-dev build dependencies (they are in
    universe).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* gpgrlhelp.c - A readline wrapper.
 
2
 *      Copyright (C) 2006 Free Software Foundation, Inc.
 
3
 *
 
4
 * This file is part of GnuPG.
 
5
 *
 
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 2 of the License, or
 
9
 * (at your option) any later version.
 
10
 *
 
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.
 
15
 *
 
16
 * You should have received a copy of the GNU General Public License
 
17
 * along with this program; if not, write to the Free Software
 
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
 
19
 * USA.
 
20
 */
 
21
 
 
22
/* This module may by used by applications to initializes readline
 
23
   support.  It is required so that we can have hooks in other parts
 
24
   of libcommon without actually requing to link against
 
25
   libreadline. It works along ttyio.c which a proper part of
 
26
   libcommon. */
 
27
 
 
28
#include <config.h>
 
29
#include <stdlib.h>
 
30
#include <stddef.h>
 
31
 
 
32
#ifdef HAVE_LIBREADLINE
 
33
#define GNUPG_LIBREADLINE_H_INCLUDED
 
34
#include <stdio.h>
 
35
#include <readline/readline.h>
 
36
#include <readline/history.h>
 
37
#endif
 
38
 
 
39
#include "util.h"
 
40
#include "common-defs.h"
 
41
 
 
42
 
 
43
#ifdef HAVE_LIBREADLINE
 
44
static void
 
45
set_completer (rl_completion_func_t *completer)
 
46
{
 
47
  rl_attempted_completion_function = completer;
 
48
  rl_inhibit_completion = 0;
 
49
}
 
50
 
 
51
static void
 
52
inhibit_completion (int value)
 
53
{
 
54
  rl_inhibit_completion = value;
 
55
}
 
56
 
 
57
static void
 
58
cleanup_after_signal (void)
 
59
{
 
60
  rl_free_line_state ();
 
61
  rl_cleanup_after_signal ();
 
62
}
 
63
 
 
64
static void
 
65
init_stream (FILE *fp)
 
66
{
 
67
  rl_catch_signals = 0;
 
68
  rl_instream = rl_outstream = fp;
 
69
  rl_inhibit_completion = 1;
 
70
}
 
71
 
 
72
#endif /*HAVE_LIBREADLINE*/
 
73
 
 
74
 
 
75
/* Initialize our readline code.  This should be called as early as
 
76
   possible as it is actually a constructur.  */
 
77
void
 
78
gnupg_rl_initialize (void)
 
79
{
 
80
#ifdef HAVE_LIBREADLINE
 
81
  tty_private_set_rl_hooks (init_stream,
 
82
                            set_completer,
 
83
                            inhibit_completion,
 
84
                            cleanup_after_signal,
 
85
                            readline,
 
86
                            add_history);
 
87
  rl_readline_name = "GnuPG";
 
88
#endif
 
89
}
 
90
 
 
91
 
 
92
 
 
93