Use void* instead of caddr_t. Cosmetics from FreeBSD.

This commit is contained in:
Ralf Corsepius
2005-05-25 17:17:14 +00:00
parent b322727c94
commit 9dcab59b1a
3 changed files with 49 additions and 31 deletions

View File

@@ -110,14 +110,14 @@ typedef struct __rpc_client {
struct rpc_err *); struct rpc_err *);
/* frees results */ /* frees results */
bool_t (*cl_freeres)(struct __rpc_client *, bool_t (*cl_freeres)(struct __rpc_client *,
xdrproc_t, caddr_t); xdrproc_t, void *);
/* destroy this structure */ /* destroy this structure */
void (*cl_destroy)(struct __rpc_client *); void (*cl_destroy)(struct __rpc_client *);
/* the ioctl() of rpc */ /* the ioctl() of rpc */
bool_t (*cl_control)(struct __rpc_client *, u_int, bool_t (*cl_control)(struct __rpc_client *, u_int,
void *); void *);
} *cl_ops; } *cl_ops;
caddr_t cl_private; /* private stuff */ void *cl_private; /* private stuff */
} CLIENT; } CLIENT;
#define RPCSMALLMSGSIZE 400 /* a more reasonable packet size */ #define RPCSMALLMSGSIZE 400 /* a more reasonable packet size */

View File

@@ -84,20 +84,20 @@ typedef struct __rpc_svcxprt {
enum xprt_stat (*xp_stat)(struct __rpc_svcxprt *); enum xprt_stat (*xp_stat)(struct __rpc_svcxprt *);
/* get arguments */ /* get arguments */
bool_t (*xp_getargs)(struct __rpc_svcxprt *, xdrproc_t, bool_t (*xp_getargs)(struct __rpc_svcxprt *, xdrproc_t,
caddr_t); void *);
/* send reply */ /* send reply */
bool_t (*xp_reply)(struct __rpc_svcxprt *, struct rpc_msg *); bool_t (*xp_reply)(struct __rpc_svcxprt *, struct rpc_msg *);
/* free mem allocated for args */ /* free mem allocated for args */
bool_t (*xp_freeargs)(struct __rpc_svcxprt *, xdrproc_t, bool_t (*xp_freeargs)(struct __rpc_svcxprt *, xdrproc_t,
caddr_t); void *);
/* destroy this struct */ /* destroy this struct */
void (*xp_destroy)(struct __rpc_svcxprt *); void (*xp_destroy)(struct __rpc_svcxprt *);
} *xp_ops; } *xp_ops;
int xp_addrlen; /* length of remote address */ int xp_addrlen; /* length of remote address */
struct sockaddr_in xp_raddr; /* remote addr. (backward ABI compat) */ struct sockaddr_in xp_raddr; /* remote addr. (backward ABI compat) */
struct opaque_auth xp_verf; /* raw response verifier */ struct opaque_auth xp_verf; /* raw response verifier */
caddr_t xp_p1; /* private */ void *xp_p1; /* private: for use by svc ops */
caddr_t xp_p2; /* private */ void *xp_p2; /* private: for use by svc ops */
} SVCXPRT; } SVCXPRT;
/* /*

View File

@@ -41,23 +41,30 @@ static char *rcsid = "$FreeBSD: src/lib/libc/rpc/pmap_rmt.c,v 1.15 2000/01/27 23
* Copyright (C) 1984, Sun Microsystems, Inc. * Copyright (C) 1984, Sun Microsystems, Inc.
*/ */
#include <sys/ioctl.h>
#include <sys/socket.h>
#include <net/if.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <assert.h>
#include <errno.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <rpc/rpc.h> #include <rpc/rpc.h>
#include <rpc/pmap_prot.h> #include <rpc/pmap_prot.h>
#include <rpc/pmap_clnt.h> #include <rpc/pmap_clnt.h>
#include <rpc/pmap_rmt.h> #include <rpc/pmap_rmt.h>
#include <sys/socket.h>
#include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <string.h>
#include <net/if.h>
#include <sys/ioctl.h>
#include <arpa/inet.h>
#include <sys/select.h> #include <sys/select.h>
#define MAX_BROADCAST_SIZE 1400 #define MAX_BROADCAST_SIZE 1400
static struct timeval timeout = { 3, 0 }; static const struct timeval timeout = { 3, 0 };
/* /*
* pmapper remote-call-service interface. * pmapper remote-call-service interface.
@@ -67,7 +74,8 @@ static struct timeval timeout = { 3, 0 };
* programs to do a lookup and call in one step. * programs to do a lookup and call in one step.
*/ */
enum clnt_stat enum clnt_stat
pmap_rmtcall(addr, prog, vers, proc, xdrargs, argsp, xdrres, resp, tout, port_ptr) pmap_rmtcall(addr, prog, vers, proc, xdrargs, argsp, xdrres, resp, tout,
port_ptr)
struct sockaddr_in *addr; struct sockaddr_in *addr;
u_long prog, vers, proc; u_long prog, vers, proc;
xdrproc_t xdrargs, xdrres; xdrproc_t xdrargs, xdrres;
@@ -75,15 +83,18 @@ pmap_rmtcall(addr, prog, vers, proc, xdrargs, argsp, xdrres, resp, tout, port_pt
struct timeval tout; struct timeval tout;
u_long *port_ptr; u_long *port_ptr;
{ {
int socket = -1; int sock = -1;
register CLIENT *client; CLIENT *client;
struct rmtcallargs a; struct rmtcallargs a;
struct rmtcallres r; struct rmtcallres r;
enum clnt_stat stat; enum clnt_stat stat;
assert(addr != NULL);
assert(port_ptr != NULL);
addr->sin_port = htons(PMAPPORT); addr->sin_port = htons(PMAPPORT);
client = clntudp_create(addr, PMAPPROG, PMAPVERS, timeout, &socket); client = clntudp_create(addr, PMAPPROG, PMAPVERS, timeout, &sock);
if (client != (CLIENT *)NULL) { if (client != NULL) {
a.prog = prog; a.prog = prog;
a.vers = vers; a.vers = vers;
a.proc = proc; a.proc = proc;
@@ -92,14 +103,15 @@ pmap_rmtcall(addr, prog, vers, proc, xdrargs, argsp, xdrres, resp, tout, port_pt
r.port_ptr = port_ptr; r.port_ptr = port_ptr;
r.results_ptr = resp; r.results_ptr = resp;
r.xdr_results = xdrres; r.xdr_results = xdrres;
stat = CLNT_CALL(client, PMAPPROC_CALLIT, xdr_rmtcall_args, &a, stat = CLNT_CALL(client, (rpcproc_t)PMAPPROC_CALLIT,
xdr_rmtcallres, &r, tout); (xdrproc_t)xdr_rmtcall_args, &a, (xdrproc_t)xdr_rmtcallres,
&r, tout);
CLNT_DESTROY(client); CLNT_DESTROY(client);
} else { } else {
stat = RPC_FAILED; stat = RPC_FAILED;
} }
if (socket != -1) if (sock != -1)
(void)_RPC_close(socket); (void)_RPC_close(sock);
addr->sin_port = 0; addr->sin_port = 0;
return (stat); return (stat);
} }
@@ -111,11 +123,14 @@ pmap_rmtcall(addr, prog, vers, proc, xdrargs, argsp, xdrres, resp, tout, port_pt
*/ */
bool_t bool_t
xdr_rmtcall_args(xdrs, cap) xdr_rmtcall_args(xdrs, cap)
register XDR *xdrs; XDR *xdrs;
register struct rmtcallargs *cap; struct rmtcallargs *cap;
{ {
u_int lenposition, argposition, position; u_int lenposition, argposition, position;
assert(xdrs != NULL);
assert(cap != NULL);
if (xdr_u_long(xdrs, &(cap->prog)) && if (xdr_u_long(xdrs, &(cap->prog)) &&
xdr_u_long(xdrs, &(cap->vers)) && xdr_u_long(xdrs, &(cap->vers)) &&
xdr_u_long(xdrs, &(cap->proc))) { xdr_u_long(xdrs, &(cap->proc))) {
@@ -142,15 +157,18 @@ xdr_rmtcall_args(xdrs, cap)
*/ */
bool_t bool_t
xdr_rmtcallres(xdrs, crp) xdr_rmtcallres(xdrs, crp)
register XDR *xdrs; XDR *xdrs;
register struct rmtcallres *crp; struct rmtcallres *crp;
{ {
caddr_t port_ptr; caddr_t port_ptr;
port_ptr = (caddr_t)crp->port_ptr; assert(xdrs != NULL);
assert(crp != NULL);
port_ptr = (caddr_t)(void *)crp->port_ptr;
if (xdr_reference(xdrs, &port_ptr, sizeof (u_long), if (xdr_reference(xdrs, &port_ptr, sizeof (u_long),
(xdrproc_t)xdr_u_long) && xdr_u_long(xdrs, &crp->resultslen)) { (xdrproc_t)xdr_u_long) && xdr_u_long(xdrs, &crp->resultslen)) {
crp->port_ptr = (u_long *)port_ptr; crp->port_ptr = (u_long *)(void *)port_ptr;
return ((*(crp->xdr_results))(xdrs, crp->results_ptr)); return ((*(crp->xdr_results))(xdrs, crp->results_ptr));
} }
return (FALSE); return (FALSE);