]> diplodocus.org Git - nmh/blob - docs/historical/mh-jun-1982/subs/fdcompare.c
Create new mh-format function %(ordinal)
[nmh] / docs / historical / mh-jun-1982 / subs / fdcompare.c
1 #ifdef COMMENT
2 Proprietary Rand Corporation, 1981.
3 Further distribution of this software
4 subject to the terms of the Rand
5 license agreement.
6 #endif
7
8 #include "../mh.h"
9 long lseek();
10
11 fdcompare(fd1, fd2)
12 {
13 int n1, n2, resp;
14 register int i;
15 register char *c1, *c2;
16 char b1[512], b2[512];
17
18 resp = 1;
19 while((n1 = read(fd1, b1, 512)) >= 0 &&
20 (n2 = read(fd2, b2, 512)) >= 0 &&
21 n1 == n2) {
22
23 c1 = b1; c2 = b2;
24 for(i = n1 < 512? n1 : 512; i--; )
25 if(*c1++ != *c2++) {
26 resp = 0;
27 goto leave;
28 }
29 if(n1 < 512)
30 goto leave;
31 }
32 resp = 0;
33 leave:
34 VOID lseek(fd1, 0l, 0);
35 VOID lseek(fd2, 0l, 0);
36 return(resp);
37 }