mirror of https://github.com/ecmwf/eccodes.git
Use fopen in binary mode (Windows support)
This commit is contained in:
parent
5bac99bc73
commit
974999976e
|
@ -90,7 +90,7 @@ int main(int argc, char** argv)
|
|||
/* Encode the keys back in the data section */
|
||||
CODES_CHECK(codes_set_long(h, "pack", 1), 0);
|
||||
|
||||
fout = fopen(outfilename, "w");
|
||||
fout = fopen(outfilename, "wb");
|
||||
if (!fout) {
|
||||
fprintf(stderr, "Failed to open (create) output file.\n");
|
||||
return 1;
|
||||
|
|
|
@ -29,7 +29,7 @@ int main(int argc,char* argv[])
|
|||
const char* key_name = "#5#brightnessTemperature";
|
||||
const double tolerance = 1e-6;
|
||||
|
||||
in=fopen(infile,"r");
|
||||
in=fopen(infile,"rb");
|
||||
assert(in);
|
||||
|
||||
while ((h = codes_handle_new_from_file(NULL, in, PRODUCT_BUFR, &err)) != NULL || err != CODES_SUCCESS)
|
||||
|
|
|
@ -46,7 +46,7 @@ int main(int argc,char* argv[])
|
|||
}
|
||||
|
||||
assert(input_filename);
|
||||
f = fopen(input_filename, "r");
|
||||
f = fopen(input_filename, "rb");
|
||||
assert(f);
|
||||
h = codes_handle_new_from_file(NULL, f, PRODUCT_BUFR, &err);
|
||||
assert(h);
|
||||
|
|
|
@ -38,13 +38,13 @@ int main(int argc, char* argv[]) {
|
|||
infile1=argv[1];
|
||||
infile2=argv[2];
|
||||
|
||||
f1=fopen(infile1,"r");
|
||||
f1=fopen(infile1,"rb");
|
||||
if (!f1) {
|
||||
perror(infile1);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
f2=fopen(infile2,"r");
|
||||
f2=fopen(infile2,"rb");
|
||||
if (!f2) {
|
||||
perror(infile2);
|
||||
exit(1);
|
||||
|
|
|
@ -36,7 +36,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;
|
||||
|
|
|
@ -36,13 +36,13 @@ int main(int argc, char** argv)
|
|||
|
||||
if (argc<2) usage(argv[0]);
|
||||
|
||||
in = fopen(argv[1],"r");
|
||||
in = fopen(argv[1],"rb");
|
||||
if(!in) {
|
||||
printf("ERROR: unable to open file %s\n",argv[1]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* create new handle from a message in a file*/
|
||||
/* create new handle */
|
||||
err = 0;
|
||||
h = grib_handle_new_from_file(0,in,&err);
|
||||
if (h == NULL) {
|
||||
|
|
|
@ -51,7 +51,7 @@ static void test_reduced_gg(int remove_local_def, int edition, const char* packi
|
|||
grib_util_packing_spec packing_spec={0,};
|
||||
|
||||
assert(input_filename);
|
||||
in = fopen(input_filename,"r"); assert(in);
|
||||
in = fopen(input_filename,"rb"); assert(in);
|
||||
handle = grib_handle_new_from_file(0,in,&err); assert(handle);
|
||||
|
||||
CODES_CHECK(grib_get_string(handle, "gridType", gridType, &slen),0);
|
||||
|
@ -60,7 +60,7 @@ static void test_reduced_gg(int remove_local_def, int edition, const char* packi
|
|||
return;
|
||||
}
|
||||
assert(output_filename);
|
||||
out = fopen(output_filename,"w"); assert(out);
|
||||
out = fopen(output_filename,"wb"); assert(out);
|
||||
|
||||
CODES_CHECK(grib_get_size(handle,"values",&inlen), 0);
|
||||
values = (double*)malloc(sizeof(double)*inlen);
|
||||
|
@ -155,7 +155,7 @@ static void test_regular_ll(int remove_local_def, int edition, const char* packi
|
|||
grib_util_packing_spec packing_spec={0,};
|
||||
|
||||
assert(input_filename);
|
||||
in = fopen(input_filename,"r"); assert(in);
|
||||
in = fopen(input_filename,"rb"); assert(in);
|
||||
handle = codes_handle_new_from_file(0, in, PRODUCT_GRIB, &err); assert(handle);
|
||||
|
||||
CODES_CHECK(codes_get_long(handle, "edition", &input_edition), 0);
|
||||
|
@ -166,7 +166,7 @@ static void test_regular_ll(int remove_local_def, int edition, const char* packi
|
|||
return;
|
||||
}
|
||||
assert(output_filename);
|
||||
out = fopen(output_filename,"w"); assert(out);
|
||||
out = fopen(output_filename,"wb"); assert(out);
|
||||
|
||||
CODES_CHECK(codes_get_size(handle,"values",&inlen), 0);
|
||||
values = (double*)malloc(sizeof(double)*inlen);
|
||||
|
@ -255,7 +255,7 @@ static void test_grid_complex_spatial_differencing(int remove_local_def, int edi
|
|||
grib_util_grid_spec spec={0,};
|
||||
grib_util_packing_spec packing_spec={0,};
|
||||
|
||||
in = fopen(input_filename,"r"); assert(in);
|
||||
in = fopen(input_filename,"rb"); assert(in);
|
||||
handle = codes_handle_new_from_file(0, in, PRODUCT_GRIB, &err); assert(handle);
|
||||
|
||||
CODES_CHECK(grib_get_string(handle, "packingType", gridType, &slen),0);
|
||||
|
@ -263,7 +263,7 @@ static void test_grid_complex_spatial_differencing(int remove_local_def, int edi
|
|||
grib_handle_delete(handle);
|
||||
return;
|
||||
}
|
||||
out = fopen(output_filename,"w"); assert(out);
|
||||
out = fopen(output_filename,"wb"); assert(out);
|
||||
|
||||
CODES_CHECK(codes_get_size(handle,"values",&inlen), 0);
|
||||
values = (double*)malloc(sizeof(double)*inlen);
|
||||
|
|
|
@ -9,15 +9,16 @@
|
|||
*/
|
||||
#include "grib_api_internal.h"
|
||||
|
||||
static void usage(const char* prog) {
|
||||
static void usage (const char *prog)
|
||||
{
|
||||
printf ("usage: %s infile\n", prog);
|
||||
exit (1);
|
||||
}
|
||||
|
||||
static unsigned char buffer[50000000];
|
||||
|
||||
int main(int argc,char* argv[]) {
|
||||
|
||||
int main (int argc, char *argv[])
|
||||
{
|
||||
char *filename;
|
||||
FILE *f;
|
||||
grib_handle *h = NULL;
|
||||
|
@ -33,10 +34,11 @@ int main(int argc,char* argv[]) {
|
|||
size_t shortNamelen = sizeof (shortName);
|
||||
size_t len;
|
||||
|
||||
if (argc!=2) usage(argv[0]);
|
||||
if (argc != 2)
|
||||
usage (argv[0]);
|
||||
filename = argv[1];
|
||||
|
||||
f=fopen(filename,"r");
|
||||
f = fopen (filename, "rb");
|
||||
if (!f) {
|
||||
perror (filename);
|
||||
exit (1);
|
||||
|
@ -51,7 +53,8 @@ int main(int argc,char* argv[]) {
|
|||
if (!h) {
|
||||
printf ("unable to new from message\n");
|
||||
exit (1);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
grib_get_long (h, "edition", &edition);
|
||||
grib_get_long (h, "step", &step);
|
||||
grib_get_long (h, "totalLength", &totalLength);
|
||||
|
@ -67,7 +70,8 @@ int main(int argc,char* argv[]) {
|
|||
count, edition, (long) size, totalLength, shortName, gridType, levelType, level, step);
|
||||
grib_handle_delete (h);
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
printf ("MESSAGE #%ld\n", count);
|
||||
}
|
||||
size = bufsize;
|
||||
|
@ -75,5 +79,4 @@ int main(int argc,char* argv[]) {
|
|||
}
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue