Index: include/proto_dbmi.h
===================================================================
RCS file: /grassrepository/grass6/include/proto_dbmi.h,v
retrieving revision 1.28
diff -u -r1.28 proto_dbmi.h
--- include/proto_dbmi.h	27 Jun 2007 16:31:51 -0000	1.28
+++ include/proto_dbmi.h	7 Oct 2007 20:50:35 -0000
@@ -245,19 +245,19 @@
 int         db__send_column_value     P((dbColumn *column ));
 int         db__send_datetime         P((dbDateTime *t ));
 int         db__send_double           P((double d ));
-int         db__send_double_array     P((double *x , int n ));
+int         db__send_double_array     P((const double *x , int n ));
 int         db__send_failure          P((void ));
 int         db__send_float            P((float d ));
-int         db__send_float_array      P((float *x , int n ));
+int         db__send_float_array      P((const float *x , int n ));
 int         db__send_handle           P((dbHandle *handle ));
 int         db__send_index            P((dbIndex *index ));
 int         db__send_index_array      P((dbIndex *list , int count ));
 int         db__send_int              P((int n ));
-int         db__send_int_array        P((int *x , int n ));
+int         db__send_int_array        P((const int *x , int n ));
 int         db__send_procedure_not_implemented P((int n ));
 int         db__send_procedure_ok     P((int n ));
 int         db__send_short            P((int n ));
-int         db__send_short_array      P((short *x , int n ));
+int         db__send_short_array      P((const short *x , int n ));
 int         db__send_string           P((dbString *x ));
 int         db__send_string_array     P((dbString *a , int count ));
 int         db__send_success          P((void ));
Index: lib/db/dbmi_base/xdr.c
===================================================================
RCS file: /grassrepository/grass6/lib/db/dbmi_base/xdr.c,v
retrieving revision 1.5
diff -u -r1.5 xdr.c
--- lib/db/dbmi_base/xdr.c	26 Apr 2007 16:44:44 -0000	1.5
+++ lib/db/dbmi_base/xdr.c	7 Oct 2007 20:50:35 -0000
@@ -15,47 +15,84 @@
  *****************************************************************************/
 #include "xdr.h"
 
+#ifdef __MINGW32__
+#define USE_STDIO 0
+#define USE_READN 1
+#else
+#define USE_STDIO 1
+#define USE_READN 0
+#endif
+
+#ifndef USE_STDIO
+#include <unistd.h>
+#endif
+
 static FILE *_send, *_recv;
 
-void
-db__set_protocol_fds (FILE *send, FILE *recv)
-{
-    _send = send;
-    _recv = recv;
-}
+#if USE_READN
 
-int
-xdr_begin_send(XDR *xdrs)
+static ssize_t readn(int fd, void *buf, size_t count)
 {
-    xdrstdio_create (xdrs, _send, XDR_ENCODE);
+	ssize_t total = 0;
+
+	while (total < count)
+	{
+		ssize_t n = read(fd, (char *) buf + total, count - total)
+		if (n < 0)
+			return n;
+		if (n == 0)
+			break;
+		total += n;
+	}
 
-    return 0;
+	return total;
 }
 
-int
-xdr_begin_recv(XDR *xdrs)
+static ssize_t writen(int fd, const void *buf, size_t count)
 {
-    xdrstdio_create (xdrs, _recv, XDR_DECODE);
+	ssize_t total = 0;
 
-    return 0;
+	while (total < count)
+	{
+		ssize_t n = write(fd, (const char *) buf + total, count - total)
+		if (n < 0)
+			return n;
+		if (n == 0)
+			break;
+		total += n;
+	}
+
+	return total;
 }
 
-int
-xdr_end_send(XDR *xdrs)
-{
-    fflush(_send);
-    xdr_destroy (xdrs);
+#endif
 
-    return 0;
+void
+db__set_protocol_fds (FILE *send, FILE *recv)
+{
+    _send = send;
+    _recv = recv;
 }
 
-int
-xdr_end_recv(XDR *xdrs)
+int db__send(const void *buf, size_t size)
 {
-    xdr_destroy (xdrs);
-
-    return 0;
+#if USE_STDIO
+    return fwrite(buf, 1, size, _send) == size;
+#elif USE_READN
+    return writen(fileno(_send), buf, size) == size;
+#else
+    return write(fileno(_send), buf, size) == size;
+#endif
 }
 
-
+int db__recv(void *buf, size_t size)
+{
+#if USE_STDIO
+    return fread(buf, 1, size, _recv) == size;
+#elif USE_READN
+    return readn(fileno(_recv), buf, size) == size;
+#else
+    return read(fileno(_recv), buf, size) == size;
+#endif
+}
 
Index: lib/db/dbmi_base/xdr.h
===================================================================
RCS file: /grassrepository/grass6/lib/db/dbmi_base/xdr.h,v
retrieving revision 1.5
diff -u -r1.5 xdr.h
--- lib/db/dbmi_base/xdr.h	9 Feb 2006 03:08:54 -0000	1.5
+++ lib/db/dbmi_base/xdr.h	7 Oct 2007 20:50:35 -0000
@@ -1,13 +1,6 @@
-#ifdef __MINGW32__
-#include <rpc/types.h>
-#include <rpc/xdr.h>
-#else
-#include <rpc/rpc.h>
-#endif
-
+#include <stdio.h>
 #include <grass/dbmi.h>
 
-int xdr_begin_send(XDR *xdrs);
-int xdr_begin_recv(XDR *xdrs);
-int xdr_end_send(XDR *xdrs);
-int xdr_end_recv(XDR *xdrs);
+extern int db__send(const void *, size_t);
+extern int db__recv(void *, size_t);
+
Index: lib/db/dbmi_base/xdrchar.c
===================================================================
RCS file: /grassrepository/grass6/lib/db/dbmi_base/xdrchar.c,v
retrieving revision 1.2
diff -u -r1.2 xdrchar.c
--- lib/db/dbmi_base/xdrchar.c	5 Oct 2006 06:13:28 -0000	1.2
+++ lib/db/dbmi_base/xdrchar.c	7 Oct 2007 20:50:35 -0000
@@ -4,17 +4,11 @@
 int
 db__send_char(int d)
 {
-    XDR xdrs;
-    int stat;
-    char c;
+    int stat = DB_OK;
+    char c = (char) d;
 
-    stat = DB_OK;
-    c = d;
-
-    xdr_begin_send (&xdrs);
-    if(!xdr_char (&xdrs, &c))
+    if (!db__send(&c, sizeof(c)))
 	stat = DB_PROTOCOL_ERR;
-    xdr_end_send (&xdrs);
 
     if (stat == DB_PROTOCOL_ERR)
 	db_protocol_error();
@@ -26,14 +20,10 @@
 int
 db__recv_char (char *d)
 {
-    XDR xdrs;
-    int stat;
+    int stat = DB_OK;
 
-    stat = DB_OK;
-    xdr_begin_recv (&xdrs);
-    if(!xdr_char (&xdrs, d))
+    if (!db__recv(d, sizeof(*d)))
 	stat = DB_PROTOCOL_ERR;
-    xdr_end_recv (&xdrs);
 
     if (stat == DB_PROTOCOL_ERR)
 	db_protocol_error();
Index: lib/db/dbmi_base/xdrdouble.c
===================================================================
RCS file: /grassrepository/grass6/lib/db/dbmi_base/xdrdouble.c,v
retrieving revision 1.2
diff -u -r1.2 xdrdouble.c
--- lib/db/dbmi_base/xdrdouble.c	5 Oct 2006 06:13:28 -0000	1.2
+++ lib/db/dbmi_base/xdrdouble.c	7 Oct 2007 20:50:35 -0000
@@ -1,20 +1,13 @@
-#include <stdlib.h>
 #include "xdr.h"
 
 
 int
-db__send_double(d)
-    double d;
+db__send_double(double d)
 {
-    XDR xdrs;
-    int stat;
+    int stat = DB_OK;
 
-    stat = DB_OK;
-
-    xdr_begin_send (&xdrs);
-    if(!xdr_double (&xdrs, &d))
+    if (!db__send(&d, sizeof(d)))
 	stat = DB_PROTOCOL_ERR;
-    xdr_end_send (&xdrs);
 
     if (stat == DB_PROTOCOL_ERR)
 	db_protocol_error();
@@ -25,14 +18,10 @@
 int
 db__recv_double (double *d)
 {
-    XDR xdrs;
-    int stat;
+    int stat = DB_OK;
 
-    stat = DB_OK;
-    xdr_begin_recv (&xdrs);
-    if(!xdr_double (&xdrs, d))
+    if (!db__recv(d, sizeof(*d)))
 	stat = DB_PROTOCOL_ERR;
-    xdr_end_recv (&xdrs);
 
     if (stat == DB_PROTOCOL_ERR)
 	db_protocol_error();
@@ -42,27 +31,15 @@
 
 
 int
-db__send_double_array (double *x, int n)
+db__send_double_array (const double *x, int n)
 {
-    XDR xdrs;
-    int i;
-    int stat;
-
-    stat = DB_OK;
+    int stat = DB_OK;
 
-    xdr_begin_send (&xdrs);
-
-    if(!xdr_int (&xdrs, &n))
+    if (!db__send(&n, sizeof(n)))
 	stat = DB_PROTOCOL_ERR;
 
-    for (i = 0; stat == DB_OK && i < n; i++)
-    {
-	if(!xdr_double (&xdrs, x))
-	    stat = DB_PROTOCOL_ERR;
-	x++;
-    }
-
-    xdr_end_send (&xdrs);
+    if (!db__send(x, n * sizeof(*x)))
+	stat = DB_PROTOCOL_ERR;
 
     if (stat == DB_PROTOCOL_ERR)
 	db_protocol_error();
@@ -75,50 +52,22 @@
 int
 db__recv_double_array (double **x, int *n)
 {
-    XDR xdrs;
-    int i, count, stat;
-    double y, *a;
-
-    *x = NULL;
-    *n = 0;
-
-    stat = DB_OK;
-    xdr_begin_recv (&xdrs);
-    if (xdr_int (&xdrs, &count))
-    {
-	if (count <= 0)
-	    stat = DB_PROTOCOL_ERR;
-	a = (double *)db_calloc (count, sizeof (double));
-	if (a == NULL && stat == DB_OK)
-	    stat = DB_MEMORY_ERR;
-
-	for (i = 0; i < count; i++)
-	{
-	    if (!xdr_double (&xdrs, &y))
-	    {
-		stat = DB_PROTOCOL_ERR;
-		break;
-	    }
-	    if (a) a[i] = y;
-	}
-	if (stat != DB_OK)
-	{
-	    if (a != NULL) free(a);
-	    a = NULL;
-	}
-    }
-    else
-	stat = DB_PROTOCOL_ERR;
-
-    if (stat == DB_OK)
-    {
-	*x = a;
-	*n = count;
-    }
-    else if (stat == DB_PROTOCOL_ERR)
-	db_protocol_error();
+    int stat = DB_OK;
+    int count = 0;
+    double *a = NULL;
+
+    if (!db__recv(&count, sizeof(count)))
+	stat = DB_PROTOCOL_ERR;
+
+    *n = count;
 
-    xdr_end_recv (&xdrs);
+    *x = a = (double *) db_calloc(count, sizeof(*a));
+
+    if (!db__recv(a, count * sizeof(*a)))
+	stat = DB_PROTOCOL_ERR;
+
+    if (stat == DB_PROTOCOL_ERR)
+	db_protocol_error();
 
     return stat;
 }
Index: lib/db/dbmi_base/xdrfloat.c
===================================================================
RCS file: /grassrepository/grass6/lib/db/dbmi_base/xdrfloat.c,v
retrieving revision 1.1
diff -u -r1.1 xdrfloat.c
--- lib/db/dbmi_base/xdrfloat.c	22 May 2003 13:58:00 -0000	1.1
+++ lib/db/dbmi_base/xdrfloat.c	7 Oct 2007 20:50:35 -0000
@@ -1,113 +1,74 @@
-#include <stdlib.h>
 #include "xdr.h"
 
-int db__send_float(float d)
-{
-    XDR xdrs;
-    int stat;
 
-    stat = DB_OK;
+int
+db__send_float(float d)
+{
+    int stat = DB_OK;
 
-    xdr_begin_send (&xdrs);
-    if(!xdr_float (&xdrs, &d))
+    if (!db__send(&d, sizeof(d)))
 	stat = DB_PROTOCOL_ERR;
-    xdr_end_send (&xdrs);
 
     if (stat == DB_PROTOCOL_ERR)
 	db_protocol_error();
+
     return stat;
 }
 
-int db__recv_float (float *d)
+int
+db__recv_float (float *d)
 {
-    XDR xdrs;
-    int stat;
+    int stat = DB_OK;
 
-    stat = DB_OK;
-    xdr_begin_recv (&xdrs);
-    if(!xdr_float (&xdrs, d))
+    if (!db__recv(d, sizeof(*d)))
 	stat = DB_PROTOCOL_ERR;
-    xdr_end_recv (&xdrs);
 
     if (stat == DB_PROTOCOL_ERR)
 	db_protocol_error();
+
     return stat;
 }
 
-int db__send_float_array (float *x, int n)
-{
-    XDR xdrs;
-    int i;
-    int stat;
-
-    stat = DB_OK;
 
-    xdr_begin_send (&xdrs);
+int
+db__send_float_array (const float *x, int n)
+{
+    int stat = DB_OK;
 
-    if(!xdr_int (&xdrs, &n))
+    if (!db__send(&n, sizeof(n)))
 	stat = DB_PROTOCOL_ERR;
-    for (i = 0; stat == DB_OK && i < n; i++)
-    {
-	if(!xdr_float (&xdrs, x))
-	    stat = DB_PROTOCOL_ERR;
-	x++;
-    }
 
-    xdr_end_send (&xdrs);
+    if (!db__send(x, n * sizeof(*x)))
+	stat = DB_PROTOCOL_ERR;
 
     if (stat == DB_PROTOCOL_ERR)
 	db_protocol_error();
+
     return stat;
 }
 
 /* returns an allocated array of floats */
 /* caller is responsible for free() */
-
-int db__recv_float_array (float **x, int *n)
+int
+db__recv_float_array (float **x, int *n)
 {
-    XDR xdrs;
-    int i, count, stat;
-    float y, *a;
-
-    *x = NULL;
-    *n = 0;
-
-    stat = DB_OK;
-    xdr_begin_recv (&xdrs);
-    if (xdr_int (&xdrs, &count))
-    {
-	if (count <= 0)
-	    stat = DB_PROTOCOL_ERR;
-	a = (float *)db_calloc (count, sizeof (float));
-	if (a == NULL && stat == DB_OK)
-	    stat = DB_MEMORY_ERR;
-
-	for (i = 0; i < count; i++)
-	{
-	    if (!xdr_float (&xdrs, &y))
-	    {
-		stat = DB_PROTOCOL_ERR;
-		break;
-	    }
-	    if (a) a[i] = y;
-	}
-	if (stat != DB_OK)
-	{
-	    if (a != NULL) free(a);
-	    a = NULL;
-	}
-    }
-    else
-	stat = DB_PROTOCOL_ERR;
-
-    if (stat == DB_OK)
-    {
-	*x = a;
-	*n = count;
-    }
-    else if (stat == DB_PROTOCOL_ERR)
+    int stat = DB_OK;
+    int count = 0;
+    float *a = NULL;
+
+    if (!db__recv(&count, sizeof(count)))
+	stat = DB_PROTOCOL_ERR;
+
+    *n = count;
+
+    *x = a = (float *) db_calloc(count, sizeof(*a));
+
+    if (!db__recv(a, count * sizeof(*a)))
+	stat = DB_PROTOCOL_ERR;
+
+    if (stat == DB_PROTOCOL_ERR)
 	db_protocol_error();
 
-    xdr_end_recv (&xdrs);
     return stat;
 }
+
Index: lib/db/dbmi_base/xdrint.c
===================================================================
RCS file: /grassrepository/grass6/lib/db/dbmi_base/xdrint.c,v
retrieving revision 1.2
diff -u -r1.2 xdrint.c
--- lib/db/dbmi_base/xdrint.c	5 Oct 2006 06:13:28 -0000	1.2
+++ lib/db/dbmi_base/xdrint.c	7 Oct 2007 20:50:35 -0000
@@ -1,37 +1,27 @@
-#include <stdlib.h>
 #include "xdr.h"
 
 
 int
 db__send_int(int n)
 {
-    XDR xdrs;
-    int stat;
+    int stat = DB_OK;
 
-    stat = DB_OK;
-
-    xdr_begin_send (&xdrs);
-    if(!xdr_int (&xdrs, &n))
+    if (!db__send(&n, sizeof(n)))
 	stat = DB_PROTOCOL_ERR;
-    xdr_end_send (&xdrs);
 
     if (stat == DB_PROTOCOL_ERR)
 	db_protocol_error();
+
     return stat;
 }
 
 int
 db__recv_int (int *n)
 {
-    XDR xdrs;
-    int stat;
+    int stat = DB_OK;
 
-    stat = DB_OK;
-
-    xdr_begin_recv (&xdrs);
-    if(!xdr_int (&xdrs, n))
+    if (!db__recv(n, sizeof(*n)))
 	stat = DB_PROTOCOL_ERR;
-    xdr_end_recv (&xdrs);
 
     if (stat == DB_PROTOCOL_ERR)
 	db_protocol_error();
@@ -40,28 +30,19 @@
 }
 
 int
-db__send_int_array (int *x, int n)
+db__send_int_array (const int *x, int n)
 {
-    XDR xdrs;
-    int i;
-    int stat;
-
-    stat = DB_OK;
-
-    xdr_begin_send (&xdrs);
-    if(!xdr_int (&xdrs, &n))
-	stat = DB_PROTOCOL_ERR;
-    for (i = 0; stat == DB_OK && i < n; i++)
-    {
-	if(!xdr_int (&xdrs, x))
-	    stat = DB_PROTOCOL_ERR;
-	x++;
-    }
+    int stat = DB_OK;
+
+    if (!db__send(&n, sizeof(n)))
+	stat = DB_PROTOCOL_ERR;
 
-    xdr_end_send (&xdrs);
+    if (!db__send(x, n * sizeof(*x)))
+	stat = DB_PROTOCOL_ERR;
 
     if (stat == DB_PROTOCOL_ERR)
 	db_protocol_error();
+
     return stat;
 }
 
@@ -70,51 +51,22 @@
 int
 db__recv_int_array (int **x, int *n)
 {
-    XDR xdrs;
-    int i, count, stat;
-    int y, *a;
-
-    *x = NULL;
-    *n = 0;
-
-    stat = DB_OK;
-    xdr_begin_recv (&xdrs);
-    if (xdr_int (&xdrs, &count))
-    {
-	if (count <= 0)
-	    stat = DB_PROTOCOL_ERR;
-
-	a = (int *)db_calloc (count, sizeof (int));
-	if (a == NULL && stat == DB_OK)
-	    stat = DB_MEMORY_ERR;
-
-	for (i = 0; i < count; i++)
-	{
-	    if (!xdr_int (&xdrs, &y))
-	    {
-		stat = DB_PROTOCOL_ERR;
-		break;
-	    }
-	    if (a) a[i] = y;
-	}
-	if (stat != DB_OK)
-	{
-	    if (a != NULL) free(a);
-	    a = NULL;
-	}
-    }
-    else
-	stat = DB_PROTOCOL_ERR;
-
-    if (stat == DB_OK)
-    {
-	*x = a;
-	*n = count;
-    }
-    else if (stat == DB_PROTOCOL_ERR)
-	db_protocol_error();
+    int stat = DB_OK;
+    int count = 0;
+    int *a = NULL;
 
-    xdr_end_recv (&xdrs);
+    if (!db__recv(&count, sizeof(count)))
+	stat = DB_PROTOCOL_ERR;
+
+    *n = count;
+
+    *x = a = (int *) db_calloc(count, sizeof(*a));
+
+    if (!db__recv(a, count * sizeof(*a)))
+	stat = DB_PROTOCOL_ERR;
+
+    if (stat == DB_PROTOCOL_ERR)
+	db_protocol_error();
 
     return stat;
 }
Index: lib/db/dbmi_base/xdrprocedure.c
===================================================================
RCS file: /grassrepository/grass6/lib/db/dbmi_base/xdrprocedure.c,v
retrieving revision 1.2
diff -u -r1.2 xdrprocedure.c
--- lib/db/dbmi_base/xdrprocedure.c	5 Oct 2006 06:13:28 -0000	1.2
+++ lib/db/dbmi_base/xdrprocedure.c	7 Oct 2007 20:50:35 -0000
@@ -35,15 +35,10 @@
 int
 db__recv_procnum (int *n)
 {
-    XDR xdrs;
-    int stat;
+    int stat = DB_OK;
 
-    stat = DB_OK;
-
-    xdr_begin_recv (&xdrs);
-    if(!xdr_int (&xdrs, n))
+    if (!db__recv(n, sizeof(*n)))
 	stat = DB_EOF;
-    xdr_end_recv (&xdrs);
 
     return stat;
 }
Index: lib/db/dbmi_base/xdrshort.c
===================================================================
RCS file: /grassrepository/grass6/lib/db/dbmi_base/xdrshort.c,v
retrieving revision 1.2
diff -u -r1.2 xdrshort.c
--- lib/db/dbmi_base/xdrshort.c	5 Oct 2006 06:13:28 -0000	1.2
+++ lib/db/dbmi_base/xdrshort.c	7 Oct 2007 20:50:35 -0000
@@ -5,18 +5,11 @@
 int
 db__send_short(int n)
 {
-    XDR xdrs;
-    int stat;
-    short h;
+    int stat = DB_OK;
+    short h = (short) n;
 
-    h = n;
-
-    stat = DB_OK;
-
-    xdr_begin_send (&xdrs);
-    if(!xdr_short (&xdrs, &h))
+    if (!db__send(&h, sizeof(h)))
 	stat = DB_PROTOCOL_ERR;
-    xdr_end_send (&xdrs);
 
     if (stat == DB_PROTOCOL_ERR)
 	db_protocol_error();
@@ -27,15 +20,10 @@
 int
 db__recv_short (short *n)
 {
-    XDR xdrs;
-    int stat;
+    int stat = DB_OK;
 
-    stat = DB_OK;
-
-    xdr_begin_recv (&xdrs);
-    if(!xdr_short (&xdrs, n))
+    if (!db__recv(n, sizeof(*n)))
 	stat = DB_PROTOCOL_ERR;
-    xdr_end_recv (&xdrs);
 
     if (stat == DB_PROTOCOL_ERR)
 	db_protocol_error();
@@ -44,25 +32,15 @@
 }
 
 int
-db__send_short_array (short *x, int n)
+db__send_short_array (const short *x, int n)
 {
-    XDR xdrs;
-    int i;
-    int stat;
-
-    stat = DB_OK;
-
-    xdr_begin_send (&xdrs);
-    if(!xdr_int (&xdrs, &n))
-	stat = DB_PROTOCOL_ERR;
-    for (i = 0; stat == DB_OK && i < n; i++)
-    {
-	if(!xdr_short (&xdrs, x))
-	    stat = DB_PROTOCOL_ERR;
-	x++;
-    }
+    int stat = DB_OK;
+
+    if (!db__send(&n, sizeof(n)))
+	stat = DB_PROTOCOL_ERR;
 
-    xdr_end_send (&xdrs);
+    if (!db__send(x, n * sizeof(*x)))
+	stat = DB_PROTOCOL_ERR;
 
     if (stat == DB_PROTOCOL_ERR)
 	db_protocol_error();
@@ -70,56 +48,28 @@
     return stat;
 }
 
-/* returns an allocated array of shorts */
+/* returns an allocated array of ints */
 /* caller is responsible for free() */
 int
 db__recv_short_array (short **x, int *n)
 {
-    XDR xdrs;
-    int i, count, stat;
-    short y, *a;
-
-    *x = NULL;
-    *n = 0;
-
-    stat = DB_OK;
-    xdr_begin_recv (&xdrs);
-    if (xdr_int (&xdrs, &count))
-    {
-	if (count <= 0)
-	    stat = DB_PROTOCOL_ERR;
-
-	a = (short *)db_calloc (count, sizeof (short));
-	if (a == NULL && stat == DB_OK)
-	    stat = DB_MEMORY_ERR;
-
-	for (i = 0; i < count; i++)
-	{
-	    if (!xdr_short (&xdrs, &y))
-	    {
-		stat = DB_PROTOCOL_ERR;
-		break;
-	    }
-	    if (a) a[i] = y;
-	}
-	if (stat != DB_OK)
-	{
-	    if (a != NULL) free(a);
-	    a = NULL;
-	}
-    }
-    else
-	stat = DB_PROTOCOL_ERR;
-
-    if (stat == DB_OK)
-    {
-	*x = a;
-	*n = count;
-    }
-    else if (stat == DB_PROTOCOL_ERR)
-	db_protocol_error();
+    int stat = DB_OK;
+    int count = 0;
+    short *a = NULL;
+
+    if (!db__recv(&count, sizeof(count)))
+	stat = DB_PROTOCOL_ERR;
+
+    *n = count;
+
+    *x = a = (short *) db_calloc(count, sizeof(*a));
+
+    if (!db__recv(a, count * sizeof(*a)))
+	stat = DB_PROTOCOL_ERR;
 
-    xdr_end_recv (&xdrs);
+    if (stat == DB_PROTOCOL_ERR)
+	db_protocol_error();
 
     return stat;
 }
+
Index: lib/db/dbmi_base/xdrstring.c
===================================================================
RCS file: /grassrepository/grass6/lib/db/dbmi_base/xdrstring.c,v
retrieving revision 1.2
diff -u -r1.2 xdrstring.c
--- lib/db/dbmi_base/xdrstring.c	5 Oct 2006 06:13:28 -0000	1.2
+++ lib/db/dbmi_base/xdrstring.c	7 Oct 2007 20:50:35 -0000
@@ -1,5 +1,4 @@
 #include <string.h>
-#include <stdlib.h>
 #include "xdr.h"
 
 
@@ -57,24 +56,18 @@
 int
 db__send_string(dbString *x)
 {
-    XDR xdrs;
-    int len;
-    int stat;
-    char *s;
-
+    int stat = DB_OK;
+    const char *s = db_get_string(x);
+    int len = s ? strlen(s) + 1 : 1;
 
-    stat = DB_OK;
+    if (!s)
+	s = "";		/* don't send a NULL string */
 
-    s = db_get_string (x);
-    if (s == NULL) s = "";  /* can't send a NULL string */
-    len = strlen(s)+1;
-
-    xdr_begin_send (&xdrs);
-    if(!xdr_int (&xdrs, &len))
+    if (!db__send(&len, sizeof(len)))
 	stat = DB_PROTOCOL_ERR;
-    else if(!xdr_string (&xdrs, &s, len))
+
+    if (!db__send(s, len))
 	stat = DB_PROTOCOL_ERR;
-    xdr_end_send (&xdrs);
 
     if (stat == DB_PROTOCOL_ERR)
 	db_protocol_error();
@@ -94,27 +87,24 @@
 int
 db__recv_string(dbString *x)
 {
-    XDR xdrs;
+    int stat = DB_OK;
     int len;
-    int stat;
     char *s;
 
-    stat = DB_OK;
-    xdr_begin_recv (&xdrs);
-    if(!xdr_int (&xdrs, &len) || len <= 0)  /* len will include the null byte */
-    {
+    if (!db__recv(&len, sizeof(len)))
+	stat = DB_PROTOCOL_ERR;
+
+    if (len <= 0)  /* len will include the null byte */
+	stat = DB_PROTOCOL_ERR;
+
+    if (db_enlarge_string(x, len) != DB_OK)
 	stat = DB_PROTOCOL_ERR;
-    }
-    else
-    {
-	stat = db_enlarge_string (x, len);
-    }
 
     s = db_get_string(x);
-    if(stat == DB_OK && !xdr_string (&xdrs, &s, len))
+
+    if (!db__recv(s, len))
 	stat = DB_PROTOCOL_ERR;
 
-    xdr_end_recv (&xdrs);
     if (stat == DB_PROTOCOL_ERR)
 	db_protocol_error();
 
