home *** CD-ROM | disk | FTP | other *** search
/ rtsi.com / 2014.01.www.rtsi.com.tar / www.rtsi.com / OS9 / OSK / TELECOM / stg_v4.lzh / ss_misc2.c < prev    next >
C/C++ Source or Header  |  1994-11-11  |  812b  |  53 lines

  1. /*
  2.  * _ss_mode2(path,code)
  3.  *
  4.  * force 8 bits, no parity on path (code=1 to set, 0 to restore)
  5.  *
  6.  * For Unix (i.e. SunOS) systems that have a brain damaged TCGET/SET
  7.  * ioctl that doesn't implement c_flag correctly.
  8.  *
  9. */
  10.  
  11. #define ERR (-1)
  12.  
  13. #ifdef sun
  14.  
  15. #include "sys/types.h"
  16. #include "sys/stat.h"
  17. #include "sgtty.h"
  18.  
  19. #define MAX_PATHS 32
  20.  
  21. struct sgttyb *tty[MAX_PATHS];
  22.  
  23. _ss_mode2(path,code)
  24. int path,code;
  25. {
  26.     struct sgttyb tmp;
  27.  
  28.     if (!tty[path])
  29.     {
  30.         tty[path]=(struct sgttyb *)malloc(sizeof(tmp));
  31.         if (!tty[path])
  32.             return(ERR);
  33.         ioctl(path,TIOCGETP,tty[path]);
  34.     }
  35.     memcpy(&tmp,tty[path],sizeof(tmp));
  36.  
  37.     if (code)
  38.     {
  39.         tmp.sg_flags|=ANYP|O_RAW;
  40.     }
  41.  
  42.     ioctl(path,TIOCSETP,&tmp);
  43.  
  44.     if (!code)
  45.     {
  46.         free(tty[path]);
  47.         tty[path]=0;
  48.     }
  49.     return(0);
  50. }
  51.  
  52. #endif
  53.