This chapter is for RPC programmers. It documents the XDR routines in the ONC RPC Run-Time Library (RTL). These routines are the programming interface to ONC RPC.
This section explains what XDR routines do and when you would call them. It also provides quick reference and detailed reference sections describing each XDR routine.
Most XDR routines share these characteristics:
• They convert data in two directions: from the host's local data format to XDR format (called encoding or marshalling), or the other way around (called decoding or unmarshalling).
• They use xdrs, a structure containing instructions for encoding, decoding, and deallocating memory.
• They return a boolean value to indicate success or failure.
Some XDR routines allocate memory while decoding an argument. To free this memory, call the xdr_free routine after the program is done with the decoded value.
Table 19-1 shows the order in which XDR routines perform encoding and decoding.
Client |
Server |
1. Encodes arguments 2. Decodes results 3. Frees results from memory |
1. Decodes arguments 2. Encodes results 3. Frees arguments from memory |
Under most circumstances, you are not likely to call any XDR routines directly. The clnt_call and svc_sendreply routines call the XDR routines.
You would call the XDR routines directly only when you write your own routines to convert data to or from XDR format.
Table 19-2 lists the XDR routines that encode and decode data.
Table 19-2 XDR Encoding and Decoding Routines |
|
This routine... |
Encodes and decodes... |
xdr_array |
Variable-length array |
xdr_bool |
Boolean value |
xdr_bytes |
Bytes |
xdr_char |
Character |
xdr_double |
Double-precision floating point number |
xdr_enum |
Enumerated type |
xdr_float |
Floating point value |
xdr_hyper |
VAX quad word to an XDR hyper-integer, or the other way |
xdr_int |
Four-byte integer |
xdr_long |
Longword |
xdr_opaque |
Contents of a buffer (treats the data as a fixed length of bytes and does not attempt to interpret them) |
xdr_pointer |
Pointer to a data structure |
xdr_reference |
Pointer to a data structure (the address must be non-zero) |
xdr_short |
Two-byte unsigned integer |
xdr_string |
Null-terminated string |
xdr_u_char |
Unsigned character |
xdr_u_hyper |
VAX quad word to an XDR unsigned hyper-integer |
xdr_u_int |
Four-byte unsigned integer |
xdr_u_long |
Unsigned longword |
xdr_u_short |
Two-byte unsigned integer |
xdr_union |
Union |
xdr_vector |
Vector (fixed length array) |
xdr_void |
Nothing |
xdr_wrapstring |
Null-terminated string |
Table 19-3 lists the XDR routines that perform various support functions.
Table 19-3 XDR Support Routines |
|
This routine... |
Does this... |
xdr_free |
Deallocates a data structure from memory |
xdrmem_create |
Creates a memory buffer XDR stream |
xdrrec_create |
Creates a record-oriented XDR stream |
xdrrec_endofrecord |
Marks the end of a record |
xdrrec_eof |
Goes to the end of the current record, then verifies whether any more data can be read |
xdrrec_skiprecord |
Goes to the end of the current record |
xdrstdio_create |
Initializes an stdio stream |
Table 19-4 lists the upper layer XDR routines that support RPC.
Table 19-4 Upper Layer XDR Routines |
|
This routine... |
Encodes and decodes... |
xdr_accepted_reply |
Part of an RPC reply message after the reply is accepted |
xdr_authunix_parms |
UNIX-style authentication information |
xdr_callhdr |
Static part of an RPC request message header (encoding only) |
xdr_callmsg |
RPC request message |
xdr_netobj |
Data in the netobj structure |
xdr_opaque_auth |
Authentication information |
xdr_pmap |
Port Mapper parameters |
xdr_pmaplist |
List of Port Mapping data |
xdr_rejected_reply |
Part of an RPC reply message after the reply is rejected |
xdr_replymsg |
RPC reply header; it then calls the appropriate routine to convert the rest of the message |
The following sections describe each XDR routine in detail.
XDR ONC Converts an RPC reply message from local format to XDR format, or the other way around.
#include
bool_t xdr_accepted_reply (XDR *xdrs, struct accepted_reply *ar);
xdrs
Address of a structure containing XDR encoding and decoding information.
ar
Address of the structure containing the RPC reply message.
The xdr_replymsg routine calls the xdr_accepted_reply routine.
This routine returns TRUE if it succeeds and FALSE if it fails.
xdr_replymsg
XDR ONC Converts a variable-length array from local format to XDR format, or the other way around.
#include
bool_t xdr_array (XDR *xdrs, u_char **addrp, u_long *sizep, u_long maxsize, u_long elsize, xdrproc_t elproc);
xdrs
Address of a structure containing XDR encoding and decoding information.
addrp
Address of the address containing the array being converted. If addrp is zero, then xdr_array allocates ((*sizep)*elsize) number of bytes when it decodes.
sizep
Address of the number of elements in the array.
maxsize
Maximum number of elements the array can hold.
elsize
Size of each element, in bytes.
elproc
XDR routine that handles each array element.
This routine returns TRUE if it succeeds and FALSE if it fails.
XDR ONC Converts UNIX-style authentication information from local format to XDR format, or the other way around.
#include
bool_t xdr_authunix_parms (XDR *xdrs, struct authunix_parms *aupp);
xdrs
Address of a structure containing XDR encoding and decoding information.
aupp
UNIX-style authentication information being converted.
This routine returns TRUE if it succeeds and FALSE if it fails.
XDR ONC Converts a boolean value from local format to XDR format, or the other way around.
#include
bool_t xdr_bool (XDR *xdrs, bool_t *bp);
xdrs
Address of a structure containing XDR encoding and decoding information.
bp
Address of the boolean value.
This routine returns TRUE if it succeeds and FALSE if it fails.
XDR ONC Converts bytes from local format to XDR format, or the other way around.
#include
bool_t xdr_bytes (XDR *xdrs, u_char **cpp, u_long *sizep, u_long maxsize);
xdrs
Address of a structure containing XDR encoding and decoding information.
cpp
Address of the address of the buffer containing the bytes being converted. If *cpp is zero, xdr_bytes allocates maxsize bytes when it decodes.
sizep
Address of the actual number of bytes being converted.
maxsize
Maximum number of bytes that can be used. The server protocol determines this number.
This routine returns TRUE if it succeeds and FALSE if it fails.
XDR ONC Encodes the static part of an RPC request message header.
#include
bool_t xdr_callhdr (XDR *xdrs, struct rpc_msg *chdr);
xdrs
Address of a structure containing XDR encoding and decoding information.
chdr
Address of the data being converted.
The xdr_callhdr routine converts the following fields: transaction ID, direction, RPC version, server program number, and server version. It converts the last four fields once, when the client handle is created.
The clnttcp_create and clntudp_create routines call the xdr_callhdr routine.
This routine always returns TRUE.
clnt_call, clnttcp_create, clntudp_create, xdr_callmsg
XDR ONC Converts an RPC request message from local format to XDR format, or the other way around.
#include
bool_t xdr_callmsg (XDR *xdrs, struct rpc_msg *cmsg);
xdrs
Address of a structure containing XDR encoding and decoding information.
cmsg
Address of the message being converted.
The xdr_callmsg routine converts the following fields: transaction ID, RPC direction, RPC version, program number, version number, procedure number, client authentication.
The pmap_rmtcall, svc_sendreply, and svc_sendreply_dq routines call xdr_callmsg.
This routine returns TRUE if it succeeds and FALSE if it fails.
xdr_callhdr
XDR ONC Converts a character from local format to XDR format, or the other way around.
#include
bool_t xdr_char (XDR *xdrs, char *cp);
xdrs
Address of a structure containing XDR encoding and decoding information.
cp
Address of the character being converted.
This routine provides the same functionality as the xdr_u_char routine.
This routine returns TRUE if it succeeds and FALSE if it fails.
xdr_u_char
XDR ONC Converts a double-precision floating point number between local and XDR format.
#include
bool_t xdr_double (XDR *xdrs, double *dp);
xdrs
Pointer to an XDR stream handle created by one of the XDR stream handle creation routines.
dp
Pointer to the double-precision floating point number.
NEW
This routine provides a filter primitive that translates between double-precision numbers and their external representations. It is actually implemented by four XDR routines:
xdr_double_D |
Converts VAX D format floating point numbers |
xdr_double_G |
Converts VAX G format floating point numbers |
xdr_double_T |
Converts IEEE T format floating point numbers |
xdr_double_X |
Converts IEEE X format floating point numbers |
You can reference these routines explicitly or you can use compiler settings to control which routine is used when you reference the xdr_double routine.
ONC
VAX
If you use... |
link your program with... |
VAX C D_float RTL |
TCPWARE_RPCLIB_SHR.EXE |
VAX C G_float RTL |
TCPWARE_RPCLIBG_SHR.EXE. |
ALPHA and I64
If you use... |
link your program with... |
DEC C D_float RTL |
TCPWARE_RPCLIBD_SHR.EXE. |
DEC C G_float RTL |
TCPWARE_RPCLIB_SHR.EXE. |
DEC C T_float RTL |
TCPWARE_RPCLIBT_SHR.EXE. |
This routine returns TRUE if it succeeds and FALSE if it fails.
XDR ONC Converts an enumerated type from local format to XDR format, or the other way around.
#include
bool_t xdr_enum (XDR *xdrs, enum_t *ep);
xdrs
Address of the structure containing XDR encoding and decoding information.
ep
Address containing the enumerated type.
This routine returns TRUE if it succeeds and FALSE if it fails.
XDR ONC Converts a floating point value from local format to XDR format, or the other way around.
#include
bool_t xdr_float (XDR *xdrs, float *fp);
xdrs
Pointer to an XDR stream handle created by one of the XDR stream handle creation routines.
fp
Pointer to a single-precision floating point number.
NEW
This routine provides a filter primitive that translates between double-precision numbers and their external representations. It is actually implemented by four XDR routines:
xdr_float_F |
Converts VAX F format floating point numbers |
xdr_float_S |
Converts IEEE T format floating point numbers |
You can reference these routines explicitly or you can use compiler settings to control which routine is used when you reference the xdr_float routine.
This routine returns TRUE if it succeeds and FALSE if it fails.
XDR ONC Deallocates a data structure from memory.
#include
void xdr_free (xdrproc_t proc, u_char *objp);
proc
XDR routine that describes the data structure.
objp
Address of the data structure.
Call this routine after decoded data is no longer needed. Do not call it for encoded data.
This routine returns TRUE if it succeeds and FALSE if it fails.
XDR ONC Converts a VAX quad word to an XDR hyper-integer, or the other way around.
bool_t xdr_hyper (XDR *xdrs, quad *ptr);
xdrs
Address of a structure containing XDR encoding and decoding information.
ptr
Address of the structure containing the quad word. The quad word is stored in standard VAX quad word format, with the low-order longword first in memory.
This routine provided the same functionality as the xdr_u_hyper routine.
This routine returns TRUE if it succeeds and FALSE if it fails.
xdr_u_hyper
XDR ONC Converts one four-byte integer from local format to XDR format, or the other way around.
#include
bool_t xdr_int (XDR *xdrs, int *ip);
xdrs
Address of a structure containing XDR encoding and decoding information.
ip
Address containing the integer.
This routine provides the same functionality as the xdr_u_int, xdr_long, and xdr_u_long routines.
This routine returns TRUE if it succeeds and FALSE if it fails.
xdr_u_int, xdr_long, xdr_u_long
XDR ONC Converts one longword from local format to XDR format, or the other way around.
#include
bool_t xdr_long (XDR *xdrs, u_long *lp);
xdrs
Address of the structure containing XDR encoding and decoding information.
lp
Address containing the longword.
This routine provides the same functionality as the xdr_u_long, xdr_int, and xdr_u_int routines.
This routine returns TRUE if it succeeds and FALSE if it fails.
xdr_u_long, xdr_int, xdr_u_int
XDR ONC Converts data in the netobj structure from the local data format to XDR format, or the other way around.
bool_t xdr_netobj (XDR *xdrs, netobj *ptr);
xdrs
Address of the structure containing XDR encoding and decoding information.
ptr
Address of the following structure:
typedef struct
{
u_long n_len;
byte *n_bytes;
} netobj;
This structure defines the data being converted.
The netobj structure is an aggregate data structure that is opaque and contains a counted array of 1024 bytes.
This routine returns TRUE if it succeeds and FALSE if it fails.
XDR ONC Converts the contents of a buffer from the local data format to XDR format, or the other way around. This routine treats the data as a fixed length of bytes and does not attempt to interpret them.
#include
bool_t xdr_opaque (XDR *xdrs, char *cp, u_long cnt);
xdrs
Address of the structure containing XDR encoding and decoding information.
cp
Address of the buffer containing opaque data.
cnt
Byte length.
This routine returns TRUE if it succeeds and FALSE if it fails.
XDR ONC Converts authentication information from the local data format to XDR format, or the other way around.
#include
bool_t xdr_opaque_auth (XDR *xdrs, struct opaque_auth *ap);
xdrs
Address of the structure containing XDR encoding and decoding information.
ap
Address of the authentication information. This data was created by the authnone_create, authunix_create, or authunix_create_default routine.
This routine returns TRUE if it succeeds and FALSE if it fails.
XDR ONC Converts Port Mapper parameters from the local data format to XDR format, or the other way around.
#include "TCPWARE_INCLUDE:PMAP_PROT.H"
bool_t xdr_pmap (XDR *xdrs, struct pmap *regs);
xdrs
Address of the structure containing XDR encoding and decoding information.
regs
Address of a structure containing the program number, version number, protocol number, and port number. This is the data being converted.
This routine returns TRUE if it succeeds and FALSE if it fails.
XDR ONC Converts a list of Port Mapping data from the local data format to XDR format, or the other way around.
#include "TCPWARE_INCLUDE:PMAP_PROT.H"
bool_t xdr_pmaplist (XDR *xdrs, struct pmaplist **rpp);
xdrs
Address of the structure containing XDR encoding and decoding information.
rpp
Address of the address of the structure containing Port Mapper data. If this routine is used to decode a Port Mapper listing, rpp is set to the address of the newly allocated linked list of structures.
This routine returns TRUE if it succeeds and FALSE if it fails.
XDR ONC Converts a recursive data structure from the local data format to XDR format, or the other way around.
#include
bool_t xdr_pointer (XDR *xdrs, u_char **objpp,
u_long obj_size,
xdrproc_t xdr_obj);
xdrs
Address of the structure containing XDR encoding and decoding information.
objpp
Address of the address containing the data being converted. May be zero.
obj_size
Size of the data structure in bytes.
xdr_obj
XDR routine that describes the object being pointed to. This routine can describe complex data structures, and these structures may contain pointers.
An XDR routine for a data structure that contains pointers to other structures, such as a linked list, would call the xdr_pointer routine. The xdr_pointer routine encodes a pointer from an address into a boolean. If the boolean is TRUE, the data follows the boolean.
bool_t xdr_pointer( xdrs, objpp, obj_size, xdr_obj)
XDR *xdrs;
char **objpp;
longw obj_size;
xdrproc_t xdr_obj;
{
bool_t more_data;
/*
** determine if the pointer is a valid address (0 is invalid)
*/
if( *objpp != NULL)
more_data = TRUE;
else
more_data = FALSE;
/*
** XDR the flag
** If we are decoding, then more_data is overwritten.
*/
if( !xdr_bool( xdrs, &more_data))
return( FALSE);
/*
** If there is no more data, set the pointer to 0 (No effect if we
** were encoding) and return TRUE
*/
if( !more_data)
{
*objpp = NULL;
return( TRUE);
}
/*
** Otherwise, call xdr_reference. The result is that xdr_pointer is
** the same as xdr_reference, except that xdr_pointer adds a Boolean
** to the encoded data and will properly handle NULL pointers.
*/
return( xdr_reference( xdrs, objpp, obj_size, xdr_obj));
} /* end function xdr_pointer() */
This routine returns TRUE if it succeeds and FALSE if it fails.
XDR ONC This routine recursively converts a structure that is referenced by a pointer inside the structure.
#include
bool_t xdr_reference (XDR *xdrs, u_char **objpp, u_long obj_size, xdrproc_t xdr_obj);
xdrs
Address of the structure containing XDR encoding and decoding information.
objpp
Address of the address of a structure containing the data being converted. If objpp is zero, the xdr_reference routine allocates the necessary storage when decoding. This argument must be non-zero when encoding.
When xdr_reference encodes data, it passes *objpp to xdr_obj. When decoding, xdr_reference allocates memory if *objpp equals zero.
obj_size
Size of the referenced structure.
xdr_obj
XDR routine that describes the object being pointed to. This routine can describe complex data structures, and these structures may contain pointers.
This routine returns TRUE if it succeeds and FALSE if it fails.
XDR ONC Converts the remainder of an RPC reply message after the header indicates that the reply is rejected.
#include
bool_t xdr_rejected_reply (XDR *xdrs, struct rejected_reply *rr);
xdrs
Address of the structure containing XDR encoding and decoding information.
rr
Address of the structure containing the reply message.
This routine returns TRUE if it succeeds and FALSE if it fails.
XDR ONC Converts the RPC reply header, then calls the appropriate routine to convert the rest of the message.
#include
bool_t xdr_replymsg (XDR *xdrs, struct rpc_msg *rmsg);
xdrs
Address of the structure containing XDR encoding and decoding information.
rmsg
Address of the structure containing the reply message.
The xdr_replymsg routine calls the xdr_rejected_reply or xdr_accepted_reply routine to convert the body of the RPC reply message from the local data format to XDR format, or the other way around.
This routine returns TRUE if it succeeds and FALSE if it fails.
xdr_accepted_reply, xdr_rejected_reply
XDR ONC Converts a two-byte integer from the local data format to XDR format, or the other way around.
#include
bool_t xdr_short (XDR *xdrs, short *sp);
xdrs
Address of the structure containing XDR encoding and decoding information.
sp
Address of the integer being converted.
This routine provides the same functionality as xdr_u_short.
This routine returns TRUE if it succeeds and FALSE if it fails.
xdr_u_short
XDR ONC Converts a null-terminated string from the local data format to XDR format, or the other way around.
#include
bool_t xdr_string (XDR *xdrs, char **cpp, u_long maxsize);
xdrs
Address of the structure containing XDR encoding and decoding information.
cpp
Address of the address of the first byte in the string.
maxsize
Maximum length of the string. The service protocol determines this value.
The xdr_string routine is the same as the xdr_wrapstring routine, except xdr_string allows you to specify the maxsize.
This routine returns TRUE if it succeeds and FALSE if it fails.
xdr_wrapstring
XDR ONC Converts an unsigned character from local format to XDR format, or the other way around.
#include
bool_t xdr_u_char (XDR *xdrs, u_char bp);
xdrs
Address of the structure containing XDR encoding and decoding information.
bp
Address of the character being converted.
This routine provides the same functionality as xdr_char.
This routine returns TRUE if it succeeds and FALSE if it fails.
xdr_char
XDR ONC Converts an VAX quad word to an XDR unsigned hyper-integer, or the other way around.
bool_t xdr_u_hyper (XDR *xdrs, quad *ptr);
xdrs
Address of a structure containing XDR encoding and decoding information.
ptr
Address of the structure containing the quad word. The quad word is stored in standard VAX format, with the low-order longword first in memory.
This routine provides the same functionality as the xdr_hyper routine.
This routine returns TRUE if it succeeds and FALSE if it fails.
xdr_hyper
XDR ONC Converts a four-byte unsigned integer from local format to XDR format, or the other way around.
#include
bool_t xdr_u_int (XDR *xdrs, int *ip);
xdrs
Address of a structure containing XDR encoding and decoding information.
ip
Address of the integer.
This routine provides the same functionality as xdr_int, xdr_long, and xdr_u_long.
This routine returns TRUE if it succeeds and FALSE if it fails.
xdr_int
XDR ONC Converts an unsigned longword from local format to XDR format, or the other way around.
#include
bool_t xdr_u_long (XDR *xdrs, u_long *lp);
xdrs
Address of the structure containing XDR encoding and decoding information.
lp
Address of the longword.
This routine provides the same functionality as xdr_long, xdr_int, and xdr_u_int.
This routine returns TRUE if it succeeds and FALSE if it fails.
xdr_long, xdr_int, xdr_u_int
XDR ONC Converts a two-byte unsigned integer from the local data format to XDR format, or the other way around.
#include
bool_t xdr_u_short (XDR *xdrs, u_short *sp);
xdrs
Address of the structure containing XDR encoding and decoding information.
sp
Address of the integer being converted.
This routine provides the same functionality as xdr_short.
This routine returns TRUE if it succeeds and FALSE if it fails.
xdr_short
XDR ONC Converts a union from the local data format to XDR format, or the other way around.
#include
bool_t xdr_union (XDR *xdrs, enum_t *dscmp, u_char *unp, xdr_discrim *choices, xdrproc_t dfault);
xdrs
Address of the structure containing XDR encoding and decoding information.
dscmp
Integer from the choices array.
unp
Address of the union.
choices
Address of an array. This array maps integers to XDR routines.
dfault
XDR routine that is called if the dscmp integer is not in the choices array.
The xdr_union routine searches the array choices for the value of dscmp. If it finds the value, it calls the corresponding XDR routine to process the remaining data.If xdr_union doesn't find the value, it calls the dfault routine.
The TCPWARE_ROOT:[TCPWARE.EXAMPLES.RPC]GETSYI_XDR_2.C file contains a sample routine that calls xdr_union.
This routine returns TRUE if it succeeds and FALSE if it fails.
XDR ONC Converts a vector (fixed length array) from the local data format to XDR format, or the other way around.
#include
bool_t xdr_vector (XDR *xdrs, u_char *basep, u_long nelem, u_long elmsize, xdrproc_t xdr_elem);
xdrs
Address of the structure containing XDR encoding and decoding information.
basep
Address of the array.
nelem
Number of elements in the array.
elmsize
Size of each element.
xdr_elem
Converts each element from the local data format to XDR format, or the other way around.
This routine returns TRUE if it succeeds and FALSE if it fails.
XDR ONC Converts nothing.
#include
bool_t xdr_void (XDR *xdrs, u_char *ptr);
xdrs
Address of the structure containing XDR encoding and decoding information.
ptr
Ignored.
Use this routine as a place-holder for a program that passes no data. The server and client expect an XDR routine to be called, even when there is no data to pass.
This routine always returns TRUE.
XDR ONC Converts a null-terminated string from the local data format to XDR format, or the other way around.
#include
bool_t xdr_wrapstring (XDR *xdrs, char **cpp);
xdrs
Address of the structure containing XDR encoding and decoding information.
cpp
Address of the address of the first byte in the string.
The xdr_wrapstring routine calls the xdr_string routine. The xdr_wrapstring routine hides the maxsize argument from the programmer. Instead, the maximum size of the string is assumed to be 232 - 1.
This routine returns TRUE if it succeeds and FALSE if it fails.
xdr_string
XDR ONC Creates a memory buffer XDR stream.
#include
void xdrmem_create (XDR *xdrs, u_char *addr, u_long size, enum xdr_op op);
xdrs
Address of the structure containing XDR encoding and decoding information.
addr
Address of the buffer containing the encoded data.
size
Size of the addr buffer.
op
Operations you will perform on the buffer. Valid values are XDR_ENCODE, XDR_DECODE, and XDR_FREE. You may change this value.
The xdrmem_create routine initializes a structure so that other XDR routines can write to a buffer. The UDP and UDPA transports use this routine.
XDR ONC Creates a record-oriented XDR stream.
#include
void xdrrec_create (XDR *xdrs, u_long sendsize,
u_long recvsize,
u_char *tcp_handle, int (*readit)(), int (*writeit)();
xdrs
Address of the structure being created. The xdrrec_create routine will write XDR encoding and decoding information to this structure.
sendsize
Size of the send buffer in bytes. The minimum size is 100 bytes. If you specify fewer than 100 bytes, 4000 bytes is used as the default.
recvsize
Size of the receive buffer in bytes. The minimum size is 100 bytes. If you specify fewer than 100 bytes, 4000 bytes is used as the default.
tcp_handle
Address of the client or server handle.
readit
Address of a user-written routine that reads data from the stream transport. This routine must use the following format:
int readit(tcp_handle, buffer, len)
u_char *tcp_handle;
u_char *buffer;
u_long len;
where *tcp_handle is the client or server handle, *buffer is the buffer to fill, and len is the number of bytes to read. The readit routine returns either the number of bytes read, or -1 if an error occurs.
writeit
Address of a user-written routine that writes data to the stream transport. This routine must use the following format:
int writeit(tcp_handle, buffer, len)
u_char *tcp_handle;
u_char *buffer;
u_long len;
– tcp_handle is the client or server handle.
– buffer is the address of the buffer being written.
– len is the number of bytes to write.
The writeit routine returns either the number of bytes written, or -1 if an error occurs.
The xdrrec_create routine requires one of the following:
• The TCP transport
• A stream-oriented interface (such as file I/O) not supported by TCPware. The stream consists of data organized into records. Each record is either an RPC request or reply.
The clnttcp_create and svcfd_create routines call the xdrrec_create routine.
clnttcp_create, svcfd_create, xdrrec_endofrecord, xdrrec_eof, xdrrec_skiprecord
XDR ONC Marks the end of a record.
#include
bool_t xdrrec_endofrecord (XDR *xdrs, bool_t sendnow);
xdrs
Address of the structure containing XDR encoding and decoding information.
sendnow
Indicates when the calling program will send the record to the writeit routine (see xdrrec_create).
If sendnow is TRUE, xdrrec_endofrecord sends the record now. If sendnow is FALSE, xdrrec_endofrecord writes the record to a buffer and sends the buffer when it runs out of buffer space.
A client or server program calls the xdrrec_endofrecord routine when it reaches the end of a record it is writing. The program must call the xdrrec_create routine before calling xdrrec_endofrecord.
This routine returns TRUE if it succeeds and FALSE if it fails.
xdrrec_create, xdrrec_eof, xdrrec_skiprecord
XDR ONC Goes to the end of the current record, then verifies whether any more data can be read.
#include
bool_t xdrrec_eof (XDR *xdrs);
xdrs
Address of the structure containing XDR encoding and decoding information.
The client or server program must call the xdrrec_create routine before calling xdrrec_eof.
This routine returns TRUE if it reaches the end of the data stream, and FALSE if it finds more data to read.
xdrrec_create, xdrrec_endofrecord, xdrrec_skiprecord
XDR ONC Goes to the end of the current record.
#include
bool_t xdrrec_skiprecord (XDR *xdrs);
xdrs
Address of the structure containing XDR encoding and decoding information.
A client or server program calls the xdrrec_skiprecord routine before it reads data from a stream. This routine ensures that the program starts reading a record from the beginning.
The xdrrec_skiprecord routine is similar to the xdrrec_eof routine, except that xdrrec_skiprecord does not verify whether any more data can be read.
The client or server program must call the xdrrec_create routine before calling xdrrec_skiprecord.
This routine returns TRUE if it has skipped to the start of a record. Otherwise, it returns FALSE.
xdrrec_create, xdrrec_endofrecord, xdrrec_eof
XDR Initializes an stdio XDR stream.
#include
void xdrstdio_create (XDR *xdrs, FILE *file, enum xdr_op op);
xdrs
Address of the structure containing XDR encoding and decoding information.
file
File pointer FILE *, which is to be associated with the stream.
op
An XDR operation, one of: XDR_ENCODE, XDR_DECODE, or XDR_FREE.
The xdrstdio_create routine initializes an stdio stream for the specified file.