Revision 12455,
693 bytes
checked in by danw, 26 years ago
(diff) |
This commit was generated by cvs2svn to compensate for changes in r12454,
which included commits to RCS files with non-trunk default branches.
|
Line | |
---|
1 | |
---|
2 | /* |
---|
3 | * fdcompare.c -- are two files identical? |
---|
4 | * |
---|
5 | * $Id: fdcompare.c,v 1.1.1.1 1999-02-07 18:14:08 danw Exp $ |
---|
6 | */ |
---|
7 | |
---|
8 | #include <h/mh.h> |
---|
9 | |
---|
10 | |
---|
11 | int |
---|
12 | fdcompare (int fd1, int fd2) |
---|
13 | { |
---|
14 | register int i, n1, n2, resp; |
---|
15 | register char *c1, *c2; |
---|
16 | char b1[BUFSIZ], b2[BUFSIZ]; |
---|
17 | |
---|
18 | resp = 1; |
---|
19 | while ((n1 = read (fd1, b1, sizeof(b1))) >= 0 |
---|
20 | && (n2 = read (fd2, b2, sizeof(b2))) >= 0 |
---|
21 | && n1 == n2) { |
---|
22 | c1 = b1; |
---|
23 | c2 = b2; |
---|
24 | for (i = n1 < sizeof(b1) ? n1 : sizeof(b1); i--;) |
---|
25 | if (*c1++ != *c2++) { |
---|
26 | resp = 0; |
---|
27 | goto leave; |
---|
28 | } |
---|
29 | if (n1 < sizeof(b1)) |
---|
30 | goto leave; |
---|
31 | } |
---|
32 | resp = 0; |
---|
33 | |
---|
34 | leave: ; |
---|
35 | lseek (fd1, (off_t) 0, SEEK_SET); |
---|
36 | lseek (fd2, (off_t) 0, SEEK_SET); |
---|
37 | return resp; |
---|
38 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.