]> git.saurik.com Git - apple/libinfo.git/blobdiff - rpc.subproj/svc_simple.c
Libinfo-392.1.tar.gz
[apple/libinfo.git] / rpc.subproj / svc_simple.c
index 6174d0435cfac9be01d9f7db672c8ef2d0d9d4da..c0952fd7936fb2e74e5e8ab3ec9984eeb1832d0b 100644 (file)
@@ -53,7 +53,7 @@
 #if defined(LIBC_SCCS) && !defined(lint)
 /*static char *sccsid = "from: @(#)svc_simple.c 1.18 87/08/11 Copyr 1984 Sun Micro";*/
 /*static char *sccsid = "from: @(#)svc_simple.c        2.2 88/08/01 4.0 RPCSRC";*/
-static char *rcsid = "$Id: svc_simple.c,v 1.2 1999/10/14 21:56:54 wsanchez Exp $";
+static char *rcsid = "$Id: svc_simple.c,v 1.3 2002/02/19 20:36:25 epeyton Exp $";
 #endif
 
 /* 
@@ -64,7 +64,10 @@ static char *rcsid = "$Id: svc_simple.c,v 1.2 1999/10/14 21:56:54 wsanchez Exp $
  */
 
 #include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
 #include <rpc/rpc.h>
+#include <rpc/pmap_clnt.h>
 #include <sys/socket.h>
 #include <netdb.h>
 
@@ -79,14 +82,21 @@ static void universal();
 static SVCXPRT *transp;
 struct proglst *pl;
 
+int
 registerrpc(prognum, versnum, procnum, progname, inproc, outproc)
+       int prognum;
+       int versnum;
+       int procnum;
        char *(*progname)();
        xdrproc_t inproc, outproc;
 {
        
        if (procnum == NULLPROC) {
-               (void) fprintf(stderr,
-                   "can't reassign procedure number %d\n", NULLPROC);
+#ifdef __LP64__
+               (void) fprintf(stderr, "can't reassign procedure number %d\n", NULLPROC);
+#else
+               (void) fprintf(stderr, "can't reassign procedure number %ld\n", NULLPROC);
+#endif
                return (-1);
        }
        if (transp == 0) {
@@ -96,13 +106,23 @@ registerrpc(prognum, versnum, procnum, progname, inproc, outproc)
                        return (-1);
                }
        }
-       (void) pmap_unset((u_long)prognum, (u_long)versnum);
-       if (!svc_register(transp, (u_long)prognum, (u_long)versnum, 
+#ifdef __LP64__
+       (void) pmap_unset((uint32_t)prognum, (uint32_t)versnum);
+       if (!svc_register(transp, (uint32_t)prognum, (uint32_t)versnum, 
            universal, IPPROTO_UDP)) {
                (void) fprintf(stderr, "couldn't register prog %d vers %d\n",
                    prognum, versnum);
                return (-1);
        }
+#else
+       (void) pmap_unset((u_long)prognum, (u_long)versnum);
+       if (!svc_register(transp, (u_long)prognum, (u_long)versnum, 
+           universal, IPPROTO_UDP)) {
+                       (void) fprintf(stderr, "couldn't register prog %d vers %d\n",
+                       prognum, versnum);
+               return (-1);
+       }
+#endif
        pl = (struct proglst *)malloc(sizeof(struct proglst));
        if (pl == NULL) {
                (void) fprintf(stderr, "registerrpc: out of memory\n");
@@ -132,7 +152,7 @@ universal(rqstp, transp)
         * enforce "procnum 0 is echo" convention
         */
        if (rqstp->rq_proc == NULLPROC) {
-               if (svc_sendreply(transp, xdr_void, (char *)NULL) == FALSE) {
+               if (svc_sendreply(transp, (xdrproc_t)xdr_void, (char *)NULL) == FALSE) {
                        (void) fprintf(stderr, "xxx\n");
                        exit(1);
                }
@@ -149,7 +169,7 @@ universal(rqstp, transp)
                                return;
                        }
                        outdata = (*(pl->p_progname))(xdrbuf);
-                       if (outdata == NULL && pl->p_outproc != xdr_void)
+                       if (outdata == NULL && pl->p_outproc != (xdrproc_t)xdr_void)
                                /* there was an error */
                                return;
                        if (!svc_sendreply(transp, pl->p_outproc, outdata)) {