* uip/sendsbr.c: replaced st_mtim with st_mtime, that's what
[mmh] / sbr / fdcompare.c
1
2 /*
3  * fdcompare.c -- are two files identical?
4  *
5  * $Id$
6  *
7  * This code is Copyright (c) 2002, by the authors of nmh.  See the
8  * COPYRIGHT file in the root directory of the nmh distribution for
9  * complete copyright information.
10  */
11
12 #include <h/mh.h>
13
14
15 int
16 fdcompare (int fd1, int fd2)
17 {
18     register int i, n1, n2, resp;
19     register char *c1, *c2;
20     char b1[BUFSIZ], 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     lseek (fd1, (off_t) 0, SEEK_SET);
40     lseek (fd2, (off_t) 0, SEEK_SET);
41     return resp;
42 }