From: Barry Jaspan Date: Thu, 24 Oct 1996 21:21:26 +0000 (+0000) Subject: * Makefile.in, rpc_test_clnt.c, rpc_test_svc.c, rpc_test.h: X-Git-Tag: krb5-1.0-freeze1~182 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=b20f4138219847e29402ff19a4398369b7f3e649;p=krb5.git * Makefile.in, rpc_test_clnt.c, rpc_test_svc.c, rpc_test.h: distribute generated rpc_test_* files instead of running rpcgen on rpc_text.x [krb5-admin/133] git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@9240 dc483132-0cff-0310-8789-dd5450dbe970 --- diff --git a/src/lib/rpc/unit-test/ChangeLog b/src/lib/rpc/unit-test/ChangeLog index c45bb419d..2adbe1320 100644 --- a/src/lib/rpc/unit-test/ChangeLog +++ b/src/lib/rpc/unit-test/ChangeLog @@ -1,3 +1,9 @@ +Thu Oct 24 17:20:11 1996 Barry Jaspan + + * Makefile.in, rpc_test_clnt.c, rpc_test_svc.c, rpc_test.h: + distribute generated rpc_test_* files instead of running rpcgen on + rpc_text.x [krb5-admin/133] + Wed Oct 16 16:13:13 1996 Barry Jaspan * rpc_test.0/expire.exp: add test for expired credentials diff --git a/src/lib/rpc/unit-test/Makefile.in b/src/lib/rpc/unit-test/Makefile.in index 7ac96c6c7..28e6862f5 100644 --- a/src/lib/rpc/unit-test/Makefile.in +++ b/src/lib/rpc/unit-test/Makefile.in @@ -10,15 +10,19 @@ server: server.o rpc_test_svc.o $(DEPLIBS) client.c server.c: rpc_test.h -rpc_test.h rpc_test_clnt.c rpc_test_svc.c: rpc_test.x - -rm -f rpc_test_clnt.c rpc_test_svc.c rpc_test.h - -ln -s $(srcdir)/rpc_test.x . - rpcgen -l rpc_test.x -o rpc_test_clnt.c - rpcgen -m rpc_test.x -o rpc_test_svc.c - rpcgen -h rpc_test.x -o rpc_test.h - -clean:: - rm -f rpc_test.h rpc_test_clnt.c rpc_test_svc.c +# If rpc_test.h and rpc_test_*.c do not work on your system, you can +# try using rpcgen by uncommenting these lines (be sure to uncomment +# then in the generated not Makefile.in). +# rpc_test.h rpc_test_clnt.c rpc_test_svc.c: rpc_test.x +# -rm -f rpc_test_clnt.c rpc_test_svc.c rpc_test.h +# -ln -s $(srcdir)/rpc_test.x . +# rpcgen -l rpc_test.x -o rpc_test_clnt.c +# rpcgen -m rpc_test.x -o rpc_test_svc.c +# rpcgen -h rpc_test.x -o rpc_test.h +# +# clean:: +# rm -f rpc_test.h rpc_test_clnt.c rpc_test_svc.c +# check unit-test:: unit-test-setup unit-test-body unit-test-cleanup diff --git a/src/lib/rpc/unit-test/rpc_test.h b/src/lib/rpc/unit-test/rpc_test.h new file mode 100644 index 000000000..6e183e54c --- /dev/null +++ b/src/lib/rpc/unit-test/rpc_test.h @@ -0,0 +1,12 @@ +#ifndef _RPC_TEST_H_RPCGEN +#define _RPC_TEST_H_RPCGEN + +#include + +#define RPC_TEST_PROG ((unsigned long)(1000001)) +#define RPC_TEST_VERS_1 ((unsigned long)(1)) +#define RPC_TEST_ECHO ((unsigned long)(1)) +extern char ** rpc_test_echo_1(); +extern int rpc_test_prog_1_freeresult(); + +#endif /* !_RPC_TEST_H_RPCGEN */ diff --git a/src/lib/rpc/unit-test/rpc_test_clnt.c b/src/lib/rpc/unit-test/rpc_test_clnt.c new file mode 100644 index 000000000..801f43d79 --- /dev/null +++ b/src/lib/rpc/unit-test/rpc_test_clnt.c @@ -0,0 +1,21 @@ +#include "rpc_test.h" + +/* Default timeout can be changed using clnt_control() */ +static struct timeval TIMEOUT = { 25, 0 }; + +char ** +rpc_test_echo_1(argp, clnt) + char **argp; + CLIENT *clnt; +{ + static char *clnt_res; + + memset((char *)&clnt_res, 0, sizeof (clnt_res)); + if (clnt_call(clnt, RPC_TEST_ECHO, + (xdrproc_t) xdr_wrapstring, (caddr_t) argp, + (xdrproc_t) xdr_wrapstring, (caddr_t) &clnt_res, + TIMEOUT) != RPC_SUCCESS) { + return (NULL); + } + return (&clnt_res); +} diff --git a/src/lib/rpc/unit-test/rpc_test_svc.c b/src/lib/rpc/unit-test/rpc_test_svc.c new file mode 100644 index 000000000..79f5e646a --- /dev/null +++ b/src/lib/rpc/unit-test/rpc_test_svc.c @@ -0,0 +1,73 @@ +#include "rpc_test.h" +#include +#include /* getenv, exit */ +#include +#include + +/* States a server can be in wrt request */ + +#define _IDLE 0 +#define _SERVED 1 + +static int _rpcsvcstate = _IDLE; /* Set when a request is serviced */ +static int _rpcsvccount = 0; /* Number of requests being serviced */ + +static +void _msgout(msg) + char *msg; +{ + syslog(LOG_ERR, msg); +} + +void +rpc_test_prog_1(rqstp, transp) + struct svc_req *rqstp; + register SVCXPRT *transp; +{ + union { + char *rpc_test_echo_1_arg; + } argument; + char *result; + bool_t (*xdr_argument)(), (*xdr_result)(); + char *(*local)(); + + _rpcsvccount++; + switch (rqstp->rq_proc) { + case NULLPROC: + (void) svc_sendreply(transp, xdr_void, + (char *)NULL); + _rpcsvccount--; + _rpcsvcstate = _SERVED; + return; + + case RPC_TEST_ECHO: + xdr_argument = xdr_wrapstring; + xdr_result = xdr_wrapstring; + local = (char *(*)()) rpc_test_echo_1; + break; + + default: + svcerr_noproc(transp); + _rpcsvccount--; + _rpcsvcstate = _SERVED; + return; + } + (void) memset((char *)&argument, 0, sizeof (argument)); + if (!svc_getargs(transp, xdr_argument, &argument)) { + svcerr_decode(transp); + _rpcsvccount--; + _rpcsvcstate = _SERVED; + return; + } + result = (*local)(&argument, rqstp); + if (result != NULL && !svc_sendreply(transp, xdr_result, result)) { + svcerr_systemerr(transp); + } + if (!svc_freeargs(transp, xdr_argument, &argument)) { + _msgout("unable to free arguments"); + exit(1); + } + _rpcsvccount--; + _rpcsvcstate = _SERVED; + return; +}