rpcgen generates C code to implement an RPC protocol. The input to rpcgen is a language similar to C known as the RPC Language (Remote Procedure Call Language). Information about the syntax of RPC Language is available in the `rpcgen' Programming Guide in the [a manual with the abbreviation NETP] manual.
rpcgen is normally used as in the first synopsis where it takes an input file and generates four output files. If the infile is named proto.x, then rpcgen generates a header file in proto.h, XDR routines in proto_xdr.c, server side stubs in proto_svc.c, and client side stubs in proto_clnt.c. With the -T option, it also generates the RPC dispatch table in proto_tbl.i.
The second synposis provides special features which allow for the creation of more sophisticated RPC servers. These features include support for RPC dispatch tables, and user provided #defines. The entries in the RPC dispatch table contain:
A server can use the dispatch table to check authorization and then to execute the service routine; a client library may use it to deal with the details of storage management and XDR data conversion.
The other two synopses shown above are used when one does not want to generate all the output files, but only a particular one. Their usage is described in the EXAMPLES section below.
The C-preprocessor, cpp.1 is run on the input file before it is actually interpreted by rpcgen, so all the cpp directives are legal within an rpcgen input file. For each type of output file, rpcgen defines a special cpp symbol for use by the rpcgen programmer:
In addition, rpcgen does a little preprocessing of its own. Any line beginning with `%' is passed directly into the output file, uninterpreted by rpcgen. For every data type referred to in infile, rpcgen assumes that there exists a routine with the string `xdr_' prepended to the data type. If this routine does not exist in the RPC/XDR library, it must be provided. Providing an undefined data type allows customization of XDR routines.
The options
-c,
-h,
-l,
-m,
-s
and
-t
are used exclusively to generate a particular type of file, while the options
-D,
-I,
-L
and
-T
are global and can be used with the other options.
The following example generates all the five files: prot.h, prot_clnt.c, prot_svc.c, prot_xdr.c and prot_tbl.i. The server error messages are logged, instead of being sent to the standard error.
example% rpcgen -LT prot.x
The following example generates prot.h, prot_clnt.c, prot_xdr.c and prot_svc.c. prot_svc.c supports server invocation by inetd. If the server is started by inetd, the server exits after 20 seconds of inactivity.
example% rpcgen -I -K 20 prot.x
The following example sends the header file (with support for dispatch tables) on the standard output.
example% rpcgen -hT prot.x
The following example sends the server side stubs file for the transport tcp on the standard output.
example% rpcgen -s tcp prot.x
`rpcgen' Programming Guide
in
[a manual with the abbreviation NETP]
The RPC Language does not support nesting of structures. As a work-around, structures can be declared at the top-level, and their name used inside other structures in order to achieve the same effect.
Name clashes can occur when using program definitions, since the apparent scoping does not really apply. Most of these can be avoided by giving unique names for programs, versions, procedures and types.
Created by unroff & hp-tools. © somebody (See intro for details). All Rights Reserved. Last modified 11/5/97