From a77570cd19f1ed5cee467f591454bc77beacadee Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Mon, 11 Mar 2019 12:53:05 +0000 Subject: [PATCH] C examples: binary open --- examples/C/box.c | 2 +- examples/C/bufr_attributes.c | 2 +- examples/C/bufr_clone.c | 4 ++-- examples/C/bufr_copy_data.c | 2 +- examples/C/bufr_expanded.c | 2 +- examples/C/bufr_get_keys.c | 2 +- examples/C/bufr_get_string_array.c | 2 +- examples/C/bufr_keys_iterator.c | 2 +- examples/C/bufr_missing.c | 3 +-- examples/C/bufr_pthreads.c | 2 +- examples/C/bufr_read_header.c | 2 +- examples/C/bufr_read_scatterometer.c | 2 +- examples/C/bufr_read_synop.c | 2 +- examples/C/bufr_read_temp.c | 2 +- examples/C/bufr_set_keys.c | 4 ++-- examples/C/bufr_subset.c | 2 +- examples/C/get_product_kind.c | 2 +- examples/C/grib_clone.c | 4 ++-- examples/C/grib_copy_message.c | 2 +- examples/C/grib_get_data.c | 2 +- examples/C/grib_get_keys.c | 2 +- examples/C/grib_iterator.c | 2 +- examples/C/grib_iterator_bitmap.c | 2 +- examples/C/grib_keys_iterator.c | 2 +- examples/C/grib_list.c | 2 +- examples/C/grib_multi.c | 2 +- examples/C/grib_multi_write.c | 2 +- examples/C/grib_precision.c | 4 ++-- examples/C/grib_print_data.c | 2 +- examples/C/grib_set_bitmap.c | 4 ++-- examples/C/grib_set_keys.c | 4 ++-- examples/C/grib_set_pv.c | 4 ++-- examples/C/multi2.c | 2 +- examples/C/new_sample.c | 2 +- examples/C/points.c | 2 +- examples/C/sections_copy.c | 4 ++-- examples/C/set_missing.c | 4 ++-- examples/C/values_check.c | 2 +- 38 files changed, 47 insertions(+), 48 deletions(-) diff --git a/examples/C/box.c b/examples/C/box.c index 1c7a02ee9..9b1bf05f3 100644 --- a/examples/C/box.c +++ b/examples/C/box.c @@ -28,7 +28,7 @@ int main(int argc, char* argv[]) west=-10; east=30; - f=fopen(infile,"r"); + f=fopen(infile,"rb"); if (!f) { perror(infile); exit(1); diff --git a/examples/C/bufr_attributes.c b/examples/C/bufr_attributes.c index d387b8f18..b7e86eba0 100644 --- a/examples/C/bufr_attributes.c +++ b/examples/C/bufr_attributes.c @@ -34,7 +34,7 @@ int main(int argc,char* argv[]) int cnt=0; const char* infile = "../../data/bufr/syno_multi.bufr"; - in=fopen(infile,"r"); + in=fopen(infile,"rb"); if (!in) { printf("ERROR: unable to open file %s\n", infile); return 1; diff --git a/examples/C/bufr_clone.c b/examples/C/bufr_clone.c index c5ddc3405..35a1f8c9f 100644 --- a/examples/C/bufr_clone.c +++ b/examples/C/bufr_clone.c @@ -40,8 +40,8 @@ int main(int argc, char *argv[]) return 1; } - in = fopen(argv[1],"r"); - out = fopen(argv[2],"w"); + in = fopen(argv[1],"rb"); + out = fopen(argv[2],"wb"); /* open input and output */ if (!in || !out) { diff --git a/examples/C/bufr_copy_data.c b/examples/C/bufr_copy_data.c index bafa95899..6dc731b8a 100644 --- a/examples/C/bufr_copy_data.c +++ b/examples/C/bufr_copy_data.c @@ -46,7 +46,7 @@ int main(int argc, char *argv[]) outfile=argv[2]; - f = fopen(argv[1],"r"); + f = fopen(argv[1],"rb"); if(!f) { perror(argv[1]); exit(1); diff --git a/examples/C/bufr_expanded.c b/examples/C/bufr_expanded.c index b339d9c25..c494bcced 100644 --- a/examples/C/bufr_expanded.c +++ b/examples/C/bufr_expanded.c @@ -40,7 +40,7 @@ int main(int argc,char* argv[]) filename=argv[1]; /* open bufr file */ - in=fopen(filename,"r"); + in=fopen(filename,"rb"); if (!in) { printf("ERROR: unable to open file %s\n", filename); return 1; diff --git a/examples/C/bufr_get_keys.c b/examples/C/bufr_get_keys.c index f3c844d17..8f2343e03 100644 --- a/examples/C/bufr_get_keys.c +++ b/examples/C/bufr_get_keys.c @@ -34,7 +34,7 @@ int main(int argc,char* argv[]) int cnt=0; const char* infile = "../../data/bufr/syno_multi.bufr"; - in=fopen(infile,"r"); + in=fopen(infile,"rb"); if (!in) { printf("ERROR: unable to open file %s\n", infile); return 1; diff --git a/examples/C/bufr_get_string_array.c b/examples/C/bufr_get_string_array.c index bc3ee165e..458b60447 100644 --- a/examples/C/bufr_get_string_array.c +++ b/examples/C/bufr_get_string_array.c @@ -27,7 +27,7 @@ int main(int argc,char* argv[]) char** strArray = NULL; /* array of strings */ const char* infile = "../../data/bufr/pgps_110.bufr"; - FILE* in = fopen(infile,"r"); + FILE* in = fopen(infile,"rb"); if (!in) { printf("ERROR: unable to open file %s\n", infile); return 1; diff --git a/examples/C/bufr_keys_iterator.c b/examples/C/bufr_keys_iterator.c index 69c6b1494..386dd5a4a 100644 --- a/examples/C/bufr_keys_iterator.c +++ b/examples/C/bufr_keys_iterator.c @@ -44,7 +44,7 @@ int main(int argc,char* argv[]) filename=argv[1]; - in=fopen(filename,"r"); + in=fopen(filename,"rb"); if (!in) { printf("ERROR: unable to open file %s\n", filename); return 1; diff --git a/examples/C/bufr_missing.c b/examples/C/bufr_missing.c index c65f750ab..ed7c5581c 100644 --- a/examples/C/bufr_missing.c +++ b/examples/C/bufr_missing.c @@ -12,7 +12,6 @@ * C Implementation: bufr_missing * * Description: how to handle missing values in BUFR messages. - * */ #include "eccodes.h" @@ -30,7 +29,7 @@ int main(int argc,char* argv[]) int cnt=0; const char* infile = "../../data/bufr/syno_1.bufr"; - in=fopen(infile,"r"); + in=fopen(infile,"rb"); if (!in) { printf("ERROR: unable to open file %s\n", infile); diff --git a/examples/C/bufr_pthreads.c b/examples/C/bufr_pthreads.c index 9a1480b1e..003da02cc 100644 --- a/examples/C/bufr_pthreads.c +++ b/examples/C/bufr_pthreads.c @@ -66,7 +66,7 @@ int main(int argc, char** argv) FILE* fin = 0; codes_handle* h1 = 0; codes_handle* h2 = 0; - fin = fopen("../../data/bufr/syno_multi.bufr", "r"); + fin = fopen("../../data/bufr/syno_multi.bufr", "rb"); assert(fin); err = pthread_create(&thread1, NULL, process_bufr, (void *)fin); diff --git a/examples/C/bufr_read_header.c b/examples/C/bufr_read_header.c index e99ec9cb1..e43a86e60 100644 --- a/examples/C/bufr_read_header.c +++ b/examples/C/bufr_read_header.c @@ -36,7 +36,7 @@ int main(int argc,char* argv[]) filename=argv[1]; - in=fopen(filename,"r"); + in=fopen(filename,"rb"); if (!in) { printf("ERROR: unable to open file %s\n", filename); return 1; diff --git a/examples/C/bufr_read_scatterometer.c b/examples/C/bufr_read_scatterometer.c index 86ef43b44..6bf85c811 100644 --- a/examples/C/bufr_read_scatterometer.c +++ b/examples/C/bufr_read_scatterometer.c @@ -38,7 +38,7 @@ int main(int argc,char* argv[]) const char* infile = "../../data/bufr/asca_139.bufr"; char key_name[128]; - in=fopen(infile,"r"); + in=fopen(infile,"rb"); if (!in) { printf("ERROR: unable to open file %s\n", infile); return 1; diff --git a/examples/C/bufr_read_synop.c b/examples/C/bufr_read_synop.c index c54cebe4a..9ee8a3be1 100644 --- a/examples/C/bufr_read_synop.c +++ b/examples/C/bufr_read_synop.c @@ -37,7 +37,7 @@ int main(int argc,char* argv[]) int cnt=0; const char* infile = "../../data/bufr/syno_multi.bufr"; - in=fopen(infile,"r"); + in=fopen(infile,"rb"); if (!in) { printf("ERROR: unable to open file %s\n", infile); return 1; diff --git a/examples/C/bufr_read_temp.c b/examples/C/bufr_read_temp.c index b26aa022e..9ba53f872 100644 --- a/examples/C/bufr_read_temp.c +++ b/examples/C/bufr_read_temp.c @@ -38,7 +38,7 @@ int main(int argc,char* argv[]) const char* infile = "../../data/bufr/temp_101.bufr"; char key_name[128]; - in=fopen(infile,"r"); + in=fopen(infile,"rb"); if (!in) { printf("ERROR: unable to open file %s\n", infile); return 1; diff --git a/examples/C/bufr_set_keys.c b/examples/C/bufr_set_keys.c index dd9591b96..e3a55d4fd 100644 --- a/examples/C/bufr_set_keys.c +++ b/examples/C/bufr_set_keys.c @@ -43,8 +43,8 @@ int main(int argc,char* argv[]) return 1; } - in = fopen(infile,"r"); - out = fopen(argv[1],"w"); + in = fopen(infile,"rb"); + out = fopen(argv[1],"wb"); if (!in || !out) { perror("ERROR: unable to open files"); diff --git a/examples/C/bufr_subset.c b/examples/C/bufr_subset.c index 454b2e00e..0db2f7e6e 100644 --- a/examples/C/bufr_subset.c +++ b/examples/C/bufr_subset.c @@ -35,7 +35,7 @@ int main(int argc,char* argv[]) int cnt=0; const char* infile = "../../data/bufr/synop_multi_subset.bufr"; - in=fopen(infile,"r"); + in=fopen(infile,"rb"); if (!in) { printf("ERROR: unable to open file %s\n", infile); return 1; diff --git a/examples/C/get_product_kind.c b/examples/C/get_product_kind.c index 7d95d8d77..a69af27c2 100644 --- a/examples/C/get_product_kind.c +++ b/examples/C/get_product_kind.c @@ -34,7 +34,7 @@ int main(int argc,char* argv[]) return 1; } infile = argv[1]; - in=fopen(infile,"r"); + in=fopen(infile,"rb"); if (!in) { printf("ERROR: unable to open file %s\n", infile); return 1; diff --git a/examples/C/grib_clone.c b/examples/C/grib_clone.c index 2d38cac98..c11d7e2a7 100644 --- a/examples/C/grib_clone.c +++ b/examples/C/grib_clone.c @@ -37,8 +37,8 @@ int main(int argc, char *argv[]) return 1; } - in = fopen(argv[1],"r"); - out = fopen(argv[2],"w"); + in = fopen(argv[1],"rb"); + out = fopen(argv[2],"wb"); if (!in || !out) { perror("ERROR: unable to open files"); diff --git a/examples/C/grib_copy_message.c b/examples/C/grib_copy_message.c index 39488f10c..c85dff594 100644 --- a/examples/C/grib_copy_message.c +++ b/examples/C/grib_copy_message.c @@ -34,7 +34,7 @@ int main(int argc, char *argv[]) return 1; } - in = fopen(argv[1],"r"); + in = fopen(argv[1],"rb"); if (!in) { perror("ERROR: unable to input file"); diff --git a/examples/C/grib_get_data.c b/examples/C/grib_get_data.c index 93880ac97..d26cd0088 100644 --- a/examples/C/grib_get_data.c +++ b/examples/C/grib_get_data.c @@ -30,7 +30,7 @@ int main (int argc, char **argv) const double missing = 9999.0; double *lats, *lons, *values; /* arrays */ - in = fopen (filename, "r"); + in = fopen(filename, "rb"); if (!in) { printf ("ERROR: unable to open input file %s\n", filename); return 1; diff --git a/examples/C/grib_get_keys.c b/examples/C/grib_get_keys.c index ce0f4054c..c0a391eff 100644 --- a/examples/C/grib_get_keys.c +++ b/examples/C/grib_get_keys.c @@ -44,7 +44,7 @@ int main(int argc, char** argv) const char* filename = "../../data/regular_latlon_surface.grib1"; codes_handle *h = NULL; - in = fopen(filename,"r"); + in = fopen(filename,"rb"); if(!in) { printf("ERROR: unable to open file %s\n",filename); return 1; diff --git a/examples/C/grib_iterator.c b/examples/C/grib_iterator.c index 4289a33db..294a8b370 100644 --- a/examples/C/grib_iterator.c +++ b/examples/C/grib_iterator.c @@ -44,7 +44,7 @@ int main(int argc, char** argv) filename=argv[1]; - in = fopen(filename,"r"); + in = fopen(filename,"rb"); if(!in) { printf("ERROR: unable to open file %s\n", filename); return 1; diff --git a/examples/C/grib_iterator_bitmap.c b/examples/C/grib_iterator_bitmap.c index e96a1fea6..801b441a0 100644 --- a/examples/C/grib_iterator_bitmap.c +++ b/examples/C/grib_iterator_bitmap.c @@ -42,7 +42,7 @@ 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) { fprintf(stderr, "ERROR: unable to open file %s\n",filename); return 1; diff --git a/examples/C/grib_keys_iterator.c b/examples/C/grib_keys_iterator.c index 0ef3a60f0..0446d22ff 100644 --- a/examples/C/grib_keys_iterator.c +++ b/examples/C/grib_keys_iterator.c @@ -59,7 +59,7 @@ int main(int argc, char *argv[]) if (argc != 2) usage(argv[0]); - f = fopen(argv[1],"r"); + f = fopen(argv[1],"rb"); if(!f) { perror(argv[1]); exit(1); diff --git a/examples/C/grib_list.c b/examples/C/grib_list.c index fae19b7c5..04fd8da76 100644 --- a/examples/C/grib_list.c +++ b/examples/C/grib_list.c @@ -36,7 +36,7 @@ int main(int argc, char** argv) const char* filename = "../../data/satellite.grib"; codes_handle *h = NULL; - in = fopen(filename,"r"); + in = fopen(filename,"rb"); if(!in) { printf("ERROR: unable to open input file %s\n",filename); return 1; diff --git a/examples/C/grib_multi.c b/examples/C/grib_multi.c index fc6a6c404..8a0cbba10 100644 --- a/examples/C/grib_multi.c +++ b/examples/C/grib_multi.c @@ -36,7 +36,7 @@ int main(int argc, char** argv) /* turn off support for multi fields messages */ /* codes_multi_support_off(0); */ - in = fopen(filename,"r"); + in = fopen(filename,"rb"); if(!in) { printf("ERROR: unable to open file %s\n",filename); return 1; diff --git a/examples/C/grib_multi_write.c b/examples/C/grib_multi_write.c index 5fed7c938..e7a45ffef 100644 --- a/examples/C/grib_multi_write.c +++ b/examples/C/grib_multi_write.c @@ -41,7 +41,7 @@ int main(int argc, char** argv) ofilename=argv[2]; /* open input file */ - in = fopen(filename,"r"); + in = fopen(filename,"rb"); if(!in) { fprintf(stderr, "ERROR: unable to open input file %s\n",filename); return 1; diff --git a/examples/C/grib_precision.c b/examples/C/grib_precision.c index 2f535900c..3bb99a022 100644 --- a/examples/C/grib_precision.c +++ b/examples/C/grib_precision.c @@ -45,13 +45,13 @@ int main(int argc, char** argv) long bitsPerValue1=0, bitsPerValue2=0; int i=0; - in = fopen(infile,"r"); + in = fopen(infile,"rb"); if(!in) { printf("ERROR: unable to open input file %s\n",infile); return 1; } - out = fopen(outfile,"w"); + out = fopen(outfile,"wb"); if(!out) { printf("ERROR: unable to open output file %s\n",outfile); fclose(in); diff --git a/examples/C/grib_print_data.c b/examples/C/grib_print_data.c index 61087cc9c..7f98a63d6 100644 --- a/examples/C/grib_print_data.c +++ b/examples/C/grib_print_data.c @@ -38,7 +38,7 @@ 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; diff --git a/examples/C/grib_set_bitmap.c b/examples/C/grib_set_bitmap.c index 6e6f7f65a..78939e693 100644 --- a/examples/C/grib_set_bitmap.c +++ b/examples/C/grib_set_bitmap.c @@ -37,13 +37,13 @@ int main(int argc, char** argv) double missing=9999; int i=0; - in = fopen(infile, "r"); + in = fopen(infile, "rb"); if(!in) { printf("ERROR: unable to open input file %s\n",infile); return 1; } - out = fopen(outfile, "w"); + out = fopen(outfile, "wb"); if(!out) { printf("ERROR: unable to open output file %s\n",outfile); fclose(in); diff --git a/examples/C/grib_set_keys.c b/examples/C/grib_set_keys.c index bfca44f85..6b155064b 100644 --- a/examples/C/grib_set_keys.c +++ b/examples/C/grib_set_keys.c @@ -36,13 +36,13 @@ int main(int argc, char** argv) const void* buffer = NULL; size_t str_len = 0; /* See the call to codes_set_string later */ - in = fopen(infile,"r"); + in = fopen(infile,"rb"); if(!in) { printf("ERROR: unable to open file %s\n",infile); return 1; } - out = fopen(outfile,"w"); + out = fopen(outfile,"wb"); if(!out) { printf("ERROR: unable to open file %s\n",outfile); fclose(in); diff --git a/examples/C/grib_set_pv.c b/examples/C/grib_set_pv.c index f1c14b7df..4848c0e6c 100644 --- a/examples/C/grib_set_pv.c +++ b/examples/C/grib_set_pv.c @@ -43,13 +43,13 @@ int main(int argc, char** argv) infile = argv[1]; outfile= argv[2]; - in = fopen(infile, "r"); + in = fopen(infile, "rb"); if(!in) { fprintf(stderr, "ERROR: unable to open input file %s\n",infile); return 1; } - out = fopen(outfile, "w"); + out = fopen(outfile, "wb"); if(!out) { fprintf(stderr, "ERROR: unable to open output file %s\n",outfile); fclose(in); diff --git a/examples/C/multi2.c b/examples/C/multi2.c index 7b2449f74..3b59ede12 100644 --- a/examples/C/multi2.c +++ b/examples/C/multi2.c @@ -32,7 +32,7 @@ static void read_data(int num_msgs) long stepRange = 0; codes_handle *h = NULL; - fp = fopen(file_path, "r"); + fp = fopen(file_path, "rb"); if(!fp) { fprintf(stderr, "ERROR: unable to open grib file %s\n", file_path); exit(1); diff --git a/examples/C/new_sample.c b/examples/C/new_sample.c index cb12ea6d1..7f641d5ca 100644 --- a/examples/C/new_sample.c +++ b/examples/C/new_sample.c @@ -369,7 +369,7 @@ int main(int argc, char** argv) CODES_CHECK(codes_set_long(h,"setBitsPerValue",0),0); /* Save the message */ - f = fopen(argv[1],"w"); + f = fopen(argv[1],"wb"); if(!f) { perror(argv[1]); exit(1); diff --git a/examples/C/points.c b/examples/C/points.c index e1deccbac..58f8f50fa 100644 --- a/examples/C/points.c +++ b/examples/C/points.c @@ -84,7 +84,7 @@ int main(int argc, char** argv) fclose(fin); fname=argv[2]; - fin=fopen(fname,"r"); + fin=fopen(fname,"rb"); if(!fin) { perror(fname); exit(1); } h=codes_handle_new_from_file(0,fin,PRODUCT_GRIB, &ret); if (!h || ret!=CODES_SUCCESS) {printf(" unable to create handle\n");exit(1);} diff --git a/examples/C/sections_copy.c b/examples/C/sections_copy.c index 701b0bb58..55ad776b3 100644 --- a/examples/C/sections_copy.c +++ b/examples/C/sections_copy.c @@ -33,7 +33,7 @@ int main ( int argc, char* argv[]) what_str=argv[3]; out_name=argv[4]; - in=fopen(in_name1,"r"); + in=fopen(in_name1,"rb"); if (!in) { perror(in_name1); exit(1); @@ -43,7 +43,7 @@ int main ( int argc, char* argv[]) CODES_CHECK(err,0); fclose(in); - in=fopen(in_name2,"r"); + in=fopen(in_name2,"rb"); if (!in) { perror(in_name2); exit(1); diff --git a/examples/C/set_missing.c b/examples/C/set_missing.c index 047a8fefc..e8783b24a 100644 --- a/examples/C/set_missing.c +++ b/examples/C/set_missing.c @@ -34,13 +34,13 @@ int main(int argc, char** argv) size_t str_len=3; long Ni = 0; - in = fopen(infile,"r"); + in = fopen(infile,"rb"); if(!in) { printf("ERROR: unable to open input file %s\n",infile); return 1; } - out = fopen(outfile,"w"); + out = fopen(outfile,"wb"); if(!out) { printf("ERROR: unable to open output file %s\n",outfile); fclose(in); diff --git a/examples/C/values_check.c b/examples/C/values_check.c index e68d3d5eb..cba687aac 100644 --- a/examples/C/values_check.c +++ b/examples/C/values_check.c @@ -21,7 +21,7 @@ int main(int argc, char* argv[]) int i; char* name = NULL; - f=fopen(infile,"r"); + f=fopen(infile,"rb"); if (!f) { perror(infile); exit(1);