[GRASS-SVN] r53219 - in grass/trunk: include/defs lib/gis lib/raster

svn_grass at osgeo.org svn_grass at osgeo.org
Tue Sep 18 14:03:13 PDT 2012


Author: glynn
Date: 2012-09-18 14:03:13 -0700 (Tue, 18 Sep 2012)
New Revision: 53219

Added:
   grass/trunk/lib/gis/xdr.c
Removed:
   grass/trunk/lib/raster/xdr.c
Modified:
   grass/trunk/include/defs/gis.h
   grass/trunk/include/defs/raster.h
   grass/trunk/lib/gis/G.h
   grass/trunk/lib/gis/gisinit.c
   grass/trunk/lib/raster/R.h
   grass/trunk/lib/raster/get_row.c
   grass/trunk/lib/raster/init.c
   grass/trunk/lib/raster/put_row.c
   grass/trunk/lib/raster/range.c
Log:
Move XDR functions from lib/raster to lib/gis


Modified: grass/trunk/include/defs/gis.h
===================================================================
--- grass/trunk/include/defs/gis.h	2012-09-18 20:39:43 UTC (rev 53218)
+++ grass/trunk/include/defs/gis.h	2012-09-18 21:03:13 UTC (rev 53219)
@@ -724,6 +724,12 @@
 /* writ_zeros.c */
 void G_write_zeros(int, size_t);
 
+/* xdr.c */
+void G_xdr_get_float(float *, const void *);
+void G_xdr_put_float(void *, const float *);
+void G_xdr_get_double(double *, const void *);
+void G_xdr_put_double(void *, const double *);
+
 /* zero.c */
 void G_zero(void *, int);
 

Modified: grass/trunk/include/defs/raster.h
===================================================================
--- grass/trunk/include/defs/raster.h	2012-09-18 20:39:43 UTC (rev 53218)
+++ grass/trunk/include/defs/raster.h	2012-09-18 21:03:13 UTC (rev 53219)
@@ -578,12 +578,6 @@
 void Rast__create_window_mapping(int);
 int Rast_row_repeat_nomask(int, int);
 
-/* xdr.c */
-void Rast_xdr_get_float(float *, const void *);
-void Rast_xdr_put_float(void *, const float *);
-void Rast_xdr_get_double(double *, const void *);
-void Rast_xdr_put_double(void *, const double *);
-
 /* zero_cell.c */
 void Rast_zero_buf(void *, RASTER_MAP_TYPE);
 void Rast_zero_input_buf(void *, RASTER_MAP_TYPE);

Modified: grass/trunk/lib/gis/G.h
===================================================================
--- grass/trunk/lib/gis/G.h	2012-09-18 20:39:43 UTC (rev 53218)
+++ grass/trunk/lib/gis/G.h	2012-09-18 21:03:13 UTC (rev 53219)
@@ -5,6 +5,7 @@
 {
     struct Cell_head window;	/* Contains the current window          */
     int window_set;		/* Flag: window set?                    */
+    int little_endian;          /* Flag denoting little-endian architecture */
 };
 
 extern struct G__ G__;		/* allocated in gisinit */

Modified: grass/trunk/lib/gis/gisinit.c
===================================================================
--- grass/trunk/lib/gis/gisinit.c	2012-09-18 20:39:43 UTC (rev 53218)
+++ grass/trunk/lib/gis/gisinit.c	2012-09-18 21:03:13 UTC (rev 53219)
@@ -108,6 +108,9 @@
     /* Mark window as not set */
     G__.window_set = 0;
 
+    /* byte order */
+    G__.little_endian = G_is_little_endian();
+
     initialized = 1;
 
     setlocale(LC_NUMERIC, "C");

Copied: grass/trunk/lib/gis/xdr.c (from rev 53215, grass/trunk/lib/raster/xdr.c)
===================================================================
--- grass/trunk/lib/gis/xdr.c	                        (rev 0)
+++ grass/trunk/lib/gis/xdr.c	2012-09-18 21:03:13 UTC (rev 53219)
@@ -0,0 +1,57 @@
+
+#include <stdlib.h>
+#include <string.h>
+#include <grass/gis.h>
+
+#include "G.h"
+
+static void swap_float(void *dstp, const void *srcp) {
+    unsigned char *dst = (unsigned char *) dstp;
+    const unsigned char *src = (const unsigned char *) srcp;
+    if (G__.little_endian) {
+	dst[0] = src[3];
+	dst[1] = src[2];
+	dst[2] = src[1];
+	dst[3] = src[0];
+    }
+    else
+	memcpy(dst, src, 4);
+}
+
+static void swap_double(void *dstp, const void *srcp) {
+    unsigned char *dst = (unsigned char *) dstp;
+    const unsigned char *src = (const unsigned char *) srcp;
+    if (G__.little_endian) {
+	dst[0] = src[7];
+	dst[1] = src[6];
+	dst[2] = src[5];
+	dst[3] = src[4];
+	dst[4] = src[3];
+	dst[5] = src[2];
+	dst[6] = src[1];
+	dst[7] = src[0];
+    }
+    else
+	memcpy(dst, src, 8);
+}
+
+void G_xdr_get_float(float *dst, const void *src)
+{
+    swap_float(dst, src);
+}
+
+void G_xdr_put_float(void *dst, const float *src)
+{
+    swap_float(dst, src);
+}
+
+void G_xdr_get_double(double *dst, const void *src)
+{
+    swap_double(dst, src);
+}
+
+void G_xdr_put_double(void *dst, const double *src)
+{
+    swap_double(dst, src);
+}
+

Modified: grass/trunk/lib/raster/R.h
===================================================================
--- grass/trunk/lib/raster/R.h	2012-09-18 20:39:43 UTC (rev 53218)
+++ grass/trunk/lib/raster/R.h	2012-09-18 21:03:13 UTC (rev 53219)
@@ -71,7 +71,6 @@
 
 struct R__			/*  Structure of library globals */
 {
-    int little_endian;          /* Flag denoting little-endian architecture */
     RASTER_MAP_TYPE fp_type;	/* type for writing floating maps */
     int mask_fd;		/* File descriptor for automatic mask   */
     int auto_mask;		/* Flag denoting automatic masking      */

Modified: grass/trunk/lib/raster/get_row.c
===================================================================
--- grass/trunk/lib/raster/get_row.c	2012-09-18 20:39:43 UTC (rev 53218)
+++ grass/trunk/lib/raster/get_row.c	2012-09-18 21:03:13 UTC (rev 53219)
@@ -292,7 +292,7 @@
 	    continue;
 	}
 
-	Rast_xdr_get_float(&c[i], &work_buf[cmap[i]-1]);
+	G_xdr_get_float(&c[i], &work_buf[cmap[i]-1]);
     }
 }
 
@@ -311,7 +311,7 @@
 	    continue;
 	}
 
-	Rast_xdr_get_double(&c[i], &work_buf[cmap[i]-1]);
+	G_xdr_get_double(&c[i], &work_buf[cmap[i]-1]);
     }
 }
 

Modified: grass/trunk/lib/raster/init.c
===================================================================
--- grass/trunk/lib/raster/init.c	2012-09-18 20:39:43 UTC (rev 53218)
+++ grass/trunk/lib/raster/init.c	2012-09-18 21:03:13 UTC (rev 53219)
@@ -79,9 +79,6 @@
 {
     Rast__init_window();
 
-    /* byte order */
-    R__.little_endian = G_is_little_endian();
-
     /* no histograms */
     R__.want_histogram = 0;
 

Modified: grass/trunk/lib/raster/put_row.c
===================================================================
--- grass/trunk/lib/raster/put_row.c	2012-09-18 20:39:43 UTC (rev 53218)
+++ grass/trunk/lib/raster/put_row.c	2012-09-18 21:03:13 UTC (rev 53219)
@@ -154,7 +154,7 @@
 	else
 	    f = rast[i];
 
-	Rast_xdr_put_float(&work_buf[i], &f);
+	G_xdr_put_float(&work_buf[i], &f);
     }
 }
 
@@ -174,7 +174,7 @@
 	else
 	    d = rast[i];
 
-	Rast_xdr_put_double(&work_buf[i], &d);
+	G_xdr_put_double(&work_buf[i], &d);
     }
 }
 

Modified: grass/trunk/lib/raster/range.c
===================================================================
--- grass/trunk/lib/raster/range.c	2012-09-18 20:39:43 UTC (rev 53218)
+++ grass/trunk/lib/raster/range.c	2012-09-18 21:03:13 UTC (rev 53219)
@@ -112,8 +112,8 @@
 	    return 2;
 	}
 
-	Rast_xdr_get_double(&dcell1, xdr_buf[0]);
-	Rast_xdr_get_double(&dcell2, xdr_buf[1]);
+	G_xdr_get_double(&dcell1, xdr_buf[0]);
+	G_xdr_get_double(&dcell2, xdr_buf[1]);
 
 	Rast_update_fp_range(dcell1, drange);
 	Rast_update_fp_range(dcell2, drange);
@@ -303,8 +303,8 @@
 	return;
     }
 
-    Rast_xdr_put_double(xdr_buf[0], &range->min);
-    Rast_xdr_put_double(xdr_buf[1], &range->max);
+    G_xdr_put_double(xdr_buf[0], &range->min);
+    G_xdr_put_double(xdr_buf[1], &range->max);
 
     if (write(fd, xdr_buf, sizeof(xdr_buf)) != sizeof(xdr_buf)) {
 	G_remove_misc("cell_misc", "f_range", name);

Deleted: grass/trunk/lib/raster/xdr.c
===================================================================
--- grass/trunk/lib/raster/xdr.c	2012-09-18 20:39:43 UTC (rev 53218)
+++ grass/trunk/lib/raster/xdr.c	2012-09-18 21:03:13 UTC (rev 53219)
@@ -1,57 +0,0 @@
-
-#include <stdlib.h>
-#include <string.h>
-#include <grass/raster.h>
-
-#include "R.h"
-
-static void swap_float(void *dstp, const void *srcp) {
-    unsigned char *dst = (unsigned char *) dstp;
-    const unsigned char *src = (const unsigned char *) srcp;
-    if (R__.little_endian) {
-	dst[0] = src[3];
-	dst[1] = src[2];
-	dst[2] = src[1];
-	dst[3] = src[0];
-    }
-    else
-	memcpy(dst, src, 4);
-}
-
-static void swap_double(void *dstp, const void *srcp) {
-    unsigned char *dst = (unsigned char *) dstp;
-    const unsigned char *src = (const unsigned char *) srcp;
-    if (R__.little_endian) {
-	dst[0] = src[7];
-	dst[1] = src[6];
-	dst[2] = src[5];
-	dst[3] = src[4];
-	dst[4] = src[3];
-	dst[5] = src[2];
-	dst[6] = src[1];
-	dst[7] = src[0];
-    }
-    else
-	memcpy(dst, src, 8);
-}
-
-void Rast_xdr_get_float(float *dst, const void *src)
-{
-    swap_float(dst, src);
-}
-
-void Rast_xdr_put_float(void *dst, const float *src)
-{
-    swap_float(dst, src);
-}
-
-void Rast_xdr_get_double(double *dst, const void *src)
-{
-    swap_double(dst, src);
-}
-
-void Rast_xdr_put_double(void *dst, const double *src)
-{
-    swap_double(dst, src);
-}
-



More information about the grass-commit mailing list