Annotation of 43BSD/contrib/mh/sbr/fdcompare.c, revision 1.1

1.1     ! root        1: /* fdcompare.c - are two files identical? */
        !             2: 
        !             3: #include "../h/mh.h"
        !             4: #include <stdio.h>
        !             5: 
        !             6: long lseek();
        !             7: 
        !             8: 
        !             9: fdcompare (fd1, fd2)
        !            10: register int fd1,
        !            11:             fd2;
        !            12: {
        !            13:     register int    i,
        !            14:                    n1,
        !            15:                     n2,
        !            16:                     resp;
        !            17:     register char  *c1,
        !            18:                    *c2;
        !            19:     char    b1[BUFSIZ],
        !            20:             b2[BUFSIZ];
        !            21: 
        !            22:     resp = 1;
        !            23:     while ((n1 = read (fd1, b1, sizeof b1)) >= 0
        !            24:            && (n2 = read (fd2, b2, sizeof b2)) >= 0
        !            25:            && n1 == n2) {
        !            26:        c1 = b1;
        !            27:        c2 = b2;
        !            28:        for (i = n1 < sizeof b1 ? n1 : sizeof b1; i--;)
        !            29:            if (*c1++ != *c2++) {
        !            30:                resp = 0;
        !            31:                goto leave;
        !            32:            }
        !            33:        if (n1 < sizeof b1)
        !            34:            goto leave;
        !            35:     }
        !            36:     resp = 0;
        !            37: 
        !            38: leave: ;
        !            39:     (void) lseek (fd1, 0L, 0);
        !            40:     (void) lseek (fd2, 0L, 0);
        !            41:     return resp;
        !            42: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.