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

« back to all changes in this revision

Viewing changes to common/ttyio.c

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2006-07-11 11:38:13 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20060711113813-zaw7unlbuh7gyxtl
Tags: 1.9.21-0ubuntu1
New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* ttyio.c -  tty i/O functions
2
 
 * Copyright (C) 1998,1999,2000,2001,2002,2003 Free Software Foundation, Inc.
 
2
 * Copyright (C) 1998,1999,2000,2001,2002,2003,
 
3
 *               2004, 2006 Free Software Foundation, Inc.
3
4
 *
4
5
 * This file is part of GnuPG.
5
6
 *
15
16
 *
16
17
 * You should have received a copy of the GNU General Public License
17
18
 * along with this program; if not, write to the Free Software
18
 
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
 
19
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
 
20
 * USA.
19
21
 */
20
22
 
21
23
#include <config.h>
45
47
#endif
46
48
#include <errno.h>
47
49
#include <ctype.h>
 
50
#ifdef HAVE_LIBREADLINE
 
51
#include <readline/readline.h>
 
52
#include <readline/history.h>
 
53
#endif
 
54
 
 
55
 
48
56
#include "util.h"
49
57
#include "memory.h"
50
58
#include "ttyio.h"
93
101
  if (!got_name)
94
102
    {
95
103
      const char *s;
 
104
      /* Note that despite our checks for these macros the function is
 
105
         not necessarily thread save.  We mainly do this for
 
106
         portability reasons, in case L_ctermid is not defined. */
 
107
# if defined(_POSIX_THREAD_SAFE_FUNCTIONS) || defined(_POSIX_TRHEADS)
 
108
      char buffer[L_ctermid];
 
109
      s = ctermid (buffer);
 
110
# else
96
111
      s = ctermid (NULL);
 
112
# endif
97
113
      if (s)
98
114
        name = strdup (s);
99
115
      got_name = 1;
100
116
    }
101
 
#endif
102
 
  /* Assume the staandrd tty on memory error or when tehre is no
 
117
#endif /*HAVE_CTERMID*/
 
118
  /* Assume the standard tty on memory error or when tehre is no
103
119
     certmid. */
104
120
  return name? name : "/dev/tty";
105
121
}
165
181
}
166
182
 
167
183
 
 
184
#ifdef HAVE_LIBREADLINE
 
185
void
 
186
tty_enable_completion(rl_completion_func_t *completer)
 
187
{
 
188
/*   if( no_terminal ) */
 
189
/*     return; */
 
190
 
 
191
/*   if( !initialized ) */
 
192
/*     init_ttyfp(); */
 
193
 
 
194
/*   rl_attempted_completion_function=completer; */
 
195
/*   rl_inhibit_completion=0; */
 
196
}
 
197
 
 
198
void
 
199
tty_disable_completion(void)
 
200
{
 
201
/*   if( no_terminal ) */
 
202
/*     return; */
 
203
 
 
204
/*   if( !initialized ) */
 
205
/*     init_ttyfp(); */
 
206
 
 
207
/*   rl_inhibit_completion=1; */
 
208
}
 
209
#endif /*HAVE_LIBREADLINE*/
 
210
 
 
211
 
168
212
int
169
213
tty_batchmode( int onoff )
170
214
{