[GRASS-SVN] r53235 - in grass/trunk: include/defs lib/gis
svn_grass at osgeo.org
svn_grass at osgeo.org
Wed Sep 19 06:59:24 PDT 2012
Author: glynn
Date: 2012-09-19 06:59:23 -0700 (Wed, 19 Sep 2012)
New Revision: 53235
Modified:
grass/trunk/include/defs/gis.h
grass/trunk/lib/gis/xdr.c
Log:
Add XDR functions for int
Modified: grass/trunk/include/defs/gis.h
===================================================================
--- grass/trunk/include/defs/gis.h 2012-09-19 13:09:05 UTC (rev 53234)
+++ grass/trunk/include/defs/gis.h 2012-09-19 13:59:23 UTC (rev 53235)
@@ -725,6 +725,8 @@
void G_write_zeros(int, size_t);
/* xdr.c */
+void G_xdr_get_int(int *, const void *);
+void G_xdr_put_int(void *, const int *);
void G_xdr_get_float(float *, const void *);
void G_xdr_put_float(void *, const float *);
void G_xdr_get_double(double *, const void *);
Modified: grass/trunk/lib/gis/xdr.c
===================================================================
--- grass/trunk/lib/gis/xdr.c 2012-09-19 13:09:05 UTC (rev 53234)
+++ grass/trunk/lib/gis/xdr.c 2012-09-19 13:59:23 UTC (rev 53235)
@@ -5,6 +5,19 @@
#include "G.h"
+static void swap_int(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_float(void *dstp, const void *srcp) {
unsigned char *dst = (unsigned char *) dstp;
const unsigned char *src = (const unsigned char *) srcp;
@@ -35,6 +48,16 @@
memcpy(dst, src, 8);
}
+void G_xdr_get_int(int *dst, const void *src)
+{
+ swap_int(dst, src);
+}
+
+void G_xdr_put_int(void *dst, const int *src)
+{
+ swap_int(dst, src);
+}
+
void G_xdr_get_float(float *dst, const void *src)
{
swap_float(dst, src);
More information about the grass-commit
mailing list