home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / misc / volume38 / menushell / part03 / settatr.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-07-30  |  1.1 KB  |  59 lines

  1. #include "mshell.h"
  2. #include <sys/time.h>
  3. #include <sys/resource.h>
  4.  
  5. set_terminal_attributes()
  6. {
  7. #ifdef BSD
  8.     struct sgttyb  sg;
  9.     struct tchars  tc;
  10.     struct ltchars lt;
  11.     int ldisc = NTTYDISC;
  12.  
  13.     ioctl ( 0, TIOCSETD, &ldisc );
  14.  
  15.     ioctl ( 0, TIOCGETP, &sg );
  16.     if (access(".stty", 0) == -1) {    /* not already set up */
  17.         sg.sg_erase = '\b';
  18.         sg.sg_kill  = 21;    /* ^U */
  19.         sg.sg_flags |= XTABS;
  20.     }
  21.     sg.sg_flags |= ECHO;
  22.     sg.sg_flags &= ~ RAW;
  23.     sg.sg_flags &= ~ CBREAK;
  24.     sg.sg_flags |= CRMOD;
  25.     ioctl ( 0, TIOCSETP, &sg );
  26.  
  27.     ioctl ( 0, TIOCGETC, &tc );
  28.     tc.t_intrc  = 3;    /* ^C */
  29.     ioctl ( 0, TIOCSETC, &tc );
  30.  
  31.     ioctl ( 0, TIOCGLTC, < );
  32.     lt.t_werasc = 23;    /* ^W */
  33.     lt.t_rprntc = 18;    /* ^R */
  34.     ioctl ( 0, TIOCSLTC, < );
  35. #endif
  36. #ifdef SYSV
  37.     struct termio t;
  38.  
  39.     ioctl ( 0, TCGETA, &t );
  40.  
  41.     t.c_cc[VINTR] = '\003';
  42.     t.c_cc[VERASE] = '\b';
  43.     t.c_cc[VKILL] = '\025';
  44.     t.c_iflag = IGNBRK | IGNPAR | ICRNL | IXON ;
  45.     t.c_oflag = OPOST | ONLCR ;
  46.     t.c_lflag = ISIG | ICANON | ECHO | ECHOE | ECHOK ;
  47.     t.c_cflag |= TAB3;
  48.  
  49.     ioctl ( 0, TCSETA, &t );
  50. #endif
  51. }
  52. set_resource_limits()
  53. {
  54.     struct rlimit lim;
  55.  
  56.     lim.rlim_cur = lim.rlim_max = 0;
  57.     setrlimit(RLIMIT_CORE, &lim);
  58. }
  59.