]> git.street.me.uk Git - andy/viking.git/blobdiff - src/dem.c
Portability: use Glib function related to stdio.h
[andy/viking.git] / src / dem.c
index e8a7698f515b90f149bab829a61b3bba48b9f680..b82510ec40bed11c5d94793a1223495ef381b19b 100644 (file)
--- a/src/dem.c
+++ b/src/dem.c
@@ -1,3 +1,24 @@
+/*
+ * viking -- GPS Data and Topo Analyzer, Explorer, and Manager
+ *
+ * Copyright (C) 2003-2008, Evan Battaglia <gtoevan@gmx.net>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ */
+
 #include <stdio.h>
 #include <string.h>
 #include <glib.h>
 #include <stdio.h>
 #include <string.h>
 #include <glib.h>
@@ -6,7 +27,6 @@
 #include <zlib.h>
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <zlib.h>
 #include <sys/types.h>
 #include <sys/stat.h>
-#include <unistd.h>
 #include <sys/mman.h>
 
 
 #include <sys/mman.h>
 
 
@@ -266,7 +286,7 @@ static void *unzip_hgt_file(gchar *zip_file, gulong *unzip_size)
 
        local_file_header = (struct _lfh *) zip_file;
        if (local_file_header->sig != 0x04034b50) {
 
        local_file_header = (struct _lfh *) zip_file;
        if (local_file_header->sig != 0x04034b50) {
-               g_warning("%s(): wrong format\n", __PRETTY_FUNCTION__);
+               g_warning("%s(): wrong format", __PRETTY_FUNCTION__);
                g_free(unzip_data);
                goto end;
        }
                g_free(unzip_data);
                goto end;
        }
@@ -345,7 +365,7 @@ static VikDEM *vik_dem_read_srtm_hgt(FILE *f, const gchar *basename, gboolean zi
   else if (file_size == (num_rows_1sec * num_rows_1sec * sizeof(gint16)))
     arcsec = 1;
   else {
   else if (file_size == (num_rows_1sec * num_rows_1sec * sizeof(gint16)))
     arcsec = 1;
   else {
-    g_warning("%s(): file %s does not have right size\n", __PRETTY_FUNCTION__, basename);
+    g_warning("%s(): file %s does not have right size", __PRETTY_FUNCTION__, basename);
     munmap(dem_file, file_size);
     g_ptr_array_free(dem->columns, TRUE);
     g_free(dem);
     munmap(dem_file, file_size);
     g_ptr_array_free(dem->columns, TRUE);
     g_free(dem);
@@ -393,7 +413,7 @@ VikDEM *vik_dem_new_from_file(const gchar *file)
   const gchar *basename = a_file_basename(file);
 
       /* FILE IO */
   const gchar *basename = a_file_basename(file);
 
       /* FILE IO */
-  f = fopen(file, "r");
+  f = g_fopen(file, "r");
   if ( !f )
     return NULL;
 
   if ( !f )
     return NULL;
 
@@ -403,6 +423,7 @@ VikDEM *vik_dem_new_from_file(const gchar *file)
     gboolean is_zip_file = (strlen(basename) == 15);
     rv = vik_dem_read_srtm_hgt(f, basename, is_zip_file);
     fclose(f);
     gboolean is_zip_file = (strlen(basename) == 15);
     rv = vik_dem_read_srtm_hgt(f, basename, is_zip_file);
     fclose(f);
+    f = NULL;
     return(rv);
   }
 
     return(rv);
   }
 
@@ -441,6 +462,7 @@ VikDEM *vik_dem_new_from_file(const gchar *file)
      /* TODO - class C records (right now says 'Invalid' and dies) */
 
   fclose(f);
      /* TODO - class C records (right now says 'Invalid' and dies) */
 
   fclose(f);
+  f = NULL;
 
   /* 24k scale */
   if ( rv->horiz_units == VIK_DEM_HORIZ_UTM_METERS && rv->n_columns >= 2 )
 
   /* 24k scale */
   if ( rv->horiz_units == VIK_DEM_HORIZ_UTM_METERS && rv->n_columns >= 2 )