00001 #include <stdlib.h>
00002 #include "xdr.h"
00003
00004 db__send_double(d)
00005 double d;
00006 {
00007 XDR xdrs;
00008 int stat;
00009
00010 stat = DB_OK;
00011
00012 xdr_begin_send (&xdrs);
00013 if(!xdr_double (&xdrs, &d))
00014 stat = DB_PROTOCOL_ERR;
00015 xdr_end_send (&xdrs);
00016
00017 if (stat == DB_PROTOCOL_ERR)
00018 db_protocol_error();
00019 return stat;
00020 }
00021
00022 db__recv_double (d)
00023 double *d;
00024 {
00025 XDR xdrs;
00026 int stat;
00027
00028 stat = DB_OK;
00029 xdr_begin_recv (&xdrs);
00030 if(!xdr_double (&xdrs, d))
00031 stat = DB_PROTOCOL_ERR;
00032 xdr_end_recv (&xdrs);
00033
00034 if (stat == DB_PROTOCOL_ERR)
00035 db_protocol_error();
00036 return stat;
00037 }
00038
00039 db__send_double_array (x, n)
00040 double *x;
00041 int n;
00042 {
00043 XDR xdrs;
00044 int i;
00045 int stat;
00046
00047 stat = DB_OK;
00048
00049 xdr_begin_send (&xdrs);
00050
00051 if(!xdr_int (&xdrs, &n))
00052 stat = DB_PROTOCOL_ERR;
00053 for (i = 0; stat == DB_OK && i < n; i++)
00054 {
00055 if(!xdr_double (&xdrs, x))
00056 stat = DB_PROTOCOL_ERR;
00057 x++;
00058 }
00059
00060 xdr_end_send (&xdrs);
00061
00062 if (stat == DB_PROTOCOL_ERR)
00063 db_protocol_error();
00064 return stat;
00065 }
00066
00067
00068
00069
00070 db__recv_double_array (x, n)
00071 double **x;
00072 int *n;
00073 {
00074 XDR xdrs;
00075 int i, count, stat;
00076 double y, *a;
00077
00078 *x = NULL;
00079 *n = 0;
00080
00081 stat = DB_OK;
00082 xdr_begin_recv (&xdrs);
00083 if (xdr_int (&xdrs, &count))
00084 {
00085 if (count <= 0)
00086 stat = DB_PROTOCOL_ERR;
00087 a = (double *)db_calloc (count, sizeof (double));
00088 if (a == NULL && stat == DB_OK)
00089 stat = DB_MEMORY_ERR;
00090
00091 for (i = 0; i < count; i++)
00092 {
00093 if (!xdr_double (&xdrs, &y))
00094 {
00095 stat = DB_PROTOCOL_ERR;
00096 break;
00097 }
00098 if (a) a[i] = y;
00099 }
00100 if (stat != DB_OK)
00101 {
00102 if (a != NULL) free(a);
00103 a = NULL;
00104 }
00105 }
00106 else
00107 stat = DB_PROTOCOL_ERR;
00108
00109 if (stat == DB_OK)
00110 {
00111 *x = a;
00112 *n = count;
00113 }
00114 else if (stat == DB_PROTOCOL_ERR)
00115 db_protocol_error();
00116
00117 xdr_end_recv (&xdrs);
00118 return stat;
00119 }