Manual Page Result
0
Command: rpcgen | Section: 1 | Source: Digital UNIX | File: rpcgen.1.gz
rpcgen(1) General Commands Manual rpcgen(1)
NAME
rpcgen - an RPC protocol compiler
SYNOPSIS
rpcgen infile
rpcgen [ -Dname[=value] ] [ -I [ -K seconds ] ] [ -L ] [ -T ] infile
rpcgen -c|-h|-l|-m [ -o outfile ] [ infile ]
rpcgen -s transport [ -o outfile ] [ infile ]
DESCRIPTION
rpcgen is a tool that generates C code to implement an RPC protocol.
The input to rpcgen is the ONC RPC (Remote Procedure Call) Language,
which is similar to C.
rpcgen is normally used as in the first synopsis where it takes an in-
put file and generates four output files. If the infile is named
proto.x, rpcgen will generate 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.
The second synopsis provides special features which allow for the cre-
ation of more sophisticated RPC servers. These features include sup-
port for RPC dispatch tables, and user provided #defines. The entries
in the ONC RPC dispatch table contain: pointers to the service routine
corresponding to that procedure a pointer to the input and output argu-
ments the size of these routines
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 synopses are used when one wants to generate a particular
output file. Their usage is described in the EXAMPLES section below.
The C-preprocessor, cpp(1), is run on all input files before they are
actually interpreted by rpcgen, so all the cpp directives are legal
within an rpcgen input file. For each type of output file, rpcgen de-
fines a special cpp symbol for use by the rpcgen programmer: Defined
when compiling into header files Defined when compiling into XDR rou-
tines Defined when compiling into server-side stubs Defined when com-
piling into client-side stubs Defined when compiling into RPC dispatch
tables
In addition, rpcgen does a little preprocessing of its own. Any line
beginning with `%' is passed directly into the output file, uninter-
preted by rpcgen.
You can customize some of your XDR routines by leaving those data types
undefined. For every data type that is undefined, rpcgen will assume
that there exists a routine with the name xdr_ prepended to the name of
the undefined type.
FLAGS
Compiles into XDR routines. Defines a symbol name. Equivalent to the
#define directive in the source. If no value is given, name is defined
as 1. This option may be called more than once. Compiles into C data-
definitions (a header file) Compiles support for inetd(8C) in the
server side stubs. Such servers can be self started or can be started
by inetd. When the server is self-started, it backgrounds itself by
default. A special define symbol RPC_SVC_FG can be used to run the
server process in foreground, or alternately the user may just compile
it without the -I option. If there are no pending client requests, the
inetd servers exit after 120 seconds (default). The default can be
changed with the -K option. All the error messages for inetd servers
are always logged in with syslog(3). If the server was started by in-
etd, specifies the time in seconds after which the server should exit
if there is no further activity. This option is useful for customiza-
tion. If seconds is 0, the server exits after serving that given re-
quest. If seconds is -1, the server hangs around for ever after being
started by inetd. This option is valid only with the -I option. Com-
piles into client-side stubs. When the servers are started in fore-
ground, uses syslog() to log the server errors instead of printing them
on the standard error. Compiles into server-side stubs, but does not
generate a "main" routine. This option is useful for doing callback-
routines and for people who need to write their own "main" routine to
do initialization. For inetd support, they should be compiled with the
-I option. In such cases, it defines 2 global variables: _rpcpmstart
and _rpcfdtype. The value of _rpcpmstart should be 1 or 0 depending
upon whether it was started by inetd or not. The value of _rpcfdtype
should be SOCK_STREAM or SOCK_DGRAM depending upon the type of the con-
nection. Specifies the name of the output file. If none is specified,
standard output is used (-c, -h, -l, -m, -s, and -t modes only). Com-
piles into server-side stubs, using the given transport. The supported
transports are udp and tcp. This option may be invoked more than once
to compile a server that serves multiple transports. For inetd sup-
port, they should be compiled with the -I option. -t Compile into RPC
dispatch table.
-T Generate the code to support RPC dispatch tables.
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.
RESTRICTIONS
Nesting is not supported. However, structures can be declared at 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 appar-
ent scoping does not really apply. Most of these can be avoided by giv-
ing unique names for programs, versions, procedures and types.
EXAMPLES
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. rpc-
gen -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
RELATED INFORMATION
cpp(1), rpc(3), inetd(8) delim off
rpcgen(1)