date and time created 88/12/14 15:30:10 by sklower
[unix-history] / usr / src / usr.bin / tcopy / tcopy.c
index d9dbb0d..7a822a9 100644 (file)
@@ -22,7 +22,7 @@ char copyright[] =
 #endif /* not lint */
 
 #ifndef lint
 #endif /* not lint */
 
 #ifndef lint
-static char sccsid[] = "@(#)tcopy.c    5.9 (Berkeley) %G%";
+static char sccsid[] = "@(#)tcopy.c    5.11 (Berkeley) %G%";
 #endif /* not lint */
 
 #include <stdio.h>
 #endif /* not lint */
 
 #include <stdio.h>
@@ -62,7 +62,7 @@ main(argc, argv)
                case 's':
                        maxblk = atoi(optarg);
                        if (maxblk <= 0) {
                case 's':
                        maxblk = atoi(optarg);
                        if (maxblk <= 0) {
-                               fputs("tcopy: illegal block size\n", stderr);
+                               fprintf(stderr, "tcopy: illegal block size\n");
                                usage();
                        }
                        guesslen = 0;
                                usage();
                        }
                        guesslen = 0;
@@ -198,11 +198,11 @@ r1:               guesslen = 0;
        exit(0);
 }
 
        exit(0);
 }
 
-static
 verify(inp, outp, outb)
        register int inp, outp;
        register char *outb;
 {
 verify(inp, outp, outb)
        register int inp, outp;
        register char *outb;
 {
+       extern int errno;
        register int eot, inmaxblk, inn, outmaxblk, outn;
        register char *inb;
        char *getspace();
        register int eot, inmaxblk, inn, outmaxblk, outn;
        register char *inb;
        char *getspace();
@@ -218,7 +218,7 @@ verify(inp, outp, outb)
                                                goto r1;
                                }
                        perror("tcopy: read error");
                                                goto r1;
                                }
                        perror("tcopy: read error");
-                       exit(1);
+                       break;
                }
 r1:            if ((outn = read(outp, outb, outmaxblk)) == -1) {
                        if (guesslen)
                }
 r1:            if ((outn = read(outp, outb, outmaxblk)) == -1) {
                        if (guesslen)
@@ -228,26 +228,28 @@ r1:               if ((outn = read(outp, outb, outmaxblk)) == -1) {
                                                goto r2;
                                }
                        perror("tcopy: read error");
                                                goto r2;
                                }
                        perror("tcopy: read error");
-                       exit(1);
+                       break;
                }
                }
-r2:            if (inn != outn)
+r2:            if (inn != outn) {
+                       printf("tcopy: tapes have different block sizes; %d != %d.\n", inn, outn);
                        break;
                        break;
+               }
                if (!inn) {
                        if (eot++) {
                if (!inn) {
                        if (eot++) {
-                               puts("tcopy: tapes are identical.");
+                               printf("tcopy: tapes are identical.\n");
                                return;
                        }
                } else {
                                return;
                        }
                } else {
-                       if (bcmp(inb, outb, inn))
+                       if (bcmp(inb, outb, inn)) {
+                               printf("tcopy: tapes have different data.\n");
                                break;
                                break;
+                       }
                        eot = 0;
                }
        }
                        eot = 0;
                }
        }
-       puts("tcopy: tapes are different.");
        exit(1);
 }
 
        exit(1);
 }
 
-static
 intr()
 {
        if (record)
 intr()
 {
        if (record)
@@ -260,20 +262,19 @@ intr()
        exit(1);
 }
 
        exit(1);
 }
 
-static char *
+char *
 getspace(blk)
        int blk;
 {
        char *bp, *malloc();
 
        if ((bp = malloc((u_int)blk)) == NULL) {
 getspace(blk)
        int blk;
 {
        char *bp, *malloc();
 
        if ((bp = malloc((u_int)blk)) == NULL) {
-               fputs("tcopy: no memory\n", stderr);
+               fprintf(stderr, "tcopy: no memory\n");
                exit(11);
        }
        return(bp);
 }
 
                exit(11);
        }
        return(bp);
 }
 
-static
 writeop(fd, type)
        int fd, type;
 {
 writeop(fd, type)
        int fd, type;
 {
@@ -287,9 +288,8 @@ writeop(fd, type)
        }
 }
 
        }
 }
 
-static
 usage()
 {
 usage()
 {
-       fputs("usage: tcopy [-cv] [-s maxblk] src [dest]\n", stderr);
+       fprintf(stderr, "usage: tcopy [-cv] [-s maxblk] src [dest]\n");
        exit(1);
 }
        exit(1);
 }