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 >
Wrap
Text File
|
1994-11-11
|
3KB
|
196 lines
#include "stglib.h"
#define MAX_Paths 32
/************************************************
**
** _ss_mode codes: 0=normal, 1=no echo, -1=raw
**
************************************************/
#ifdef _OS9
#include <sgstat.h>
struct sgbuf *apsTermMode[MAX_Paths], *malloc();
_ss_mode(path,code)
int path,code;
{
struct sgbuf sTempMode;
if (!apsTermMode[path])
{
apsTermMode[path]=malloc(sizeof(struct sgbuf));
if (!apsTermMode[path])
return(ERR);
if (_gs_opt(path,apsTermMode[path])==ERR)
return(ERR);
}
memcpy(&sTempMode,apsTermMode[path],sizeof(struct sgbuf));
if (code&1)
sTempMode.sg_echo=0;
if (code<0)
{
sTempMode.sg_pause=0;
sTempMode.sg_eorch=0;
sTempMode.sg_eofch=0;
sTempMode.sg_rlnch=0;
sTempMode.sg_dulnch=0;
sTempMode.sg_psch=0;
sTempMode.sg_kbich=0;
sTempMode.sg_kbach=0;
sTempMode.sg_xon=0;
sTempMode.sg_xoff=0;
}
if (_ss_opt(path,&sTempMode)==ERR)
return(ERR);
/* fake a write to force update of settings */
write(path,"",0);
if (!code)
{
free(apsTermMode[path]);
apsTermMode[path]=0;
}
return(0);
}
_ss_own(path,uid)
int path;
int uid;
{
unsigned char buf[32];
_gs_gfd(path,buf,32);
buf[1]=(uid&0x00FF0000)>>16;
buf[2]=(uid&0x000000FF);
return(_ss_pfd(path,buf));
}
fchown(path,uid,gid)
int path;
int uid;
int gid;
{
/* ignore gid - not in OS-9 */
return(_ss_own(path,uid));
}
#endif
#ifdef _UNIX
#include <termio.h>
struct termio *apsTermMode[MAX_Paths];
#include <sys/filio.h>
_ss_mode(path,code)
int path,code;
{
struct termio sTempMode;
if (!apsTermMode[path])
{
apsTermMode[path]=
(struct termio *)malloc(sizeof(struct termio));
if (!apsTermMode[path])
return(ERR);
ioctl(path,TCGETA,apsTermMode[path]);
}
memcpy(&sTempMode,apsTermMode[path],sizeof(struct termio));
if (code&1) /* just turn echo off */
{
sTempMode.c_lflag&=~ECHO;
/* sTempMode.c_cc[4]=1; */
}
if (code<0) /* RAW MODE */
{
/* input flags */
sTempMode.c_iflag&=~INPCK; /* no parity check */
sTempMode.c_iflag&=~ISTRIP; /* no strip char */
sTempMode.c_iflag&=~INLCR; /* no map nl to cr */
sTempMode.c_iflag&=~IGNCR; /* no ignore cr */
sTempMode.c_iflag&=~ICRNL; /* no map cr to nl */
sTempMode.c_iflag&=~IUCLC; /* no map case */
sTempMode.c_iflag&=~IXON; /* no xon output */
sTempMode.c_iflag&=~IXOFF; /* no xon input */
sTempMode.c_iflag&=~IMAXBEL; /* no bell */
/* output flags */
sTempMode.c_oflag&=~OPOST; /* no postprocess */
/* control flags */
sTempMode.c_cflag&=CSIZE; /* turn off 'bits' bits */
sTempMode.c_cflag|=CS8; /* 8 bits */
sTempMode.c_cflag&=~PARENB; /* no parity */
/* line flags */
sTempMode.c_lflag&=~ICANON; /* no canon processing */
}
ioctl(path,TCSETA,&sTempMode);
if (!code)
{
free(apsTermMode[path]);
apsTermMode[path]=0;
}
return(0);
}
_gs_rdy(path)
int path;
{
long lReady;
ioctl(path,FIONREAD,&lReady);
if (!lReady)
return(-1);
return((int)lReady);
}
long
_gs_size(path)
int path;
{
long save,size;
save=lseek(path,0l,1);
size=lseek(path,0l,2);
lseek(path,save,0);
return(size);
}
int
_ss_size(path,size)
int path;
long size;
{
return(truncate(path,size));
}
/*
_ss_own(path,uid)
int path;
int uid;
{
return(fchown(path,uid,-1));
}
*/
_ss_lock()
{
return(0);
}
#endif