Passing a Simple User-Defined Structure Example

This section explains the procedure for passing a simple user-defined structure example.


struct simple {
        int a;
       short b;
} simple;

callrpc(hostname, PROGNUM, VERSNUM, PROCNUM,
        xdr_simple, &simple ...);
The xdr_simple function is written as:

#include <rpc/rpc.h>

xdr_simple(xdrsp, simplep)
    XDR *xdrsp;
    struct simple *simplep;
{
    if (!xdr_int(xdrsp, &simplep->a))
        return (0);
    if (!xdr_short(xdrsp, &simplep->b))
        return (0);
    return (1);
}