* Makefile.in, rpc_test_clnt.c, rpc_test_svc.c, rpc_test.h:
authorBarry Jaspan <bjaspan@mit.edu>
Thu, 24 Oct 1996 21:21:26 +0000 (21:21 +0000)
committerBarry Jaspan <bjaspan@mit.edu>
Thu, 24 Oct 1996 21:21:26 +0000 (21:21 +0000)
  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

src/lib/rpc/unit-test/ChangeLog
src/lib/rpc/unit-test/Makefile.in
src/lib/rpc/unit-test/rpc_test.h [new file with mode: 0644]
src/lib/rpc/unit-test/rpc_test_clnt.c [new file with mode: 0644]
src/lib/rpc/unit-test/rpc_test_svc.c [new file with mode: 0644]

index c45bb419d8cfbb43425d7a4bd9be6850476a89b1..2adbe13205a021432e165b42636fd4c15ccfd50f 100644 (file)
@@ -1,3 +1,9 @@
+Thu Oct 24 17:20:11 1996  Barry Jaspan  <bjaspan@mit.edu>
+
+       * 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  <bjaspan@mit.edu>
 
        * rpc_test.0/expire.exp: add test for expired credentials
index 7ac96c6c7d9f75d5ba1c7b3e767f83a08c7f5942..28e6862f5dfe8f26cbab9a92754ff9a42c0465fb 100644 (file)
@@ -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 (file)
index 0000000..6e183e5
--- /dev/null
@@ -0,0 +1,12 @@
+#ifndef _RPC_TEST_H_RPCGEN
+#define        _RPC_TEST_H_RPCGEN
+
+#include <rpc/rpc.h>
+
+#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 (file)
index 0000000..801f43d
--- /dev/null
@@ -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 (file)
index 0000000..79f5e64
--- /dev/null
@@ -0,0 +1,73 @@
+#include "rpc_test.h"
+#include <stdio.h>
+#include <stdlib.h> /* getenv, exit */
+#include <sys/types.h>
+#include <syslog.h>
+
+/* 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;
+}