xdr_reference()--Provide Pointer Chasing within Structures


  Syntax
  #include <rpc/xdr.h>

  bool_t xdr_reference(XDR *xdrs,
                       caddr_t *pp,
                       u_int size,
                       const xdrproc_t proc);

  Service Program Name: QZNFTRPC

  Default Public Authority: *USE

  Threadsafe: No

The xdr_reference() function is a filter primitive that provides pointer chasing within structures. This primitive allows the serializing, deserializing, and freeing of any pointers within one structure that are referenced by another structure.

The xdr_reference() function does not attach special meaning to a null pointer during serialization, and passing the address of a null pointer may cause a memory error. Therefore, the programmer must describe data with a two-sided discriminated union. One side is used when the pointer is valid; the other side, when the pointer is null.

Pointer chasing is the substitution of the pointer itself with the actual structure it points to.


Parameters

xdrs  (Input) 
A pointer to the External Data Representation (XDR) stream handle.

pp  (I/O) 
The address of the structure. When you decode data, XDR allocates storage if the pointer is NULL.

size  (Input) 
The byte size of the structure pointed to by the pp parameter.

proc  (Input) 
A translation of the structure between its C form and its external representation. This parameter is the XDR procedure that describes the structure.

Authorities

No authorization is required.


Return Value

TRUE (1) Successful
FALSE (0) Unsuccessful


Error Conditions

None.


Error Messages

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.


Example

The following example shows how xdr_reference() is used.

Note: By using the code examples, you agree to the terms of the Code license and disclaimer information.

#include <xdr.h>

typedef struct node
{
        int              value;
        struct node *p;
} node ;

/*
 * Do not call it with p_node==NULL, because it will fail.
 */
bool_t xdr_list(XDR *xdrs, node **p_node)
{
        return xdr_reference(xdrs,(caddr_t)p_node,
        sizeof(node),(xdrproc_t)xdr_node)
}

bool_t xdr_node(XDR *xdrs, node *p_node)
{
        xdr_int(xdrs,&(p_node->value));
        return xdr_list(xdrs,&(p_node->p));
}



API introduced: V4R2

[ Back to top | Remote Procedure Call (RPC) APIs | APIs by category ]