]> Pileus Git - ~andy/rsl/commitdiff
Open files in binary mode for Win32
authorAndy Spencer <andy753421@gmail.com>
Mon, 29 Aug 2011 00:03:22 +0000 (00:03 +0000)
committerAndy Spencer <andy753421@gmail.com>
Mon, 29 Aug 2011 00:03:22 +0000 (00:03 +0000)
18 files changed:
src/africa_to_radar.c
src/anyformat_to_radar.c
src/dorade_to_radar.c
src/gzip.c
src/histogram.c
src/image_gen.c
src/lassen_to_radar.c
src/mcgill.c
src/nsig.c
src/radar_to_uf.c
src/radtec.c
src/rainbow_to_radar.c
src/rapic_to_radar.c
src/read_write.c
src/toga.c
src/uf_to_radar.c
src/wsr88d.c
src/wsr88d_get_site.c

index a5bffddbf1b86aee4ac4084c7cab1caf39e5ef44..b65fde2a9fb9260f07fb7ef794f94d3e18bb0c22 100644 (file)
@@ -69,9 +69,9 @@ Radar *RSL_africa_to_radar(char *infile)
 
   if (infile == NULL) {
        save_fd = dup(0);
-       fp = fdopen(save_fd, "r");
+       fp = fdopen(save_fd, "rb");
   } else {
-       fp = fopen(infile, "r");
+       fp = fopen(infile, "rb");
   }
   fp = uncompress_pipe(fp);
   n = 0;
index 6f0d8fb4c17b09a763b5e624e0fe012d81f507ab..d3263bd92524b97eed3ece992a6e128161b5be25 100644 (file)
@@ -59,7 +59,7 @@ enum File_type RSL_filetype(char *infile)
   FILE *fp;\r
   char magic[11];\r
 \r
-  if ((fp = fopen(infile, "r")) == NULL) {\r
+  if ((fp = fopen(infile, "rb")) == NULL) {\r
        perror(infile);\r
        return UNKNOWN;\r
   }\r
index b3c8c6631fbca7853c8f503bbedb13b839b4c3f6..f061665995a35da957c7fea7c0d43a8dbe54a7a4 100644 (file)
@@ -184,9 +184,9 @@ Radar *RSL_dorade_to_radar(char *infile)
   if (infile == NULL) {
     int save_fd;
     save_fd = dup(0);
-    fp = fdopen(save_fd, "r");
+    fp = fdopen(save_fd, "rb");
   }  else
-    if((fp=fopen(infile, "r"))==(FILE *)NULL) {
+    if((fp=fopen(infile, "rb"))==(FILE *)NULL) {
       perror(infile);
       return radar;
     }
index 9c2ef315a16aaf97adebf701b321f00cfcca7c13..8a34fa4e580e189278375afff79a0fe0ad3cb5f9 100644 (file)
@@ -81,7 +81,7 @@ FILE *uncompress_pipe (FILE *fp)
     return NULL;
   }
 
-  fpipe = popen("gzip -q -d -f --stdout", "r");
+  fpipe = popen("gzip -q -d -f --stdout", "rb");
   if (fpipe == NULL) perror("uncompress_pipe");
   close(0);
   if (dup(save_fd) < 0) {
@@ -108,7 +108,7 @@ FILE *compress_pipe (FILE *fp)
     return NULL;
   }
 
-  fpipe = popen("gzip -q -1 -c", "w");
+  fpipe = popen("gzip -q -1 -c", "wb");
   if (fpipe == NULL) perror("compress_pipe");
   close(1);
   if (dup(save_fd) < 0) {
index ffefe1e1b22284ff3b9918a335e3e04249c1b383..5acc7f147407dd8df82a29716bba0cad22494b54 100644 (file)
@@ -107,7 +107,7 @@ void RSL_print_histogram(Histogram *histogram, int min_range, int max_range,
        }
 
     if (radar_verbose_flag) fprintf(stderr,"print_histogram: %s\n",filename);
-       if((fp = fopen(filename,"w")) == NULL ) {
+       if((fp = fopen(filename,"wb")) == NULL ) {
                perror(filename);
                return;
     }
@@ -156,7 +156,7 @@ Histogram *RSL_read_histogram(char *infile)
   int nbins;
   Histogram *histogram;
 
-  if ((fp = fopen(infile, "r")) == NULL) {
+  if ((fp = fopen(infile, "rb")) == NULL) {
        perror(infile);
        return NULL;
   }
@@ -191,7 +191,7 @@ int RSL_write_histogram(Histogram *histogram, char *outfile)
   FILE *fp;
   int n;
 
-  if ((fp = fopen(outfile, "w")) == NULL) {
+  if ((fp = fopen(outfile, "wb")) == NULL) {
        perror(outfile);
        return -1;
   }
index ba968c2413b606809ca17d871e267333f479b1c7..3c69b7b34966e095dab775bbe624ee09ae9f08d8 100644 (file)
@@ -82,7 +82,7 @@ void RSL_load_color_table(char *infile, char buffer[256], int *num_colors)
 {
   FILE *fp;
 
-  fp = fopen(infile, "r");
+  fp = fopen(infile, "rb");
   if (fp == NULL) {
        perror(infile);
        exit(-1);
@@ -290,7 +290,7 @@ void RSL_bscan_sweep(Sweep *s, char *outfile)
   FILE *fp;
   if (s == NULL) return;
   
-  fp = fopen(outfile,"w");
+  fp = fopen(outfile,"wb");
   if (fp == NULL) {
        perror(outfile);
        return;
@@ -522,7 +522,7 @@ void RSL_write_gif(char *outfile, unsigned char *image, int xdim, int ydim, char
   fpipe = NULL;
   nbytes = xdim*ydim;
   (void)sprintf(pipecmd, "ppmtogif > %s 2>/dev/null", outfile);
-  fpipe = popen(pipecmd, "w");  /* Global FILE * */
+  fpipe = popen(pipecmd, "wb");  /* Global FILE * */
   if (fpipe == NULL) {
        perror("RSL_write_gif1");
        return;
@@ -563,7 +563,7 @@ void RSL_write_pict(char *outfile, unsigned char *image, int xdim, int ydim, cha
   }
   nbytes = xdim*ydim;
   (void)sprintf(pipecmd, "ppmtopict > %s 2>/dev/null", outfile);
-  fpipe = popen(pipecmd, "w");  /* Global FILE * */
+  fpipe = popen(pipecmd, "wb");  /* Global FILE * */
   fprintf(fpipe, "P6\n# %s\n%d %d\n255\n",outfile, xdim, ydim);
   for (i=0; i<nbytes; i++)
          if (fwrite(c_table[image[i]], sizeof(char), 3, fpipe) != 3)
@@ -589,7 +589,7 @@ void RSL_write_ppm(char *outfile, unsigned char *image, int xdim, int ydim, char
     return;
   }
   nbytes = xdim*ydim;
-  fpipe = fopen(outfile, "w");  /* Global FILE * */
+  fpipe = fopen(outfile, "wb");  /* Global FILE * */
   fprintf(fpipe, "P6\n# %s\n%d %d\n255\n",outfile, xdim, ydim);
   for (i=0; i<nbytes; i++)
          if (fwrite(c_table[image[i]], sizeof(char), 3, fpipe) != 3)
@@ -616,7 +616,7 @@ void RSL_write_pgm(char *outfile, unsigned char *image, int xdim, int ydim)
   }
   nbytes = xdim*ydim;
   (void)sprintf(pipecmd, "gzip > %s.gz 2>/dev/null", outfile);
-  fpipe = popen(pipecmd, "w");  /* Global FILE * */
+  fpipe = popen(pipecmd, "wb");  /* Global FILE * */
   fprintf(fpipe, "P5\n# %s\n%d %d\n255\n",outfile, xdim, ydim);
   if (fwrite(image, sizeof(char), nbytes, fpipe) != nbytes)
        fprintf(stderr, "RSL_write_pgm: short write\n");
@@ -625,7 +625,7 @@ void RSL_write_pgm(char *outfile, unsigned char *image, int xdim, int ydim)
 /*  The following is commented and is for non compressed. */
 #ifdef COMPILE
   nbytes = xdim*ydim;
-  fpipe = fopen(outfile, "w");  /* Global FILE * */
+  fpipe = fopen(outfile, "wb");  /* Global FILE * */
   fprintf(fpipe, "P5\n# %s\n%d %d\n255\n",outfile, xdim, ydim);
   (void)fwrite(image, sizeof(char), nbytes, fpipe);
   (void)fclose(fpipe);
index 7925c50c6fd415c1d801a80fb8e3708c19c2adcd..4b42f69c28ab55b32baf12f0d134eafef0213fe4 100644 (file)
@@ -278,9 +278,9 @@ Radar *RSL_lassen_to_radar(char *infile)
   if (infile == NULL) {
        int save_fd;
        save_fd = dup(0);
-       f = fdopen(save_fd, "r");
+       f = fdopen(save_fd, "rb");
   }  else
-    if((f=fopen(infile, "r"))==(FILE *)NULL) {
+    if((f=fopen(infile, "rb"))==(FILE *)NULL) {
          perror(infile);
          return NULL;
     }
index f4805ca88a26e9a23fa749cd729628c2b56849b5..5b9174b96b164e296c65916e1c31af4636be2330 100644 (file)
@@ -126,7 +126,7 @@ mcgFile_t *mcgFileOpen(int *code, char *filename)
          }
    
    /* Open Mcgill data file for reading */
-   if ((file->fp = fopen(filename, "r")) == NULL)
+   if ((file->fp = fopen(filename, "rb")) == NULL)
          {
          *code = MCG_OPEN_FILE_ERR;
          return(NULL);
index 9ae591356cbd02b6d50b82377f452aef2e44cf31..bb07fc423e256f37167fb5f104f5740bea6a2df1 100644 (file)
@@ -70,8 +70,8 @@ FILE *nsig_open(char *file_name)
    /* Open input file */
   if (file_name == NULL) { /* Use stdin */
     save_fd = dup(0);
-    fp = fdopen(save_fd, "r");
-  } else if((fp = fopen(file_name,"r")) == NULL) {
+    fp = fdopen(save_fd, "rb");
+  } else if((fp = fopen(file_name,"rb")) == NULL) {
     perror(file_name);
     return fp;
   }
index fae49a2a0445dbe8fc8e0f083d83927a3fdb85ee..de1f96dd4d8c800d45541366feb0a7ee7bd660a1 100644 (file)
@@ -527,7 +527,7 @@ void RSL_radar_to_uf(Radar *r, char *outfile)
     return;
   }
 
-  if ((fp = fopen(outfile, "w")) == NULL) {
+  if ((fp = fopen(outfile, "wb")) == NULL) {
     perror(outfile);
     return;
   }
@@ -549,7 +549,7 @@ void RSL_radar_to_uf_gzip(Radar *r, char *outfile)
     return;
   }
 
-  if ((fp = fopen(outfile, "w")) == NULL) {
+  if ((fp = fopen(outfile, "wb")) == NULL) {
     perror(outfile);
     return;
   }
index 366bbce7f4c8f2248860871957b1010e9e9cea69..b17d7ab27d2c84268e9c9820daa249e1bfbae83a 100644 (file)
@@ -239,7 +239,7 @@ Radtec_file *radtec_read_file(char *infile)
   if (infile == NULL) {
        fp = stdin;
   } else {
-       if((fp = fopen(infile, "r")) == NULL) {
+       if((fp = fopen(infile, "rb")) == NULL) {
          perror(infile);
          return NULL;
        }
index 5dc0a28269081c3f9a0010cdcffe3d5e07aa0780..c3f05bc131a34d1ebed5bffd0ec5427ebc1c343e 100644 (file)
@@ -85,9 +85,9 @@ Radar *RSL_rainbow_to_radar(char *infile)
     if (infile == NULL) {
        int save_fd;
        save_fd = dup(0);
-       fp = fdopen(save_fd, "r");
+       fp = fdopen(save_fd, "rb");
     }
-    else if ((fp = fopen(infile, "r")) == NULL) {
+    else if ((fp = fopen(infile, "rb")) == NULL) {
        perror(infile);
        return NULL;
     }
index 7d9b7cae7de54f278ea6bfb30681adac5085022b..a2d8dea5458f297ab660adb90554bc44edc19cf2 100644 (file)
@@ -15,9 +15,9 @@ Radar *RSL_rapic_to_radar(char *infile)
   radar = NULL;
   if (infile == NULL) {
        save_fd = dup(0);
-       fp = fdopen(save_fd, "r");
+       fp = fdopen(save_fd, "rb");
   }  else {
-       if ((fp = fopen(infile, "r")) == NULL) {
+       if ((fp = fopen(infile, "rb")) == NULL) {
          perror(infile);
          return radar;
        }
index 8c9398799b433d0c54dab4289cf0acf251309a30..65b378cd3b9fb132a22c2802b61847b09ba2c01e 100644 (file)
@@ -194,7 +194,7 @@ Radar *RSL_read_radar(char *infile)
   int nradar;
   char title[100];
 
-  if ((fp = fopen(infile, "r")) == NULL) {
+  if ((fp = fopen(infile, "rb")) == NULL) {
        perror(infile);
        return NULL;
   }
@@ -366,7 +366,7 @@ int RSL_write_radar(Radar *radar, char *outfile)
 
   if (radar == NULL) return 0;
   
-  if ((fp = fopen(outfile, "w")) == NULL) {
+  if ((fp = fopen(outfile, "wb")) == NULL) {
        perror(outfile);
        return -1;
   }
@@ -386,7 +386,7 @@ int RSL_write_radar_gzip(Radar *radar, char *outfile)
   int n;
   if (radar == NULL) return 0;
   
-  if ((fp = fopen(outfile, "w")) == NULL) {
+  if ((fp = fopen(outfile, "wb")) == NULL) {
        perror(outfile);
        return -1;
   }
index 38edd6b11e44b258e29536cd8968f503f29bb2c2..d249ea8ed65af255c44a556a8495544a5510ddb0 100644 (file)
@@ -102,7 +102,7 @@ int tg_open(char *filename,tg_file_str *tg_file)
    /* Unfortunately, there is no tg_close to modularize the following
     * pipe close.  Shouldn't be any problems anyway.
     */
-   (void) uncompress_pipe(fdopen(tg_file->fd, "r")); /* Redirect through gunzip. */
+   (void) uncompress_pipe(fdopen(tg_file->fd, "rb")); /* Redirect through gunzip. */
    /* initialize buffer pointers, flags */
    tg_file->buf_ind = 32769;
    tg_file->buf_end = 32769;
index d9d0673b842061b69ebd50b9380f2b2f4c363aa1..463f969e9b327090b4c96cbe7aa214b97ec738fe 100644 (file)
@@ -604,8 +604,8 @@ Radar *RSL_uf_to_radar(char *infile)
   if (infile == NULL) {
     int save_fd;
     save_fd = dup(0);
-    fp = fdopen(save_fd, "r");
-  }  else if ((fp = fopen(infile, "r")) == NULL) {
+    fp = fdopen(save_fd, "rb");
+  }  else if ((fp = fopen(infile, "rb")) == NULL) {
     perror(infile);
     return radar;
   }
index eeadeb83857cc8c2c25066a70f5d228716369422..5ab590dcaae6f90616137bac9a5c5ad96e5d47d1 100644 (file)
@@ -240,9 +240,9 @@ Wsr88d_file *wsr88d_open(char *filename)
 
   if ( strcmp(filename, "stdin") == 0 ) {
        save_fd = dup(0);
-       wf->fptr = fdopen(save_fd,"r");
+       wf->fptr = fdopen(save_fd,"rb");
   } else {
-       wf->fptr = fopen(filename, "r");
+       wf->fptr = fopen(filename, "rb");
   }
 
   if (wf->fptr == NULL) return NULL;
@@ -324,7 +324,7 @@ int wsr88d_read_tape_header(char *first_file,
   int n;
   char c;
 
-  if ((fp = fopen(first_file, "r")) == NULL) {
+  if ((fp = fopen(first_file, "rb")) == NULL) {
        perror(first_file);
        return 0;
   }
index 6b5f661b7ee8afc39c19617c21a31c809ace79aa..4f08e816c6413878f134c496ce67e5cb3cf74245 100644 (file)
@@ -46,7 +46,7 @@ Wsr88d_site_info *wsr88d_get_site(char *in_sitenm)
        struct radar_site *currsite=NULL;
        FILE *in_file;
 
-       if((in_file=fopen(WSR88D_SITE_INFO_FILE, "r")) !=NULL)
+       if((in_file=fopen(WSR88D_SITE_INFO_FILE, "rb")) !=NULL)
        {
        /* read each line */
                while (fgets(line,sizeof(line),in_file) != NULL)