[GRASS-SVN] r53256 - in grass/trunk: include/Make lib/raster3d

svn_grass at osgeo.org svn_grass at osgeo.org
Fri Sep 21 02:55:13 PDT 2012


Author: glynn
Date: 2012-09-21 02:55:13 -0700 (Fri, 21 Sep 2012)
New Revision: 53256

Modified:
   grass/trunk/include/Make/Grass.make
   grass/trunk/lib/raster3d/alloc.c
   grass/trunk/lib/raster3d/cats.c
   grass/trunk/lib/raster3d/color.c
   grass/trunk/lib/raster3d/doubleio.c
   grass/trunk/lib/raster3d/error.c
   grass/trunk/lib/raster3d/filecompare.c
   grass/trunk/lib/raster3d/fpxdr.c
   grass/trunk/lib/raster3d/header.c
   grass/trunk/lib/raster3d/intio.c
   grass/trunk/lib/raster3d/misc.c
   grass/trunk/lib/raster3d/range.c
   grass/trunk/lib/raster3d/raster3d_intern.h
   grass/trunk/lib/raster3d/tilealloc.c
   grass/trunk/lib/raster3d/tileread.c
   grass/trunk/lib/raster3d/tilewrite.c
Log:
Eliminate XDR dependency from raster3d library


Modified: grass/trunk/include/Make/Grass.make
===================================================================
--- grass/trunk/include/Make/Grass.make	2012-09-21 07:28:35 UTC (rev 53255)
+++ grass/trunk/include/Make/Grass.make	2012-09-21 09:55:13 UTC (rev 53256)
@@ -195,7 +195,7 @@
 DRIVERDEPS       = $(GISLIB) $(FTLIB) $(ICONVLIB) $(MATHLIB)
 DSPFDEPS         = $(GISLIB)
 FORMDEPS         = $(DBMILIB) $(GISLIB)
-RASTER3DDEPS          = $(RASTERLIB) $(GISLIB) $(XDRLIB)
+RASTER3DDEPS     = $(RASTERLIB) $(GISLIB)
 GISDEPS          = $(DATETIMELIB) $(ZLIBLIBPATH) $(ZLIB) $(INTLLIB) $(REGEXLIBPATH) $(REGEXLIB) $(ICONVLIB) $(PTHREADLIBPATH) $(PTHREADLIB) $(MATHLIB)
 GMATHDEPS        = $(GISLIB) $(FFTWLIB) $(LAPACKLIB) $(BLASLIB) $(CCMATHLIB) $(OMPLIBPATH) $(OMPLIB)
 GPDEDEPS         = $(RASTER3DLIB) $(RASTERLIB) $(GISLIB) $(GMATHLIB) $(OMPLIBPATH) $(OMPLIB) $(MATHLIB)

Modified: grass/trunk/lib/raster3d/alloc.c
===================================================================
--- grass/trunk/lib/raster3d/alloc.c	2012-09-21 07:28:35 UTC (rev 53255)
+++ grass/trunk/lib/raster3d/alloc.c	2012-09-21 09:55:13 UTC (rev 53256)
@@ -2,8 +2,6 @@
 #include <stdlib.h>
 #include <sys/types.h>
 #include <unistd.h>
-#include <rpc/types.h>
-#include <rpc/xdr.h>
 #include "raster3d_intern.h"
 
 /*---------------------------------------------------------------------------*/

Modified: grass/trunk/lib/raster3d/cats.c
===================================================================
--- grass/trunk/lib/raster3d/cats.c	2012-09-21 07:28:35 UTC (rev 53255)
+++ grass/trunk/lib/raster3d/cats.c	2012-09-21 09:55:13 UTC (rev 53256)
@@ -2,8 +2,6 @@
 #include <stdlib.h>
 #include <sys/types.h>
 #include <unistd.h>
-#include <rpc/types.h>
-#include <rpc/xdr.h>
 
 #include <grass/gis.h>
 #include <grass/raster.h>

Modified: grass/trunk/lib/raster3d/color.c
===================================================================
--- grass/trunk/lib/raster3d/color.c	2012-09-21 07:28:35 UTC (rev 53255)
+++ grass/trunk/lib/raster3d/color.c	2012-09-21 09:55:13 UTC (rev 53256)
@@ -4,8 +4,6 @@
 #include <string.h>
 #include <sys/types.h>
 #include <unistd.h>
-#include <rpc/types.h>
-#include <rpc/xdr.h>
 
 #include <grass/gis.h>
 #include <grass/raster.h>

Modified: grass/trunk/lib/raster3d/doubleio.c
===================================================================
--- grass/trunk/lib/raster3d/doubleio.c	2012-09-21 07:28:35 UTC (rev 53255)
+++ grass/trunk/lib/raster3d/doubleio.c	2012-09-21 09:55:13 UTC (rev 53256)
@@ -2,16 +2,12 @@
 #include <stdlib.h>
 #include <sys/types.h>
 #include <unistd.h>
-#include <rpc/types.h>
-#include <rpc/xdr.h>
 #include "raster3d_intern.h"
 
 /*---------------------------------------------------------------------------*/
 
 int Rast3d_write_doubles(int fd, int useXdr, const double *i, int nofNum)
 {
-    int firstTime = 1;
-    XDR xdrEncodeStream;
     char xdrDoubleBuf[RASTER3D_XDR_DOUBLE_LENGTH * 1024];
     u_int n;
 
@@ -28,29 +24,15 @@
 	}
     }
 
-
-    if (firstTime) {
-	xdrmem_create(&xdrEncodeStream, xdrDoubleBuf,
-		      RASTER3D_XDR_DOUBLE_LENGTH * 1024, XDR_ENCODE);
-	firstTime = 1;
-    }
-
     do {
+	int j;
 	n = nofNum % 1024;
 	if (n == 0)
 	    n = 1024;
 
-	if (!xdr_setpos(&xdrEncodeStream, 0)) {
-	    Rast3d_error("Rast3d_write_doubles: positioning xdr failed");
-	    return 0;
-	}
+	for (j = 0; j < n; j++)
+	    G_xdr_put_double(&xdrDoubleBuf[RASTER3D_XDR_DOUBLE_LENGTH * j], i);
 
-	if (!xdr_vector(&xdrEncodeStream, (char *)i, n, sizeof(double),
-			(xdrproc_t) xdr_double)) {
-	    Rast3d_error("Rast3d_write_doubles: writing xdr failed");
-	    return 0;
-	}
-
 	if (write(fd, xdrDoubleBuf, RASTER3D_XDR_DOUBLE_LENGTH * n) !=
 	    RASTER3D_XDR_DOUBLE_LENGTH * n) {
 	    Rast3d_error("Rast3d_write_doubles: writing xdr to file failed");
@@ -68,8 +50,6 @@
 
 int Rast3d_read_doubles(int fd, int useXdr, double *i, int nofNum)
 {
-    int firstTime = 1;
-    XDR xdrDecodeStream;
     char xdrDoubleBuf[RASTER3D_XDR_DOUBLE_LENGTH * 1024];
     u_int n;
 
@@ -86,13 +66,8 @@
 	}
     }
 
-    if (firstTime) {
-	xdrmem_create(&xdrDecodeStream, xdrDoubleBuf,
-		      RASTER3D_XDR_DOUBLE_LENGTH * 1024, XDR_DECODE);
-	firstTime = 1;
-    }
-
     do {
+	int j;
 	n = nofNum % 1024;
 	if (n == 0)
 	    n = 1024;
@@ -103,17 +78,9 @@
 	    return 0;
 	}
 
-	if (!xdr_setpos(&xdrDecodeStream, 0)) {
-	    Rast3d_error("Rast3d_read_doubles: positioning xdr failed");
-	    return 0;
-	}
+	for (j = 0; j < n; j++)
+	    G_xdr_get_double(i, &xdrDoubleBuf[RASTER3D_XDR_DOUBLE_LENGTH * j]);
 
-	if (!xdr_vector(&xdrDecodeStream, (char *)i, n, sizeof(double),
-			(xdrproc_t) xdr_double)) {
-	    Rast3d_error("Rast3d_read_doubles: reading xdr failed");
-	    return 0;
-	}
-
 	nofNum -= n;
 	i += n;
     } while (nofNum);

Modified: grass/trunk/lib/raster3d/error.c
===================================================================
--- grass/trunk/lib/raster3d/error.c	2012-09-21 07:28:35 UTC (rev 53255)
+++ grass/trunk/lib/raster3d/error.c	2012-09-21 09:55:13 UTC (rev 53256)
@@ -4,8 +4,6 @@
 #include <unistd.h>
 #include <time.h>
 #include <stdarg.h>
-#include <rpc/types.h>
-#include <rpc/xdr.h>
 #include <grass/gis.h>
 
 #include "raster3d_intern.h"

Modified: grass/trunk/lib/raster3d/filecompare.c
===================================================================
--- grass/trunk/lib/raster3d/filecompare.c	2012-09-21 07:28:35 UTC (rev 53255)
+++ grass/trunk/lib/raster3d/filecompare.c	2012-09-21 09:55:13 UTC (rev 53256)
@@ -1,5 +1,3 @@
-#include <rpc/types.h>
-#include <rpc/xdr.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <sys/types.h>
@@ -13,36 +11,16 @@
 
 /*---------------------------------------------------------------------------*/
 
-static void Rast3d_float2xdrFloat(float *f, float *xdrf)
+static void Rast3d_float2xdrFloat(const float *f, float *xdrf)
 {
-    XDR xdrEncodeStream;
-
-    xdrmem_create(&xdrEncodeStream, (caddr_t) xdrf, 4, XDR_ENCODE);
-
-    if (!xdr_setpos(&xdrEncodeStream, 0))
-	Rast3d_fatal_error("Rast3d_float2xdrFloat: positioning xdr failed");
-
-    if (!xdr_float(&xdrEncodeStream, f))
-	Rast3d_fatal_error("Rast3d_float2xdrFloat: writing xdr failed");
-
-    xdr_destroy(&xdrEncodeStream);
+    G_xdr_put_float(xdrf, f);
 }
 
 /*---------------------------------------------------------------------------*/
 
-static void Rast3d_double2xdrDouble(double *d, double *xdrd)
+static void Rast3d_double2xdrDouble(const double *d, double *xdrd)
 {
-    XDR xdrEncodeStream;
-
-    xdrmem_create(&xdrEncodeStream, (caddr_t) xdrd, 8, XDR_ENCODE);
-
-    if (!xdr_setpos(&xdrEncodeStream, 0))
-	Rast3d_fatal_error("Rast3d_double2xdrDouble: positioning xdr failed");
-
-    if (!xdr_double(&xdrEncodeStream, d))
-	Rast3d_fatal_error("Rast3d_double2xdrDouble: writing xdr failed");
-
-    xdr_destroy(&xdrEncodeStream);
+    G_xdr_put_double(xdrd, d);
 }
 
 /*---------------------------------------------------------------------------*/

Modified: grass/trunk/lib/raster3d/fpxdr.c
===================================================================
--- grass/trunk/lib/raster3d/fpxdr.c	2012-09-21 07:28:35 UTC (rev 53255)
+++ grass/trunk/lib/raster3d/fpxdr.c	2012-09-21 09:55:13 UTC (rev 53256)
@@ -3,8 +3,6 @@
 #include <string.h>
 #include <sys/types.h>
 #include <unistd.h>
-#include <rpc/types.h>
-#include <rpc/xdr.h>
 
 #include <grass/raster.h>
 
@@ -62,7 +60,7 @@
 
 /*---------------------------------------------------------------------------*/
 
-XDR xdrEncodeStream, xdrDecodeStream;	/* xdr support structures */
+static size_t xdr_off;
 
 int Rast3d_init_fp_xdr(RASTER3D_Map * map, int misuseBytes)
 
@@ -71,10 +69,6 @@
  /* nof addtl bytes allocated for the xdr array so that */
 		      /* the array can also be (mis)used for other purposes */
 {
-    int doAlloc;
-
-    doAlloc = 0;
-
     if (xdr == NULL) {
 	xdrLength = map->tileSize * RASTER3D_MAX(map->numLengthExtern,
 					    map->numLengthIntern) +
@@ -84,8 +78,6 @@
 	    Rast3d_error("Rast3d_init_fp_xdr: error in Rast3d_malloc");
 	    return 0;
 	}
-
-	doAlloc = 1;
     }
     else if (map->tileSize * RASTER3D_MAX(map->numLengthExtern,
 				     map->numLengthIntern) + misuseBytes
@@ -98,15 +90,8 @@
 	    Rast3d_error("Rast3d_init_fp_xdr: error in Rast3d_realloc");
 	    return 0;
 	}
-
-	doAlloc = 1;
     }
 
-    if (doAlloc) {
-	xdrmem_create(&(xdrEncodeStream), xdr, (u_int) xdrLength, XDR_ENCODE);
-	xdrmem_create(&(xdrDecodeStream), xdr, (u_int) xdrLength, XDR_DECODE);
-    }
-
     return 1;
 }
 
@@ -114,8 +99,6 @@
 
 static void *xdrTmp;
 static int dstType, srcType, type, externLength, eltLength, isFloat, useXdr;
-static int (*xdrFun) ();
-static XDR *xdrs;
 static double tmpValue, *tmp;
 
 int Rast3d_init_copy_to_xdr(RASTER3D_Map * map, int sType)
@@ -124,22 +107,13 @@
     useXdr = map->useXdr;
     srcType = sType;
 
-    if (map->useXdr == RASTER3D_USE_XDR) {
-	if (!xdr_setpos(&(xdrEncodeStream), 0)) {
-	    Rast3d_error("Rast3d_InitCopyToXdr: positioning xdr failed");
-	    return 0;
-	}
-	xdrs = &(xdrEncodeStream);
-    }
+    if (map->useXdr == RASTER3D_USE_XDR)
+	xdr_off = 0;
 
     type = map->type;
     isFloat = (type == FCELL_TYPE);
     externLength = Rast3d_extern_length(type);
     eltLength = Rast3d_length(srcType);
-    if (isFloat)
-	xdrFun = xdr_float;
-    else
-	xdrFun = xdr_double;
     tmp = &tmpValue;
 
     return 1;
@@ -147,6 +121,25 @@
 
 /*---------------------------------------------------------------------------*/
 
+static int xdr_put(const void *src)
+{
+    if (isFloat) {
+	if (xdr_off + RASTER3D_XDR_FLOAT_LENGTH > xdrLength) 
+	    return 0;
+	G_xdr_put_float((char*)xdr + xdr_off, src);
+	xdr_off += RASTER3D_XDR_FLOAT_LENGTH;
+    }
+    else {
+	if (xdr_off + RASTER3D_XDR_DOUBLE_LENGTH > xdrLength)
+	    return 0;
+	G_xdr_put_double((char*)xdr + xdr_off, src);
+	xdr_off += RASTER3D_XDR_DOUBLE_LENGTH;
+    }
+    return 1;
+}
+
+/*---------------------------------------------------------------------------*/
+
 int Rast3d_copy_to_xdr(const void *src, int nofNum)
 {
     int i;
@@ -161,14 +154,11 @@
 
 	if (Rast3d_is_null_value_num(src, srcType)) {
 	    Rast3d_set_xdr_null_num(xdrTmp, isFloat);
-	    if (!xdr_setpos(xdrs, xdr_getpos(xdrs) + externLength)) {
-		Rast3d_error("Rast3d_copy_to_xdr: positioning xdr failed");
-		return 0;
-	    }
+	    xdr_off += externLength;
 	}
 	else {
 	    if (type == srcType) {
-		if (xdrFun(xdrs, src) < 0) {
+		if (!xdr_put(src)) {
 		    Rast3d_error("Rast3d_copy_to_xdr: writing xdr failed");
 		    return 0;
 		}
@@ -178,7 +168,7 @@
 		    *((float *)tmp) = (float)*((double *)src);
 		else
 		    *((double *)tmp) = (double)*((float *)src);
-		if (xdrFun(xdrs, tmp) < 0) {
+		if (!xdr_put(tmp)) {
 		    Rast3d_error("Rast3d_copy_to_xdr: writing xdr failed");
 		    return 0;
 		}
@@ -199,22 +189,13 @@
     useXdr = map->useXdr;
     dstType = dType;
 
-    if (useXdr == RASTER3D_USE_XDR) {
-	if (!xdr_setpos(&(xdrDecodeStream), 0)) {
-	    Rast3d_error("Rast3d_init_copy_from_xdr: positioning xdr failed");
-	    return 0;
-	}
-	xdrs = &(xdrDecodeStream);
-    }
+    if (useXdr == RASTER3D_USE_XDR)
+	xdr_off = 0;
 
     type = map->type;
     isFloat = (type == FCELL_TYPE);
     externLength = Rast3d_extern_length(type);
     eltLength = Rast3d_length(dstType);
-    if (isFloat)
-	xdrFun = xdr_float;
-    else
-	xdrFun = xdr_double;
     tmp = &tmpValue;
 
     return 1;
@@ -222,6 +203,25 @@
 
 /*---------------------------------------------------------------------------*/
 
+static int xdr_get(void *src)
+{
+    if (isFloat) {
+	if (xdr_off + RASTER3D_XDR_FLOAT_LENGTH > xdrLength) 
+	    return 0;
+	G_xdr_get_float(src, (char*)xdr + xdr_off);
+	xdr_off += RASTER3D_XDR_FLOAT_LENGTH;
+    }
+    else {
+	if (xdr_off + RASTER3D_XDR_DOUBLE_LENGTH > xdrLength)
+	    return 0;
+	G_xdr_get_double(src, (char*)xdr + xdr_off);
+	xdr_off += RASTER3D_XDR_DOUBLE_LENGTH;
+    }
+    return 1;
+}
+
+/*---------------------------------------------------------------------------*/
+
 int Rast3d_copy_from_xdr(int nofNum, void *dst)
 {
     int i;
@@ -236,20 +236,17 @@
 
 	if (Rast3d_is_xdr_null_num(xdrTmp, isFloat)) {
 	    Rast3d_set_null_value(dst, 1, dstType);
-	    if (!xdr_setpos(xdrs, xdr_getpos(xdrs) + externLength)) {
-		Rast3d_error("Rast3d_copy_from_xdr: positioning xdr failed");
-		return 0;
-	    }
+	    xdr_off += externLength;
 	}
 	else {
 	    if (type == dstType) {
-		if (xdrFun(xdrs, dst) < 0) {
+		if (!xdr_get(dst)) {
 		    Rast3d_error("Rast3d_copy_from_xdr: reading xdr failed");
 		    return 0;
 		}
 	    }
 	    else {
-		if (xdrFun(xdrs, tmp) < 0) {
+		if (!xdr_get(tmp)) {
 		    Rast3d_error("Rast3d_copy_from_xdr: reading xdr failed");
 		    return 0;
 		}

Modified: grass/trunk/lib/raster3d/header.c
===================================================================
--- grass/trunk/lib/raster3d/header.c	2012-09-21 07:28:35 UTC (rev 53255)
+++ grass/trunk/lib/raster3d/header.c	2012-09-21 09:55:13 UTC (rev 53256)
@@ -2,8 +2,6 @@
 #include <stdlib.h>
 #include <sys/types.h>
 #include <unistd.h>
-#include <rpc/types.h>
-#include <rpc/xdr.h>
 #include <grass/raster3d.h>
 #include <grass/glocale.h>
 #include "raster3d_intern.h"

Modified: grass/trunk/lib/raster3d/intio.c
===================================================================
--- grass/trunk/lib/raster3d/intio.c	2012-09-21 07:28:35 UTC (rev 53255)
+++ grass/trunk/lib/raster3d/intio.c	2012-09-21 09:55:13 UTC (rev 53256)
@@ -2,16 +2,12 @@
 #include <stdlib.h>
 #include <sys/types.h>
 #include <unistd.h>
-#include <rpc/types.h>
-#include <rpc/xdr.h>
 #include "raster3d_intern.h"
 
 /*---------------------------------------------------------------------------*/
 
 int Rast3d_write_ints(int fd, int useXdr, const int *i, int nofNum)
 {
-    int firstTime = 1;
-    XDR xdrEncodeStream;
     char xdrIntBuf[RASTER3D_XDR_INT_LENGTH * 1024];
     u_int n;
 
@@ -28,28 +24,15 @@
 	}
     }
 
-    if (firstTime) {
-	xdrmem_create(&xdrEncodeStream, xdrIntBuf, RASTER3D_XDR_INT_LENGTH * 1024,
-		      XDR_ENCODE);
-	firstTime = 1;
-    }
-
     do {
+	int j;
 	n = nofNum % 1024;
 	if (n == 0)
 	    n = 1024;
 
-	if (!xdr_setpos(&xdrEncodeStream, 0)) {
-	    Rast3d_error("Rast3d_write_ints: positioning xdr failed");
-	    return 0;
-	}
+	for (j = 0; j < n; j++)
+	    G_xdr_put_int(&xdrIntBuf[RASTER3D_XDR_INT_LENGTH * j], i);
 
-	if (!xdr_vector(&xdrEncodeStream, (char *)i, n, sizeof(int),
-			(xdrproc_t) xdr_int)) {
-	    Rast3d_error("Rast3d_write_ints: writing xdr failed");
-	    return 0;
-	}
-
 	if (write(fd, xdrIntBuf, RASTER3D_XDR_INT_LENGTH * n) !=
 	    RASTER3D_XDR_INT_LENGTH * n) {
 	    Rast3d_error("Rast3d_write_ints: writing xdr to file failed");
@@ -67,8 +50,6 @@
 
 int Rast3d_read_ints(int fd, int useXdr, int *i, int nofNum)
 {
-    int firstTime = 1;
-    XDR xdrDecodeStream;
     char xdrIntBuf[RASTER3D_XDR_INT_LENGTH * 1024];
     u_int n;
 
@@ -85,13 +66,8 @@
 	}
     }
 
-    if (firstTime) {
-	xdrmem_create(&xdrDecodeStream, xdrIntBuf, RASTER3D_XDR_INT_LENGTH * 1024,
-		      XDR_DECODE);
-	firstTime = 1;
-    }
-
     do {
+	int j;
 	n = nofNum % 1024;
 	if (n == 0)
 	    n = 1024;
@@ -102,17 +78,9 @@
 	    return 0;
 	}
 
-	if (!xdr_setpos(&xdrDecodeStream, 0)) {
-	    Rast3d_error("Rast3d_read_ints: positioning xdr failed");
-	    return 0;
-	}
+	for (j = 0; j < n; j++)
+	    G_xdr_get_int(i, &xdrIntBuf[RASTER3D_XDR_INT_LENGTH * j]);
 
-	if (!xdr_vector(&xdrDecodeStream, (char *)i, n, sizeof(int),
-			(xdrproc_t) xdr_int)) {
-	    Rast3d_error("Rast3d_read_ints: reading xdr failed");
-	    return 0;
-	}
-
 	nofNum -= n;
 	i += n;
     } while (nofNum);

Modified: grass/trunk/lib/raster3d/misc.c
===================================================================
--- grass/trunk/lib/raster3d/misc.c	2012-09-21 07:28:35 UTC (rev 53255)
+++ grass/trunk/lib/raster3d/misc.c	2012-09-21 09:55:13 UTC (rev 53256)
@@ -3,8 +3,6 @@
 #include <string.h>
 #include <sys/types.h>
 #include <unistd.h>
-#include <rpc/types.h>
-#include <rpc/xdr.h>
 
 #include <grass/raster.h>
 

Modified: grass/trunk/lib/raster3d/range.c
===================================================================
--- grass/trunk/lib/raster3d/range.c	2012-09-21 07:28:35 UTC (rev 53255)
+++ grass/trunk/lib/raster3d/range.c	2012-09-21 09:55:13 UTC (rev 53256)
@@ -2,8 +2,6 @@
 #include <stdlib.h>
 #include <sys/types.h>
 #include <unistd.h>
-#include <rpc/types.h>
-#include <rpc/xdr.h>
 
 #include <grass/gis.h>
 #include <grass/raster.h>
@@ -63,9 +61,8 @@
 {
     int fd;
     int bytes_read;
-    char xdr_buf[100];
+    char xdr_buf[2 * RASTER3D_XDR_DOUBLE_LENGTH];
     DCELL dcell1, dcell2;
-    XDR xdr_str;
 
     Rast_init_fp_range(drange);
 
@@ -92,15 +89,9 @@
 	return 2;
     }
 
-    xdrmem_create(&xdr_str, xdr_buf, (u_int) RASTER3D_XDR_DOUBLE_LENGTH * 2,
-		  XDR_DECODE);
+    G_xdr_get_double(&dcell1, &xdr_buf[RASTER3D_XDR_DOUBLE_LENGTH * 0]);
+    G_xdr_get_double(&dcell2, &xdr_buf[RASTER3D_XDR_DOUBLE_LENGTH * 1]);
 
-    if (!xdr_double(&xdr_str, &dcell1) || !xdr_double(&xdr_str, &dcell2)) {
-	close(fd);
-	G_warning(_("Error reading range file for [%s in %s]"), name, mapset);
-	return -1;
-    }
-
     Rast_update_fp_range(dcell1, drange);
     Rast_update_fp_range(dcell2, drange);
     close(fd);
@@ -156,9 +147,8 @@
 static int writeRange(const char *name, struct FPRange *range)
  /* adapted from Rast_write_fp_range */
 {
-    char xdr_buf[100];
+    char xdr_buf[2 * RASTER3D_XDR_DOUBLE_LENGTH];
     int fd;
-    XDR xdr_str;
 
     fd = G_open_new_misc(RASTER3D_DIRECTORY, RASTER3D_RANGE_ELEMENT, name);
     if (fd < 0) {
@@ -172,14 +162,9 @@
 	return 0;
     }
 
-    xdrmem_create(&xdr_str, xdr_buf, (u_int) RASTER3D_XDR_DOUBLE_LENGTH * 2,
-		  XDR_ENCODE);
+    G_xdr_put_double(&xdr_buf[RASTER3D_XDR_DOUBLE_LENGTH * 0], &range->min);
+    G_xdr_put_double(&xdr_buf[RASTER3D_XDR_DOUBLE_LENGTH * 1], &range->max);
 
-    if (!xdr_double(&xdr_str, &(range->min)))
-	goto error;
-    if (!xdr_double(&xdr_str, &(range->max)))
-	goto error;
-
     if (write(fd, xdr_buf, RASTER3D_XDR_DOUBLE_LENGTH * 2) != RASTER3D_XDR_DOUBLE_LENGTH * 2)
 	goto error;
 

Modified: grass/trunk/lib/raster3d/raster3d_intern.h
===================================================================
--- grass/trunk/lib/raster3d/raster3d_intern.h	2012-09-21 07:28:35 UTC (rev 53255)
+++ grass/trunk/lib/raster3d/raster3d_intern.h	2012-09-21 09:55:13 UTC (rev 53256)
@@ -1,8 +1,3 @@
-#include <rpc/types.h>
-#include <rpc/xdr.h>
-
-/*---------------------------------------------------------------------------*/
-
 #include <grass/raster3d.h>
 #include <grass/gis.h>
 

Modified: grass/trunk/lib/raster3d/tilealloc.c
===================================================================
--- grass/trunk/lib/raster3d/tilealloc.c	2012-09-21 07:28:35 UTC (rev 53255)
+++ grass/trunk/lib/raster3d/tilealloc.c	2012-09-21 09:55:13 UTC (rev 53256)
@@ -2,8 +2,6 @@
 #include <stdlib.h>
 #include <sys/types.h>
 #include <unistd.h>
-#include <rpc/types.h>
-#include <rpc/xdr.h>
 #include "raster3d_intern.h"
 
 /*---------------------------------------------------------------------------*/

Modified: grass/trunk/lib/raster3d/tileread.c
===================================================================
--- grass/trunk/lib/raster3d/tileread.c	2012-09-21 07:28:35 UTC (rev 53255)
+++ grass/trunk/lib/raster3d/tileread.c	2012-09-21 09:55:13 UTC (rev 53256)
@@ -2,8 +2,6 @@
 #include <stdlib.h>
 #include <sys/types.h>
 #include <unistd.h>
-#include <rpc/types.h>
-#include <rpc/xdr.h>
 
 #include <grass/raster.h>
 #include "raster3d_intern.h"

Modified: grass/trunk/lib/raster3d/tilewrite.c
===================================================================
--- grass/trunk/lib/raster3d/tilewrite.c	2012-09-21 07:28:35 UTC (rev 53255)
+++ grass/trunk/lib/raster3d/tilewrite.c	2012-09-21 09:55:13 UTC (rev 53256)
@@ -2,8 +2,6 @@
 #include <stdlib.h>
 #include <sys/types.h>
 #include <unistd.h>
-#include <rpc/types.h>
-#include <rpc/xdr.h>
 
 #include <grass/raster.h>
 #include "raster3d_intern.h"



More information about the grass-commit mailing list