diff --git a/examples/C/grib_precipitation.c b/examples/C/grib_precipitation.c index 7fd94ff57..3d1ce2c93 100644 --- a/examples/C/grib_precipitation.c +++ b/examples/C/grib_precipitation.c @@ -44,14 +44,14 @@ int main(int argc, char** argv) if (argc<2) usage(argv[0]); filename=argv[1]; - in = fopen(filename,"r"); + in = fopen(filename,"rb"); if(!in) { printf("ERROR: unable to open file %s\n",filename); return 1; } /* create new handle from a message in a file*/ - while((h = codes_handle_new_from_file(0,f,&err)) != NULL) { + while((h = codes_handle_new_from_file(0,in,&err)) != NULL) { /* get the size of the values array*/ CODES_CHECK(codes_get_size(h,"values",&values_len),0); diff --git a/tests/bufr_ecc-604.c b/tests/bufr_ecc-604.c index 2ed7ec68f..cfc5951ec 100644 --- a/tests/bufr_ecc-604.c +++ b/tests/bufr_ecc-604.c @@ -27,10 +27,10 @@ static int encode_file(char *template_file, char *output_file) long numSubsets = 0; assert(template_file); - in = fopen(template_file,"r"); assert(in); + in = fopen(template_file,"rb"); assert(in); if (opt_write) { assert(output_file); - out = fopen(output_file,"w"); assert(out); + out = fopen(output_file,"wb"); assert(out); } /* loop over the messages in the source BUFR and clone them */ diff --git a/tests/grib_ccsds_perf.c b/tests/grib_ccsds_perf.c index 23f1f0b71..12e0001b4 100644 --- a/tests/grib_ccsds_perf.c +++ b/tests/grib_ccsds_perf.c @@ -21,7 +21,7 @@ size_t grib_handle_write(grib_handle* h,char* filename) { FILE* of=NULL; const void *buffer; size_t size; - of = fopen(filename,"w"); + of = fopen(filename,"wb"); if(!of) { perror(filename); exit(1); @@ -99,13 +99,13 @@ int main(int argc, char* argv[]) { repeatsimple=atoi(argv[iarg++]); bitsPerValue=atoi(argv[iarg++]); - fin = fopen(finname,"r"); + fin = fopen(finname,"rb"); if(!fin) {perror(finname);exit(1);} if (append) - fout = fopen(ofilename,"a"); + fout = fopen(ofilename,"ab"); else - fout = fopen(ofilename,"w"); + fout = fopen(ofilename,"wb"); if(!fout) {perror(ofilename);exit(1);} diff --git a/tests/grib_ecc-604.c b/tests/grib_ecc-604.c index 136889e98..45dcc8d84 100644 --- a/tests/grib_ecc-604.c +++ b/tests/grib_ecc-604.c @@ -25,9 +25,9 @@ static int encode_file(char *template_file, char *output_file) int err = 0; double *values; - in = fopen(template_file,"r"); assert(in); + in = fopen(template_file,"rb"); assert(in); if (opt_write) { - out = fopen(output_file,"w"); assert(out); + out = fopen(output_file,"wb"); assert(out); } /* loop over the messages in the source GRIB and clone them */ diff --git a/tests/grib_encode_pthreads.c b/tests/grib_encode_pthreads.c index 2de35b24c..8099878dc 100644 --- a/tests/grib_encode_pthreads.c +++ b/tests/grib_encode_pthreads.c @@ -56,8 +56,8 @@ static int encode_file(char *input_file, char *output_file) const void *buffer = NULL; int err = 0; - FILE* in = fopen(input_file,"r"); - FILE* out = fopen(output_file,"w"); + FILE* in = fopen(input_file,"rb"); + FILE* out = fopen(output_file,"wb"); assert(in); assert(out); diff --git a/tests/grib_lam_bf.c b/tests/grib_lam_bf.c index 9ebb2cde5..73c493836 100644 --- a/tests/grib_lam_bf.c +++ b/tests/grib_lam_bf.c @@ -768,7 +768,7 @@ int main (int argc, char *argv[]) size_t size; const void *buffer = NULL; sprintf (f, "lam_bf_%s_%s.grib", grids[igrid], trunc[itrunc].name); - fp = fopen (f, "w"); + fp = fopen (f, "wb"); GRIB_CHECK (grib_get_message (h, &buffer, &size), 0); if (fwrite (buffer, 1, size, fp) != size) { perror (f); @@ -793,7 +793,7 @@ int main (int argc, char *argv[]) sprintf (f, "lam_bf_%s_%s.grib", grids[igrid], trunc[itrunc].name); - fp = fopen (f, "r"); + fp = fopen (f, "rb"); h = grib_handle_new_from_file (0, fp, &err); vals = (double *) malloc (sizeof (double) * trunc[itrunc].len); values_len = trunc[itrunc].len; diff --git a/tests/grib_lam_gp.c b/tests/grib_lam_gp.c index f2b30c2b0..eeb8fd2c6 100644 --- a/tests/grib_lam_gp.c +++ b/tests/grib_lam_gp.c @@ -917,7 +917,7 @@ int main (int argc, char *argv[]) size_t size; const void *buffer = NULL; sprintf (f, "lam_gp_%s.grib", grids[igrid]); - fp = fopen (f, "w"); + fp = fopen (f, "wb"); GRIB_CHECK (grib_get_message (h, &buffer, &size), 0); if (fwrite (buffer, 1, size, fp) != size) { @@ -941,7 +941,7 @@ int main (int argc, char *argv[]) char geometry[128]; sprintf (f, "lam_gp_%s.grib", grids[igrid]); - fp = fopen (f, "r"); + fp = fopen (f, "rb"); h = grib_handle_new_from_file (0, fp, &err); vals = (double *) malloc (sizeof (double) * 4096); values_len = 4096; diff --git a/tests/grib_multi_from_message.c b/tests/grib_multi_from_message.c index 450449c1d..d511e5395 100644 --- a/tests/grib_multi_from_message.c +++ b/tests/grib_multi_from_message.c @@ -49,7 +49,7 @@ int main(int argc,char* argv[]) { else usage(argv[0]); assert(filename); - f=fopen(filename,"r"); + f=fopen(filename,"rb"); if (!f) {perror(filename);exit(1);} fstat(fileno((FILE*)f),&finfo); diff --git a/tests/gribex_perf.c b/tests/gribex_perf.c index 6f8add8cf..ce2125ec8 100644 --- a/tests/gribex_perf.c +++ b/tests/gribex_perf.c @@ -215,7 +215,7 @@ size_t grib_handle_write(grib_handle* h,char* filename) { FILE* of=NULL; const void *buffer; size_t size; - of = fopen(filename,"w"); + of = fopen(filename,"wb"); if(!of) { perror(filename); exit(1); @@ -303,7 +303,7 @@ int main(int argc, char* argv[]) { repeatsimple=atoi(argv[iarg++]); bitsPerValue=atoi(argv[iarg++]); - fin = fopen(finname,"r"); + fin = fopen(finname,"rb"); if(!fin) {perror(finname);exit(1);} c=grib_context_get_default(); @@ -313,9 +313,9 @@ int main(int argc, char* argv[]) { if (append) - fout = fopen(ofilename,"a"); + fout = fopen(ofilename,"ab"); else - fout = fopen(ofilename,"w"); + fout = fopen(ofilename,"wb"); if(!fout) {perror(ofilename);exit(1);} diff --git a/tests/jpeg_perf.c b/tests/jpeg_perf.c index 9c4d9008e..b2fcf038d 100644 --- a/tests/jpeg_perf.c +++ b/tests/jpeg_perf.c @@ -21,7 +21,7 @@ size_t grib_handle_write(grib_handle* h,char* filename) { FILE* of=NULL; const void *buffer; size_t size; - of = fopen(filename,"w"); + of = fopen(filename,"wb"); if(!of) { perror(filename); exit(1); @@ -99,13 +99,13 @@ int main(int argc, char* argv[]) { repeatsimple=atoi(argv[iarg++]); bitsPerValue=atoi(argv[iarg++]); - fin = fopen(finname,"r"); + fin = fopen(finname,"rb"); if(!fin) {perror(finname);exit(1);} if (append) - fout = fopen(ofilename,"a"); + fout = fopen(ofilename,"ab"); else - fout = fopen(ofilename,"w"); + fout = fopen(ofilename,"wb"); if(!fout) {perror(ofilename);exit(1);} diff --git a/tests/laplacian.c b/tests/laplacian.c index 0483fb961..ac47b41b5 100644 --- a/tests/laplacian.c +++ b/tests/laplacian.c @@ -230,7 +230,7 @@ int main(int argc, char* argv[]) { char finname[]="sh.grib"; - fin = fopen(finname,"r"); + fin = fopen(finname,"rb"); if(!fin) {perror(finname);exit(1);} c=grib_context_get_default(); @@ -268,7 +268,7 @@ int main(int argc, char* argv[]) { ksec4,gvalues,nvalues, buf,&gribex_msg_len,"C")); - fout=fopen("out_gribex.grib","w"); + fout=fopen("out_gribex.grib","wb"); if (!fout) {perror("out_gribex.grib");exit(1);} if (fwrite(buf,1,gribex_msg_len,fout)!=gribex_msg_len) { perror("out_gribex.grib"); exit(1); diff --git a/tests/pack_unpack.c b/tests/pack_unpack.c index 5d25d9f1a..f8b353487 100644 --- a/tests/pack_unpack.c +++ b/tests/pack_unpack.c @@ -229,7 +229,7 @@ int main(int argc, char* argv[]) { if (argc != 2) usage(argv[0]); finname=argv[1]; - fin = fopen(finname,"r"); + fin = fopen(finname,"rb"); if(!fin) {perror(finname);exit(1);} c=grib_context_get_default(); diff --git a/tests/packing.c b/tests/packing.c index 6c319fce0..66d0f5824 100644 --- a/tests/packing.c +++ b/tests/packing.c @@ -407,7 +407,7 @@ int main(int argc, char* argv[]) { err_threshold=atof(argv[++argi]); finname=argv[++argi]; - fin = fopen(finname,"r"); + fin = fopen(finname,"rb"); if(!fin) {perror(finname);exit(1);} c=grib_context_get_default(); @@ -483,7 +483,7 @@ int main(int argc, char* argv[]) { /* writing the output grib files if required */ if (write_grib == 1) { if (!foutgribex) { - foutgribex=fopen(foutnamegribex,"w"); + foutgribex=fopen(foutnamegribex,"wb"); if (!foutgribex) { perror(foutnamegribex); exit(1); @@ -502,7 +502,7 @@ int main(int argc, char* argv[]) { if (write_grib == 2) { GRIB_CHECK(grib_get_message(h,&msg,&msg_len),0); if (!foutgrib) { - foutgrib=fopen(foutnamegrib,"w"); + foutgrib=fopen(foutnamegrib,"wb"); if (!foutgrib) { perror(foutnamegrib); exit(1); diff --git a/tests/packing_check.c b/tests/packing_check.c index 1753407a9..64a6e041f 100644 --- a/tests/packing_check.c +++ b/tests/packing_check.c @@ -235,7 +235,7 @@ int main(int argc, char* argv[]) { if (argc != 2 ) usage(argv[0]); finname=argv[1]; - fin = fopen(finname,"r"); + fin = fopen(finname,"rb"); if(!fin) {perror(finname);exit(1);} c=grib_context_get_default(); diff --git a/tests/png_perf.c b/tests/png_perf.c index 4a373eb17..9dd552f34 100644 --- a/tests/png_perf.c +++ b/tests/png_perf.c @@ -21,7 +21,7 @@ size_t grib_handle_write(grib_handle* h,char* filename) { FILE* of=NULL; const void *buffer; size_t size; - of = fopen(filename,"w"); + of = fopen(filename,"wb"); if(!of) { perror(filename); exit(1); @@ -99,13 +99,13 @@ int main(int argc, char* argv[]) { repeatsimple=atoi(argv[iarg++]); bitsPerValue=atoi(argv[iarg++]); - fin = fopen(finname,"r"); + fin = fopen(finname,"rb"); if(!fin) {perror(finname);exit(1);} if (append) - fout = fopen(ofilename,"a"); + fout = fopen(ofilename,"ab"); else - fout = fopen(ofilename,"w"); + fout = fopen(ofilename,"wb"); if(!fout) {perror(ofilename);exit(1);} diff --git a/tests/so_perf.c b/tests/so_perf.c index cf16c991d..1b94815b5 100644 --- a/tests/so_perf.c +++ b/tests/so_perf.c @@ -215,7 +215,7 @@ size_t grib_handle_write(grib_handle* h,char* filename) { FILE* of=NULL; const void *buffer; size_t size; - of = fopen(filename,"w"); + of = fopen(filename,"wb"); if(!of) { perror(filename); exit(1); @@ -312,7 +312,7 @@ int main(int argc, char* argv[]) { repeatsimple=atoi(argv[iarg++]); bitsPerValue=atoi(argv[iarg++]); - fin = fopen(finname,"r"); + fin = fopen(finname,"rb"); if(!fin) {perror(finname);exit(1);} c=grib_context_get_default(); @@ -322,9 +322,9 @@ int main(int argc, char* argv[]) { if (append) - fout = fopen(ofilename,"a"); + fout = fopen(ofilename,"ab"); else - fout = fopen(ofilename,"w"); + fout = fopen(ofilename,"wb"); if(!fout) {perror(ofilename);exit(1);} diff --git a/tests/timing.c b/tests/timing.c index 21e28aee1..3b51633eb 100644 --- a/tests/timing.c +++ b/tests/timing.c @@ -238,7 +238,7 @@ int main(int argc, char* argv[]) { if (argc != 2) usage(argv[0]); finname=argv[1]; - fin = fopen(finname,"r"); + fin = fopen(finname,"rb"); if(!fin) {perror(finname);exit(1);} c=grib_context_get_default(); diff --git a/tests/values_to_ascii.c b/tests/values_to_ascii.c index bd1458676..8ead8e8da 100755 --- a/tests/values_to_ascii.c +++ b/tests/values_to_ascii.c @@ -34,7 +34,7 @@ int main(int argc, char** argv) { if(argc > 1) - in = fopen(argv[1],"r"); + in = fopen(argv[1],"rb"); else{ printf("usage : gribvals filename [format]\n"); exit(1);