/* ** File name: GETSYI_XDR_2.C ** ** Copyright (c) 1991, by ** Process Software Corporation ** Framingham, Massachusetts */ /* ** This file is the same as GETSYI_XDR.C, except that the xdr_getsyi_res ** function here demonstrates how the xdr_union function is called. See the ** file GETSYI.COM on how to use this file. */ #include "TCPWARE_INCLUDE:RPC.H" #include "GETSYI.H" /* ** Except for xdr_getsyi_res, all of the function are the same those in ** GETSYI_XDR.C. See that file for their descriptions. */ /******************** xdr_item() ********************/ bool_t xdr_item( xdrs, objp) XDR *xdrs; item *objp; { if( !xdr_string( xdrs, objp, MAX_STRING_LEN)) return( FALSE); return( TRUE); } /******************** xdr_result() ********************/ bool_t xdr_result( xdrs, objp) XDR *xdrs; result *objp; { if( !xdr_string( xdrs, objp, MAX_STRING_LEN)) return( FALSE); return( TRUE); } /******************** xdr_message() ********************/ bool_t xdr_message( xdrs, objp) XDR *xdrs; message *objp; { if( !xdr_string( xdrs, objp, MAX_STRING_LEN)) return( FALSE); return( TRUE); } /******************** xdr_getsyi_args() ********************/ bool_t xdr_getsyi_args( xdrs, objp) XDR *xdrs; getsyi_args *objp; { if( !xdr_string( xdrs, &objp->gsa_node_name, MAX_STRING_LEN)) return( FALSE); if( !xdr_array( xdrs, (char **)&objp->gsa_item_codes.gsa_item_codes_val, (u_int *)&objp->gsa_item_codes.gsa_item_codes_len, MAX_ITEM_CODES, sizeof( item), xdr_item)) { return( FALSE); } return( TRUE); } /******************** xdr_getsyi_info() ********************/ bool_t xdr_getsyi_info( xdrs, objp) XDR *xdrs; getsyi_info *objp; { if( !xdr_array( xdrs, (char **)&objp->gsi_results.gsi_results_val, (u_int *)&objp->gsi_results.gsi_results_len, MAX_ITEM_CODES, sizeof( result), xdr_result)) { return( FALSE); } return( TRUE); } /******************** xdr_getsyi_res() ********************/ /* ** The XDR function for the server's reply. If gsr_status is 1, then the reply ** contains result strings, otherwise it contains an error message. ** ** The array cases contains a list of values and the XDR to interpret the union ** if gsr_status is that value. The pairing of value 0 to XDR function 0 ends ** the list. The default XDR routine is not included in the list. For the ** getsyi protocol, this list contains only 1 value. */ static xdr_discrim cases[] = {{ 1, xdr_getsyi_info}, /* if gsr_status is 1, call xdr_getsyi_info */ { 0, 0}}; /* ends the list */ bool_t xdr_getsyi_res( xdrs, objp) XDR *xdrs; getsyi_res *objp; { return( xdr_union( xdrs, &objp->gsr_status, /* how to interpret the union */ &objp->getsyi_res_u, /* the union */ cases, /* value to XDR function mapping */ xdr_message)); /* default XDR function */ /* If there was no default XDR */ /* function, this would be 0. */ } /* end file GETSYI_XDR_2.C */