home *** CD-ROM | disk | FTP | other *** search
/ rtsi.com / 2014.01.www.rtsi.com.tar / www.rtsi.com / OS9 / OSK / TELECOM / GNU_ATP_1_40.lzh / EDITLINE / sysunix.c < prev    next >
Text File  |  1993-05-01  |  2KB  |  90 lines

  1. /*  $Revision: 1.1 $
  2. **
  3. **  Unix system-dependant routines for editline library.
  4. */
  5. #include "editline.h"
  6.  
  7. #if    defined(HAVE_TCGETATTR)
  8. #include <termios.h>
  9.  
  10. void
  11. rl_ttyset(Reset)
  12.     int                Reset;
  13. {
  14.     static struct termios    old;
  15.     struct termios        new;
  16.  
  17.     if (Reset == 0) {
  18.     (void)tcgetattr(0, &old);
  19.     rl_erase = old.c_cc[VERASE];
  20.     rl_kill = old.c_cc[VKILL];
  21.     rl_eof = old.c_cc[VEOF];
  22.     rl_intr = old.c_cc[VINTR];
  23.     rl_quit = old.c_cc[VQUIT];
  24.  
  25.     new = old;
  26.     new.c_cc[VINTR] = -1;
  27.     new.c_cc[VQUIT] = -1;
  28.     new.c_lflag &= ~(ECHO | ICANON);
  29.     new.c_iflag &= ~(ISTRIP | INPCK);
  30.     new.c_cc[VMIN] = 1;
  31.     new.c_cc[VTIME] = 0;
  32.     (void)tcsetattr(0, TCSANOW, &new);
  33.     }
  34.     else
  35.     (void)tcsetattr(0, TCSANOW, &old);
  36. }
  37.  
  38. #else
  39. #include <sgtty.h>
  40.  
  41. void
  42. rl_ttyset(Reset)
  43.     int                Reset;
  44. {
  45.     static struct sgttyb    old_sgttyb;
  46.     static struct tchars    old_tchars;
  47.     struct sgttyb        new_sgttyb;
  48.     struct tchars        new_tchars;
  49.  
  50.     if (Reset == 0) {
  51.     (void)ioctl(0, TIOCGETP, &old_sgttyb);
  52.     rl_erase = old_sgttyb.sg_erase;
  53.     rl_kill = old_sgttyb.sg_kill;
  54.  
  55.     (void)ioctl(0, TIOCGETC, &old_tchars);
  56.     rl_eof = old_tchars.t_eofc;
  57.     rl_intr = old_tchars.t_intrc;
  58.     rl_quit = old_tchars.t_quitc;
  59.  
  60.     new_sgttyb = old_sgttyb;
  61.     new_sgttyb.sg_flags &= ~ECHO;
  62.     new_sgttyb.sg_flags |= RAW;
  63. #if    defined(PASS8)
  64.     new_sgttyb.sg_flags |= PASS8;
  65. #endif    /* defined(PASS8) */
  66.     (void)ioctl(0, TIOCSETP, &new_sgttyb);
  67.  
  68.     new_tchars = old_tchars;
  69.     new_tchars.t_intrc = -1;
  70.     new_tchars.t_quitc = -1;
  71.     (void)ioctl(0, TIOCSETC, &new_tchars);
  72.     }
  73.     else {
  74.     (void)ioctl(0, TIOCSETP, &old_sgttyb);
  75.     (void)ioctl(0, TIOCSETC, &old_tchars);
  76.     }
  77. }
  78. #endif    /* defined(HAVE_TCGETATTR) */
  79.  
  80. void
  81. rl_add_slash(path, p)
  82.     char    *path;
  83.     char    *p;
  84. {
  85.     struct stat    Sb;
  86.  
  87.     if (stat(path, &Sb) >= 0)
  88.     (void)strcat(p, S_ISDIR(Sb.st_mode) ? SEPST : " ");
  89. }
  90.