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