Subject: RPC header file patches...
To: None <current-users@sun-lamp.cs.berkeley.edu>
From: Christos Zoulas <christos@deshaw.com>
List: current-users
Date: 04/12/1994 09:31:50
Hello,

The following are some patches for <rpc/*.h>. These are necessary for c++
programs, since () != (any, number, of, arguments) in c++.

In addition, there were 2 instances of nested comments which have been fixed.

Note that I've tested the changes only with my c++ code and have not tried
to compile anything else yet. I am afraid that with the extra prototypes,
things that use the callbacks in questionable ways can produce warnings/errors.

christos


*** auth.h	Fri Dec 17 01:18:57 1993
--- /usr/include/rpc/auth.h	Mon Apr 11 21:56:08 1994
***************
*** 164,170 ****
  extern AUTH *authunix_create		__P((char *, int, int, int, int *));
  extern AUTH *authunix_create_default	__P((void));
  extern AUTH *authnone_create		__P((void));
! extern AUTH *authdes_create();
  __END_DECLS
  
  #define AUTH_NONE	0		/* no authentication */
--- 164,172 ----
  extern AUTH *authunix_create		__P((char *, int, int, int, int *));
  extern AUTH *authunix_create_default	__P((void));
  extern AUTH *authnone_create		__P((void));
! extern AUTH *authdes_create		__P((char *, u_int, 
! 					     struct sockaddr_in *,
! 					     des_block *));
  __END_DECLS
  
  #define AUTH_NONE	0		/* no authentication */
*** clnt.h	Fri Dec 17 01:18:58 1993
--- /usr/include/rpc/clnt.h	Tue Apr 12 01:42:53 1994
***************
*** 39,45 ****
--- 39,47 ----
  
  #ifndef _RPC_CLNT_H_
  #define _RPC_CLNT_H_
+ #include <sys/types.h>
  #include <sys/cdefs.h>
+ #include "xdr.h"
  
  /*
   * Rpc calls return an enum clnt_stat.  This should be looked at more,
***************
*** 114,128 ****
   * Created by individual implementations, see e.g. rpc_udp.c.
   * Client is responsible for initializing auth, see e.g. auth_none.c.
   */
! typedef struct {
  	AUTH	*cl_auth;			/* authenticator */
  	struct clnt_ops {
! 		enum clnt_stat	(*cl_call)();	/* call remote procedure */
! 		void		(*cl_abort)();	/* abort a call */
! 		void		(*cl_geterr)();	/* get specific error code */
! 		bool_t		(*cl_freeres)(); /* frees results */
! 		void		(*cl_destroy)();/* destroy this structure */
! 		bool_t          (*cl_control)();/* the ioctl() of rpc */
  	} *cl_ops;
  	caddr_t			cl_private;	/* private stuff */
  } CLIENT;
--- 116,142 ----
   * Created by individual implementations, see e.g. rpc_udp.c.
   * Client is responsible for initializing auth, see e.g. auth_none.c.
   */
! typedef struct CLIENT {
  	AUTH	*cl_auth;			/* authenticator */
  	struct clnt_ops {
! 		/* call remote procedure */
! 		enum clnt_stat	(*cl_call) __P((struct CLIENT*, u_long,
! 						xdrproc_t, caddr_t,
! 						xdrproc_t, caddr_t,
! 						struct timeval));
! 		/* abort a call */
! 		void		(*cl_abort) __P((struct CLIENT*));
! 		/* get specific error code */
! 		void		(*cl_geterr) __P((struct CLIENT*,
! 						  struct rpc_err*));
! 		/* frees results */
! 		bool_t		(*cl_freeres) __P((struct CLIENT*, xdrproc_t,
! 						   caddr_t));
! 		/* destroy this structure */
! 		void		(*cl_destroy) __P((struct CLIENT*));
! 		/* the ioctl() of rpc */
! 		bool_t          (*cl_control) __P((struct CLIENT*, u_int,
! 						   char*));
  	} *cl_ops;
  	caddr_t			cl_private;	/* private stuff */
  } CLIENT;
*** pmap_clnt.h	Fri Dec 17 01:18:58 1993
--- /usr/include/rpc/pmap_clnt.h	Mon Apr 11 22:06:54 1994
***************
*** 64,69 ****
--- 64,71 ----
  #define _RPC_PMAPCLNT_H
  #include <sys/cdefs.h>
  
+ typedef bool_t (*resultproc_t)(char *, struct in_addr *);
+ 
  __BEGIN_DECLS
  extern bool_t		pmap_set	__P((u_long, u_long, int, int));
  extern bool_t		pmap_unset	__P((u_long, u_long));
***************
*** 76,82 ****
  extern enum clnt_stat	clnt_broadcast	__P((u_long, u_long, u_long,
  					     xdrproc_t, char *,
  					     xdrproc_t, char *,
! 					     bool_t (*)()));
  extern u_short		pmap_getport	__P((struct sockaddr_in *,
  					     u_long, u_long, u_int));
  __END_DECLS
--- 78,84 ----
  extern enum clnt_stat	clnt_broadcast	__P((u_long, u_long, u_long,
  					     xdrproc_t, char *,
  					     xdrproc_t, char *,
! 					     resultproc_t));
  extern u_short		pmap_getport	__P((struct sockaddr_in *,
  					     u_long, u_long, u_int));
  __END_DECLS
*** svc.h	Fri Dec 17 01:19:00 1993
--- /usr/include/rpc/svc.h	Tue Apr 12 01:43:14 1994
***************
*** 39,45 ****
--- 39,47 ----
  
  #ifndef _RPC_SVC_H
  #define _RPC_SVC_H
+ #include <sys/types.h>
  #include <sys/cdefs.h>
+ #include "xdr.h"
  
  /*
   * This interface must manage two items concerning remote procedure calling:
***************
*** 72,87 ****
  /*
   * Server side transport handle
   */
! typedef struct {
  	int		xp_sock;
  	u_short		xp_port;	 /* associated port number */
  	struct xp_ops {
! 	    bool_t	(*xp_recv)();	 /* receive incomming requests */
! 	    enum xprt_stat (*xp_stat)(); /* get transport status */
! 	    bool_t	(*xp_getargs)(); /* get arguments */
! 	    bool_t	(*xp_reply)();	 /* send reply */
! 	    bool_t	(*xp_freeargs)();/* free mem allocated for args */
! 	    void	(*xp_destroy)(); /* destroy this struct */
  	} *xp_ops;
  	int		xp_addrlen;	 /* length of remote address */
  	struct sockaddr_in xp_raddr;	 /* remote address */
--- 74,98 ----
  /*
   * Server side transport handle
   */
! 
! typedef struct SVCXPRT {
  	int		xp_sock;
  	u_short		xp_port;	 /* associated port number */
  	struct xp_ops {
! 	    /* receive incomming requests */
! 	    bool_t	(*xp_recv) __P((struct SVCXPRT*, struct rpc_msg*));
! 	    /* get transport status */
! 	    enum xprt_stat (*xp_stat) __P((struct SVCXPRT*));
! 	    /* get arguments */
! 	    bool_t	(*xp_getargs) __P((struct SVCXPRT*, xdrproc_t,
! 					   caddr_t));
! 	    /* send reply */
! 	    bool_t	(*xp_reply) __P((struct SVCXPRT*, struct rpc_msg*));
! 	    /* free mem allocated for args */
! 	    bool_t	(*xp_freeargs) __P((struct SVCXPRT*, xdrproc_t,
! 					    caddr_t));
! 	    /* destroy this struct */
! 	    void	(*xp_destroy) __P((struct SVCXPRT*));
  	} *xp_ops;
  	int		xp_addrlen;	 /* length of remote address */
  	struct sockaddr_in xp_raddr;	 /* remote address */
***************
*** 155,164 ****
   *	u_long prog;
   *	u_long vers;
   *	void (*dispatch)();
!  *	int protocol;  /* like TCP or UDP, zero means do not register 
   */
  __BEGIN_DECLS
! extern bool_t	svc_register __P((SVCXPRT *, u_long, u_long, void (*)(), int));
  __END_DECLS
  
  /*
--- 166,176 ----
   *	u_long prog;
   *	u_long vers;
   *	void (*dispatch)();
!  *	int protocol; like TCP or UDP, zero means do not register 
   */
  __BEGIN_DECLS
! extern bool_t	svc_register __P((SVCXPRT *, u_long, u_long,
! 				  void (*)(struct svc_req *, SVCXPRT *), int));
  __END_DECLS
  
  /*
***************
*** 247,264 ****
--- 259,280 ----
   * Global keeper of rpc service descriptors in use
   * dynamic; must be inspected before each call to select 
   */
+ __BEGIN_DECLS
  #ifdef FD_SETSIZE
  extern fd_set svc_fdset;
  #define svc_fds svc_fdset.fds_bits[0]	/* compatibility */
  #else
  extern int svc_fds;
  #endif /* def FD_SETSIZE */
+ __END_DECLS
  
  /*
   * a small program implemented by the svc_rpc implementation itself;
   * also see clnt.h for protocol numbers.
   */
+ __BEGIN_DECLS
  extern void rpctest_service();
+ __END_DECLS
  
  __BEGIN_DECLS
  extern void	svc_getreq	__P((int));
***************
*** 297,302 ****
--- 313,325 ----
   */
  __BEGIN_DECLS
  extern SVCXPRT *svctcp_create __P((int, u_int, u_int));
+ __END_DECLS
+ 
+ /*
+  * Fd based rpc.
+  */
+ __BEGIN_DECLS
+ extern SVCXPRT *svcfd_create __P((int, u_int, u_int));
  __END_DECLS
  
  #endif /* !_RPC_SVC_H */
*** xdr.h	Fri Dec 17 01:19:01 1993
--- /usr/include/rpc/xdr.h	Tue Apr 12 01:42:27 1994
***************
*** 39,44 ****
--- 39,45 ----
  
  #ifndef _RPC_XDR_H
  #define _RPC_XDR_H
+ #include <sys/types.h>
  #include <sys/cdefs.h>
  
  /*
***************
*** 89,104 ****
  #define RNDUP(x)  ((((x) + BYTES_PER_XDR_UNIT - 1) / BYTES_PER_XDR_UNIT) \
  		    * BYTES_PER_XDR_UNIT)
  
- /*
-  * A xdrproc_t exists for each data type which is to be encoded or decoded.
-  *
-  * The second argument to the xdrproc_t is a pointer to an opaque pointer.
-  * The opaque pointer generally points to a structure of the data type
-  * to be decoded.  If this pointer is 0, then the type routines should
-  * allocate dynamic storage of the appropriate size and return it.
-  * bool_t	(*xdrproc_t)(XDR *, caddr_t *);
-  */
- typedef	bool_t (*xdrproc_t)();
  
  /*
   * The XDR handle.
--- 90,95 ----
***************
*** 106,122 ****
   * an operations vector for the paticular implementation (e.g. see xdr_mem.c),
   * and two private fields for the use of the particular impelementation.
   */
! typedef struct {
  	enum xdr_op	x_op;		/* operation; fast additional param */
  	struct xdr_ops {
! 		bool_t	(*x_getlong)();	/* get a long from underlying stream */
! 		bool_t	(*x_putlong)();	/* put a long to " */
! 		bool_t	(*x_getbytes)();/* get some bytes from " */
! 		bool_t	(*x_putbytes)();/* put some bytes to " */
! 		u_int	(*x_getpostn)();/* returns bytes off from beginning */
! 		bool_t  (*x_setpostn)();/* lets you reposition the stream */
! 		long *	(*x_inline)();	/* buf quick ptr to buffered data */
! 		void	(*x_destroy)();	/* free privates of this xdr_stream */
  	} *x_ops;
  	caddr_t 	x_public;	/* users' data */
  	caddr_t		x_private;	/* pointer to private data */
--- 97,121 ----
   * an operations vector for the paticular implementation (e.g. see xdr_mem.c),
   * and two private fields for the use of the particular impelementation.
   */
! typedef struct XDR {
  	enum xdr_op	x_op;		/* operation; fast additional param */
  	struct xdr_ops {
! 		/* get a long from underlying stream */
! 		bool_t	(*x_getlong) __P((struct XDR*, long*));
! 		/* put a long to " */
! 		bool_t	(*x_putlong) __P((struct XDR*, long*));
! 		/* get some bytes from " */
! 		bool_t	(*x_getbytes) __P((struct XDR*, caddr_t, u_int));
! 		/* put some bytes to " */
! 		bool_t	(*x_putbytes) __P((struct XDR*, caddr_t, u_int));
! 		/* returns bytes off from beginning */
! 		u_int	(*x_getpostn) __P((struct XDR*));
! 		/* lets you reposition the stream */
! 		bool_t  (*x_setpostn) __P((struct XDR*, u_int));
! 		/* buf quick ptr to buffered data */
! 		long *	(*x_inline) __P((struct XDR*, u_int));
! 		/* free privates of this xdr_stream */
! 		void	(*x_destroy) __P((struct XDR*));
  	} *x_ops;
  	caddr_t 	x_public;	/* users' data */
  	caddr_t		x_private;	/* pointer to private data */
***************
*** 125,130 ****
--- 124,140 ----
  } XDR;
  
  /*
+  * A xdrproc_t exists for each data type which is to be encoded or decoded.
+  *
+  * The second argument to the xdrproc_t is a pointer to an opaque pointer.
+  * The opaque pointer generally points to a structure of the data type
+  * to be decoded.  If this pointer is 0, then the type routines should
+  * allocate dynamic storage of the appropriate size and return it.
+  * bool_t	(*xdrproc_t)(XDR *, caddr_t *);
+  */
+ typedef	bool_t (*xdrproc_t) __P((XDR*, caddr_t*));
+ 
+ /*
   * Operations defined on a XDR handle
   *
   * XDR		*xdrs;
***************
*** 276,282 ****
  #endif
  
  /* XDR pseudo records for tcp */
! extern void   xdrrec_create	__P((XDR *, u_int, u_int, char *, int (*)(), int (*)()));
  
  /* make end of xdr record */
  extern bool_t xdrrec_endofrecord __P((XDR *, int));
--- 286,292 ----
  #endif
  
  /* XDR pseudo records for tcp */
! extern void   xdrrec_create	__P((XDR *, u_int, u_int, char *, int (*)(void), int (*)(void)));
  
  /* make end of xdr record */
  extern bool_t xdrrec_endofrecord __P((XDR *, int));
*** /usr/src/include/rpc/rpc.h	Fri Dec 17 01:18:59 1993
--- ./rpc.h	Mon Apr 11 16:10:51 1994
***************
*** 59,65 ****
   *  Uncomment-out the next line if you are building the rpc library with    
   *  DES Authentication (see the README file in the secure_rpc/ directory).
   */
! /*#include <rpc/auth_des.h>	/* protocol for des style cred */
  
  /* Server side only remote procedure callee */
  #include <rpc/svc.h>		/* service manager and multiplexer */
--- 59,67 ----
   *  Uncomment-out the next line if you are building the rpc library with    
   *  DES Authentication (see the README file in the secure_rpc/ directory).
   */
! #if 0
! #include <rpc/auth_des.h>	/* protocol for des style cred */
! #endif
  
  /* Server side only remote procedure callee */
  #include <rpc/svc.h>		/* service manager and multiplexer */

------------------------------------------------------------------------------