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.c
< prev
next >
Wrap
C/C++ Source or Header
|
1994-11-11
|
3KB
|
196 lines
#include "stglib.h"
#define MAX_Paths 32
/*
* _ss_mode(path,code)
*
* code: 0 = normal
* 1 = no echo
* 2 = disable line buffering [UNIX]
* -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&2) /* turn off line buffering */
{
/* local flags */
sTempMode.c_lflag&=~ICANON; /* no canon processing */
}
if (code<0) /* RAW MODE */
{
/* input flags */
sTempMode.c_iflag=0;
/* output flags */
sTempMode.c_oflag=0;
/* control flags */
sTempMode.c_cflag&=~PARENB;
sTempMode.c_cflag|=CS8;
/* local modes */
sTempMode.c_lflag=0;
}
ioctl(path,TCSETAW,&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