]> diplodocus.org Git - nmh/blob - docs/historical/mh-6.8.5/sbr/RCS/fdcompare.c,v
sbr/mts.c: Delete mmdlm2; use same-valued mmdlm1 instead.
[nmh] / docs / historical / mh-6.8.5 / sbr / RCS / fdcompare.c,v
1 head 1.4;
2 access;
3 symbols;
4 locks; strict;
5 comment @ * @;
6
7
8 1.4
9 date 93.08.25.18.29.28; author jromine; state Exp;
10 branches;
11 next 1.3;
12
13 1.3
14 date 93.08.25.17.43.26; author jromine; state Exp;
15 branches;
16 next 1.2;
17
18 1.2
19 date 93.08.25.17.19.34; author jromine; state Exp;
20 branches;
21 next 1.1;
22
23 1.1
24 date 93.08.25.17.19.21; author jromine; state Exp;
25 branches;
26 next ;
27
28
29 desc
30 @@
31
32
33 1.4
34 log
35 @need sys/types.h
36 @
37 text
38 @/* fdcompare.c - are two files identical? */
39 #ifndef lint
40 static char Id[] = "@@(#)$Id: fdcompare.c,v 1.3 1993/08/25 17:43:26 jromine Exp jromine $";
41 #endif
42
43 #include "../h/mh.h"
44 #include <stdio.h>
45 #include <sys/types.h> /* for off_t */
46
47 off_t lseek();
48
49
50 fdcompare (fd1, fd2)
51 register int fd1,
52 fd2;
53 {
54 register int i,
55 n1,
56 n2,
57 resp;
58 register char *c1,
59 *c2;
60 char b1[BUFSIZ],
61 b2[BUFSIZ];
62
63 resp = 1;
64 while ((n1 = read (fd1, b1, sizeof b1)) >= 0
65 && (n2 = read (fd2, b2, sizeof b2)) >= 0
66 && n1 == n2) {
67 c1 = b1;
68 c2 = b2;
69 for (i = n1 < sizeof b1 ? n1 : sizeof b1; i--;)
70 if (*c1++ != *c2++) {
71 resp = 0;
72 goto leave;
73 }
74 if (n1 < sizeof b1)
75 goto leave;
76 }
77 resp = 0;
78
79 leave: ;
80 (void) lseek (fd1, (off_t)0, 0);
81 (void) lseek (fd2, (off_t)0, 0);
82 return resp;
83 }
84 @
85
86
87 1.3
88 log
89 @add id
90 @
91 text
92 @d3 1
93 a3 1
94 static char Id[] = "@@(#)$Id:$";
95 d8 1
96 @
97
98
99 1.2
100 log
101 @off_t fixes for BSD44
102 @
103 text
104 @d2 3
105 @
106
107
108 1.1
109 log
110 @Initial revision
111 @
112 text
113 @d6 1
114 a6 1
115 long lseek();
116 d39 2
117 a40 2
118 (void) lseek (fd1, 0L, 0);
119 (void) lseek (fd2, 0L, 0);
120 @