Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!akgua!mcnc!ecsvax!mbs From: mbs@ecsvax.UUCP Newsgroups: micro.unix,micro.sources,net.sources Subject: A slower and better download source Message-ID: <2099@ecsvax.UUCP> Date: Sun, 4-Mar-84 20:38:19 EST Article-I.D.: ecsvax.2099 Posted: Sun Mar 4 20:38:19 1984 Date-Received: Mon, 5-Mar-84 06:54:58 EST Lines: 75 <> For those of you who don't have protocol oriented file transder programs and whose micro has trouble keeping up with a downloaded cat may want to consider using the following program to download your sources. It reads the file you wish to download 2 lines at a time, writes the output to STDOUT, and then sleeps for 1 second. For me, it has prevented the loss of a lot of data, since my micro has difficulty keeping up. For those on the ecsvax machine, a copy of the object code is in the directory /ecs/pub/misc under the name "copy", and the source file is in the same directory, but named "copy.c". --- Michael Smith {ittvax!ittral, akgua!mcnc, decvax!mcnc}!ecsvax!mbs main(argc, argv) int argc; char **argv; { char *p; short fin; extern char *get_line(); if( argc != 2 ) { printf("invalid number of arguments\n"); exit(1); } if( (fin = open(argv[1], 0)) < 0 ) { printf("cannot open: %s \n", argv[1]); exit(1); } while( 1 ) { p = get_line(fin); write(1, p, strlen(p)); p = get_line(fin); if( *p == '\0' ) { close(fin); /* this condition signifies end-of-file */ exit(0); } write(1, p, strlen(p)); sleep(1); } } char get_char(fyle) short fyle; { char c; if( read(fyle, &c, 1) != 1 ) return( -1 ); else return( c ); } char *get_line(fyle) short fyle; { char c; register char *pb; static char buf[512]; pb = buf; while( (c = get_char(fyle)) > 0 ) if( c == '\n' ) { *pb++ = '\n'; break; } else if ( c < 0 ) break; else *pb++ = c; *pb = '\0'; if( c < 0 ) return( pb ); else return( buf ); }