/*
 * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
 * unrestricted use provided that this legend is included on all tape
 * media and as a part of the software program in whole or part.  Users
 * may copy or modify Sun RPC without charge, but are not authorized
 * to license or distribute it to anyone else except as part of a product or
 * program developed by the user.
 * 
 * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
 * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
 * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
 * 
 * Sun RPC is provided with no support and without any obligation on the
 * part of Sun Microsystems, Inc. to assist in its use, correction,
 * modification or enhancement.
 * 
 * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
 * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
 * OR ANY PART THEREOF.
 * 
 * In no event will Sun Microsystems, Inc. be liable for any lost revenue
 * or profits or other special, indirect and consequential damages, even if
 * Sun has been advised of the possibility of such damages.
 * 
 * Sun Microsystems, Inc.
 * 2550 Garcia Avenue
 * Mountain View, California  94043
 */

#if !defined(lint) && defined(SCCSIDS)
static char sccsid[] = "@(#)raw_test_svc.c  1.1  90/02/10  Copyr 1988 Sun Micro";
#endif

#include <stdio.h>
#include <rpc/rpc.h>
#include "test.h"

extern void *raw_null_call_1();
extern int *raw_thru_o_1400_1();
extern int *raw_thru_o_var_1();
extern int *raw_thru_ui_var_1();
extern int *raw_thru_ti_var_1();
extern int *raw_thru_xu_var_1();
extern int *raw_thru_xt_var_1();

void
perf_1(rqstp, transp)
	struct svc_req *rqstp;
	register SVCXPRT *transp;
{
	union {
		opaqueArg1400 thru_o_1400_1_arg;
		opaqueArgVar thru_o_var_1_arg;
		UintArgVar thru_ui_var_1_arg;
		TintArgVar thru_ti_var_1_arg;
		UtestArgVar thru_xu_var_1_arg;
		TtestArgVar thru_xt_var_1_arg;
	} argument;
	char *result;
	bool_t (*xdr_argument)(), (*xdr_result)();
	char *(*local)();

	switch (rqstp->rq_proc) {
	case NULLPROC:
		(void) svc_sendreply(transp, xdr_void, (char *)NULL);
		return;

	case NULL_CALL:
		xdr_argument = xdr_int;
		xdr_result = xdr_int;
		local = (char *(*)()) raw_null_call_1;
		break;

	case THRU_O_1400:
		xdr_argument = xdr_opaqueArg1400;
		xdr_result = xdr_int;
		local = (char *(*)()) raw_thru_o_1400_1;
		break;

	case THRU_O_VAR:
		xdr_argument = xdr_opaqueArgVar;
		xdr_result = xdr_int;
		local = (char *(*)()) raw_thru_o_var_1;
		break;

	case THRU_UI_VAR:
		xdr_argument = xdr_UintArgVar;
		xdr_result = xdr_int;
		local = (char *(*)()) raw_thru_ui_var_1;
		break;

	case THRU_TI_VAR:
		xdr_argument = xdr_TintArgVar;
		xdr_result = xdr_int;
		local = (char *(*)()) raw_thru_ti_var_1;
		break;

	default:
		svcerr_noproc(transp);
		return;
	}
	(void) memset((char *)&argument, 0, sizeof (argument));
	if (!svc_getargs(transp, xdr_argument, (char *)&argument)) {
		svcerr_decode(transp);
		return;
	}
	result = (*local)(&argument, rqstp);
	if (result != NULL && !svc_sendreply(transp, xdr_result, (char *)result)) {
		svcerr_systemerr(transp);
	}
	if (!svc_freeargs(transp, xdr_argument, (char *)&argument)) {
		fprintf(stderr, "unable to free arguments");
		exit(1);
	}
	return;
}
