static char sccsid
[] = "@(#)tio.c 4.4 (Berkeley) %G%";
#define min(a,b) (((a)<(b))?(a):(b))
* htonl is a function that converts a long from host
* ntohl is a function that converts a long from network
* network order is 0 1 2 3 (bytes in a long)
* host order on a vax is 3 2 1 0
* host order on a pdp11 is 1 0 3 2
* host order on a 68000 is 0 1 2 3
* most other machines are 0 1 2 3
if ((i
= len
% TPACKSIZE
)) {
len
= len
+ TPACKSIZE
- i
;
len
= read(fn
, str
, TPACKSIZE
);
if (*(str
- 1) == '\0' && (cnt
% TPACKSIZE
) == 0)
while ((len
= read(fileno(fp1
), bufr
.t_data
, TBUFSIZE
)) > 0) {
#if defined(vax) || defined(pdp11)
bufr
.t_nbytes
= htonl((long)len
);
DEBUG(8,"twrdata sending %d bytes\n",len
);
ret
= twrblk((char *)&bufr
, len
, fn
);
if (len
!= TBUFSIZE
+sizeof(long))
ret
= twrblk((char *)&bufr
, len
, fn
);
mil
= t2
.millitm
- t1
.millitm
;
sprintf(text
, "sent data %ld bytes %ld.%02d secs",
bytes
, (long)t2
.time
, mil
/10);
sysacct(bytes
, t2
.time
- t1
.time
);
len
= trdblk((char *)&Nbytes
,sizeof Nbytes
,fn
);
if (len
!= sizeof Nbytes
)
#if defined(vax) || defined(pdp11)
DEBUG(8,"trddata expecting %ld bytes\n",Nbytes
);
len
= trdblk(bufr
, nread
, fn
);
DEBUG(11,"trddata got %ld\n",bytes
);
if (write(fileno(fp2
), bufr
, len
) != len
) {
mil
= t2
.millitm
- t1
.millitm
;
sprintf(bufr
, "received data %ld bytes %ld.%02d secs",
bytes
, (long)t2
.time
, mil
/10);
sysacct(bytes
, t2
.time
- t1
.time
);
#if !defined(BSD4_2) && !defined(USG)
#if !defined(BSD4_2) && !defined(USG)
/* call ultouch occasionally */
for (i
= 0; i
< len
; i
+= ret
) {
ret
= read(fn
, blk
, len
- i
);
#if !defined(BSD4_2) && !defined(USG)
/* call ultouch occasionally */
return write(fn
, blk
, len
);