xref: /netbsd-src/usr.bin/rpcgen/rpcgen.1 (revision cda4f8f6ee55684e8d311b86c99ea59191e6b74f)
1.\" @(#)rpcgen.1	2.2 88/08/02 4.0 RPCSRC
2.\" converted to -mdoc macros by J.T. Conklin <jtc@wimsey.com>
3.Dd January 18, 1988
4.Dt RPCGEN 1
5.Os
6.Sh NAME
7.Nm rpcgen
8.Nd RPC protocol compiler
9.Sh SYNOPSIS
10.Nm rpcgen
11.Ar infile
12.Nm rpcgen
13.Fl c Li |
14.Fl h Li |
15.Fl l Li |
16.Fl m
17.Op Fl o Ar outfile
18.Op Ar infile
19.Nm rpcgen
20.Fl s Ar transport
21.Op Fl o Ar outfile
22.Op Ar infile
23.Sh DESCRIPTION
24.Nm rpcgen
25is a tool that generates C code to implement an
26.Tn RPC
27protocol.  The input to
28.Nm rpcgen
29is a language similar to C known as
30.Tn RPC
31Language (Remote Procedure Call Language).  Information about the
32syntax of
33.Tn RPC
34Language is available in the
35.Rs
36.%T "rpcgen Programming Guide"
37.Re
38.Pp
39.Nm rpcgen
40is normally used as in the first synopsis where it takes an input file
41and generates four output files. If the
42.Ar infile
43is named
44.Pa proto.x ,
45then
46.Nm rpcgen
47will generate a header file in
48.Pa proto.h ,
49.Tn XDR
50routines in
51.Pa proto_xdr.c ,
52server-side stubs in
53.Pa proto_svc.c ,
54and client-side stubs in
55.Pa proto_clnt.c .
56.Pp
57The other synopses shown above are used when one does not want to
58generate all the output files, but only a particular one.
59.\" Their usage is described in the
60.\" .Sx USAGE
61.\" section below.
62.Pp
63The C-preprocessor,
64.Xr cpp 1 ,
65is run on all input files before they are actually
66interpreted by
67.Nm rpcgen ,
68so all the
69.Xr cpp
70directives are legal within an
71.Nm rpcgen
72input file.  For each type of output file,
73.Nm rpcgen
74defines a special
75.Xr cpp
76symbol for use by the
77.Nm rpcgen
78programmer:
79.Pp
80.Bl -tag -width RPC_CLNT -compact
81.It Dv RPC_HDR
82defined when compiling into header files
83.It Dv RPC_XDR
84defined when compiling into
85.Tn XDR
86routines
87.It Dv RPC_SVC
88defined when compiling into server-side stubs
89.It Dv RPC_CLNT
90defined when compiling into client-side stubs
91.El
92.Pp
93In addition,
94.Nm rpcgen
95does a little preprocessing of its own.  Any line beginning with
96.Sq %
97is passed directly into the output file, uninterpreted by
98.Nm rpcgen .
99.Pp
100You can customize some of your
101.Tn XDR
102routines by leaving those data types undefined.  For every data type
103that is undefined,
104.Nm rpcgen
105will assume that there exists a routine with the name
106.Tn xdr_
107prepended to the name of the undefined type.
108.Sh OPTIONS
109.Bl -tag -width indent
110.It Fl c
111Compile into
112.Tn XDR
113routines.
114.It Fl h
115Compile into C data-definitions (a header file).
116.It Fl l
117Compile into client-side stubs.
118.It Fl m
119Compile into server-side stubs, but do not generate a
120.Fn main
121routine.  This option is useful for doing callback-routines and for
122people who need to write their own
123.Fn main
124routine to do initialization.
125.It Fl o Ar outfile
126Specify the name of the output file.  If none is specified, standard
127output is used (
128.Fl c ,
129.Fl h ,
130.Fl l
131and
132.Fl s
133modes only).
134.It Fl s Ar transport
135Compile into server-side stubs, using the the given transport.  The
136supported transports are
137.Tn udp
138and
139.Tn tcp .
140This option may be invoked more than once so as to compile a server
141that serves multiple transports.
142.El
143.Sh SEE ALSO
144.Xr cpp 1
145.Rs
146.%T "rpcgen Programming Guide"
147.Re
148.Sh BUGS
149Nesting is not supported.  As a work-around, structures can be
150declared at top-level, and their name used inside other structures in
151order to achieve the same effect.
152.Pp
153Name clashes can occur when using program definitions, since the
154apparent scoping does not really apply. Most of these can be avoided
155by giving unique names for programs, versions, procedures and types.
156