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_misc.old < prev    next >
Text File  |  1994-11-11  |  3KB  |  196 lines

  1. #include "stglib.h"
  2.  
  3. #define MAX_Paths 32
  4.  
  5. /************************************************
  6.  **
  7.  ** _ss_mode codes: 0=normal, 1=no echo, -1=raw 
  8.  **
  9.  ************************************************/
  10.  
  11. #ifdef _OS9
  12.  
  13. #include <sgstat.h>
  14.  
  15. struct sgbuf *apsTermMode[MAX_Paths], *malloc();
  16.  
  17. _ss_mode(path,code)
  18. int path,code;
  19. {
  20.     struct sgbuf sTempMode;
  21.  
  22.     if (!apsTermMode[path])
  23.     {
  24.         apsTermMode[path]=malloc(sizeof(struct sgbuf));
  25.         if (!apsTermMode[path])
  26.             return(ERR);
  27.         if (_gs_opt(path,apsTermMode[path])==ERR)
  28.             return(ERR);
  29.     }
  30.  
  31.     memcpy(&sTempMode,apsTermMode[path],sizeof(struct sgbuf));
  32.  
  33.     if (code&1)
  34.         sTempMode.sg_echo=0;
  35.  
  36.     if (code<0)
  37.     {
  38.         sTempMode.sg_pause=0;
  39.         sTempMode.sg_eorch=0;
  40.         sTempMode.sg_eofch=0;
  41.         sTempMode.sg_rlnch=0;
  42.         sTempMode.sg_dulnch=0;
  43.         sTempMode.sg_psch=0;
  44.         sTempMode.sg_kbich=0;
  45.         sTempMode.sg_kbach=0;
  46.         sTempMode.sg_xon=0;
  47.         sTempMode.sg_xoff=0;
  48.     }
  49.     if (_ss_opt(path,&sTempMode)==ERR)
  50.         return(ERR);
  51.  
  52.     /* fake a write to force update of settings */
  53.     write(path,"",0);
  54.  
  55.     if (!code)
  56.     {
  57.         free(apsTermMode[path]);
  58.         apsTermMode[path]=0;
  59.     }
  60.     return(0);
  61. }
  62.  
  63. _ss_own(path,uid)
  64. int path;
  65. int uid;
  66. {
  67.     unsigned char buf[32];
  68.  
  69.     _gs_gfd(path,buf,32);
  70.     buf[1]=(uid&0x00FF0000)>>16;
  71.     buf[2]=(uid&0x000000FF);
  72.     return(_ss_pfd(path,buf));
  73. }
  74.  
  75. fchown(path,uid,gid)
  76. int path;
  77. int uid;
  78. int gid;
  79. {
  80.     /* ignore gid - not in OS-9 */
  81.     return(_ss_own(path,uid));
  82. }
  83.  
  84. #endif
  85.  
  86. #ifdef _UNIX
  87.  
  88. #include <termio.h>
  89. struct termio *apsTermMode[MAX_Paths];
  90.  
  91. #include <sys/filio.h>
  92.  
  93. _ss_mode(path,code)
  94. int path,code;
  95. {
  96.     struct termio sTempMode;
  97.  
  98.     if (!apsTermMode[path])
  99.     {
  100.         apsTermMode[path]=
  101.             (struct termio *)malloc(sizeof(struct termio));
  102.         if (!apsTermMode[path])
  103.             return(ERR);
  104.         ioctl(path,TCGETA,apsTermMode[path]);
  105.     }
  106.     memcpy(&sTempMode,apsTermMode[path],sizeof(struct termio));
  107.  
  108.     if (code&1)    /* just turn echo off */
  109.     {
  110.         sTempMode.c_lflag&=~ECHO;
  111. /*        sTempMode.c_cc[4]=1; */
  112.     }
  113.  
  114.     if (code<0)    /* RAW MODE */
  115.     {
  116.         /* input flags */
  117.         sTempMode.c_iflag&=~INPCK;    /* no parity check */
  118.         sTempMode.c_iflag&=~ISTRIP;    /* no strip char */
  119.         sTempMode.c_iflag&=~INLCR;    /* no map nl to cr */
  120.         sTempMode.c_iflag&=~IGNCR;    /* no ignore cr */
  121.         sTempMode.c_iflag&=~ICRNL;    /* no map cr to nl */
  122.         sTempMode.c_iflag&=~IUCLC;    /* no map case */
  123.         sTempMode.c_iflag&=~IXON;    /* no xon output */
  124.         sTempMode.c_iflag&=~IXOFF;    /* no xon input */
  125.         sTempMode.c_iflag&=~IMAXBEL;    /* no bell */
  126.  
  127.         /* output flags */
  128.         sTempMode.c_oflag&=~OPOST;    /* no postprocess */
  129.  
  130.         /* control flags */
  131.         sTempMode.c_cflag&=CSIZE;    /* turn off 'bits' bits */
  132.         sTempMode.c_cflag|=CS8;        /* 8 bits */
  133.         sTempMode.c_cflag&=~PARENB;    /* no parity */
  134.  
  135.         /* line flags */
  136.         sTempMode.c_lflag&=~ICANON;    /* no canon processing */
  137.     }
  138.  
  139.     ioctl(path,TCSETA,&sTempMode);
  140.     if (!code)
  141.     {
  142.         free(apsTermMode[path]);
  143.         apsTermMode[path]=0;
  144.     }
  145.     return(0);
  146. }
  147.  
  148. _gs_rdy(path)
  149. int path;
  150. {
  151.     long lReady;
  152.  
  153.     ioctl(path,FIONREAD,&lReady);
  154.  
  155.     if (!lReady)
  156.         return(-1);
  157.  
  158.     return((int)lReady);
  159. }
  160.  
  161. long
  162. _gs_size(path)
  163. int path;
  164. {
  165.     long save,size;
  166.  
  167.     save=lseek(path,0l,1);
  168.     size=lseek(path,0l,2);
  169.     lseek(path,save,0);
  170.     return(size);
  171. }
  172.  
  173. int
  174. _ss_size(path,size)
  175. int path;
  176. long size;
  177. {
  178.     return(truncate(path,size));
  179. }
  180.  
  181. /*
  182. _ss_own(path,uid)
  183. int path;
  184. int uid;
  185. {
  186.     return(fchown(path,uid,-1));
  187. }
  188. */
  189.  
  190. _ss_lock()
  191. {
  192.     return(0);
  193. }
  194.  
  195. #endif
  196.