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