home *** CD-ROM | disk | FTP | other *** search
/ minnie.tuhs.org / unixen.tar / unixen / PDP-11 / Tools / Serial / uue.shar / uue.c < prev   
Encoding:
C/C++ Source or Header  |  1998-03-18  |  834 b   |  37 lines

  1. #include <stdio.h>
  2. #include <sys/types.h>
  3. #include <sys/stat.h>
  4.  
  5.  
  6. main(int argc, char *argv[])
  7. {
  8.   struct stat st;
  9.   int a, b, c, size;
  10.   FILE *in;
  11.   
  12.   if (argc!=2) { fprintf(stderr, "Usage: uue filename\n"); exit(1); }
  13.  
  14.   in=fopen(argv[1], "r");
  15.   if (in==NULL) { fprintf(stderr, "Can't open %s\n",argv[1]); exit(1); }
  16.   if (stat(argv[1], &st)==-1)
  17.         { fprintf(stderr, "Can't stat %s\n",argv[1]); exit(1); }
  18.  
  19.     /* Send command to start up remote decoder */
  20.   printf("stty cbreak -echo\n./uud > %s\n", argv[1]);
  21.  
  22.     /* Send size, as short */
  23.   size= st.st_size; printf("%d\n",  size);
  24.  
  25.   while (size) {
  26.     c= fgetc(in);
  27.  
  28.     /* Send c as two printable ASCII characters */
  29.      a= ((c & 0xff) >> 4) | '@';
  30.      b= (c & 0x0f) | '@';
  31.     putchar(a); putchar(b); size--;
  32.   }
  33.  
  34.     /* Send command to restore terminal */
  35.   printf("stty -cbreak echo\n");
  36. }
  37.