#include <rpc/xdr.h>
bool_t xdr_bytes(XDR *xdrs,
char **sp,
u_int *sizep,
const u_int maxsize);
The xdr_bytes() function is a filter primitive that translates between counted byte arrays and their external representations. This function treats a subset of generic arrays in which the size of array elements is known to be 1 and the external description of each element is built-in. The length of the byte sequence is explicitly located in an unsigned integer. The byte sequence is not ended by a null character. The external representation of the bytes is the same as their internal representation.
No authorization is required.
| TRUE (1) | Successful |
| FALSE (0) | Unsuccessful |
None.
| Message ID | Error Message Text |
|---|---|
| CPE3418 E | Possible APAR condition or hardware failure. |
| CPF3CF2 E | Error(s) occurred during running of &1 API. |
| CPF9872 E | Program or service program &1 in library &2 ended. Reason code &3. |
See Code disclaimer information for information pertaining to code examples.
The following example shows how xdr_bytes() is used:
#include <stdio.h>
#include <values.h>
#include <xdr.h>
#define ARRAY_SIZE 256
typedef struct xarray
{
int size;
char *p_array;
} xarray ;
bool_t xdr_xarray(XDR *xdrs, xarray *p_xarray )
{
/*
* Force XDR to allocate memory while decoding
*/
if((xdrs->x_op==XDR_DECODE)&&
(p_xarray->p_array!=NULL))
{
free(p_xarray->p_array);
p_xarray->p_array=NULL;
}
/*
* This code has a dual job :
* A) While decoding, it allocated memory, stores the decoded
* xarray in it, and updates size field in xarray
* struct.
* B) While decoding it stores xarray's size and the data
* itself in XDR.
*/
return xdr_bytes(
xdrs,
(&(p_xarray->p_array)),
&(p_xarray->size),
MAX_INT);
}
| Top | Remote Procedure Call (RPC) APIs | APIs by category |