xdr_union()--Translate between Unions and Their XDR
Syntax
#include <rpc/xdr.h> bool_t xdr_union(XDR *xdrs, enum_t *dscmp, char *unp, const struct xdr_discrim *choices, const xdrproc_t (*defaultarm));
Service Program Name: QZNFTRPC
Default Public Authority: *USE
Threadsafe: No
The xdr_union() function is a filter primitive that translates between discriminated C unions and their corresponding external representations.
Parameters
- xdrs (Input)
- A pointer to the External Data Representation (XDR) stream handle.
- dscmp (Input)
- The address of the union's discriminant. The discriminant is an enumeration
(enum_t) value.
- unp (I/O)
- The address of the union.
- choices (Input)
- A pointer to an array of xdr_discrim structures.
- defaultarm (Input)
- A structure provided in case no discriminants are found. This parameter can have a null value.
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. |
Usage Notes
The size of any enum data types passed to the xdr_union() must be defined as 4 bytes.
Example
The following example shows how xdr_union() is used.
Note: By using the code examples, you agree to the terms of the Code license and disclaimer information.
#include <stdio.h> #include <xdr.h> #pragma enum size(4) /* Set enum size to 4 bytes */ typedef enum time_type {END=0,DC,CT} time_type ; #pragma enum size() /* Reset enum size */ typedef union time_value { int discrete_time; float continuous_time; } time_value ; typedef struct time { time_type type; time_value value; } time; bool_t xdr_time(XDR *xdrs, time *p_time) { struct xdr_discrim handlers[] = { {DT,(xdrproc_t)xdr_int}, {CT,(xdrproc_t)xdr_float}, {END,NULL} }; return xdr_union(xdrs,(enum_t *)(&(p_time->type)), (caddr_t)&(p_time->value),handlers,NULL); }
API introduced: V4R2
[ Back to top | Remote Procedure Call (RPC) APIs | APIs by category ]