/*
 * Please do not edit this file.
 * It was generated using rpcgen.
 */

#include "mount.h"
#include <stdio.h>
#include <stdlib.h>/* getenv, exit */
#include <rpc/pmap_clnt.h> /* for pmap_unset */
#include <string.h> /* strcmp */ 
#include <memory.h>
#include <sys/socket.h>
#include <netinet/in.h>

#ifdef __STDC__
#define SIG_PF void(*)(int)
#endif

static void
mountprog_1(struct svc_req *rqstp, register SVCXPRT *transp)
{
	union {
		dirpath mountproc_mnt_1_arg;
		dirpath mountproc_umnt_1_arg;
	} argument;
	char *result;
	xdrproc_t xdr_argument, xdr_result;
	char *(*local)(char *, struct svc_req *);

	switch (rqstp->rq_proc) {
	case MOUNTPROC_NULL:
		xdr_argument = (xdrproc_t) xdr_void;
		xdr_result = (xdrproc_t) xdr_void;
		local = (char *(*)(char *, struct svc_req *)) mountproc_null_1_svc;
		break;

	case MOUNTPROC_MNT:
		xdr_argument = (xdrproc_t) xdr_dirpath;
		xdr_result = (xdrproc_t) xdr_fhstatus;
		local = (char *(*)(char *, struct svc_req *)) mountproc_mnt_1_svc;
		break;

	case MOUNTPROC_DUMP:
		xdr_argument = (xdrproc_t) xdr_void;
		xdr_result = (xdrproc_t) xdr_mountlist;
		local = (char *(*)(char *, struct svc_req *)) mountproc_dump_1_svc;
		break;

	case MOUNTPROC_UMNT:
		xdr_argument = (xdrproc_t) xdr_dirpath;
		xdr_result = (xdrproc_t) xdr_void;
		local = (char *(*)(char *, struct svc_req *)) mountproc_umnt_1_svc;
		break;

	case MOUNTPROC_UMNTALL:
		xdr_argument = (xdrproc_t) xdr_void;
		xdr_result = (xdrproc_t) xdr_void;
		local = (char *(*)(char *, struct svc_req *)) mountproc_umntall_1_svc;
		break;

	case MOUNTPROC_EXPORT:
		xdr_argument = (xdrproc_t) xdr_void;
		xdr_result = (xdrproc_t) xdr_exports;
		local = (char *(*)(char *, struct svc_req *)) mountproc_export_1_svc;
		break;

	case MOUNTPROC_EXPORTALL:
		xdr_argument = (xdrproc_t) xdr_void;
		xdr_result = (xdrproc_t) xdr_exports;
		local = (char *(*)(char *, struct svc_req *)) mountproc_exportall_1_svc;
		break;

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

int
main(int argc, char **argv)
{
	register SVCXPRT *transp;

	(void) pmap_unset(MOUNTPROG, MOUNTVERS);

	transp = svcudp_create(RPC_ANYSOCK);
	if (transp == NULL) {
		fprintf(stderr, "cannot create udp service.");
		exit(1);
	}
	if (!svc_register(transp, MOUNTPROG, MOUNTVERS, mountprog_1, IPPROTO_UDP)) {
		fprintf(stderr, "unable to register (MOUNTPROG, MOUNTVERS, udp).");
		exit(1);
	}

	transp = svctcp_create(RPC_ANYSOCK, 0, 0);
	if (transp == NULL) {
		fprintf(stderr, "cannot create tcp service.");
		exit(1);
	}
	if (!svc_register(transp, MOUNTPROG, MOUNTVERS, mountprog_1, IPPROTO_TCP)) {
		fprintf(stderr, "unable to register (MOUNTPROG, MOUNTVERS, tcp).");
		exit(1);
	}

	svc_run();
	fprintf(stderr, "svc_run returned");
	exit(1);
	/* NOTREACHED */
}
