diff -c +new-file term.old/TODO term/TODO
*** term.old/TODO	Tue Dec 29 11:42:16 1992
--- term/TODO	Sat Jan  2 10:11:08 1993
***************
*** 43,45 ****
--- 43,47 ----
  Fix seven bit support.
  
  Integrate checkline/linerem into term.c
+ 
+ Write a tdownload.
Binary files term.old/checksum.o and term/checksum.o differ
Binary files term.old/client.a and term/client.a differ
Binary files term.old/client.o and term/client.o differ
Binary files term.old/compress.o and term/compress.o differ
Binary files term.old/lib.o and term/lib.o differ
Binary files term.old/link.o and term/link.o differ
Binary files term.old/main.o and term/main.o differ
Binary files term.old/meta.o and term/meta.o differ
Binary files term.old/misc.o and term/misc.o differ
Binary files term.old/pty.o and term/pty.o differ
Binary files term.old/redir.o and term/redir.o differ
Binary files term.old/select.o and term/select.o differ
Binary files term.old/serial.o and term/serial.o differ
Binary files term.old/socket.o and term/socket.o differ
Binary files term.old/statistics.o and term/statistics.o differ
Binary files term.old/term and term/term differ
Binary files term.old/term.old and term/term.old differ
Binary files term.old/terminal.o and term/terminal.o differ
Binary files term.old/test and term/test differ
Binary files term.old/tmon and term/tmon differ
Binary files term.old/tmon.o and term/tmon.o differ
Binary files term.old/tredir and term/tredir differ
Binary files term.old/trsh and term/trsh differ
Binary files term.old/trshell.o and term/trshell.o differ
Binary files term.old/tupload and term/tupload differ
Binary files term.old/txconn and term/txconn differ
diff -c +new-file term.old/upload.c term/upload.c
*** term.old/upload.c	Fri Jan  1 15:15:48 1993
--- term/upload.c	Fri Jan  1 18:56:54 1993
***************
*** 95,107 ****
      }
  
  				/* see if the file exists to be resumed */
!     size = -1;
      if ((send_command(s, C_STAT, 0, "%s", remote)) >= 0) {
  				/* Ok. The remote file exists. lets */
  				/* check a few things here.. */
        size = atoi(command_result);
  				/* Now get the local file size. */
-       stat(file, &st);
        if (st.st_size < size) {
  	if (!force) {
  	  printf("\tRemote file %s exists. Won't overwrite.\n",
--- 95,108 ----
      }
  
  				/* see if the file exists to be resumed */
!     size = 0;
!     stat(file, &st);
! 
      if ((send_command(s, C_STAT, 0, "%s", remote)) >= 0) {
  				/* Ok. The remote file exists. lets */
  				/* check a few things here.. */
        size = atoi(command_result);
  				/* Now get the local file size. */
        if (st.st_size < size) {
  	if (!force) {
  	  printf("\tRemote file %s exists. Won't overwrite.\n",
***************
*** 142,147 ****
--- 143,149 ----
        printf("This is too much. Internal error. Aborting.\n");
        abort();
      }
+ 
    retry:
  				/* try to go dumb so we don't gotta */
  				/* escape switch chars. We actually */
***************
*** 155,161 ****
  	      command_result ); 
        continue;
      }
-     
      /* dump the file over the socket */
      while (st.st_size > size) {
        int bit = st.st_size - size;
--- 157,162 ----
***************
*** 170,176 ****
  	  fprintf(stderr, "\tArgh!!! The file truncated while we were");
  	  fprintf(stderr, "uploading it.\n\tWe can't handle this yet,");
  	  fprintf(stderr, " so you will just have to re-try.\n");
! 	  continue;
  	}
        }
        else {
--- 171,177 ----
  	  fprintf(stderr, "\tArgh!!! The file truncated while we were");
  	  fprintf(stderr, "uploading it.\n\tWe can't handle this yet,");
  	  fprintf(stderr, " so you will just have to re-try.\n");
! 	  goto again;
  	}
        }
        else {
***************
*** 180,185 ****
--- 181,187 ----
  	  perror("write");
  	  continue;
  	}			/* end if j < 1 */
+ 	else size += j;
        }				/* end if !inb.size */
      }				/* end while st.size > size */
  
***************
*** 190,195 ****
--- 192,198 ----
        goto retry;
  				/* Now wait untill the file has */
  				/* finished uploading.. */
+     send_command(s, C_STAT, 0, "%s", remote);
      if ((send_command(s, C_STAT, 0, "%s", remote)) >= 0) {
        if (atoi(command_result) != st.st_size) 
  	printf("Remote file is a different size from local after upload!\n");
***************
*** 196,202 ****
      } else {
        printf("Couldn't stat remote file after upload. Please check it.\n");
      }
! 
    }				/* While first < argc */
    close(s);
  }
--- 199,205 ----
      } else {
        printf("Couldn't stat remote file after upload. Please check it.\n");
      }
!   again:
    }				/* While first < argc */
    close(s);
  }
diff -c +new-file term.old/upload.c.old term/upload.c.old
*** term.old/upload.c.old
--- term/upload.c.old	Mon Dec 28 13:28:19 1992
***************
*** 0 ****
--- 1,89 ----
+ 
+ /*
+  * A client for term.
+  */
+ #define I_IOCTL
+ #include "includes.h"
+ 
+ #include "client.h"
+ 
+ int debug = 0;
+ /*---------------------------------------------------------------------------*/
+ void main(int argc, char *argv[]) {
+   int s, i, j, first, size;
+   char *file, *remote;
+   struct Buffer inb = {0, };
+ 				/* Downgrade priority for file transfers. */
+   priority = -2;
+   first = client_options(argc,argv);
+   if ((argc-first) != 2 && (argc-first) != 1) {
+     printf(
+      "Usage: upload [-r] [-c] [-p <num>] <local file> [<remote file>]\n");
+     exit(1);
+   }
+   
+   file = argv[first];
+   if (first == argc-1)
+     remote = file;
+   else remote = argv[first+1];
+ 
+   s = connect_server(term_server);
+   
+   if (strcmp(file, "-")) 
+     i = open(file, O_RDONLY);
+   else i = 0 ; /* stdin */
+ 
+   if ( i < 0) {
+     fprintf(stderr, "Can't open local file %s\n", file);
+     close(s);
+     exit(1);
+   }
+   size = -1;
+   if ((send_command(s, C_STAT, 0, "%s", remote)) >= 0)
+     size = atoi(command_result);
+ 
+   if (send_command(s, size>0?C_OPEN:C_UPLOAD, 0, "%s", remote) < 0) {
+     fprintf(stderr,"FATAL:Couldn't open remote file\n");
+     fprintf(stderr,"Reason given: %s\n", command_result);
+     exit(1);
+   }
+ 
+   if (size > 0) {
+     fprintf(stderr, "Restarting upload from %d.\n", size);
+     if (send_command(s, C_SEEK, 0, "%d", size) < 0) {
+       fprintf(stderr, "FATAL:Couldn't resume upload. Remote seek failed\n");
+       fprintf(stderr, "Reason given: %s\n", command_result);
+       exit(1);
+     }
+     if (lseek(i, size, 0)<0) {
+       fprintf(stderr, "FATAL:Couldn't resume upload. Local seek failed\n");
+       perror("Reason given");
+       exit(1);
+     }
+   }
+ 
+   if (send_command(s, C_DUMB, 1, 0) < 0) {
+     fprintf(stderr, "FATAL:Couldn't turn off command processing.\n");
+     fprintf(stderr, "Reason given: %s\n", command_result);
+     exit(1);
+   }
+ 
+   while (1) {
+     if (!inb.size) {
+       j = read_into_buff(i, &inb);
+       if (j < 1) {
+ 	close(s);
+ 	close(i);
+ 	exit(0);
+       }
+     }
+     else {
+       j = write_from_buff(s, &inb, 0);
+       if (j < 1) {
+ 	fprintf(stderr, "Damned errors. Sorry. file transfer failed\n");
+ 	perror("write");
+ 	exit(1);
+       }
+     }
+   }
+ }
Binary files term.old/upload.o and term/upload.o differ
Binary files term.old/xconn.o and term/xconn.o differ
