xdr_enum()--Translate between Enumeration and XDR


  Syntax
 #include <rpc/xdr.h>

 bool_t xdr_enum(XDR *xdrs,
                 enum_t *ep);

  Service Program Name: QZNFTRPC

  Default Public Authority: *USE

  Threadsafe: No

The xdr_enum function is a filter primitive that translates between C-language enumeration (enum) and its external representation.


Parameters

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

ep  (I/O) 
The address of the enumeration data.

Authorities

No authorization is required.


Start of change

Notes

Callers of the xdr_enum() function should ensure that ep points to a 4 byte location in memory. The ENUM(*INT) compiler option should be used when compiling code that calls xdr_enum() to ensure that enumerated data types are represented internally as integers. Failure to do so, may cause unexpected values to be encoded to the XDR data stream.

End of change

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

See Code disclaimer information for information pertaining to code examples.

The following example shows how xdr_enum() is used:

#include <stdio.h>
#include <xdr.h>

typedef enum fruit_state { green, ripe } fruit_state;
typedef enum fruit_weight { small, sufficient } fruit_weight;

typedef struct fruit
{
        fruit_state state;
        fruit_weight weight;
} fruit;

bool xdr_fruit(XDR *xdrs, fruit *p_fruit)
{
        if(!xdr_enum(xdrs,(enum_t *)&(p_fruit->state)))
                return FALSE;
        return xdr_enum(xdrs,
                                 (enum_t *)&(p_fruit->weight));
}

API introduced: V4R2
Top | Remote Procedure Call (RPC) APIs | APIs by category