home *** CD-ROM | disk | FTP | other *** search
/ What PC? 1996 April / WHAT_PC_APR_96.ISO / internet / twinsock / src / term.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-03-24  |  1.8 KB  |  80 lines

  1. /*
  2.  *  TwinSock - "Troy's Windows Sockets"
  3.  *
  4.  *  Copyright (C) 1994  Troy Rollo <troy@cbme.unsw.EDU.AU>
  5.  *
  6.  *  This program is free software; you can redistribute it and/or modify
  7.  *  it under the terms of the license in the file LICENSE.TXT included
  8.  *  with the TwinSock distribution.
  9.  *
  10.  *  This program is distributed in the hope that it will be useful,
  11.  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
  13.  */
  14.  
  15. #ifndef NO_SGTTY_H
  16. #include <sgtty.h>
  17. #else
  18. #include <sys/ioctl.h>
  19. #endif
  20. #ifdef NEED_TTOLD_H
  21. #include <sys/ttold.h>
  22. #endif
  23.  
  24. #if !defined(CBREAK) && defined(O_CBREAK)
  25. #define CBREAK O_CBREAK
  26. #endif
  27. #if !defined(LITOUT) && defined(O_LITOUT)
  28. #define LITOUT O_LITOUT
  29. #endif
  30. #if !defined(PASS8) && defined(O_PASS8)
  31. #define PASS8 O_PASS8
  32. #endif
  33. #if !defined(DECCTQ) && defined(O_DECCTQ)
  34. #define DECCTQ O_DECCTQ
  35. #endif
  36. #if !defined(RAW) && defined(O_RAW)
  37. #define RAW O_RAW
  38. #endif
  39. #if !defined(ECHO) && defined(O_ECHO)
  40. #define ECHO O_ECHO
  41. #endif
  42. #if !defined(CRMOD) && defined(O_CRMOD)
  43. #define CRMOD O_CRMOD
  44. #endif
  45. #if !defined(TILDE) && defined(O_TILDE)
  46. #define TILDE O_TILDE
  47. #endif
  48. #if !defined(NOHANG) && defined(O_NOHANG)
  49. #define NOHANG O_NOHANG
  50. #endif
  51. #if !defined(CTLECH) && defined(O_CTLECH)
  52. #define CTLECH O_CTLECH
  53. #endif
  54.  
  55. struct    sgttyb Old;
  56. struct    sgttyb New;
  57.  
  58. void    InitTerm(void)
  59. {
  60.     ioctl(0, TIOCGETP, &Old);
  61.     New = Old;
  62.     New.sg_flags |= CBREAK | RAW;
  63. #ifdef PASS8
  64.     New.sg_flags |= PASS8;
  65. #endif
  66. #ifdef DECCTQ
  67.     New.sg_flags |= DECCTQ;
  68. #endif
  69. #ifdef LITOUT
  70.     New.sg_flags |= LITOUT;
  71. #endif
  72.     New.sg_flags &= ~(ECHO | CRMOD | TILDE | NOHANG | CTLECH);
  73.     ioctl(0, TIOCSETP, &New);
  74. }
  75.  
  76. void    UnInitTerm(void)
  77. {
  78.     ioctl(0, TIOCSETP, &Old);
  79. }
  80.