home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
rtsi.com
/
2014.01.www.rtsi.com.tar
/
www.rtsi.com
/
OS9
/
TOP
/
USR
/
SRC
/
zmodem.t.Z
/
zmodem.t
/
alarmread.c
next >
Wrap
C/C++ Source or Header
|
1988-06-13
|
1KB
|
61 lines
#include <time.h>
int alarmread(fd,buffer,count,function,timeout)
register int fd;
register char *buffer;
int count;
int (*function)();
register int timeout;
{
register unsigned int i;
register int n;
static int ticksec = 0;
if(ticksec == 0) ticksec = CLK_TCK;
timeout = timeout * (ticksec + 1); /* at least one second of sleep */
while( ((n=_gs_rdy(fd)) <= 0) && (--timeout != 0) )
{
tsleep(2); /* give at least one time slice */
}
if( timeout != 0)
return( read(fd,buffer, (count >= n) ? n : count) );
return((*function)());
}
#include <direct.h>
utime (file, timep)
char *file;
time_t timep[2];
{
struct tm *localtime ();
struct tm *tbuf;
int fd;
struct fildes buf;
if ((fd = open (file, 0)) < 0)
return -1;
if (_gs_gfd (fd, &buf, sizeof (struct fildes)) < 0)
{
close (fd);
return -1;
}
tbuf = localtime (&(timep[1]));
sprintf (buf.fd_date, "%c%c%c%c%c",
(char) tbuf->tm_year,
(char) tbuf->tm_mon,
(char) tbuf->tm_mday,
(char) tbuf->tm_hour,
(char) tbuf->tm_min );
if (_ss_pfd (fd, &buf) < 0)
{
close (fd);
return -1;
}
close (fd);
return 0;
}