OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [gdb-6.8/] [readline/] [rltty.c] - Diff between revs 827 and 840

Only display areas with differences | Details | Blame | View Log

Rev 827 Rev 840
/* rltty.c -- functions to prepare and restore the terminal for readline's
/* rltty.c -- functions to prepare and restore the terminal for readline's
   use. */
   use. */
 
 
/* Copyright (C) 1992-2005 Free Software Foundation, Inc.
/* Copyright (C) 1992-2005 Free Software Foundation, Inc.
 
 
   This file is part of the GNU Readline Library, a library for
   This file is part of the GNU Readline Library, a library for
   reading lines of text with interactive input and history editing.
   reading lines of text with interactive input and history editing.
 
 
   The GNU Readline Library is free software; you can redistribute it
   The GNU Readline Library is free software; you can redistribute it
   and/or modify it under the terms of the GNU General Public License
   and/or modify it under the terms of the GNU General Public License
   as published by the Free Software Foundation; either version 2, or
   as published by the Free Software Foundation; either version 2, or
   (at your option) any later version.
   (at your option) any later version.
 
 
   The GNU Readline Library is distributed in the hope that it will be
   The GNU Readline Library is distributed in the hope that it will be
   useful, but WITHOUT ANY WARRANTY; without even the implied warranty
   useful, but WITHOUT ANY WARRANTY; without even the implied warranty
   of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.
   GNU General Public License for more details.
 
 
   The GNU General Public License is often shipped with GNU software, and
   The GNU General Public License is often shipped with GNU software, and
   is generally kept in a file called COPYING or LICENSE.  If you do not
   is generally kept in a file called COPYING or LICENSE.  If you do not
   have a copy of the license, write to the Free Software Foundation,
   have a copy of the license, write to the Free Software Foundation,
   59 Temple Place, Suite 330, Boston, MA 02111 USA. */
   59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#define READLINE_LIBRARY
#define READLINE_LIBRARY
 
 
#if defined (HAVE_CONFIG_H)
#if defined (HAVE_CONFIG_H)
#  include <config.h>
#  include <config.h>
#endif
#endif
 
 
#include <sys/types.h>
#include <sys/types.h>
#include <signal.h>
#include <signal.h>
#include <errno.h>
#include <errno.h>
#include <stdio.h>
#include <stdio.h>
 
 
#if defined (HAVE_UNISTD_H)
#if defined (HAVE_UNISTD_H)
#  include <unistd.h>
#  include <unistd.h>
#endif /* HAVE_UNISTD_H */
#endif /* HAVE_UNISTD_H */
 
 
#include "rldefs.h"
#include "rldefs.h"
 
 
#if defined (GWINSZ_IN_SYS_IOCTL)
#if defined (GWINSZ_IN_SYS_IOCTL)
#  include <sys/ioctl.h>
#  include <sys/ioctl.h>
#endif /* GWINSZ_IN_SYS_IOCTL */
#endif /* GWINSZ_IN_SYS_IOCTL */
 
 
#include "rltty.h"
#include "rltty.h"
#include "readline.h"
#include "readline.h"
#include "rlprivate.h"
#include "rlprivate.h"
 
 
#if !defined (errno)
#if !defined (errno)
extern int errno;
extern int errno;
#endif /* !errno */
#endif /* !errno */
 
 
rl_vintfunc_t *rl_prep_term_function = rl_prep_terminal;
rl_vintfunc_t *rl_prep_term_function = rl_prep_terminal;
rl_voidfunc_t *rl_deprep_term_function = rl_deprep_terminal;
rl_voidfunc_t *rl_deprep_term_function = rl_deprep_terminal;
 
 
static void block_sigint PARAMS((void));
static void block_sigint PARAMS((void));
static void release_sigint PARAMS((void));
static void release_sigint PARAMS((void));
 
 
static void set_winsize PARAMS((int));
static void set_winsize PARAMS((int));
 
 
/* **************************************************************** */
/* **************************************************************** */
/*                                                                  */
/*                                                                  */
/*                         Signal Management                        */
/*                         Signal Management                        */
/*                                                                  */
/*                                                                  */
/* **************************************************************** */
/* **************************************************************** */
 
 
#if defined (HAVE_POSIX_SIGNALS)
#if defined (HAVE_POSIX_SIGNALS)
static sigset_t sigint_set, sigint_oset;
static sigset_t sigint_set, sigint_oset;
#else /* !HAVE_POSIX_SIGNALS */
#else /* !HAVE_POSIX_SIGNALS */
#  if defined (HAVE_BSD_SIGNALS)
#  if defined (HAVE_BSD_SIGNALS)
static int sigint_oldmask;
static int sigint_oldmask;
#  endif /* HAVE_BSD_SIGNALS */
#  endif /* HAVE_BSD_SIGNALS */
#endif /* !HAVE_POSIX_SIGNALS */
#endif /* !HAVE_POSIX_SIGNALS */
 
 
static int sigint_blocked;
static int sigint_blocked;
 
 
/* Cause SIGINT to not be delivered until the corresponding call to
/* Cause SIGINT to not be delivered until the corresponding call to
   release_sigint(). */
   release_sigint(). */
static void
static void
block_sigint ()
block_sigint ()
{
{
  if (sigint_blocked)
  if (sigint_blocked)
    return;
    return;
 
 
#if defined (HAVE_POSIX_SIGNALS)
#if defined (HAVE_POSIX_SIGNALS)
  sigemptyset (&sigint_set);
  sigemptyset (&sigint_set);
  sigemptyset (&sigint_oset);
  sigemptyset (&sigint_oset);
  sigaddset (&sigint_set, SIGINT);
  sigaddset (&sigint_set, SIGINT);
  sigprocmask (SIG_BLOCK, &sigint_set, &sigint_oset);
  sigprocmask (SIG_BLOCK, &sigint_set, &sigint_oset);
#else /* !HAVE_POSIX_SIGNALS */
#else /* !HAVE_POSIX_SIGNALS */
#  if defined (HAVE_BSD_SIGNALS)
#  if defined (HAVE_BSD_SIGNALS)
  sigint_oldmask = sigblock (sigmask (SIGINT));
  sigint_oldmask = sigblock (sigmask (SIGINT));
#  else /* !HAVE_BSD_SIGNALS */
#  else /* !HAVE_BSD_SIGNALS */
#    if defined (HAVE_USG_SIGHOLD)
#    if defined (HAVE_USG_SIGHOLD)
  sighold (SIGINT);
  sighold (SIGINT);
#    endif /* HAVE_USG_SIGHOLD */
#    endif /* HAVE_USG_SIGHOLD */
#  endif /* !HAVE_BSD_SIGNALS */
#  endif /* !HAVE_BSD_SIGNALS */
#endif /* !HAVE_POSIX_SIGNALS */
#endif /* !HAVE_POSIX_SIGNALS */
 
 
  sigint_blocked = 1;
  sigint_blocked = 1;
}
}
 
 
/* Allow SIGINT to be delivered. */
/* Allow SIGINT to be delivered. */
static void
static void
release_sigint ()
release_sigint ()
{
{
  if (sigint_blocked == 0)
  if (sigint_blocked == 0)
    return;
    return;
 
 
#if defined (HAVE_POSIX_SIGNALS)
#if defined (HAVE_POSIX_SIGNALS)
  sigprocmask (SIG_SETMASK, &sigint_oset, (sigset_t *)NULL);
  sigprocmask (SIG_SETMASK, &sigint_oset, (sigset_t *)NULL);
#else
#else
#  if defined (HAVE_BSD_SIGNALS)
#  if defined (HAVE_BSD_SIGNALS)
  sigsetmask (sigint_oldmask);
  sigsetmask (sigint_oldmask);
#  else /* !HAVE_BSD_SIGNALS */
#  else /* !HAVE_BSD_SIGNALS */
#    if defined (HAVE_USG_SIGHOLD)
#    if defined (HAVE_USG_SIGHOLD)
  sigrelse (SIGINT);
  sigrelse (SIGINT);
#    endif /* HAVE_USG_SIGHOLD */
#    endif /* HAVE_USG_SIGHOLD */
#  endif /* !HAVE_BSD_SIGNALS */
#  endif /* !HAVE_BSD_SIGNALS */
#endif /* !HAVE_POSIX_SIGNALS */
#endif /* !HAVE_POSIX_SIGNALS */
 
 
  sigint_blocked = 0;
  sigint_blocked = 0;
}
}
 
 
/* **************************************************************** */
/* **************************************************************** */
/*                                                                  */
/*                                                                  */
/*                    Saving and Restoring the TTY                  */
/*                    Saving and Restoring the TTY                  */
/*                                                                  */
/*                                                                  */
/* **************************************************************** */
/* **************************************************************** */
 
 
/* Non-zero means that the terminal is in a prepped state. */
/* Non-zero means that the terminal is in a prepped state. */
static int terminal_prepped;
static int terminal_prepped;
 
 
static _RL_TTY_CHARS _rl_tty_chars, _rl_last_tty_chars;
static _RL_TTY_CHARS _rl_tty_chars, _rl_last_tty_chars;
 
 
/* If non-zero, means that this process has called tcflow(fd, TCOOFF)
/* If non-zero, means that this process has called tcflow(fd, TCOOFF)
   and output is suspended. */
   and output is suspended. */
#if defined (__ksr1__)
#if defined (__ksr1__)
static int ksrflow;
static int ksrflow;
#endif
#endif
 
 
/* Dummy call to force a backgrounded readline to stop before it tries
/* Dummy call to force a backgrounded readline to stop before it tries
   to get the tty settings. */
   to get the tty settings. */
static void
static void
set_winsize (tty)
set_winsize (tty)
     int tty;
     int tty;
{
{
#if defined (TIOCGWINSZ)
#if defined (TIOCGWINSZ)
  struct winsize w;
  struct winsize w;
 
 
  if (ioctl (tty, TIOCGWINSZ, &w) == 0)
  if (ioctl (tty, TIOCGWINSZ, &w) == 0)
      (void) ioctl (tty, TIOCSWINSZ, &w);
      (void) ioctl (tty, TIOCSWINSZ, &w);
#endif /* TIOCGWINSZ */
#endif /* TIOCGWINSZ */
}
}
 
 
#if defined (NO_TTY_DRIVER)
#if defined (NO_TTY_DRIVER)
/* Nothing */
/* Nothing */
#elif defined (NEW_TTY_DRIVER)
#elif defined (NEW_TTY_DRIVER)
 
 
/* Values for the `flags' field of a struct bsdtty.  This tells which
/* Values for the `flags' field of a struct bsdtty.  This tells which
   elements of the struct bsdtty have been fetched from the system and
   elements of the struct bsdtty have been fetched from the system and
   are valid. */
   are valid. */
#define SGTTY_SET       0x01
#define SGTTY_SET       0x01
#define LFLAG_SET       0x02
#define LFLAG_SET       0x02
#define TCHARS_SET      0x04
#define TCHARS_SET      0x04
#define LTCHARS_SET     0x08
#define LTCHARS_SET     0x08
 
 
struct bsdtty {
struct bsdtty {
  struct sgttyb sgttyb; /* Basic BSD tty driver information. */
  struct sgttyb sgttyb; /* Basic BSD tty driver information. */
  int lflag;            /* Local mode flags, like LPASS8. */
  int lflag;            /* Local mode flags, like LPASS8. */
#if defined (TIOCGETC)
#if defined (TIOCGETC)
  struct tchars tchars; /* Terminal special characters, including ^S and ^Q. */
  struct tchars tchars; /* Terminal special characters, including ^S and ^Q. */
#endif
#endif
#if defined (TIOCGLTC)
#if defined (TIOCGLTC)
  struct ltchars ltchars; /* 4.2 BSD editing characters */
  struct ltchars ltchars; /* 4.2 BSD editing characters */
#endif
#endif
  int flags;            /* Bitmap saying which parts of the struct are valid. */
  int flags;            /* Bitmap saying which parts of the struct are valid. */
};
};
 
 
#define TIOTYPE struct bsdtty
#define TIOTYPE struct bsdtty
 
 
static TIOTYPE otio;
static TIOTYPE otio;
 
 
static void save_tty_chars PARAMS((TIOTYPE *));
static void save_tty_chars PARAMS((TIOTYPE *));
static int _get_tty_settings PARAMS((int, TIOTYPE *));
static int _get_tty_settings PARAMS((int, TIOTYPE *));
static int get_tty_settings PARAMS((int, TIOTYPE *));
static int get_tty_settings PARAMS((int, TIOTYPE *));
static int _set_tty_settings PARAMS((int, TIOTYPE *));
static int _set_tty_settings PARAMS((int, TIOTYPE *));
static int set_tty_settings PARAMS((int, TIOTYPE *));
static int set_tty_settings PARAMS((int, TIOTYPE *));
 
 
static void prepare_terminal_settings PARAMS((int, TIOTYPE, TIOTYPE *));
static void prepare_terminal_settings PARAMS((int, TIOTYPE, TIOTYPE *));
 
 
static void set_special_char PARAMS((Keymap, TIOTYPE *, int, rl_command_func_t));
static void set_special_char PARAMS((Keymap, TIOTYPE *, int, rl_command_func_t));
 
 
static void
static void
save_tty_chars (tiop)
save_tty_chars (tiop)
     TIOTYPE *tiop;
     TIOTYPE *tiop;
{
{
  _rl_last_tty_chars = _rl_tty_chars;
  _rl_last_tty_chars = _rl_tty_chars;
 
 
  if (tiop->flags & SGTTY_SET)
  if (tiop->flags & SGTTY_SET)
    {
    {
      _rl_tty_chars.t_erase = tiop->sgttyb.sg_erase;
      _rl_tty_chars.t_erase = tiop->sgttyb.sg_erase;
      _rl_tty_chars.t_kill = tiop->sgttyb.sg_kill;
      _rl_tty_chars.t_kill = tiop->sgttyb.sg_kill;
    }
    }
 
 
  if (tiop->flags & TCHARS_SET)
  if (tiop->flags & TCHARS_SET)
    {
    {
      _rl_tty_chars.t_intr = tiop->tchars.t_intrc;
      _rl_tty_chars.t_intr = tiop->tchars.t_intrc;
      _rl_tty_chars.t_quit = tiop->tchars.t_quitc;
      _rl_tty_chars.t_quit = tiop->tchars.t_quitc;
      _rl_tty_chars.t_start = tiop->tchars.t_startc;
      _rl_tty_chars.t_start = tiop->tchars.t_startc;
      _rl_tty_chars.t_stop = tiop->tchars.t_stopc;
      _rl_tty_chars.t_stop = tiop->tchars.t_stopc;
      _rl_tty_chars.t_eof = tiop->tchars.t_eofc;
      _rl_tty_chars.t_eof = tiop->tchars.t_eofc;
      _rl_tty_chars.t_eol = '\n';
      _rl_tty_chars.t_eol = '\n';
      _rl_tty_chars.t_eol2 = tiop->tchars.t_brkc;
      _rl_tty_chars.t_eol2 = tiop->tchars.t_brkc;
    }
    }
 
 
  if (tiop->flags & LTCHARS_SET)
  if (tiop->flags & LTCHARS_SET)
    {
    {
      _rl_tty_chars.t_susp = tiop->ltchars.t_suspc;
      _rl_tty_chars.t_susp = tiop->ltchars.t_suspc;
      _rl_tty_chars.t_dsusp = tiop->ltchars.t_dsuspc;
      _rl_tty_chars.t_dsusp = tiop->ltchars.t_dsuspc;
      _rl_tty_chars.t_reprint = tiop->ltchars.t_rprntc;
      _rl_tty_chars.t_reprint = tiop->ltchars.t_rprntc;
      _rl_tty_chars.t_flush = tiop->ltchars.t_flushc;
      _rl_tty_chars.t_flush = tiop->ltchars.t_flushc;
      _rl_tty_chars.t_werase = tiop->ltchars.t_werasc;
      _rl_tty_chars.t_werase = tiop->ltchars.t_werasc;
      _rl_tty_chars.t_lnext = tiop->ltchars.t_lnextc;
      _rl_tty_chars.t_lnext = tiop->ltchars.t_lnextc;
    }
    }
 
 
  _rl_tty_chars.t_status = -1;
  _rl_tty_chars.t_status = -1;
}
}
 
 
static int
static int
get_tty_settings (tty, tiop)
get_tty_settings (tty, tiop)
     int tty;
     int tty;
     TIOTYPE *tiop;
     TIOTYPE *tiop;
{
{
  set_winsize (tty);
  set_winsize (tty);
 
 
  tiop->flags = tiop->lflag = 0;
  tiop->flags = tiop->lflag = 0;
 
 
  errno = 0;
  errno = 0;
  if (ioctl (tty, TIOCGETP, &(tiop->sgttyb)) < 0)
  if (ioctl (tty, TIOCGETP, &(tiop->sgttyb)) < 0)
    return -1;
    return -1;
  tiop->flags |= SGTTY_SET;
  tiop->flags |= SGTTY_SET;
 
 
#if defined (TIOCLGET)
#if defined (TIOCLGET)
  if (ioctl (tty, TIOCLGET, &(tiop->lflag)) == 0)
  if (ioctl (tty, TIOCLGET, &(tiop->lflag)) == 0)
    tiop->flags |= LFLAG_SET;
    tiop->flags |= LFLAG_SET;
#endif
#endif
 
 
#if defined (TIOCGETC)
#if defined (TIOCGETC)
  if (ioctl (tty, TIOCGETC, &(tiop->tchars)) == 0)
  if (ioctl (tty, TIOCGETC, &(tiop->tchars)) == 0)
    tiop->flags |= TCHARS_SET;
    tiop->flags |= TCHARS_SET;
#endif
#endif
 
 
#if defined (TIOCGLTC)
#if defined (TIOCGLTC)
  if (ioctl (tty, TIOCGLTC, &(tiop->ltchars)) == 0)
  if (ioctl (tty, TIOCGLTC, &(tiop->ltchars)) == 0)
    tiop->flags |= LTCHARS_SET;
    tiop->flags |= LTCHARS_SET;
#endif
#endif
 
 
  return 0;
  return 0;
}
}
 
 
static int
static int
set_tty_settings (tty, tiop)
set_tty_settings (tty, tiop)
     int tty;
     int tty;
     TIOTYPE *tiop;
     TIOTYPE *tiop;
{
{
  if (tiop->flags & SGTTY_SET)
  if (tiop->flags & SGTTY_SET)
    {
    {
      ioctl (tty, TIOCSETN, &(tiop->sgttyb));
      ioctl (tty, TIOCSETN, &(tiop->sgttyb));
      tiop->flags &= ~SGTTY_SET;
      tiop->flags &= ~SGTTY_SET;
    }
    }
  readline_echoing_p = 1;
  readline_echoing_p = 1;
 
 
#if defined (TIOCLSET)
#if defined (TIOCLSET)
  if (tiop->flags & LFLAG_SET)
  if (tiop->flags & LFLAG_SET)
    {
    {
      ioctl (tty, TIOCLSET, &(tiop->lflag));
      ioctl (tty, TIOCLSET, &(tiop->lflag));
      tiop->flags &= ~LFLAG_SET;
      tiop->flags &= ~LFLAG_SET;
    }
    }
#endif
#endif
 
 
#if defined (TIOCSETC)
#if defined (TIOCSETC)
  if (tiop->flags & TCHARS_SET)
  if (tiop->flags & TCHARS_SET)
    {
    {
      ioctl (tty, TIOCSETC, &(tiop->tchars));
      ioctl (tty, TIOCSETC, &(tiop->tchars));
      tiop->flags &= ~TCHARS_SET;
      tiop->flags &= ~TCHARS_SET;
    }
    }
#endif
#endif
 
 
#if defined (TIOCSLTC)
#if defined (TIOCSLTC)
  if (tiop->flags & LTCHARS_SET)
  if (tiop->flags & LTCHARS_SET)
    {
    {
      ioctl (tty, TIOCSLTC, &(tiop->ltchars));
      ioctl (tty, TIOCSLTC, &(tiop->ltchars));
      tiop->flags &= ~LTCHARS_SET;
      tiop->flags &= ~LTCHARS_SET;
    }
    }
#endif
#endif
 
 
  return 0;
  return 0;
}
}
 
 
static void
static void
prepare_terminal_settings (meta_flag, oldtio, tiop)
prepare_terminal_settings (meta_flag, oldtio, tiop)
     int meta_flag;
     int meta_flag;
     TIOTYPE oldtio, *tiop;
     TIOTYPE oldtio, *tiop;
{
{
  readline_echoing_p = (oldtio.sgttyb.sg_flags & ECHO);
  readline_echoing_p = (oldtio.sgttyb.sg_flags & ECHO);
 
 
  /* Copy the original settings to the structure we're going to use for
  /* Copy the original settings to the structure we're going to use for
     our settings. */
     our settings. */
  tiop->sgttyb = oldtio.sgttyb;
  tiop->sgttyb = oldtio.sgttyb;
  tiop->lflag = oldtio.lflag;
  tiop->lflag = oldtio.lflag;
#if defined (TIOCGETC)
#if defined (TIOCGETC)
  tiop->tchars = oldtio.tchars;
  tiop->tchars = oldtio.tchars;
#endif
#endif
#if defined (TIOCGLTC)
#if defined (TIOCGLTC)
  tiop->ltchars = oldtio.ltchars;
  tiop->ltchars = oldtio.ltchars;
#endif
#endif
  tiop->flags = oldtio.flags;
  tiop->flags = oldtio.flags;
 
 
  /* First, the basic settings to put us into character-at-a-time, no-echo
  /* First, the basic settings to put us into character-at-a-time, no-echo
     input mode. */
     input mode. */
  tiop->sgttyb.sg_flags &= ~(ECHO | CRMOD);
  tiop->sgttyb.sg_flags &= ~(ECHO | CRMOD);
  tiop->sgttyb.sg_flags |= CBREAK;
  tiop->sgttyb.sg_flags |= CBREAK;
 
 
  /* If this terminal doesn't care how the 8th bit is used, then we can
  /* If this terminal doesn't care how the 8th bit is used, then we can
     use it for the meta-key.  If only one of even or odd parity is
     use it for the meta-key.  If only one of even or odd parity is
     specified, then the terminal is using parity, and we cannot. */
     specified, then the terminal is using parity, and we cannot. */
#if !defined (ANYP)
#if !defined (ANYP)
#  define ANYP (EVENP | ODDP)
#  define ANYP (EVENP | ODDP)
#endif
#endif
  if (((oldtio.sgttyb.sg_flags & ANYP) == ANYP) ||
  if (((oldtio.sgttyb.sg_flags & ANYP) == ANYP) ||
      ((oldtio.sgttyb.sg_flags & ANYP) == 0))
      ((oldtio.sgttyb.sg_flags & ANYP) == 0))
    {
    {
      tiop->sgttyb.sg_flags |= ANYP;
      tiop->sgttyb.sg_flags |= ANYP;
 
 
      /* Hack on local mode flags if we can. */
      /* Hack on local mode flags if we can. */
#if defined (TIOCLGET)
#if defined (TIOCLGET)
#  if defined (LPASS8)
#  if defined (LPASS8)
      tiop->lflag |= LPASS8;
      tiop->lflag |= LPASS8;
#  endif /* LPASS8 */
#  endif /* LPASS8 */
#endif /* TIOCLGET */
#endif /* TIOCLGET */
    }
    }
 
 
#if defined (TIOCGETC)
#if defined (TIOCGETC)
#  if defined (USE_XON_XOFF)
#  if defined (USE_XON_XOFF)
  /* Get rid of terminal output start and stop characters. */
  /* Get rid of terminal output start and stop characters. */
  tiop->tchars.t_stopc = -1; /* C-s */
  tiop->tchars.t_stopc = -1; /* C-s */
  tiop->tchars.t_startc = -1; /* C-q */
  tiop->tchars.t_startc = -1; /* C-q */
 
 
  /* If there is an XON character, bind it to restart the output. */
  /* If there is an XON character, bind it to restart the output. */
  if (oldtio.tchars.t_startc != -1)
  if (oldtio.tchars.t_startc != -1)
    rl_bind_key (oldtio.tchars.t_startc, rl_restart_output);
    rl_bind_key (oldtio.tchars.t_startc, rl_restart_output);
#  endif /* USE_XON_XOFF */
#  endif /* USE_XON_XOFF */
 
 
  /* If there is an EOF char, bind _rl_eof_char to it. */
  /* If there is an EOF char, bind _rl_eof_char to it. */
  if (oldtio.tchars.t_eofc != -1)
  if (oldtio.tchars.t_eofc != -1)
    _rl_eof_char = oldtio.tchars.t_eofc;
    _rl_eof_char = oldtio.tchars.t_eofc;
 
 
#  if defined (NO_KILL_INTR)
#  if defined (NO_KILL_INTR)
  /* Get rid of terminal-generated SIGQUIT and SIGINT. */
  /* Get rid of terminal-generated SIGQUIT and SIGINT. */
  tiop->tchars.t_quitc = -1; /* C-\ */
  tiop->tchars.t_quitc = -1; /* C-\ */
  tiop->tchars.t_intrc = -1; /* C-c */
  tiop->tchars.t_intrc = -1; /* C-c */
#  endif /* NO_KILL_INTR */
#  endif /* NO_KILL_INTR */
#endif /* TIOCGETC */
#endif /* TIOCGETC */
 
 
#if defined (TIOCGLTC)
#if defined (TIOCGLTC)
  /* Make the interrupt keys go away.  Just enough to make people happy. */
  /* Make the interrupt keys go away.  Just enough to make people happy. */
  tiop->ltchars.t_dsuspc = -1;  /* C-y */
  tiop->ltchars.t_dsuspc = -1;  /* C-y */
  tiop->ltchars.t_lnextc = -1;  /* C-v */
  tiop->ltchars.t_lnextc = -1;  /* C-v */
#endif /* TIOCGLTC */
#endif /* TIOCGLTC */
}
}
 
 
#else  /* !defined (NEW_TTY_DRIVER) */
#else  /* !defined (NEW_TTY_DRIVER) */
 
 
#if !defined (VMIN)
#if !defined (VMIN)
#  define VMIN VEOF
#  define VMIN VEOF
#endif
#endif
 
 
#if !defined (VTIME)
#if !defined (VTIME)
#  define VTIME VEOL
#  define VTIME VEOL
#endif
#endif
 
 
#if defined (TERMIOS_TTY_DRIVER)
#if defined (TERMIOS_TTY_DRIVER)
#  define TIOTYPE struct termios
#  define TIOTYPE struct termios
#  define DRAIN_OUTPUT(fd)      tcdrain (fd)
#  define DRAIN_OUTPUT(fd)      tcdrain (fd)
#  define GETATTR(tty, tiop)    (tcgetattr (tty, tiop))
#  define GETATTR(tty, tiop)    (tcgetattr (tty, tiop))
#  ifdef M_UNIX
#  ifdef M_UNIX
#    define SETATTR(tty, tiop)  (tcsetattr (tty, TCSANOW, tiop))
#    define SETATTR(tty, tiop)  (tcsetattr (tty, TCSANOW, tiop))
#  else
#  else
#    define SETATTR(tty, tiop)  (tcsetattr (tty, TCSADRAIN, tiop))
#    define SETATTR(tty, tiop)  (tcsetattr (tty, TCSADRAIN, tiop))
#  endif /* !M_UNIX */
#  endif /* !M_UNIX */
#else
#else
#  define TIOTYPE struct termio
#  define TIOTYPE struct termio
#  define DRAIN_OUTPUT(fd)
#  define DRAIN_OUTPUT(fd)
#  define GETATTR(tty, tiop)    (ioctl (tty, TCGETA, tiop))
#  define GETATTR(tty, tiop)    (ioctl (tty, TCGETA, tiop))
#  define SETATTR(tty, tiop)    (ioctl (tty, TCSETAW, tiop))
#  define SETATTR(tty, tiop)    (ioctl (tty, TCSETAW, tiop))
#endif /* !TERMIOS_TTY_DRIVER */
#endif /* !TERMIOS_TTY_DRIVER */
 
 
static TIOTYPE otio;
static TIOTYPE otio;
 
 
static void save_tty_chars PARAMS((TIOTYPE *));
static void save_tty_chars PARAMS((TIOTYPE *));
static int _get_tty_settings PARAMS((int, TIOTYPE *));
static int _get_tty_settings PARAMS((int, TIOTYPE *));
static int get_tty_settings PARAMS((int, TIOTYPE *));
static int get_tty_settings PARAMS((int, TIOTYPE *));
static int _set_tty_settings PARAMS((int, TIOTYPE *));
static int _set_tty_settings PARAMS((int, TIOTYPE *));
static int set_tty_settings PARAMS((int, TIOTYPE *));
static int set_tty_settings PARAMS((int, TIOTYPE *));
 
 
static void prepare_terminal_settings PARAMS((int, TIOTYPE, TIOTYPE *));
static void prepare_terminal_settings PARAMS((int, TIOTYPE, TIOTYPE *));
 
 
static void set_special_char PARAMS((Keymap, TIOTYPE *, int, rl_command_func_t));
static void set_special_char PARAMS((Keymap, TIOTYPE *, int, rl_command_func_t));
static void _rl_bind_tty_special_chars PARAMS((Keymap, TIOTYPE));
static void _rl_bind_tty_special_chars PARAMS((Keymap, TIOTYPE));
 
 
#if defined (FLUSHO)
#if defined (FLUSHO)
#  define OUTPUT_BEING_FLUSHED(tp)  (tp->c_lflag & FLUSHO)
#  define OUTPUT_BEING_FLUSHED(tp)  (tp->c_lflag & FLUSHO)
#else
#else
#  define OUTPUT_BEING_FLUSHED(tp)  0
#  define OUTPUT_BEING_FLUSHED(tp)  0
#endif
#endif
 
 
static void
static void
save_tty_chars (tiop)
save_tty_chars (tiop)
     TIOTYPE *tiop;
     TIOTYPE *tiop;
{
{
  _rl_last_tty_chars = _rl_tty_chars;
  _rl_last_tty_chars = _rl_tty_chars;
 
 
  _rl_tty_chars.t_eof = tiop->c_cc[VEOF];
  _rl_tty_chars.t_eof = tiop->c_cc[VEOF];
  _rl_tty_chars.t_eol = tiop->c_cc[VEOL];
  _rl_tty_chars.t_eol = tiop->c_cc[VEOL];
#ifdef VEOL2
#ifdef VEOL2
  _rl_tty_chars.t_eol2 = tiop->c_cc[VEOL2];
  _rl_tty_chars.t_eol2 = tiop->c_cc[VEOL2];
#endif
#endif
  _rl_tty_chars.t_erase = tiop->c_cc[VERASE];
  _rl_tty_chars.t_erase = tiop->c_cc[VERASE];
#ifdef VWERASE
#ifdef VWERASE
  _rl_tty_chars.t_werase = tiop->c_cc[VWERASE];
  _rl_tty_chars.t_werase = tiop->c_cc[VWERASE];
#endif
#endif
  _rl_tty_chars.t_kill = tiop->c_cc[VKILL];
  _rl_tty_chars.t_kill = tiop->c_cc[VKILL];
#ifdef VREPRINT
#ifdef VREPRINT
  _rl_tty_chars.t_reprint = tiop->c_cc[VREPRINT];
  _rl_tty_chars.t_reprint = tiop->c_cc[VREPRINT];
#endif
#endif
  _rl_tty_chars.t_intr = tiop->c_cc[VINTR];
  _rl_tty_chars.t_intr = tiop->c_cc[VINTR];
  _rl_tty_chars.t_quit = tiop->c_cc[VQUIT];
  _rl_tty_chars.t_quit = tiop->c_cc[VQUIT];
#ifdef VSUSP
#ifdef VSUSP
  _rl_tty_chars.t_susp = tiop->c_cc[VSUSP];
  _rl_tty_chars.t_susp = tiop->c_cc[VSUSP];
#endif
#endif
#ifdef VDSUSP
#ifdef VDSUSP
  _rl_tty_chars.t_dsusp = tiop->c_cc[VDSUSP];
  _rl_tty_chars.t_dsusp = tiop->c_cc[VDSUSP];
#endif
#endif
#ifdef VSTART
#ifdef VSTART
  _rl_tty_chars.t_start = tiop->c_cc[VSTART];
  _rl_tty_chars.t_start = tiop->c_cc[VSTART];
#endif
#endif
#ifdef VSTOP
#ifdef VSTOP
  _rl_tty_chars.t_stop = tiop->c_cc[VSTOP];
  _rl_tty_chars.t_stop = tiop->c_cc[VSTOP];
#endif
#endif
#ifdef VLNEXT
#ifdef VLNEXT
  _rl_tty_chars.t_lnext = tiop->c_cc[VLNEXT];
  _rl_tty_chars.t_lnext = tiop->c_cc[VLNEXT];
#endif
#endif
#ifdef VDISCARD
#ifdef VDISCARD
  _rl_tty_chars.t_flush = tiop->c_cc[VDISCARD];
  _rl_tty_chars.t_flush = tiop->c_cc[VDISCARD];
#endif
#endif
#ifdef VSTATUS
#ifdef VSTATUS
  _rl_tty_chars.t_status = tiop->c_cc[VSTATUS];
  _rl_tty_chars.t_status = tiop->c_cc[VSTATUS];
#endif
#endif
}
}
 
 
#if defined (_AIX) || defined (_AIX41)
#if defined (_AIX) || defined (_AIX41)
/* Currently this is only used on AIX */
/* Currently this is only used on AIX */
static void
static void
rltty_warning (msg)
rltty_warning (msg)
     char *msg;
     char *msg;
{
{
  fprintf (stderr, "readline: warning: %s\n", msg);
  fprintf (stderr, "readline: warning: %s\n", msg);
}
}
#endif
#endif
 
 
#if defined (_AIX)
#if defined (_AIX)
void
void
setopost(tp)
setopost(tp)
TIOTYPE *tp;
TIOTYPE *tp;
{
{
  if ((tp->c_oflag & OPOST) == 0)
  if ((tp->c_oflag & OPOST) == 0)
    {
    {
      rltty_warning ("turning on OPOST for terminal\r");
      rltty_warning ("turning on OPOST for terminal\r");
      tp->c_oflag |= OPOST|ONLCR;
      tp->c_oflag |= OPOST|ONLCR;
    }
    }
}
}
#endif
#endif
 
 
static int
static int
_get_tty_settings (tty, tiop)
_get_tty_settings (tty, tiop)
     int tty;
     int tty;
     TIOTYPE *tiop;
     TIOTYPE *tiop;
{
{
  int ioctl_ret;
  int ioctl_ret;
 
 
  while (1)
  while (1)
    {
    {
      ioctl_ret = GETATTR (tty, tiop);
      ioctl_ret = GETATTR (tty, tiop);
      if (ioctl_ret < 0)
      if (ioctl_ret < 0)
        {
        {
          if (errno != EINTR)
          if (errno != EINTR)
            return -1;
            return -1;
          else
          else
            continue;
            continue;
        }
        }
      if (OUTPUT_BEING_FLUSHED (tiop))
      if (OUTPUT_BEING_FLUSHED (tiop))
        {
        {
#if defined (FLUSHO) && defined (_AIX41)
#if defined (FLUSHO) && defined (_AIX41)
          rltty_warning ("turning off output flushing");
          rltty_warning ("turning off output flushing");
          tiop->c_lflag &= ~FLUSHO;
          tiop->c_lflag &= ~FLUSHO;
          break;
          break;
#else
#else
          continue;
          continue;
#endif
#endif
        }
        }
      break;
      break;
    }
    }
 
 
  return 0;
  return 0;
}
}
 
 
static int
static int
get_tty_settings (tty, tiop)
get_tty_settings (tty, tiop)
     int tty;
     int tty;
     TIOTYPE *tiop;
     TIOTYPE *tiop;
{
{
  set_winsize (tty);
  set_winsize (tty);
 
 
  errno = 0;
  errno = 0;
  if (_get_tty_settings (tty, tiop) < 0)
  if (_get_tty_settings (tty, tiop) < 0)
    return -1;
    return -1;
 
 
#if defined (_AIX)
#if defined (_AIX)
  setopost(tiop);
  setopost(tiop);
#endif
#endif
 
 
  return 0;
  return 0;
}
}
 
 
static int
static int
_set_tty_settings (tty, tiop)
_set_tty_settings (tty, tiop)
     int tty;
     int tty;
     TIOTYPE *tiop;
     TIOTYPE *tiop;
{
{
  while (SETATTR (tty, tiop) < 0)
  while (SETATTR (tty, tiop) < 0)
    {
    {
      if (errno != EINTR)
      if (errno != EINTR)
        return -1;
        return -1;
      errno = 0;
      errno = 0;
    }
    }
  return 0;
  return 0;
}
}
 
 
static int
static int
set_tty_settings (tty, tiop)
set_tty_settings (tty, tiop)
     int tty;
     int tty;
     TIOTYPE *tiop;
     TIOTYPE *tiop;
{
{
  if (_set_tty_settings (tty, tiop) < 0)
  if (_set_tty_settings (tty, tiop) < 0)
    return -1;
    return -1;
 
 
#if 0
#if 0
 
 
#if defined (TERMIOS_TTY_DRIVER)
#if defined (TERMIOS_TTY_DRIVER)
#  if defined (__ksr1__)
#  if defined (__ksr1__)
  if (ksrflow)
  if (ksrflow)
    {
    {
      ksrflow = 0;
      ksrflow = 0;
      tcflow (tty, TCOON);
      tcflow (tty, TCOON);
    }
    }
#  else /* !ksr1 */
#  else /* !ksr1 */
  tcflow (tty, TCOON);          /* Simulate a ^Q. */
  tcflow (tty, TCOON);          /* Simulate a ^Q. */
#  endif /* !ksr1 */
#  endif /* !ksr1 */
#else
#else
  ioctl (tty, TCXONC, 1);       /* Simulate a ^Q. */
  ioctl (tty, TCXONC, 1);       /* Simulate a ^Q. */
#endif /* !TERMIOS_TTY_DRIVER */
#endif /* !TERMIOS_TTY_DRIVER */
 
 
#endif /* 0 */
#endif /* 0 */
 
 
  return 0;
  return 0;
}
}
 
 
static void
static void
prepare_terminal_settings (meta_flag, oldtio, tiop)
prepare_terminal_settings (meta_flag, oldtio, tiop)
     int meta_flag;
     int meta_flag;
     TIOTYPE oldtio, *tiop;
     TIOTYPE oldtio, *tiop;
{
{
  readline_echoing_p = (oldtio.c_lflag & ECHO);
  readline_echoing_p = (oldtio.c_lflag & ECHO);
 
 
  tiop->c_lflag &= ~(ICANON | ECHO);
  tiop->c_lflag &= ~(ICANON | ECHO);
 
 
  if ((unsigned char) oldtio.c_cc[VEOF] != (unsigned char) _POSIX_VDISABLE)
  if ((unsigned char) oldtio.c_cc[VEOF] != (unsigned char) _POSIX_VDISABLE)
    _rl_eof_char = oldtio.c_cc[VEOF];
    _rl_eof_char = oldtio.c_cc[VEOF];
 
 
#if defined (USE_XON_XOFF)
#if defined (USE_XON_XOFF)
#if defined (IXANY)
#if defined (IXANY)
  tiop->c_iflag &= ~(IXON | IXOFF | IXANY);
  tiop->c_iflag &= ~(IXON | IXOFF | IXANY);
#else
#else
  /* `strict' Posix systems do not define IXANY. */
  /* `strict' Posix systems do not define IXANY. */
  tiop->c_iflag &= ~(IXON | IXOFF);
  tiop->c_iflag &= ~(IXON | IXOFF);
#endif /* IXANY */
#endif /* IXANY */
#endif /* USE_XON_XOFF */
#endif /* USE_XON_XOFF */
 
 
  /* Only turn this off if we are using all 8 bits. */
  /* Only turn this off if we are using all 8 bits. */
  if (((tiop->c_cflag & CSIZE) == CS8) || meta_flag)
  if (((tiop->c_cflag & CSIZE) == CS8) || meta_flag)
    tiop->c_iflag &= ~(ISTRIP | INPCK);
    tiop->c_iflag &= ~(ISTRIP | INPCK);
 
 
  /* Make sure we differentiate between CR and NL on input. */
  /* Make sure we differentiate between CR and NL on input. */
  tiop->c_iflag &= ~(ICRNL | INLCR);
  tiop->c_iflag &= ~(ICRNL | INLCR);
 
 
#if !defined (HANDLE_SIGNALS)
#if !defined (HANDLE_SIGNALS)
  tiop->c_lflag &= ~ISIG;
  tiop->c_lflag &= ~ISIG;
#else
#else
  tiop->c_lflag |= ISIG;
  tiop->c_lflag |= ISIG;
#endif
#endif
 
 
  tiop->c_cc[VMIN] = 1;
  tiop->c_cc[VMIN] = 1;
  tiop->c_cc[VTIME] = 0;
  tiop->c_cc[VTIME] = 0;
 
 
#if defined (FLUSHO)
#if defined (FLUSHO)
  if (OUTPUT_BEING_FLUSHED (tiop))
  if (OUTPUT_BEING_FLUSHED (tiop))
    {
    {
      tiop->c_lflag &= ~FLUSHO;
      tiop->c_lflag &= ~FLUSHO;
      oldtio.c_lflag &= ~FLUSHO;
      oldtio.c_lflag &= ~FLUSHO;
    }
    }
#endif
#endif
 
 
  /* Turn off characters that we need on Posix systems with job control,
  /* Turn off characters that we need on Posix systems with job control,
     just to be sure.  This includes ^Y and ^V.  This should not really
     just to be sure.  This includes ^Y and ^V.  This should not really
     be necessary.  */
     be necessary.  */
#if defined (TERMIOS_TTY_DRIVER) && defined (_POSIX_VDISABLE)
#if defined (TERMIOS_TTY_DRIVER) && defined (_POSIX_VDISABLE)
 
 
#if defined (VLNEXT)
#if defined (VLNEXT)
  tiop->c_cc[VLNEXT] = _POSIX_VDISABLE;
  tiop->c_cc[VLNEXT] = _POSIX_VDISABLE;
#endif
#endif
 
 
#if defined (VDSUSP)
#if defined (VDSUSP)
  tiop->c_cc[VDSUSP] = _POSIX_VDISABLE;
  tiop->c_cc[VDSUSP] = _POSIX_VDISABLE;
#endif
#endif
 
 
#endif /* TERMIOS_TTY_DRIVER && _POSIX_VDISABLE */
#endif /* TERMIOS_TTY_DRIVER && _POSIX_VDISABLE */
}
}
#endif  /* !NEW_TTY_DRIVER */
#endif  /* !NEW_TTY_DRIVER */
 
 
/* Put the terminal in CBREAK mode so that we can detect key presses. */
/* Put the terminal in CBREAK mode so that we can detect key presses. */
#if defined (NO_TTY_DRIVER)
#if defined (NO_TTY_DRIVER)
void
void
rl_prep_terminal (meta_flag)
rl_prep_terminal (meta_flag)
     int meta_flag;
     int meta_flag;
{
{
  readline_echoing_p = 1;
  readline_echoing_p = 1;
}
}
 
 
void
void
rl_deprep_terminal ()
rl_deprep_terminal ()
{
{
}
}
 
 
#else /* ! NO_TTY_DRIVER */
#else /* ! NO_TTY_DRIVER */
void
void
rl_prep_terminal (meta_flag)
rl_prep_terminal (meta_flag)
     int meta_flag;
     int meta_flag;
{
{
  int tty;
  int tty;
  TIOTYPE tio;
  TIOTYPE tio;
 
 
  if (terminal_prepped)
  if (terminal_prepped)
    return;
    return;
 
 
  /* Try to keep this function from being INTerrupted. */
  /* Try to keep this function from being INTerrupted. */
  block_sigint ();
  block_sigint ();
 
 
  tty = fileno (rl_instream);
  tty = fileno (rl_instream);
 
 
  if (get_tty_settings (tty, &tio) < 0)
  if (get_tty_settings (tty, &tio) < 0)
    {
    {
#if defined (ENOTSUP)
#if defined (ENOTSUP)
      /* MacOS X, at least, lies about the value of errno if tcgetattr fails. */
      /* MacOS X, at least, lies about the value of errno if tcgetattr fails. */
      if (errno == ENOTTY || errno == ENOTSUP)
      if (errno == ENOTTY || errno == ENOTSUP)
#else
#else
      if (errno == ENOTTY)
      if (errno == ENOTTY)
#endif
#endif
        readline_echoing_p = 1;         /* XXX */
        readline_echoing_p = 1;         /* XXX */
      release_sigint ();
      release_sigint ();
      return;
      return;
    }
    }
 
 
  otio = tio;
  otio = tio;
 
 
  if (_rl_bind_stty_chars)
  if (_rl_bind_stty_chars)
    {
    {
#if defined (VI_MODE)
#if defined (VI_MODE)
      /* If editing in vi mode, make sure we restore the bindings in the
      /* If editing in vi mode, make sure we restore the bindings in the
         insertion keymap no matter what keymap we ended up in. */
         insertion keymap no matter what keymap we ended up in. */
      if (rl_editing_mode == vi_mode)
      if (rl_editing_mode == vi_mode)
        rl_tty_unset_default_bindings (vi_insertion_keymap);
        rl_tty_unset_default_bindings (vi_insertion_keymap);
      else
      else
#endif
#endif
        rl_tty_unset_default_bindings (_rl_keymap);
        rl_tty_unset_default_bindings (_rl_keymap);
    }
    }
  save_tty_chars (&otio);
  save_tty_chars (&otio);
  RL_SETSTATE(RL_STATE_TTYCSAVED);
  RL_SETSTATE(RL_STATE_TTYCSAVED);
  if (_rl_bind_stty_chars)
  if (_rl_bind_stty_chars)
    {
    {
#if defined (VI_MODE)
#if defined (VI_MODE)
      /* If editing in vi mode, make sure we set the bindings in the
      /* If editing in vi mode, make sure we set the bindings in the
         insertion keymap no matter what keymap we ended up in. */
         insertion keymap no matter what keymap we ended up in. */
      if (rl_editing_mode == vi_mode)
      if (rl_editing_mode == vi_mode)
        _rl_bind_tty_special_chars (vi_insertion_keymap, tio);
        _rl_bind_tty_special_chars (vi_insertion_keymap, tio);
      else
      else
#endif
#endif
        _rl_bind_tty_special_chars (_rl_keymap, tio);
        _rl_bind_tty_special_chars (_rl_keymap, tio);
    }
    }
 
 
  prepare_terminal_settings (meta_flag, otio, &tio);
  prepare_terminal_settings (meta_flag, otio, &tio);
 
 
  if (set_tty_settings (tty, &tio) < 0)
  if (set_tty_settings (tty, &tio) < 0)
    {
    {
      release_sigint ();
      release_sigint ();
      return;
      return;
    }
    }
 
 
  if (_rl_enable_keypad)
  if (_rl_enable_keypad)
    _rl_control_keypad (1);
    _rl_control_keypad (1);
 
 
  fflush (rl_outstream);
  fflush (rl_outstream);
  terminal_prepped = 1;
  terminal_prepped = 1;
  RL_SETSTATE(RL_STATE_TERMPREPPED);
  RL_SETSTATE(RL_STATE_TERMPREPPED);
 
 
  release_sigint ();
  release_sigint ();
}
}
 
 
/* Restore the terminal's normal settings and modes. */
/* Restore the terminal's normal settings and modes. */
void
void
rl_deprep_terminal ()
rl_deprep_terminal ()
{
{
  int tty;
  int tty;
 
 
  if (!terminal_prepped)
  if (!terminal_prepped)
    return;
    return;
 
 
  /* Try to keep this function from being interrupted. */
  /* Try to keep this function from being interrupted. */
  block_sigint ();
  block_sigint ();
 
 
  tty = fileno (rl_instream);
  tty = fileno (rl_instream);
 
 
  if (_rl_enable_keypad)
  if (_rl_enable_keypad)
    _rl_control_keypad (0);
    _rl_control_keypad (0);
 
 
  fflush (rl_outstream);
  fflush (rl_outstream);
 
 
  if (set_tty_settings (tty, &otio) < 0)
  if (set_tty_settings (tty, &otio) < 0)
    {
    {
      release_sigint ();
      release_sigint ();
      return;
      return;
    }
    }
 
 
  terminal_prepped = 0;
  terminal_prepped = 0;
  RL_UNSETSTATE(RL_STATE_TERMPREPPED);
  RL_UNSETSTATE(RL_STATE_TERMPREPPED);
 
 
  release_sigint ();
  release_sigint ();
}
}
#endif /* !NO_TTY_DRIVER */
#endif /* !NO_TTY_DRIVER */


/* **************************************************************** */
/* **************************************************************** */
/*                                                                  */
/*                                                                  */
/*                      Bogus Flow Control                          */
/*                      Bogus Flow Control                          */
/*                                                                  */
/*                                                                  */
/* **************************************************************** */
/* **************************************************************** */
 
 
int
int
rl_restart_output (count, key)
rl_restart_output (count, key)
     int count, key;
     int count, key;
{
{
#if defined (__MINGW32__)
#if defined (__MINGW32__)
  return 0;
  return 0;
#else /* !__MING32__ */
#else /* !__MING32__ */
 
 
  int fildes = fileno (rl_outstream);
  int fildes = fileno (rl_outstream);
#if defined (TIOCSTART)
#if defined (TIOCSTART)
#if defined (apollo)
#if defined (apollo)
  ioctl (&fildes, TIOCSTART, 0);
  ioctl (&fildes, TIOCSTART, 0);
#else
#else
  ioctl (fildes, TIOCSTART, 0);
  ioctl (fildes, TIOCSTART, 0);
#endif /* apollo */
#endif /* apollo */
 
 
#else /* !TIOCSTART */
#else /* !TIOCSTART */
#  if defined (TERMIOS_TTY_DRIVER)
#  if defined (TERMIOS_TTY_DRIVER)
#    if defined (__ksr1__)
#    if defined (__ksr1__)
  if (ksrflow)
  if (ksrflow)
    {
    {
      ksrflow = 0;
      ksrflow = 0;
      tcflow (fildes, TCOON);
      tcflow (fildes, TCOON);
    }
    }
#    else /* !ksr1 */
#    else /* !ksr1 */
  tcflow (fildes, TCOON);               /* Simulate a ^Q. */
  tcflow (fildes, TCOON);               /* Simulate a ^Q. */
#    endif /* !ksr1 */
#    endif /* !ksr1 */
#  else /* !TERMIOS_TTY_DRIVER */
#  else /* !TERMIOS_TTY_DRIVER */
#    if defined (TCXONC)
#    if defined (TCXONC)
  ioctl (fildes, TCXONC, TCOON);
  ioctl (fildes, TCXONC, TCOON);
#    endif /* TCXONC */
#    endif /* TCXONC */
#  endif /* !TERMIOS_TTY_DRIVER */
#  endif /* !TERMIOS_TTY_DRIVER */
#endif /* !TIOCSTART */
#endif /* !TIOCSTART */
 
 
  return 0;
  return 0;
#endif /* !__MINGW32__ */
#endif /* !__MINGW32__ */
}
}
 
 
int
int
rl_stop_output (count, key)
rl_stop_output (count, key)
     int count, key;
     int count, key;
{
{
#if defined (__MINGW32__)
#if defined (__MINGW32__)
  return 0;
  return 0;
#else
#else
 
 
  int fildes = fileno (rl_instream);
  int fildes = fileno (rl_instream);
 
 
#if defined (TIOCSTOP)
#if defined (TIOCSTOP)
# if defined (apollo)
# if defined (apollo)
  ioctl (&fildes, TIOCSTOP, 0);
  ioctl (&fildes, TIOCSTOP, 0);
# else
# else
  ioctl (fildes, TIOCSTOP, 0);
  ioctl (fildes, TIOCSTOP, 0);
# endif /* apollo */
# endif /* apollo */
#else /* !TIOCSTOP */
#else /* !TIOCSTOP */
# if defined (TERMIOS_TTY_DRIVER)
# if defined (TERMIOS_TTY_DRIVER)
#  if defined (__ksr1__)
#  if defined (__ksr1__)
  ksrflow = 1;
  ksrflow = 1;
#  endif /* ksr1 */
#  endif /* ksr1 */
  tcflow (fildes, TCOOFF);
  tcflow (fildes, TCOOFF);
# else
# else
#   if defined (TCXONC)
#   if defined (TCXONC)
  ioctl (fildes, TCXONC, TCOON);
  ioctl (fildes, TCXONC, TCOON);
#   endif /* TCXONC */
#   endif /* TCXONC */
# endif /* !TERMIOS_TTY_DRIVER */
# endif /* !TERMIOS_TTY_DRIVER */
#endif /* !TIOCSTOP */
#endif /* !TIOCSTOP */
 
 
  return 0;
  return 0;
#endif /* !__MINGW32__ */
#endif /* !__MINGW32__ */
}
}
 
 
/* **************************************************************** */
/* **************************************************************** */
/*                                                                  */
/*                                                                  */
/*                      Default Key Bindings                        */
/*                      Default Key Bindings                        */
/*                                                                  */
/*                                                                  */
/* **************************************************************** */
/* **************************************************************** */
 
 
#if !defined (NO_TTY_DRIVER)
#if !defined (NO_TTY_DRIVER)
#define SET_SPECIAL(sc, func)   set_special_char(kmap, &ttybuff, sc, func)
#define SET_SPECIAL(sc, func)   set_special_char(kmap, &ttybuff, sc, func)
#endif
#endif
 
 
#if defined (NO_TTY_DRIVER)
#if defined (NO_TTY_DRIVER)
 
 
#define SET_SPECIAL(sc, func)
#define SET_SPECIAL(sc, func)
#define RESET_SPECIAL(c)
#define RESET_SPECIAL(c)
 
 
#elif defined (NEW_TTY_DRIVER)
#elif defined (NEW_TTY_DRIVER)
static void
static void
set_special_char (kmap, tiop, sc, func)
set_special_char (kmap, tiop, sc, func)
     Keymap kmap;
     Keymap kmap;
     TIOTYPE *tiop;
     TIOTYPE *tiop;
     int sc;
     int sc;
     rl_command_func_t *func;
     rl_command_func_t *func;
{
{
  if (sc != -1 && kmap[(unsigned char)sc].type == ISFUNC)
  if (sc != -1 && kmap[(unsigned char)sc].type == ISFUNC)
    kmap[(unsigned char)sc].function = func;
    kmap[(unsigned char)sc].function = func;
}
}
 
 
#define RESET_SPECIAL(c) \
#define RESET_SPECIAL(c) \
  if (c != -1 && kmap[(unsigned char)c].type == ISFUNC)
  if (c != -1 && kmap[(unsigned char)c].type == ISFUNC)
    kmap[(unsigned char)c].function = rl_insert;
    kmap[(unsigned char)c].function = rl_insert;
 
 
static void
static void
_rl_bind_tty_special_chars (kmap, ttybuff)
_rl_bind_tty_special_chars (kmap, ttybuff)
     Keymap kmap;
     Keymap kmap;
     TIOTYPE ttybuff;
     TIOTYPE ttybuff;
{
{
  if (ttybuff.flags & SGTTY_SET)
  if (ttybuff.flags & SGTTY_SET)
    {
    {
      SET_SPECIAL (ttybuff.sgttyb.sg_erase, rl_rubout);
      SET_SPECIAL (ttybuff.sgttyb.sg_erase, rl_rubout);
      SET_SPECIAL (ttybuff.sgttyb.sg_kill, rl_unix_line_discard);
      SET_SPECIAL (ttybuff.sgttyb.sg_kill, rl_unix_line_discard);
    }
    }
 
 
#  if defined (TIOCGLTC)
#  if defined (TIOCGLTC)
  if (ttybuff.flags & LTCHARS_SET)
  if (ttybuff.flags & LTCHARS_SET)
    {
    {
      SET_SPECIAL (ttybuff.ltchars.t_werasc, rl_unix_word_rubout);
      SET_SPECIAL (ttybuff.ltchars.t_werasc, rl_unix_word_rubout);
      SET_SPECIAL (ttybuff.ltchars.t_lnextc, rl_quoted_insert);
      SET_SPECIAL (ttybuff.ltchars.t_lnextc, rl_quoted_insert);
    }
    }
#  endif /* TIOCGLTC */
#  endif /* TIOCGLTC */
}
}
 
 
#else /* !NEW_TTY_DRIVER */
#else /* !NEW_TTY_DRIVER */
static void
static void
set_special_char (kmap, tiop, sc, func)
set_special_char (kmap, tiop, sc, func)
     Keymap kmap;
     Keymap kmap;
     TIOTYPE *tiop;
     TIOTYPE *tiop;
     int sc;
     int sc;
     rl_command_func_t *func;
     rl_command_func_t *func;
{
{
  unsigned char uc;
  unsigned char uc;
 
 
  uc = tiop->c_cc[sc];
  uc = tiop->c_cc[sc];
  if (uc != (unsigned char)_POSIX_VDISABLE && kmap[uc].type == ISFUNC)
  if (uc != (unsigned char)_POSIX_VDISABLE && kmap[uc].type == ISFUNC)
    kmap[uc].function = func;
    kmap[uc].function = func;
}
}
 
 
/* used later */
/* used later */
#define RESET_SPECIAL(uc) \
#define RESET_SPECIAL(uc) \
  if (uc != (unsigned char)_POSIX_VDISABLE && kmap[uc].type == ISFUNC) \
  if (uc != (unsigned char)_POSIX_VDISABLE && kmap[uc].type == ISFUNC) \
    kmap[uc].function = rl_insert;
    kmap[uc].function = rl_insert;
 
 
static void
static void
_rl_bind_tty_special_chars (kmap, ttybuff)
_rl_bind_tty_special_chars (kmap, ttybuff)
     Keymap kmap;
     Keymap kmap;
     TIOTYPE ttybuff;
     TIOTYPE ttybuff;
{
{
  SET_SPECIAL (VERASE, rl_rubout);
  SET_SPECIAL (VERASE, rl_rubout);
  SET_SPECIAL (VKILL, rl_unix_line_discard);
  SET_SPECIAL (VKILL, rl_unix_line_discard);
 
 
#  if defined (VLNEXT) && defined (TERMIOS_TTY_DRIVER)
#  if defined (VLNEXT) && defined (TERMIOS_TTY_DRIVER)
  SET_SPECIAL (VLNEXT, rl_quoted_insert);
  SET_SPECIAL (VLNEXT, rl_quoted_insert);
#  endif /* VLNEXT && TERMIOS_TTY_DRIVER */
#  endif /* VLNEXT && TERMIOS_TTY_DRIVER */
 
 
#  if defined (VWERASE) && defined (TERMIOS_TTY_DRIVER)
#  if defined (VWERASE) && defined (TERMIOS_TTY_DRIVER)
  SET_SPECIAL (VWERASE, rl_unix_word_rubout);
  SET_SPECIAL (VWERASE, rl_unix_word_rubout);
#  endif /* VWERASE && TERMIOS_TTY_DRIVER */
#  endif /* VWERASE && TERMIOS_TTY_DRIVER */
}
}
 
 
#endif /* !NEW_TTY_DRIVER */
#endif /* !NEW_TTY_DRIVER */
 
 
/* Set the system's default editing characters to their readline equivalents
/* Set the system's default editing characters to their readline equivalents
   in KMAP.  Should be static, now that we have rl_tty_set_default_bindings. */
   in KMAP.  Should be static, now that we have rl_tty_set_default_bindings. */
void
void
rltty_set_default_bindings (kmap)
rltty_set_default_bindings (kmap)
     Keymap kmap;
     Keymap kmap;
{
{
#if !defined (NO_TTY_DRIVER)
#if !defined (NO_TTY_DRIVER)
  TIOTYPE ttybuff;
  TIOTYPE ttybuff;
  int tty;
  int tty;
  static int called = 0;
  static int called = 0;
 
 
  tty = fileno (rl_instream);
  tty = fileno (rl_instream);
 
 
  if (get_tty_settings (tty, &ttybuff) == 0)
  if (get_tty_settings (tty, &ttybuff) == 0)
    _rl_bind_tty_special_chars (kmap, ttybuff);
    _rl_bind_tty_special_chars (kmap, ttybuff);
#endif
#endif
}
}
 
 
/* New public way to set the system default editing chars to their readline
/* New public way to set the system default editing chars to their readline
   equivalents. */
   equivalents. */
void
void
rl_tty_set_default_bindings (kmap)
rl_tty_set_default_bindings (kmap)
     Keymap kmap;
     Keymap kmap;
{
{
  rltty_set_default_bindings (kmap);
  rltty_set_default_bindings (kmap);
}
}
 
 
/* Rebind all of the tty special chars that readline worries about back
/* Rebind all of the tty special chars that readline worries about back
   to self-insert.  Call this before saving the current terminal special
   to self-insert.  Call this before saving the current terminal special
   chars with save_tty_chars().  This only works on POSIX termios or termio
   chars with save_tty_chars().  This only works on POSIX termios or termio
   systems. */
   systems. */
void
void
rl_tty_unset_default_bindings (kmap)
rl_tty_unset_default_bindings (kmap)
     Keymap kmap;
     Keymap kmap;
{
{
  /* Don't bother before we've saved the tty special chars at least once. */
  /* Don't bother before we've saved the tty special chars at least once. */
  if (RL_ISSTATE(RL_STATE_TTYCSAVED) == 0)
  if (RL_ISSTATE(RL_STATE_TTYCSAVED) == 0)
    return;
    return;
 
 
  RESET_SPECIAL (_rl_tty_chars.t_erase);
  RESET_SPECIAL (_rl_tty_chars.t_erase);
  RESET_SPECIAL (_rl_tty_chars.t_kill);
  RESET_SPECIAL (_rl_tty_chars.t_kill);
 
 
#  if defined (VLNEXT) && defined (TERMIOS_TTY_DRIVER)
#  if defined (VLNEXT) && defined (TERMIOS_TTY_DRIVER)
  RESET_SPECIAL (_rl_tty_chars.t_lnext);
  RESET_SPECIAL (_rl_tty_chars.t_lnext);
#  endif /* VLNEXT && TERMIOS_TTY_DRIVER */
#  endif /* VLNEXT && TERMIOS_TTY_DRIVER */
 
 
#  if defined (VWERASE) && defined (TERMIOS_TTY_DRIVER)
#  if defined (VWERASE) && defined (TERMIOS_TTY_DRIVER)
  RESET_SPECIAL (_rl_tty_chars.t_werase);
  RESET_SPECIAL (_rl_tty_chars.t_werase);
#  endif /* VWERASE && TERMIOS_TTY_DRIVER */
#  endif /* VWERASE && TERMIOS_TTY_DRIVER */
}
}
 
 
#if defined (HANDLE_SIGNALS)
#if defined (HANDLE_SIGNALS)
 
 
#if defined (NEW_TTY_DRIVER) || defined (NO_TTY_DRIVER)
#if defined (NEW_TTY_DRIVER) || defined (NO_TTY_DRIVER)
int
int
_rl_disable_tty_signals ()
_rl_disable_tty_signals ()
{
{
  return 0;
  return 0;
}
}
 
 
int
int
_rl_restore_tty_signals ()
_rl_restore_tty_signals ()
{
{
  return 0;
  return 0;
}
}
#else
#else
 
 
static TIOTYPE sigstty, nosigstty;
static TIOTYPE sigstty, nosigstty;
static int tty_sigs_disabled = 0;
static int tty_sigs_disabled = 0;
 
 
int
int
_rl_disable_tty_signals ()
_rl_disable_tty_signals ()
{
{
  if (tty_sigs_disabled)
  if (tty_sigs_disabled)
    return 0;
    return 0;
 
 
  if (_get_tty_settings (fileno (rl_instream), &sigstty) < 0)
  if (_get_tty_settings (fileno (rl_instream), &sigstty) < 0)
    return -1;
    return -1;
 
 
  nosigstty = sigstty;
  nosigstty = sigstty;
 
 
  nosigstty.c_lflag &= ~ISIG;
  nosigstty.c_lflag &= ~ISIG;
  nosigstty.c_iflag &= ~IXON;
  nosigstty.c_iflag &= ~IXON;
 
 
  if (_set_tty_settings (fileno (rl_instream), &nosigstty) < 0)
  if (_set_tty_settings (fileno (rl_instream), &nosigstty) < 0)
    return (_set_tty_settings (fileno (rl_instream), &sigstty));
    return (_set_tty_settings (fileno (rl_instream), &sigstty));
 
 
  tty_sigs_disabled = 1;
  tty_sigs_disabled = 1;
  return 0;
  return 0;
}
}
 
 
int
int
_rl_restore_tty_signals ()
_rl_restore_tty_signals ()
{
{
  int r;
  int r;
 
 
  if (tty_sigs_disabled == 0)
  if (tty_sigs_disabled == 0)
    return 0;
    return 0;
 
 
  r = _set_tty_settings (fileno (rl_instream), &sigstty);
  r = _set_tty_settings (fileno (rl_instream), &sigstty);
 
 
  if (r == 0)
  if (r == 0)
    tty_sigs_disabled = 0;
    tty_sigs_disabled = 0;
 
 
  return r;
  return r;
}
}
#endif /* !NEW_TTY_DRIVER */
#endif /* !NEW_TTY_DRIVER */
 
 
#endif /* HANDLE_SIGNALS */
#endif /* HANDLE_SIGNALS */
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.