소스 검색

r3.in.v5d LFS-safe, awaits testing

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@38657 15284696-431f-4ddb-bdfa-cd5b030d7da7
Markus Metz 15 년 전
부모
커밋
4057c85bf3
4개의 변경된 파일21개의 추가작업 그리고 12개의 파일을 삭제
  1. 5 0
      raster3d/r3.in.v5d/Makefile
  2. 1 0
      raster3d/r3.in.v5d/main.c
  3. 10 8
      raster3d/r3.in.v5d/v5d.c
  4. 5 4
      raster3d/r3.in.v5d/v5d.h

+ 5 - 0
raster3d/r3.in.v5d/Makefile

@@ -5,6 +5,11 @@ PGM=r3.in.v5d
 #for Linux/x86 et al. (needs fix for MacOSX)
 EXTRA_CFLAGS = -DLITTLE
 
+#compile if LFS Large File Support present:
+ifneq ($(USE_LARGEFILES),)
+	EXTRA_CFLAGS += -D_FILE_OFFSET_BITS=64
+endif
+
 LIBES = $(G3DLIB) $(GISLIB)
 DEPENDENCIES = $(G3DDEP) $(GISDEP)
 

+ 1 - 0
raster3d/r3.in.v5d/main.c

@@ -25,6 +25,7 @@
  *   Boston, MA  02111-1307, USA.
  */
 
+#include <grass/config.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>

+ 10 - 8
raster3d/r3.in.v5d/v5d.c

@@ -64,12 +64,12 @@
 
 
 
+#include <grass/config.h>
 #include <assert.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <math.h>
-#include <grass/config.h>
 #include <grass/gis.h>
 #include "binio.h"
 #include "v5d.h"
@@ -337,8 +337,8 @@ void v5dPrintStruct(const v5dstruct * v)
     else {
 	printf("Compression:  %d bytes per gridpoint.\n", v->CompressMode);
     }
-    printf("header size=%d\n", v->FirstGridPos);
-    printf("sizeof(v5dstruct)=%d\n", sizeof(v5dstruct));
+    printf("header size=%d\n", (int)v->FirstGridPos);
+    printf("sizeof(v5dstruct)=%d\n", (int)sizeof(v5dstruct));
     printf("\n");
 
     printf("NumVars = %d\n", v->NumVars);
@@ -467,7 +467,8 @@ void v5dPrintStruct(const v5dstruct * v)
  */
 static int grid_position(const v5dstruct * v, int time, int var)
 {
-    int pos, i;
+    int i;
+    off_t pos;
 
     assert(time >= 0);
     assert(var >= 0);
@@ -1309,7 +1310,7 @@ static int read_comp_header(int f, v5dstruct * v)
 	/* Older COMP5D format */
 	int gridtimes, gridparms;
 	int i, j, it, iv, nl;
-	int gridsize;
+	off_t gridsize;
 	float hgttop, hgtinc;
 
 	/*char *compgrid; */
@@ -1377,7 +1378,7 @@ static int read_comp_header(int f, v5dstruct * v)
 	    v->VarName[i][4] = 0;
 	}
 
-	gridsize = ((v->Nr * v->Nc * nl + 3) / 4) * 4;
+	gridsize = (((off_t)v->Nr * v->Nc * nl + 3) / 4) * 4;
 	for (i = 0; i < v->NumVars; i++) {
 	    v->GridSize[i] = 8 + gridsize;
 	}
@@ -1421,7 +1422,8 @@ static int read_comp_header(int f, v5dstruct * v)
     }
     else if (id == 0x80808082 || id == 0x80808083) {
 	/* Newer COMP5D format */
-	int gridtimes, gridsize;
+	int gridtimes;
+	off_t gridsize;
 	int it, iv, nl, i, j;
 	float delta;
 
@@ -1503,7 +1505,7 @@ static int read_comp_header(int f, v5dstruct * v)
 
 	/* calculate grid storage sizes */
 	if (id == 0x80808082) {
-	    gridsize = nl * 2 * 4 + ((v->Nr * v->Nc * nl + 3) / 4) * 4;
+	    gridsize = nl * 2 * 4 + (((off_t)v->Nr * v->Nc * nl + 3) / 4) * 4;
 	}
 	else {
 	    /* McIDAS grid and file numbers present */

+ 5 - 4
raster3d/r3.in.v5d/v5d.h

@@ -26,6 +26,7 @@
 #ifndef V5D_H
 #define V5D_H
 
+#include <sys/types.h>
 
 /*
  * A numeric version number which we can test for in utility programs which
@@ -232,10 +233,10 @@ typedef struct
     unsigned int FileFormat;	/* COMP5D file version or 0 if .v5d */
     int FileDesc;		/* Unix file descriptor */
     char Mode;			/* 'r' = read, 'w' = write */
-    int CurPos;			/* current position of file pointer */
-    int FirstGridPos;		/* position of first grid in file */
-    int GridSize[MAXVARS];	/* size of each grid */
-    int SumGridSizes;		/* sum of GridSize[0..NumVars-1] */
+    off_t CurPos;			/* current position of file pointer */
+    off_t FirstGridPos;		/* position of first grid in file */
+    off_t GridSize[MAXVARS];	/* size of each grid */
+    off_t SumGridSizes;		/* sum of GridSize[0..NumVars-1] */
 } v5dstruct;