1 /* 2 * Please do not edit this file. 3 * It was generated using rpcgen. 4 */ 5 6 #include "rstat.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 * Copyright (c) 1985, 1990, 1991 by Sun Microsystems, Inc. 30 */ 31 /* from rstat.x */ 32 33 /* 34 * Server side stub routines for the rstat daemon 35 */ 36 37 extern int _rpcpmstart; /* Started by a port monitor ? */ 38 39 /* States a server can be in wrt request */ 40 41 #define _IDLE 0 42 #define _SERVED 1 43 44 /* LINTED static unused if no main */ 45 static int _rpcsvcstate = _IDLE; /* Set when a request is serviced */ 46 static int _rpcsvccount = 0; /* Number of requests being serviced */ 47 48 #if defined(RPC_MSGOUT) 49 extern void RPC_MSGOUT(const char *, ...); 50 #else /* defined(RPC_MSGOUT) */ 51 static void 52 RPC_MSGOUT(const char *fmt, char *msg) 53 { 54 #ifdef RPC_SVC_FG 55 if (_rpcpmstart) 56 syslog(LOG_ERR, fmt, msg); 57 else { 58 (void) fprintf(stderr, fmt, msg); 59 (void) putc('\n', stderr); 60 } 61 #else 62 syslog(LOG_ERR, fmt, msg); 63 #endif 64 } 65 #endif /* defined(RPC_MSGOUT) */ 66 67 void 68 rstatprog_4(struct svc_req *rqstp, register SVCXPRT *transp) 69 { 70 union { 71 int fill; 72 } argument; 73 char *result; 74 xdrproc_t _xdr_argument, _xdr_result; 75 char *(*local)(char *, struct svc_req *); 76 77 _rpcsvccount++; 78 switch (rqstp->rq_proc) { 79 case NULLPROC: 80 (void) svc_sendreply(transp, 81 (xdrproc_t)xdr_void, NULL); 82 _rpcsvccount--; 83 _rpcsvcstate = _SERVED; 84 return; /* CSTYLED */ 85 86 case RSTATPROC_STATS: 87 _xdr_argument = (xdrproc_t) 88 xdr_void; 89 _xdr_result = (xdrproc_t) 90 xdr_statsvar; 91 local = (char *(*)(char *, struct svc_req *)) 92 rstatproc_stats_4_svc; 93 break; 94 95 case RSTATPROC_HAVEDISK: 96 _xdr_argument = (xdrproc_t) 97 xdr_void; 98 _xdr_result = (xdrproc_t) 99 xdr_u_int; 100 local = (char *(*)(char *, struct svc_req *)) 101 rstatproc_havedisk_4_svc; 102 break; 103 104 default: 105 svcerr_noproc(transp); 106 _rpcsvccount--; 107 _rpcsvcstate = _SERVED; 108 return; /* CSTYLED */ 109 } 110 (void) memset((char *)&argument, 0, sizeof (argument)); 111 if (!svc_getargs(transp, _xdr_argument, (caddr_t)&argument)) { 112 svcerr_decode(transp); 113 _rpcsvccount--; 114 _rpcsvcstate = _SERVED; 115 return; /* CSTYLED */ 116 } 117 result = (*local)((char *)&argument, rqstp); 118 if (_xdr_result && result != NULL && 119 !svc_sendreply(transp, _xdr_result, result)) { 120 svcerr_systemerr(transp); 121 } 122 if (!svc_freeargs(transp, _xdr_argument, (caddr_t)&argument)) { 123 RPC_MSGOUT("%s", 124 "unable to free arguments"); 125 exit(1); 126 } 127 _rpcsvccount--; 128 _rpcsvcstate = _SERVED; 129 return; /* CSTYLED */ 130 } 131 132 void 133 rstatprog_3(struct svc_req *rqstp, register SVCXPRT *transp) 134 { 135 union { 136 int fill; 137 } argument; 138 char *result; 139 xdrproc_t _xdr_argument, _xdr_result; 140 char *(*local)(char *, struct svc_req *); 141 142 _rpcsvccount++; 143 switch (rqstp->rq_proc) { 144 case NULLPROC: 145 (void) svc_sendreply(transp, 146 (xdrproc_t)xdr_void, NULL); 147 _rpcsvccount--; 148 _rpcsvcstate = _SERVED; 149 return; /* CSTYLED */ 150 151 case RSTATPROC_STATS: 152 _xdr_argument = (xdrproc_t) 153 xdr_void; 154 _xdr_result = (xdrproc_t) 155 xdr_statstime; 156 local = (char *(*)(char *, struct svc_req *)) 157 rstatproc_stats_3_svc; 158 break; 159 160 case RSTATPROC_HAVEDISK: 161 _xdr_argument = (xdrproc_t) 162 xdr_void; 163 _xdr_result = (xdrproc_t) 164 xdr_u_int; 165 local = (char *(*)(char *, struct svc_req *)) 166 rstatproc_havedisk_3_svc; 167 break; 168 169 default: 170 svcerr_noproc(transp); 171 _rpcsvccount--; 172 _rpcsvcstate = _SERVED; 173 return; /* CSTYLED */ 174 } 175 (void) memset((char *)&argument, 0, sizeof (argument)); 176 if (!svc_getargs(transp, _xdr_argument, (caddr_t)&argument)) { 177 svcerr_decode(transp); 178 _rpcsvccount--; 179 _rpcsvcstate = _SERVED; 180 return; /* CSTYLED */ 181 } 182 result = (*local)((char *)&argument, rqstp); 183 if (_xdr_result && result != NULL && 184 !svc_sendreply(transp, _xdr_result, result)) { 185 svcerr_systemerr(transp); 186 } 187 if (!svc_freeargs(transp, _xdr_argument, (caddr_t)&argument)) { 188 RPC_MSGOUT("%s", 189 "unable to free arguments"); 190 exit(1); 191 } 192 _rpcsvccount--; 193 _rpcsvcstate = _SERVED; 194 return; /* CSTYLED */ 195 } 196