3 /* Copyright (C) 2002 Brad Jorsch <anomie@users.sourceforge.net>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 #include "wmweather+.h"
27 int diff(char *file1
, char *file2
){
33 char *s1
=(char *)bigbuf
, *s2
=(char *)(bigbuf
+len
);
35 if((fp1
=fopen(file1
, "r"))==NULL
) return -1;
36 if((fp2
=fopen(file2
, "r"))==NULL
){ fclose(fp1
); return -1; }
37 if(fstat(fileno(fp1
), &statbuf
)<0 || !S_ISREG(statbuf
.st_mode
)){
43 if(fstat(fileno(fp2
), &statbuf
)<0 || !S_ISREG(statbuf
.st_mode
)){
49 if(len1
!=len2
){ fclose(fp1
); fclose(fp2
); return 1; }
50 if(len1
==0){ fclose(fp1
); fclose(fp2
); return 0; }
51 while(!feof(fp1
) && !feof(fp2
)){
52 len1
=fread(s1
, sizeof(char), len
, fp1
);
53 len2
=fread(s2
, sizeof(char), len
, fp2
);
54 if(len1
!=len2
|| memcmp(s1
, s2
, len1
)){
55 fclose(fp1
); fclose(fp2
); return 1;
58 ret
=(!feof(fp1
) || !feof(fp2
));