1 /*
2  * Please do not edit this file.
3  * It was generated using rpcgen.
4  */
5 
6 #include "rstat_v2.h"
7 #include <stdio.h>
8 #include <stdlib.h> /* getenv, exit */
9 #include <signal.h>
10 #include <rpc/pmap_clnt.h> /* for pmap_unset */
11 #include <string.h> /* strcmp */
12 #include <unistd.h> /* setsid */
13 #include <sys/types.h>
14 #include <memory.h>
15 #include <stropts.h>
16 #include <sys/resource.h> /* rlimit */
17 #include <syslog.h>
18 
19 #ifndef SIG_PF
20 #define	SIG_PF void(*)(int)
21 #endif
22 
23 #ifdef DEBUG
24 #define	RPC_SVC_FG
25 #endif
26 
27 #define	_RPCSVC_CLOSEDOWN 120
28 /*
29  * Version 2 rstat; for backwards compatibility only.
30  */
31 /*
32  * Copyright (c) 1985, 1990, 1991 by Sun Microsystems, Inc.
33  */
34 /* from rstat_v2.x */
35 extern int _rpcpmstart;		/* Started by a port monitor ? */
36 
37 /* States a server can be in wrt request */
38 
39 #define	_IDLE 0
40 #define	_SERVED 1
41 
42 /* LINTED static unused if no main */
43 static int _rpcsvcstate = _IDLE;	/* Set when a request is serviced */
44 static int _rpcsvccount = 0;		/* Number of requests being serviced */
45 
46 #if	defined(RPC_MSGOUT)
47 extern void RPC_MSGOUT(const char *, ...);
48 #else	/* defined(RPC_MSGOUT) */
49 static void
50 RPC_MSGOUT(const char *fmt, char *msg)
51 {
52 #ifdef RPC_SVC_FG
53 	if (_rpcpmstart)
54 		syslog(LOG_ERR, fmt, msg);
55 	else {
56 		(void) fprintf(stderr, fmt, msg);
57 		(void) putc('\n', stderr);
58 	}
59 #else
60 	syslog(LOG_ERR, fmt, msg);
61 #endif
62 }
63 #endif	/* defined(RPC_MSGOUT) */
64 
65 void
66 rstatprog_2(struct svc_req *rqstp, register SVCXPRT *transp)
67 {
68 	union {
69 		int fill;
70 	} argument;
71 	char *result;
72 	xdrproc_t _xdr_argument, _xdr_result;
73 	char *(*local)(char *, struct svc_req *);
74 
75 	_rpcsvccount++;
76 	switch (rqstp->rq_proc) {
77 	case NULLPROC:
78 		(void) svc_sendreply(transp,
79 		    (xdrproc_t)xdr_void, NULL);
80 		_rpcsvccount--;
81 		_rpcsvcstate = _SERVED;
82 		return; /* CSTYLED */
83 
84 	case RSTATPROC_STATS:
85 		_xdr_argument = (xdrproc_t)
86 		    xdr_void;
87 		_xdr_result = (xdrproc_t)
88 		    xdr_statsswtch;
89 		local = (char *(*)(char *, struct svc_req *))
90 		    rstatproc_stats_2_svc;
91 		break;
92 
93 	case RSTATPROC_HAVEDISK:
94 		_xdr_argument = (xdrproc_t)
95 		    xdr_void;
96 		_xdr_result = (xdrproc_t)
97 		    xdr_u_int;
98 		local = (char *(*)(char *, struct svc_req *))
99 		    rstatproc_havedisk_2_svc;
100 		break;
101 
102 	default:
103 		svcerr_noproc(transp);
104 		_rpcsvccount--;
105 		_rpcsvcstate = _SERVED;
106 		return; /* CSTYLED */
107 	}
108 	(void) memset((char *)&argument, 0, sizeof (argument));
109 	if (!svc_getargs(transp, _xdr_argument, (caddr_t)&argument)) {
110 		svcerr_decode(transp);
111 		_rpcsvccount--;
112 		_rpcsvcstate = _SERVED;
113 		return; /* CSTYLED */
114 	}
115 	result = (*local)((char *)&argument, rqstp);
116 	if (_xdr_result && result != NULL &&
117 	    !svc_sendreply(transp, _xdr_result, result)) {
118 		svcerr_systemerr(transp);
119 	}
120 	if (!svc_freeargs(transp, _xdr_argument, (caddr_t)&argument)) {
121 		RPC_MSGOUT("%s",
122 		    "unable to free arguments");
123 		exit(1);
124 	}
125 	_rpcsvccount--;
126 	_rpcsvcstate = _SERVED;
127 	return; /* CSTYLED */
128 }
129