Some minor tweaks for statd

- use rpcgen to generate unmodified code instead of havinf it in the
  repository
- use "natural" function names to avoid conflicts with prototypes etc.
This commit is contained in:
Peter Wemm 1996-04-01 05:36:06 +00:00
parent ce81d24b05
commit a60dc5e0f9
8 changed files with 50 additions and 202 deletions

View File

@ -1,13 +1,26 @@
# $Id$
# $Id: Makefile,v 1.1.1.1 1996/02/17 15:11:28 peter Exp $
PROG = rpc.statd
SRCS = statd.c procs.c file.c
SRCS = file.c sm_inter_svc.c statd.c procs.c
MAN8 = rpc.statd.8
DPADD= ${LIBRPCSVC}
LDADD= -lrpcsvc
.include <bsd.prog.mk>
CFLAGS+= -I.
CLEANFILES= sm_inter_svc.c sm_inter.h
RPCSRC= ${.DESTDIR}/usr/include/rpcsvc/sm_inter.x
RPCGEN= rpcgen -L -C
sm_inter_svc.c: ${RPCSRC} sm_inter.h
${RPCGEN} -m -o ${.TARGET} ${RPCSRC}
sm_inter.h: ${RPCSRC}
${RPCGEN} -h -o ${.TARGET} ${RPCSRC}
test: test.c
cc -o test test.c -lrpcsvc
.include <bsd.prog.mk>

View File

@ -49,7 +49,7 @@
an address.
*/
struct sm_stat_res *sm_stat_1(sm_name *arg)
struct sm_stat_res *sm_stat_1_svc(sm_name *arg, struct svc_req *req)
{
static sm_stat_res res;
@ -75,7 +75,7 @@ struct sm_stat_res *sm_stat_1(sm_name *arg)
valid (as judged by gethostbyname())
*/
struct sm_stat_res *sm_mon_1(mon *arg)
struct sm_stat_res *sm_mon_1_svc(mon *arg, struct svc_req *req)
{
static sm_stat_res res;
HostInfo *hp;
@ -129,7 +129,7 @@ struct sm_stat_res *sm_mon_1(mon *arg)
/*
Purpose: Remove a monitor request from a host
Returns: TRUE if found, FALSE if not found.
Notes: Common code from sm_unmon_1 and sm_unmon_all_1
Notes: Common code from sm_unmon_1_svc and sm_unmon_all_1_svc
In the unlikely event of more than one identical monitor
request, all are removed.
*/
@ -172,7 +172,7 @@ static int do_unmon(HostInfo *hp, my_id *idp)
earlier call to sm_mon_1
*/
struct sm_stat *sm_unmon_1(mon_id *arg)
struct sm_stat *sm_unmon_1_svc(mon_id *arg, struct svc_req *req)
{
static sm_stat res;
HostInfo *hp;
@ -210,7 +210,7 @@ struct sm_stat *sm_unmon_1(mon_id *arg)
host and program number.
*/
struct sm_stat *sm_unmon_all_1(my_id *arg)
struct sm_stat *sm_unmon_all_1_svc(my_id *arg, struct svc_req *req)
{
static sm_stat res;
HostInfo *hp;
@ -248,7 +248,7 @@ struct sm_stat *sm_unmon_all_1(my_id *arg)
and inform all hosts on the monitor list.
*/
void *sm_simu_crash_1(void)
void *sm_simu_crash_1_svc(void *v, struct svc_req *req)
{
static char dummy;
int work_to_do;
@ -292,7 +292,7 @@ void *sm_simu_crash_1(void)
that modify the list.
*/
void *sm_notify_1(stat_chge *arg)
void *sm_notify_1_svc(stat_chge *arg, struct svc_req *req)
{
struct timeval timeout = { 20, 0 }; /* 20 secs timeout */
CLIENT *cli;

View File

@ -50,7 +50,7 @@ static char rcsid[] = "$id: $";
int debug = 0; /* Controls syslog() calls for debug messages */
static void sm_prog_1();
extern void sm_prog_1(struct svc_req *rqstp, SVCXPRT *transp);
static void handle_sigchld();
main(int argc, char **argv)
@ -141,92 +141,3 @@ static void handle_sigchld(int sig, int code, struct sigcontext *scp)
WEXITSTATUS(status));
}
/* sm_prog1 ---------------------------------------------------------------- */
/*
Purpose: Handle one RPC request
Returns: Nothing
Notes: Called from RPC libraray on receipt of a request.
Code for this function was auto-generated by rpcgen.
*/
static void
sm_prog_1(struct svc_req *rqstp, SVCXPRT *transp)
{
union
{
struct sm_name sm_stat_1_arg;
struct mon sm_mon_1_arg;
struct mon_id sm_unmon_1_arg;
struct my_id sm_unmon_all_1_arg;
struct stat_chge sm_notify_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 SM_STAT:
xdr_argument = xdr_sm_name;
xdr_result = xdr_sm_stat_res;
local = (char *(*)()) sm_stat_1;
break;
case SM_MON:
xdr_argument = xdr_mon;
xdr_result = xdr_sm_stat_res;
local = (char *(*)()) sm_mon_1;
break;
case SM_UNMON:
xdr_argument = xdr_mon_id;
xdr_result = xdr_sm_stat;
local = (char *(*)()) sm_unmon_1;
break;
case SM_UNMON_ALL:
xdr_argument = xdr_my_id;
xdr_result = xdr_sm_stat;
local = (char *(*)()) sm_unmon_all_1;
break;
case SM_SIMU_CRASH:
xdr_argument = xdr_void;
xdr_result = xdr_void;
local = (char *(*)()) sm_simu_crash_1;
break;
case SM_NOTIFY:
xdr_argument = xdr_stat_chge;
xdr_result = xdr_void;
local = (char *(*)()) sm_notify_1;
break;
default:
svcerr_noproc(transp);
return;
}
bzero((char *)&argument, sizeof(argument));
if (!svc_getargs(transp, xdr_argument, (caddr_t)&argument))
{
svcerr_decode(transp);
return;
}
result = (*local)(&argument, rqstp);
if (result != NULL && !svc_sendreply(transp, xdr_result, result))
{
svcerr_systemerr(transp);
}
if (!svc_freeargs(transp, xdr_argument, (caddr_t)&argument))
{
syslog(LOG_ERR, "unable to free arguments");
exit(1);
}
}

View File

@ -33,7 +33,7 @@
#include <rpcsvc/sm_inter.h>
#include "sm_inter.h"
/* These pieces are missing from the distributed sm_inter.x, which */
/* omits the SM_NOTIFY procedure used between cooperating rpc.statd's */

View File

@ -1,13 +1,26 @@
# $Id$
# $Id: Makefile,v 1.1.1.1 1996/02/17 15:11:28 peter Exp $
PROG = rpc.statd
SRCS = statd.c procs.c file.c
SRCS = file.c sm_inter_svc.c statd.c procs.c
MAN8 = rpc.statd.8
DPADD= ${LIBRPCSVC}
LDADD= -lrpcsvc
.include <bsd.prog.mk>
CFLAGS+= -I.
CLEANFILES= sm_inter_svc.c sm_inter.h
RPCSRC= ${.DESTDIR}/usr/include/rpcsvc/sm_inter.x
RPCGEN= rpcgen -L -C
sm_inter_svc.c: ${RPCSRC} sm_inter.h
${RPCGEN} -m -o ${.TARGET} ${RPCSRC}
sm_inter.h: ${RPCSRC}
${RPCGEN} -h -o ${.TARGET} ${RPCSRC}
test: test.c
cc -o test test.c -lrpcsvc
.include <bsd.prog.mk>

View File

@ -49,7 +49,7 @@
an address.
*/
struct sm_stat_res *sm_stat_1(sm_name *arg)
struct sm_stat_res *sm_stat_1_svc(sm_name *arg, struct svc_req *req)
{
static sm_stat_res res;
@ -75,7 +75,7 @@ struct sm_stat_res *sm_stat_1(sm_name *arg)
valid (as judged by gethostbyname())
*/
struct sm_stat_res *sm_mon_1(mon *arg)
struct sm_stat_res *sm_mon_1_svc(mon *arg, struct svc_req *req)
{
static sm_stat_res res;
HostInfo *hp;
@ -129,7 +129,7 @@ struct sm_stat_res *sm_mon_1(mon *arg)
/*
Purpose: Remove a monitor request from a host
Returns: TRUE if found, FALSE if not found.
Notes: Common code from sm_unmon_1 and sm_unmon_all_1
Notes: Common code from sm_unmon_1_svc and sm_unmon_all_1_svc
In the unlikely event of more than one identical monitor
request, all are removed.
*/
@ -172,7 +172,7 @@ static int do_unmon(HostInfo *hp, my_id *idp)
earlier call to sm_mon_1
*/
struct sm_stat *sm_unmon_1(mon_id *arg)
struct sm_stat *sm_unmon_1_svc(mon_id *arg, struct svc_req *req)
{
static sm_stat res;
HostInfo *hp;
@ -210,7 +210,7 @@ struct sm_stat *sm_unmon_1(mon_id *arg)
host and program number.
*/
struct sm_stat *sm_unmon_all_1(my_id *arg)
struct sm_stat *sm_unmon_all_1_svc(my_id *arg, struct svc_req *req)
{
static sm_stat res;
HostInfo *hp;
@ -248,7 +248,7 @@ struct sm_stat *sm_unmon_all_1(my_id *arg)
and inform all hosts on the monitor list.
*/
void *sm_simu_crash_1(void)
void *sm_simu_crash_1_svc(void *v, struct svc_req *req)
{
static char dummy;
int work_to_do;
@ -292,7 +292,7 @@ void *sm_simu_crash_1(void)
that modify the list.
*/
void *sm_notify_1(stat_chge *arg)
void *sm_notify_1_svc(stat_chge *arg, struct svc_req *req)
{
struct timeval timeout = { 20, 0 }; /* 20 secs timeout */
CLIENT *cli;

View File

@ -50,7 +50,7 @@ static char rcsid[] = "$id: $";
int debug = 0; /* Controls syslog() calls for debug messages */
static void sm_prog_1();
extern void sm_prog_1(struct svc_req *rqstp, SVCXPRT *transp);
static void handle_sigchld();
main(int argc, char **argv)
@ -141,92 +141,3 @@ static void handle_sigchld(int sig, int code, struct sigcontext *scp)
WEXITSTATUS(status));
}
/* sm_prog1 ---------------------------------------------------------------- */
/*
Purpose: Handle one RPC request
Returns: Nothing
Notes: Called from RPC libraray on receipt of a request.
Code for this function was auto-generated by rpcgen.
*/
static void
sm_prog_1(struct svc_req *rqstp, SVCXPRT *transp)
{
union
{
struct sm_name sm_stat_1_arg;
struct mon sm_mon_1_arg;
struct mon_id sm_unmon_1_arg;
struct my_id sm_unmon_all_1_arg;
struct stat_chge sm_notify_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 SM_STAT:
xdr_argument = xdr_sm_name;
xdr_result = xdr_sm_stat_res;
local = (char *(*)()) sm_stat_1;
break;
case SM_MON:
xdr_argument = xdr_mon;
xdr_result = xdr_sm_stat_res;
local = (char *(*)()) sm_mon_1;
break;
case SM_UNMON:
xdr_argument = xdr_mon_id;
xdr_result = xdr_sm_stat;
local = (char *(*)()) sm_unmon_1;
break;
case SM_UNMON_ALL:
xdr_argument = xdr_my_id;
xdr_result = xdr_sm_stat;
local = (char *(*)()) sm_unmon_all_1;
break;
case SM_SIMU_CRASH:
xdr_argument = xdr_void;
xdr_result = xdr_void;
local = (char *(*)()) sm_simu_crash_1;
break;
case SM_NOTIFY:
xdr_argument = xdr_stat_chge;
xdr_result = xdr_void;
local = (char *(*)()) sm_notify_1;
break;
default:
svcerr_noproc(transp);
return;
}
bzero((char *)&argument, sizeof(argument));
if (!svc_getargs(transp, xdr_argument, (caddr_t)&argument))
{
svcerr_decode(transp);
return;
}
result = (*local)(&argument, rqstp);
if (result != NULL && !svc_sendreply(transp, xdr_result, result))
{
svcerr_systemerr(transp);
}
if (!svc_freeargs(transp, xdr_argument, (caddr_t)&argument))
{
syslog(LOG_ERR, "unable to free arguments");
exit(1);
}
}

View File

@ -33,7 +33,7 @@
#include <rpcsvc/sm_inter.h>
#include "sm_inter.h"
/* These pieces are missing from the distributed sm_inter.x, which */
/* omits the SM_NOTIFY procedure used between cooperating rpc.statd's */