sysunix.c

Go to the documentation of this file.
00001 /*  $Revision: 1.1.1.1 $
00002 **
00003 **  Unix system-dependant routines for editline library.
00004 */
00005 #include "editline.h"
00006 
00007 #if     defined(HAVE_TCGETATTR)
00008 #include <termios.h>
00009 
00010 void
00011 rl_ttyset(Reset)
00012     int                         Reset;
00013 {
00014     static struct termios       old;
00015     struct termios              new;
00016 
00017     if (Reset == 0) {
00018         (void)tcgetattr(0, &old);
00019         rl_erase = old.c_cc[VERASE];
00020         rl_kill = old.c_cc[VKILL];
00021         rl_eof = old.c_cc[VEOF];
00022         rl_intr = old.c_cc[VINTR];
00023         rl_quit = old.c_cc[VQUIT];
00024 
00025         new = old;
00026         new.c_lflag &= ~(ECHO | ICANON | ISIG | IEXTEN);
00027         new.c_iflag &= ~(ICRNL);
00028         new.c_cc[VMIN] = 1;
00029         new.c_cc[VTIME] = 0;
00030         (void)tcsetattr(0, TCSADRAIN, &new);
00031     }
00032     else
00033         (void)tcsetattr(0, TCSADRAIN, &old);
00034 }
00035 
00036 #else
00037 #if     defined(HAVE_TERMIO)
00038 #include <termio.h>
00039 
00040 void
00041 rl_ttyset(Reset)
00042     int                         Reset;
00043 {
00044     static struct termio        old;
00045     struct termio               new;
00046 
00047     if (Reset == 0) {
00048         (void)ioctl(0, TCGETA, &old);
00049         rl_erase = old.c_cc[VERASE];
00050         rl_kill = old.c_cc[VKILL];
00051         rl_eof = old.c_cc[VEOF];
00052         rl_intr = old.c_cc[VINTR];
00053         rl_quit = old.c_cc[VQUIT];
00054 
00055         new = old;
00056         new.c_cc[VINTR] = -1;
00057         new.c_cc[VQUIT] = -1;
00058         new.c_lflag &= ~(ECHO | ICANON);
00059         new.c_cc[VMIN] = 1;
00060         new.c_cc[VTIME] = 0;
00061         (void)ioctl(0, TCSETAW, &new);
00062     }
00063     else
00064         (void)ioctl(0, TCSETAW, &old);
00065 }
00066 
00067 #else
00068 #include <sgtty.h>
00069 
00070 void
00071 rl_ttyset(Reset)
00072     int                         Reset;
00073 {
00074     static struct sgttyb        old_sgttyb;
00075     static struct tchars        old_tchars;
00076     struct sgttyb               new_sgttyb;
00077     struct tchars               new_tchars;
00078 
00079     if (Reset == 0) {
00080         (void)ioctl(0, TIOCGETP, &old_sgttyb);
00081         rl_erase = old_sgttyb.sg_erase;
00082         rl_kill = old_sgttyb.sg_kill;
00083 
00084         (void)ioctl(0, TIOCGETC, &old_tchars);
00085         rl_eof = old_tchars.t_eofc;
00086         rl_intr = old_tchars.t_intrc;
00087         rl_quit = old_tchars.t_quitc;
00088 
00089         new_sgttyb = old_sgttyb;
00090         new_sgttyb.sg_flags &= ~ECHO;
00091         new_sgttyb.sg_flags |= RAW;
00092         (void)ioctl(0, TIOCSETP, &new_sgttyb);
00093 
00094         new_tchars = old_tchars;
00095         new_tchars.t_intrc = -1;
00096         new_tchars.t_quitc = -1;
00097         (void)ioctl(0, TIOCSETC, &new_tchars);
00098     }
00099     else {
00100         (void)ioctl(0, TIOCSETP, &old_sgttyb);
00101         (void)ioctl(0, TIOCSETC, &old_tchars);
00102     }
00103 }
00104 #endif  /* defined(HAVE_TERMIO) */
00105 #endif  /* defined(HAVE_TCGETATTR) */
00106 
00107 void
00108 rl_add_slash(path, p)
00109     char        *path;
00110     char        *p;
00111 {
00112     struct stat Sb;
00113 
00114     if (stat(path, &Sb) >= 0)
00115         (void)strcat(p, S_ISDIR(Sb.st_mode) ? "/" : " ");
00116 }
00117 
00118 /*
00119  * $PchId: sysunix.c,v 1.4 1996/02/22 21:16:56 philip Exp $
00120  */

Generated on Fri Apr 14 22:57:26 2006 for minix by  doxygen 1.4.6