/* @(#)cpnull.c 4.1 82/03/05 */
char *index(), *rindex(), *malloc();
if (argc
> 0 && !strcmp(*argv
, "-r"))
if (argc
> 0 && !strcmp(*argv
, "-v"))
fprintf(stderr
, "usage: cpnull machine blocks\n");
rem
= rexec(&host
, IPPORT_SHELLSERVER
, "cpnull -r", 0, 0);
sprintf(buf
, "C%d\n", blocks
* BUFSIZ
);
write(rem
, buf
, strlen(buf
));
printf("sending %d blocks\n", blocks
);
for (i
= 0; i
< blocks
; i
++) {
if (vflag
&& (i
% 100 == 0))
printf("< 1 second to transfer\n");
printf("%d bytes %d seconds %d baud\n",
blocks
* BUFSIZ
, now
- then
,
(blocks
* BUFSIZ
* 8) / (now
- then
));
char resp
, c
, rbuf
[BUFSIZ
], *cp
= rbuf
;
if (read(rem
, &resp
, 1) != 1) {
printf("Response read != 1\n");
if (read(rem
, &c
, 1) != 1) {
printf("response loop != 1\n");
} while (cp
< &rbuf
[BUFSIZ
] && c
!= '\n');
write(2, rbuf
, cp
- rbuf
);
fprintf(stderr
, "SIGPIPE.\n");
fprintf(stderr
, "Lost connection.\n");
char namebuf
[BUFSIZ
], buf
[BUFSIZ
], *name
, *cp
, c
;
#define SCREWUP(str) { whopp = str; goto screwup; }
SCREWUP("unexpected '\\n'");
SCREWUP("expected control record");
while (*cp
>= '0' && *cp
<= '9')
size
= size
* 10 + (*cp
++ - '0');
SCREWUP("size not delimited");
for (i
= 0; i
< size
; i
+= BUFSIZ
) {
int j
= read(0, cp
, amt
);
sprintf(buf
, "\01%s: %s\n", cp
, sys_errlist
[errno
]);
write(rem
, buf
, strlen(buf
));
sprintf(buf
, "\02Procotol screwup: %s.\n", whopp
);
write(rem
, buf
, strlen(buf
));