Remove RCS keywords, since they no longer work after git migration.
[mmh] / sbr / fdcompare.c
1
2 /*
3  * fdcompare.c -- are two files identical?
4  *
5  * This code is Copyright (c) 2002, by the authors of nmh.  See the
6  * COPYRIGHT file in the root directory of the nmh distribution for
7  * complete copyright information.
8  */
9
10 #include <h/mh.h>
11
12
13 int
14 fdcompare (int fd1, int fd2)
15 {
16     register int i, n1, n2, resp;
17     register char *c1, *c2;
18     char b1[BUFSIZ], b2[BUFSIZ];
19
20     resp = 1;
21     while ((n1 = read (fd1, b1, sizeof(b1))) >= 0
22             && (n2 = read (fd2, b2, sizeof(b2))) >= 0
23             && n1 == n2) {
24         c1 = b1;
25         c2 = b2;
26         for (i = n1 < sizeof(b1) ? n1 : sizeof(b1); i--;)
27             if (*c1++ != *c2++) {
28                 resp = 0;
29                 goto leave;
30             }
31         if (n1 < sizeof(b1))
32             goto leave;
33     }
34     resp = 0;
35
36 leave: ;
37     lseek (fd1, (off_t) 0, SEEK_SET);
38     lseek (fd2, (off_t) 0, SEEK_SET);
39     return resp;
40 }