static void compare_files(const char* file1,const char* file2, blacklist* bl) { FILE *f1 = fopen(file1,"r"); FILE *f2 = fopen(file2,"r"); int e1 = 0; int e2 = 0; grib_handle *h1; grib_handle *h2; int count = 0; int err = 0; grib_context* c=grib_context_get_default( ); grib_multi_support_off(c); if(!f1) { perror(file1); exit(1); } if(!f2) { perror(file2); exit(1); } h1 = grib_handle_new_from_file(c,f1,&e1); h2 = grib_handle_new_from_file(c,f2,&e2); while(h1 && h2) { ++count; printf("..............................\n"); if(compare_handles(h1,h2,bl)) err++; printf("..............................\n"); if(compare_handles(h2,h1,bl)) err++; grib_handle_delete(h1); grib_handle_delete(h2); e1 = e2 = 0; h1 = grib_handle_new_from_file(c,f1,&e1); h2 = grib_handle_new_from_file(c,f2,&e2); } GRIB_CHECK(e1,file1); GRIB_CHECK(e2,file2); if(h1 != h2) { fprintf(stderr,"%s: Premature eof on %s\n",prog,h1 == 0 ? file1 : file2); exit(1); } if(err) exit(1); }
static void compare_files(const char* file1,const char* file2,FILE* out) { FILE *f1 = fopen(file1,"r"); FILE *f2 = fopen(file2,"r"); int e1 = 0; int e2 = 0; grib_handle *h1; grib_handle *h2; const void* b1; const void* b2; size_t s1; size_t s2; int count = 0; if(!f1) { perror(file1); exit(1); } if(!f2) { perror(file2); exit(1); } h1 = grib_handle_new_from_file(NULL,f1,&e1); h2 = grib_handle_new_from_file(NULL,f2,&e2); while(h1 && h2) { ++count; GRIB_CHECK(grib_get_message(h1,&b1,&s1),file1); GRIB_CHECK(grib_get_message(h2,&b2,&s2),file2); compare_handles(count,h1,h2,out); grib_handle_delete(h1); grib_handle_delete(h2); e1 = e2 = 0; h1 = grib_handle_new_from_file(NULL,f1,&e1); h2 = grib_handle_new_from_file(NULL,f2,&e2); } GRIB_CHECK(e1,file1); GRIB_CHECK(e2,file2); if(h1 != h2) { fprintf(stderr,"%s: Premature eof on %s\n",prog,h1 == 0 ? file1 : file2); exit(1); } }
inline bool operator!=(const basic_pipe<Char, Traits> & lhs, const basic_pipe<Char, Traits> & rhs) { return !compare_handles(lhs.native_source(), rhs.native_source()) || !compare_handles(lhs.native_sink(), rhs.native_sink()); }