static char sccsid
[] = "@(#)tio.c 4.9 (Berkeley) %G%";
#include <machine/machparam.h>
#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
extern long Bytes_Sent
, Bytes_Received
;
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) || defined(ns32000)
bufr
.t_nbytes
= htonl((long)len
);
#else !vax and !pdp11 and !ns32000
#endif !vax and !pdp11 and !ns32000
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
;
ft
= (float)t2
.time
+ (float)mil
/1000.;
sprintf(text
, "sent data %ld bytes %.2f secs %ld bps",
bytes
, ft
, (long)((float)bytes
*8./ft
));
len
= trdblk((char *)&Nbytes
,sizeof Nbytes
,fn
);
if (len
!= sizeof Nbytes
)
#if defined(vax) || defined(pdp11) || defined(ns32000)
#endif vax or pdp11 or ns32000
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
;
ft
= (float)t2
.time
+ (float)mil
/1000.;
sprintf(bufr
, "received data %ld bytes %.2f secs %ld bps",
bytes
, ft
, (long)((float)bytes
*8./ft
));
#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
);