1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416
|
.TH DISGEN 1 "1 November 1995"
.SH NAME
disgen \- DIS protocol compiler
.SH SYNOPSIS
.BI disgen " infile"
.br
.B disgen
[
.BI \-D name [= value ]
] [
.B \-I
[
.BI \-K " seconds"
] ] [
.B \-L
] [
.B \-T
]
.I infile
.br
.B disgen
.B "\-c \|| \|\-h \|| \|\-l \|| \|\-m \|| \|\-t"
[
.BI \-o " outfile"
]
[
.I infile
]
.br
.B disgen
.B \-s
.I transport
[
.BI \-o " outfile"
]
[
.I infile
]
.SH DESCRIPTION
.IX "compilers" disgen "" "\fLdisgen\fR \(em generate RPC protocols, C header files"
.IX disgen "" "\fLdisgen\fR \(em generate RPC protocol, C header files, and server skeleton"
.IX RPC "generate protocols \(em \fLdisgen\fR"
.LP
.B disgen
generates C code to implement the
.SM Distributed Interactive Simulation
protocol.
The input to
.B disgen
is a language similar to C
known as the
.SM RPC
Language (Remote Procedure Call Language).
Information about the syntax of
.SM RPC
Language is available in the
.RI ` rpcgen ' " Programming Guide"
in the
.TX NETP
manual.
.LP
.B disgen
is normally used as in the first synopsis where it takes an input file
and generates four output files.
If the
.I infile
is named
.BR proto.x ,
then
.B disgen
generates a header file in
.BR proto.h ,
.SM XDR
routines in
.BR proto_xdr.c ,
server side stubs in
.BR proto_svc.c ,
and client side stubs in
.BR proto_clnt.c .
With the
.B \-T
option, it also generates the
.SM RPC
dispatch table in
.BR proto_tbl.i .
.LP
The second synposis provides special features which
allow for the creation of more sophisticated
.SM RPC
servers.
These features include support for
.SM RPC
dispatch tables,
and user provided
.BR #defines .
The entries in the
.SM RPC
dispatch table contain:
.LP
.RS
.PD 0
.TP 3
\(bu
pointers to the service routine corresponding
to that procedure
.TP
\(bu
a pointer to the input and output arguments
.TP
\(bu
the size of these routines
.PD
.RE
.LP
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
.SM XDR
data conversion.
.LP
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
.SM EXAMPLES
section below.
.LP
The C-preprocessor,
.BR cpp (1),
is run on the input file before it is actually
interpreted by
.BR disgen ,
so all the
.B cpp
directives are legal within an
.B disgen
input file. For each type of output file,
.B disgen
defines a special
.B cpp
symbol for use by the
.B disgen
programmer:
.LP
.RS
.PD 0
.TP 12
.SB RPC_HDR
defined when compiling into header files
.TP
.SB RPC_XDR
defined when compiling into
.SM XDR
routines
.TP
.SB RPC_SVC
defined when compiling into server side stubs
.TP
.SB RPC_CLNT
defined when compiling into client side stubs
.TP
.SB RPC_TBL
defined when compiling into
.SM RPC
dispatch tables
.PD
.RE
.LP
In addition,
.B disgen
does a little preprocessing of its own.
Any line beginning with
.RB ` % '
is passed directly into the output file, uninterpreted by
.BR disgen .
For every data type referred to in
.IR infile ,
.B disgen
assumes that there exists a routine with the string
.RB ` xdr_ '
prepended to the data type.
If this routine does not exist in the
.SM RPC/XDR
library, it must be provided.
Providing an undefined data type
allows customization of
.SM XDR
routines.
.SH OPTIONS
.TP 12
.B \-c
Compile into
.SM XDR
routines.
.TP
.BI \-D name [= value ]
Define a symbol
.IR name .
Equivalent to the
.B #define
directive in the source.
If no
.I value
is given,
.I name
is defined as 1.
This option may be called more than once.
.TP
.B \-h
Compile into C data-definitions (a header file).
The
.B \-T
option can be used in conjunction to produce a header file which supports
.SM RPC
dispatch tables.
.TP
.B \-I
Compile support for
.BR inetd (8C)
in the server side stubs.
Such servers can be self started or can be started by
.BR inetd .
When the server is self-started, it backgrounds itself by default.
A special define symbol
.SB RPC_SVC_FG
can be used to run the server process in foreground, or alternately the
user may just compile it without the
.B \-I
option.
If there are no pending client requests, the
.B inetd
servers exit after 120 seconds (default).
The default can be changed with the
.B \-K
option.
All the error messages for
.B inetd
servers are always logged in with
.BR syslog (3).
.TP
.BI \-K " seconds"
If the server was started by
.BR inetd ,
specify the time in seconds after which the server should exit if there is
no further activity.
This option is useful for customization.
If
.I seconds
is 0, the server exits after serving that given request.
If
.I seconds
is
\-1, the server hangs around for ever after being started by
.BR inetd .
This option is valid only with the
.B \-I
option.
.TP
.B \-l
Compile into client side stubs.
.TP
.B \-L
When the servers are started in foreground, use
.B syslog(\|)
to log the server errors instead of printing them on the standard error.
.TP
.B \-m
Compile into server side stubs, but do not generate a \*(lqmain\*(rq routine.
This option is useful for doing callback-routines and for people who
need to write their own \*(lqmain\*(rq routine to do initialization.
For
.B inetd
support, they should be compiled with the
.B \-I
option. In such cases, it defines 2 global variables:
.B _rpcpmstart
and
.BR _rpcfdtype .
The value of
.B _rpcpmstart
should be 1 or 0 depending upon whether it was started by
.B inetd
or not. The value of
.B _rpcfdtype
should be
.SB SOCK_STREAM
or
.SB SOCK_DGRAM
depending upon the type of the connection.
.TP
.BI \-o " outfile"
Specify the name of the output file.
If none is specified, the standard output is used
.RB ( \-c ,
.BR \-h ,
.BR \-l ,
.BR \-m ,
.B \-s
and
.B \-t
modes only).
.TP
.BI \-s " transport"
Compile into server side stubs for the given transport.
The supported transports are
.B udp
and
.BR tcp .
This option may be called more than once
so as to compile a server that serves multiple transports.
For
.B inetd
support, they should be compiled with the
.B \-I
option.
.TP
.B \-t
Compile into
.SM RPC
dispatch table.
.TP
.B \-T
Generate the code to support
.SM RPC
dispatch tables.
.LP
The options
.BR \-c ,
.BR \-h ,
.BR \-l ,
.BR \-m ,
.B \-s
and
.B \-t
are used exclusively to generate a particular type of file, while the options
.BR \-D ,
.BR \-I ,
.B \-L
and
.B \-T
are global and can be used with the other options.
.br
.ne 5
.SH EXAMPLES
.LP
The following example generates all the five files:
.BR prot.h,
.BR prot_clnt.c ,
.BR prot_svc.c ,
.B prot_xdr.c
and
.BR prot_tbl.i .
The server error messages are logged, instead of being sent
to the standard error.
.IP
.ft B
example% disgen \-LT prot.x
.ft R
.LP
The following example generates
.BR prot.h ,
.BR prot_clnt.c ,
.B prot_xdr.c
and
.BR prot_svc.c .
.B prot_svc.c
supports server invocation by
.BR inetd .
If the server is started by
.BR inetd ,
the server exits after 20 seconds of inactivity.
.IP
.ft B
example% disgen \-I \-K 20 prot.x
.ft R
.LP
The following example sends the header file
(with support for dispatch tables)
on the standard output.
.IP
.ft B
example% disgen \-hT prot.x
.ft R
.LP
The following example sends the server side stubs
file for the transport
.B tcp
on the standard output.
.IP
.ft B
example% disgen \-s tcp prot.x
.ft R
.SH "SEE ALSO"
.BR cpp (1),
.BR rpc (3N),
.BR inetd (8C)
.LP
.RI ` disgen ' " Programming Guide"
in
.TX NETP
.br
.ne 7
.SH BUGS
.LP
The
.SM 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.
.LP
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.
|