Passing a Variable-Length Array Example
This section describes the procedure for passing a variable-length array example.
struct varintarr {
int *data;
int arrlnth;
} arr;
callrpc(hostname, PROGNUM, VERSNUM, PROCNUM,
xdr_varintarr, &arr...);
The xdr_varintarr subroutine is defined as:
xdr_varintarr(xdrsp, arrp)
XDR *xdrsp;
struct varintarr *arrp;
{
return (xdr_array(xdrsp, &arrp->data, &arrp->arrlnth,
MAXLEN, sizeof(int), xdr_int));
}
This routine's parameters are the eXternal Data Representation (XDR) handle (xdrsp), a pointer to the array (aarp->data), a pointer to the size of the array (aarp->arrlnth), the maximum allowable array size (MAXLEN), the size of each array element (sizeof), and an XDR routine for handling each array element (xdr_int).