Print this page
rpcgen should only produce ANSI code

*** 1,597 **** ! '\" te .\" Copyright (C) 2009, Sun Microsystems, Inc. All Rights Reserved .\" Copyright 1989 AT&T .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License. You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. .\" See the License for the specific language governing permissions and limitations under the License. When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the .\" fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner] ! .TH RPCGEN 1 "Dec 16, 2013" ! .SH NAME ! rpcgen \- an RPC protocol compiler ! .SH SYNOPSIS ! .LP ! .nf ! \fBrpcgen\fR \fIinfile\fR ! .fi ! ! .LP ! .nf ! \fBrpcgen\fR [\fB-a\fR] [\fB-A\fR] [\fB-b\fR] [\fB-C\fR] [\fB-D\fR \fIname\fR [= \fIvalue\fR]] [\fB-i\fR \fIsize\fR] ! [\fB-I\fR [\fB-K\fR \fIseconds\fR]] [\fB-L\fR] [\fB-M\fR] [\fB-N\fR] [\fB- T\fR] [\fB-v\fR] ! [\fB-Y\fR \fIpathname\fR] \fIinfile\fR ! .fi ! ! .LP ! .nf ! \fBrpcgen\fR [\fB-c\fR | \fB-h\fR | \fB-l\fR | \fB-m\fR | \fB-t\fR | \fB-Sc\fR | \fB-Ss\fR | \fB-Sm\fR] ! [\fB-o\fR \fIoutfile\fR] [\fIinfile\fR] ! .fi ! ! .LP ! .nf ! \fBrpcgen\fR [\fB-s\fR \fInettype\fR] [\fB-o\fR \fIoutfile\fR] [\fIinfile\fR] ! .fi ! ! .LP ! .nf ! \fBrpcgen\fR [\fB-n\fR \fInetid\fR] [\fB-o\fR \fIoutfile\fR] [\fIinfile\fR] ! .fi ! ! .SH DESCRIPTION ! .sp ! .LP ! The \fBrpcgen\fR utility is a tool that generates C code to implement an ! \fBRPC\fR protocol. The input to \fBrpcgen\fR is a language similar to C known ! as \fBRPC\fR Language (Remote Procedure Call Language). ! .sp ! .LP ! The \fBrpcgen\fR utility is normally used as in the first synopsis where it ! takes an input file and generates four output files. If the \fIinfile\fR is ! named \fBproto.x\fR, then \fBrpcgen\fR generates a header in \fBproto.h\fR, ! \fBXDR\fR routines in \fBproto_xdr.c\fR, server-side stubs in ! \fBproto_svc.c\fR, and client-side stubs in \fBproto_clnt.c\fR. With the ! \fB-T\fR option, it also generates the \fBRPC\fR dispatch table in ! \fBproto_tbl.i\fR. ! .sp ! .LP ! \fBrpcgen\fR can also generate sample client and server files that can be ! customized to suit a particular application. The \fB-Sc\fR, \fB-Ss\fR, and ! \fB-Sm\fR options generate sample client, server and makefile, respectively. ! The \fB-a\fR option generates all files, including sample files. If the infile ! is \fBproto.x\fR, then the client side sample file is written to ! \fBproto_client.c\fR, the server side sample file to \fBproto_server.c\fR and ! the sample makefile to \fBmakefile.proto\fR. ! .sp ! .LP The server created can be started both by the port monitors (for example, ! \fBinetd\fR or \fBlisten\fR) or by itself. When it is started by a port monitor, it creates servers only for the transport for which the file ! descriptor \fB0\fR was passed. The name of the transport must be specified by ! setting up the environment variable \fBPM_TRANSPORT\fR. When the server ! generated by \fBrpcgen\fR is executed, it creates server handles for all the ! transports specified in the \fBNETPATH\fR environment variable, or if it is unset, it creates server handles for all the visible transports from the ! \fB/etc/netconfig\fR file. Note: the transports are chosen at run time and not at compile time. When the server is self-started, it backgrounds itself by ! default. A special define symbol \fBRPC_SVC_FG\fR can be used to run the server ! process in foreground. ! .sp ! .LP The second synopsis provides special features which allow for the creation of ! more sophisticated \fBRPC\fR servers. These features include support for ! user-provided \fB#defines\fR and \fBRPC\fR dispatch tables. The entries in the ! \fBRPC\fR dispatch table contain: ! .RS +4 ! .TP ! .ie t \(bu ! .el o pointers to the service routine corresponding to that procedure ! .RE ! .RS +4 ! .TP ! .ie t \(bu ! .el o a pointer to the input and output arguments ! .RE ! .RS +4 ! .TP ! .ie t \(bu ! .el o the size of these routines ! .RE ! .sp ! .LP A server can use the dispatch table to check authorization and then to execute the service routine. A client library can use the dispatch table to deal with ! the details of storage management and \fBXDR\fR data conversion. ! .sp ! .LP The other three synopses shown above are used when one does not want to ! generate all the output files, but only a particular one. See the EXAMPLES ! section below for examples of \fBrpcgen\fR usage. When \fBrpcgen\fR is executed ! with the \fB-s\fR option, it creates servers for that particular class of ! transports. When executed with the \fB-n\fR option, it creates a server for the ! transport specified by \fInetid\fR. If \fIinfile\fR is not specified, ! \fBrpcgen\fR accepts the standard input. ! .sp ! .LP All the options mentioned in the second synopsis can be used with the other three synopses, but the changes are made only to the specified output file. ! .sp ! .LP ! The C preprocessor \fBcc\fR \fB-E\fR is run on the input file before it is ! actually interpreted by \fBrpcgen\fR. For each type of output file, ! \fBrpcgen\fR defines a special preprocessor symbol for use by the \fBrpcgen\fR programmer: ! .sp ! .ne 2 ! .na ! \fB\fBRPC_HDR\fR\fR ! .ad ! .RS 12n defined when compiling into headers ! .RE ! ! .sp ! .ne 2 ! .na ! \fB\fBRPC_XDR\fR\fR ! .ad ! .RS 12n ! defined when compiling into \fBXDR\fR routines ! .RE ! ! .sp ! .ne 2 ! .na ! \fB\fBRPC_SVC\fR\fR ! .ad ! .RS 12n defined when compiling into server-side stubs ! .RE ! ! .sp ! .ne 2 ! .na ! \fB\fBRPC_CLNT\fR\fR ! .ad ! .RS 12n defined when compiling into client-side stubs ! .RE ! ! .sp ! .ne 2 ! .na ! \fB\fBRPC_TBL\fR\fR ! .ad ! .RS 12n ! defined when compiling into \fBRPC\fR dispatch tables ! .RE ! ! .sp ! .LP ! Any line beginning with ``\fB%\fR'' is passed directly into the output file, ! uninterpreted by \fBrpcgen\fR, except that the leading ``\fB%\fR" is stripped ! off. To specify the path name of the C preprocessor, use the \fB-Y\fR flag. ! .sp ! .LP ! For every data type referred to in \fIinfile\fR, \fBrpcgen\fR assumes that ! there exists a routine with the string \fBxdr_\fR prepended to the name of the ! data type. If this routine does not exist in the \fBRPC\fR/\fBXDR\fR library, it must be provided. Providing an undefined data type allows customization of ! \fBXDR\fR routines. ! .SS "Server Error Reporting" ! .sp ! .LP ! By default, errors detected by \fBproto_svc.c\fR is reported to standard error ! and/or the system log. ! .sp ! .LP This behavior can be overridden by compiling the file with a definition of ! \fBRPC_MSGOUT\fR, for example, \fB-DRPC_MSGOUT=mymsgfunc\fR. The function specified is called to report errors. It must conform to the following ! \fBprintf\fR-like signature: ! .sp ! .in +2 ! .nf ! extern void RPC_MSGOUT(const char *fmt, ...); ! .fi ! .in -2 ! .sp ! ! .SH OPTIONS ! .sp ! .LP The following options are supported: ! .sp ! .ne 2 ! .na ! \fB\fB-a\fR\fR ! .ad ! .RS 18n Generates all files, including sample files. ! .RE ! ! .sp ! .ne 2 ! .na ! \fB\fB-A\fR\fR ! .ad ! .RS 18n ! Enables the Automatic \fBMT\fR mode in the server main program. In this mode, ! the \fBRPC\fR library automatically creates threads to service client requests. This option generates multithread-safe stubs by implicitly turning on the ! \fB-M\fR option. Server multithreading modes and parameters can be set using ! the \fBrpc_control\fR(3NSL) call. \fBrpcgen\fR generated code does not change ! the default values for the Automatic \fBMT\fR mode. ! .RE ! ! .sp ! .ne 2 ! .na ! \fB\fB-b\fR\fR ! .ad ! .RS 18n ! Backward compatibility mode. Generates transport-specific \fBRPC\fR code for older versions of the operating system. ! .RE ! ! .sp ! .ne 2 ! .na ! \fB\fB-c\fR\fR ! .ad ! .RS 18n ! Compiles into \fBXDR\fR routines. ! .RE ! ! .sp ! .ne 2 ! .na ! \fB\fB-C\fR\fR ! .ad ! .RS 18n Generates header and stub files which can be used with ANSI C compilers. ! Headers generated with this flag can also be used with C++ programs. ! .RE ! ! .sp ! .ne 2 ! .na ! \fB\fB-D\fR\fIname\fR\fB[=\fR\fIvalue\fR\fB]\fR\fR ! .ad ! .RS 18n Defines a symbol \fIname\fR. Equivalent to the \fB#define\fR directive in the source. If no \fIvalue\fR is given, \fIvalue\fR is defined as \fB1\fR. This option can be specified more than once. ! .RE ! ! .sp ! .ne 2 ! .na ! \fB\fB-h\fR\fR ! .ad ! .RS 18n ! Compiles into \fBC\fR data-definitions (a header). The \fB-T\fR option can be ! used in conjunction to produce a header which supports \fBRPC\fR dispatch tables. ! .RE ! ! .sp ! .ne 2 ! .na ! \fB\fB-i\fR \fIsize\fR\fR ! .ad ! .RS 18n Size at which to start generating inline code. This option is useful for ! optimization. The default \fIsize\fR is 5. ! .RE ! ! .sp ! .ne 2 ! .na ! \fB\fB-I\fR\fR ! .ad ! .RS 18n ! Compiles support for \fBinetd\fR(1M) in the server side stubs. Such servers can ! be self-started or can be started by \fBinetd\fR. When the server is self-started, it backgrounds itself by default. A special define symbol ! \fBRPC_SVC_FG\fR can be used to run the server process in foreground, or the ! user can simply compile without the \fB-I\fR option. ! .sp ! If there are no pending client requests, the \fBinetd\fR servers exit after 120 ! seconds (default). The default can be changed with the \fB-K\fR option. All of ! the error messages for \fBinetd\fR servers are always logged with ! \fBsyslog\fR(3C). ! .sp ! \fBNote:\fR This option is supported for backward compatibility only. It should ! always be used in conjunction with the \fB-b\fR option which generates backward ! compatibility code. By default (that is, when \fB-b\fR is not specified), ! \fBrpcgen\fR generates servers that can be invoked through portmonitors. ! .RE ! ! .sp ! .ne 2 ! .na ! \fB\fB-K\fR \fIseconds\fR\fR ! .ad ! .RS 18n ! By default, services created using \fBrpcgen\fR and invoked through port monitors wait 120 seconds after servicing a request before exiting. That ! interval can be changed using the \fB-K\fR flag. To create a server that exits ! immediately upon servicing a request, use \fB-K\fR \fB0\fR. To create a server ! that never exits, the appropriate argument is \fB-K\fR \fB\(mi1\fR\&. ! .sp ! When monitoring for a server, some portmonitors, like \fBlisten\fR(1M), ! \fBalways\fR spawn a new process in response to a service request. If it is known that a server are used with such a monitor, the server should exit ! immediately on completion. For such servers, \fBrpcgen\fR should be used with ! \fB-K\fR \fB0\fR. ! .RE ! ! .sp ! .ne 2 ! .na ! \fB\fB-l\fR\fR ! .ad ! .RS 18n Compiles into client-side stubs. ! .RE ! ! .sp ! .ne 2 ! .na ! \fB\fB-L\fR\fR ! .ad ! .RS 18n ! When the servers are started in foreground, uses \fBsyslog\fR(3C) to log the ! server errors instead of printing them on the standard error. ! .RE ! ! .sp ! .ne 2 ! .na ! \fB\fB-m\fR\fR ! .ad ! .RS 18n Compiles into server-side stubs, but do not generate a "main" routine. This option is useful for doing callback-routines and for users who need to write their own "main" routine to do initialization. ! .RE ! ! .sp ! .ne 2 ! .na ! \fB\fB-M\fR\fR ! .ad ! .RS 18n Generates multithread-safe stubs for passing arguments and results between ! \fBrpcgen\fR-generated code and user written code. This option is useful for users who want to use threads in their code. ! .RE ! ! .sp ! .ne 2 ! .na ! \fB\fB-N\fR\fR ! .ad ! .RS 18n This option allows procedures to have multiple arguments. It also uses the style of parameter passing that closely resembles C. So, when passing an argument to a remote procedure, you do not have to pass a pointer to the argument, but can pass the argument itself. This behavior is different from the ! old style of \fBrpcgen\fR-generated code. To maintain backward compatibility, ! this option is not the default. ! .RE ! ! .sp ! .ne 2 ! .na ! \fB\fB-n\fR \fInetid\fR\fR ! .ad ! .RS 18n ! Compiles into server-side stubs for the transport specified by \fInetid\fR. ! There should be an entry for \fInetid\fR in the \fBnetconfig\fR database. This option can be specified more than once, so as to compile a server that serves multiple transports. ! .RE ! ! .sp ! .ne 2 ! .na ! \fB\fB-o\fR \fIoutfile\fR\fR ! .ad ! .RS 18n Specifies the name of the output file. If none is specified, standard output is ! used (\fB-c\fR, \fB-h\fR, \fB-l\fR, \fB-m\fR, \fB-n\fR, \fB-s\fR, \fB-Sc\fR, ! \fB-Sm\fR, \fB-Ss\fR, and \fB-t\fR modes only). ! .RE ! ! .sp ! .ne 2 ! .na ! \fB\fB-s\fR \fInettype\fR\fR ! .ad ! .RS 18n Compiles into server-side stubs for all the transports belonging to the class ! \fInettype\fR. The supported classes are \fBnetpath\fR, \fBvisible\fR, ! \fBcircuit_n\fR, \fBcircuit_v\fR, \fBdatagram_n\fR, \fBdatagram_v\fR, ! \fBtcp\fR, and \fBudp\fR (see \fBrpc\fR(3NSL) for the meanings associated with ! these classes). This option can be specified more than once. \fBNote:\fR The ! transports are chosen at run time and not at compile time. ! .RE ! ! .sp ! .ne 2 ! .na ! \fB\fB-Sc\fR\fR ! .ad ! .RS 18n Generates sample client code that uses remote procedure calls. ! .RE ! ! .sp ! .ne 2 ! .na ! \fB\fB-Sm\fR\fR ! .ad ! .RS 18n Generates a sample Makefile which can be used for compiling the application. ! .RE ! ! .sp ! .ne 2 ! .na ! \fB\fB-Ss\fR\fR ! .ad ! .RS 18n Generates sample server code that uses remote procedure calls. ! .RE ! ! .sp ! .ne 2 ! .na ! \fB\fB-t\fR\fR ! .ad ! .RS 18n ! Compiles into \fBRPC\fR dispatch table. ! .RE ! ! .sp ! .ne 2 ! .na ! \fB\fB-T\fR\fR ! .ad ! .RS 18n ! Generates the code to support \fBRPC\fR dispatch tables. ! .sp ! The options \fB-c\fR, \fB-h\fR, \fB-l\fR, \fB-m\fR, \fB-s\fR, \fB-Sc\fR, ! \fB-Sm\fR, \fB-Ss\fR, and \fB-t\fR are used exclusively to generate a ! particular type of file, while the options \fB-D\fR and \fB-T\fR are global and ! can be used with the other options. ! .RE ! ! .sp ! .ne 2 ! .na ! \fB\fB-v\fR\fR ! .ad ! .RS 18n Displays the version number. ! .RE ! ! .sp ! .ne 2 ! .na ! \fB\fB-Y\fR \fIpathname\fR\fR ! .ad ! .RS 18n ! Gives the name of the directory where \fBrpcgen\fR starts looking for the C ! preprocessor. ! .RE ! ! .SH OPERANDS ! .sp ! .LP The following operand is supported: ! .sp ! .ne 2 ! .na ! \fB\fIinfile\fR\fR ! .ad ! .RS 10n input file ! .RE ! ! .SH EXAMPLES ! .LP ! \fBExample 1 \fRGenerating the output files and dispatch table ! .sp ! .LP The following entry ! ! .sp ! .in +2 ! .nf ! example% \fBrpcgen -T prot.x\fR ! .fi ! .in -2 ! .sp ! ! .sp ! .LP ! generates all the five files: \fBprot.h\fR, \fBprot_clnt.c\fR, ! \fBprot_svc.c\fR, \fBprot_xdr.c\fR, and \fBprot_tbl.i\fR. ! ! .LP ! \fBExample 2 \fRSending headers to standard output ! .sp ! .LP The following example sends the C data-definitions (header) to the standard output: ! ! .sp ! .in +2 ! .nf ! example% \fBrpcgen -h prot.x\fR ! .fi ! .in -2 ! .sp ! ! .LP ! \fBExample 3 \fRSending a test version ! .sp ! .LP ! To send the test version of the \fB-DTEST\fR, server side stubs for all the ! transport belonging to the class \fBdatagram_n\fR to standard output, use: ! ! .sp ! .in +2 ! .nf ! example% \fBrpcgen -s datagram_n -DTEST prot.x\fR ! .fi ! .in -2 ! .sp ! ! .LP ! \fBExample 4 \fRCreating server side stubs ! .sp ! .LP ! To create the server side stubs for the transport indicated by \fInetid\fR ! \fBtcp\fR, use: ! ! .sp ! .in +2 ! .nf ! example% \fBrpcgen -n tcp -o prot_svc.c prot.x\fR ! .fi ! .in -2 ! .sp ! ! .SH EXIT STATUS ! .sp ! .ne 2 ! .na ! \fB\fB0\fR\fR ! .ad ! .RS 6n ! Successful operation. ! .RE ! ! .sp ! .ne 2 ! .na ! \fB\fB>0\fR\fR ! .ad ! .RS 6n ! An error occurred. ! .RE ! ! .SH SEE ALSO ! .sp ! .LP ! \fBinetd\fR(1M), \fBlisten\fR(1M), \fBrpc\fR(3NSL), \fBrpc_control\fR(3NSL), ! \fBrpc_svc_calls\fR(3NSL), \fBsyslog\fR(3C), \fBnetconfig\fR(4), ! \fBattributes\fR(5) ! .sp ! .LP ! The \fBrpcgen\fR chapter in the \fIONC+ Developer\&'s Guide\fR manual. --- 1,498 ---- ! .\" Copyright 2014 Garrett D'Amore <garrett@damore.org> .\" Copyright (C) 2009, Sun Microsystems, Inc. All Rights Reserved .\" Copyright 1989 AT&T .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License. You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. .\" See the License for the specific language governing permissions and limitations under the License. When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the .\" fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner] ! .Dd "Aug 2, 2014" ! .Dt RPCGEN 1 ! .Os ! .Sh NAME ! .Nm rpcgen ! .Nd an RPC protocol compiler ! .Sh SYNOPSIS ! .Nm ! .Ar infile ! . ! .Nm ! .Op Fl a ! .Op Fl A ! .Op Fl b ! .Op Fl C ! .Op Fl D Ar name Ns Op = Ns Ar value ! .Op Fl i Ar size ! .Op Fl I Op Fl K Ar seconds ! .Op Fl L ! .Op Fl M ! .Op Fl N ! .Op Fl T ! .Op Fl v ! .Op Fl Y Ar pathname ! .Ar infile ! . ! .Nm ! .Op Fl c | Fl h | Fl l | Fl m | Fl t | Fl "Sc" | Fl "Ss" | Fl "Sm" ! .Op Fl o Ar outfile ! .Op Ar infile ! . ! .Nm ! .Op Fl s Ar nettype ! .Op Fl o Ar outfile ! .Op Ar infile ! . ! .Nm ! .Op Fl n Ar netid ! .Op Fl o Ar outfile ! .Op infile ! . ! .Sh DESCRIPTION ! The ! .Nm ! utility is a tool that generates C code to implement an ! RPC protocol. The input to ! .Nm ! is a language similar to C known ! as ! .Em RPC Language ! (Remote Procedure Call Language). ! .Lp ! The ! .Nm ! utility is normally used as in the first synopsis where it ! takes an input file and generates four output files. If the ! .Ar infile ! is ! named ! .Pa proto.x , ! then ! .Nm ! generates a header in ! .Pa proto.h , ! XDR routines in ! .Pa proto_xdr.c , ! server-side stubs in ! .Pa proto_svc.c , ! and client-side stubs in ! .Pa proto_clnt.c . ! With the ! .Fl T ! option, it also generates the RPC dispatch table in ! .Pa proto_tbl.i . ! .Lp ! .Nm ! can also generate sample client and server files that can be ! customized to suit a particular application. The ! .Fl "Sc" , ! .Fl "Ss" , ! and ! .Fl "Sm" ! options generate sample client, server and makefile, respectively. ! The ! .Fl a ! option generates all files, including sample files. If the infile ! is ! .Pa proto.x , ! then the client side sample file is written to ! .Pa proto_client.c , ! the server side sample file to ! .Pa proto_server.c ! and the sample makefile to ! .Pa makefile.proto . ! .Lp The server created can be started both by the port monitors (for example, ! .Xr inetd 1M ! or ! .Xr listen 1M ) ! or by itself. When it is started by a port monitor, it creates servers only for the transport for which the file ! descriptor 0 was passed. The name of the transport must be specified by ! setting up the environment variable ! .Ev PM_TRANSPORT . ! When the server ! generated by ! .Nm ! is executed, it creates server handles for all the ! transports specified in the ! .Ev NETPATH ! environment variable, or if it is unset, it creates server handles for all the visible transports from the ! .Pa /etc/netconfig ! file. Note: the transports are chosen at run time and not at compile time. When the server is self-started, it backgrounds itself by ! default. A special define symbol ! .Dv RPC_SVC_FG ! can be used to run the server process in foreground. ! .Lp The second synopsis provides special features which allow for the creation of ! more sophisticated RPC servers. These features include support for ! user-provided ! .Li #defines ! and RPC dispatch tables. The entries in the ! RPC dispatch table contain: ! .Bl -bullet -offset indent ! .It pointers to the service routine corresponding to that procedure ! .It a pointer to the input and output arguments ! .It the size of these routines ! .El ! .Lp A server can use the dispatch table to check authorization and then to execute the service routine. A client library can use the dispatch table to deal with ! the details of storage management and XDR data conversion. ! .Lp The other three synopses shown above are used when one does not want to ! generate all the output files, but only a particular one. See the ! .Sx EXAMPLES ! section below for examples of ! .Nm ! usage. When ! .Nm ! is executed with the ! .Fl s ! option, it creates servers for that particular class of ! transports. When executed with the ! .Fl n ! option, it creates a server for the ! transport specified by ! .Ar netid . ! If ! .Ar infile ! is not specified, ! .Nm ! accepts the standard input. ! .Lp All the options mentioned in the second synopsis can be used with the other three synopses, but the changes are made only to the specified output file. ! .Lp ! The C preprocessor ! .Ic cc Fl E ! is run on the input file before it is ! actually interpreted by ! .Nm . ! For each type of output file, ! .Nm ! defines a special preprocessor symbol for use by the ! .Nm programmer: ! .Bl -tag -width Dv -offset indent ! .It Dv RPC_HDR defined when compiling into headers ! .It Dv RPC_XDR ! defined when compiling into XDR routines ! .It Dv RPC_SVC defined when compiling into server-side stubs ! .It Dv RPC_CLNT defined when compiling into client-side stubs ! .It Dv RPC_TBL ! defined when compiling into RPC dispatch tables ! .El ! .Lp ! Any line beginning with ! .Dq % ! is passed directly into the output file, ! uninterpreted by ! .Nm , ! except that the leading ! .Dq % ! is stripped ! off. To specify the path name of the C preprocessor, use the ! .Fl Y ! flag. ! .Lp ! For every data type referred to in ! .Ar infile , ! .Nm ! assumes that ! there exists a routine with the string ! .Sy xdr_ ! prepended to the name of 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. ! .Ss "Server Error Reporting" ! By default, errors detected by ! .Pa proto_svc.c ! is reported to standard error and/or the system log. ! .Lp This behavior can be overridden by compiling the file with a definition of ! .Dv RPC_MSGOUT , ! for example, ! .Fl D Dv RPC_MSGOUT Ns = Ns Ar mymsgfunc . ! The function specified is called to report errors. It must conform to the following ! .Xr printf 3C ! style signature: ! .Lp ! .Dl extern void RPC_MSGOUT(const char *fmt, ...); ! .Sh OPTIONS The following options are supported: ! .Bl -tag -width Fl ! . ! .It Fl a Generates all files, including sample files. ! . ! .It Fl A ! Enables the Automatic ! MT mode in the server main program. In this mode, ! the RPC library automatically creates threads to service client requests. This option generates multithread-safe stubs by implicitly turning on the ! .Fl M ! option. Server multithreading modes and parameters can be set using ! the ! .Xr rpc_control 3NSL ! call. ! .Nm ! generated code does not change ! the default values for the Automatic MT mode. ! . ! .It Fl b ! Backward compatibility mode. Generates transport-specific RPC code for older versions of the operating system. ! . ! .It Fl c ! Compiles into XDR routines. ! . ! .It Fl C Generates header and stub files which can be used with ANSI C compilers. ! Headers generated with this flag can also be used with C++ programs. This ! behavior is now default, and therefore this option ! is redundant. It remains here for compatibility. ! .It Fl D Ar name Ns Op = Ns Ar value Defines a symbol \fIname\fR. Equivalent to the \fB#define\fR directive in the source. If no \fIvalue\fR is given, \fIvalue\fR is defined as \fB1\fR. This option can be specified more than once. ! . ! .It Fl h ! Compiles into C data-definitions (a header). The ! .Fl T ! option can be ! used in conjunction to produce a header which supports RPC dispatch tables. ! . ! .It Fl i Ar size Size at which to start generating inline code. This option is useful for ! optimization. The default ! .Ar size ! is 5. ! . ! .It Fl I ! Compiles support for ! .Xr inetd 1M ! in the server side stubs. Such servers can ! be self-started or can be started by ! .Xr inetd 3C . ! When the server is self-started, it backgrounds itself by default. A special define symbol ! .Dv RPC_SVC_FG ! can be used to run the server process in foreground, or the ! user can simply compile without the ! .Fl I ! option. ! .Lp ! If there are no pending client requests, the ! .Xr inetd 1M ! servers exit after 120 ! seconds (default). The default can be changed with the ! .Fl -K ! option. All of ! the error messages for ! .Xr inetd 1M ! servers are always logged with ! .Xr syslog 3C . ! .Lp ! .Em Note: ! This option is supported for backward compatibility only. It should ! always be used in conjunction with the ! .Fl b ! option which generates backward ! compatibility code. By default (that is, when ! .Fl b ! is not specified), ! .Nm ! generates servers that can be invoked through portmonitors. ! . ! .It Fl K Ar seconds ! By default, services created using ! .Nm ! and invoked through port monitors wait 120 seconds after servicing a request before exiting. That ! interval can be changed using the ! .Fl K ! flag. To create a server that exits ! immediately upon servicing a request, use ! .Fl K Li 0 . ! To create a server ! that never exits, the appropriate argument is ! .Fl K Li \(mi1 . ! .Lp ! When monitoring for a server, some portmonitors, like ! .Xr listen 1M , ! .Em always ! spawn a new process in response to a service request. If it is known that a server are used with such a monitor, the server should exit ! immediately on completion. For such servers, ! .Nm ! should be used with ! .Fl K Li 0 . ! . ! .It Fl l Compiles into client-side stubs. ! . ! .It Fl L ! When the servers are started in foreground, uses ! .Xr syslog 3C ! to log the server errors instead of printing them on the standard error. ! . ! .It Fl m Compiles into server-side stubs, but do not generate a "main" routine. This option is useful for doing callback-routines and for users who need to write their own "main" routine to do initialization. ! . ! .It Fl M Generates multithread-safe stubs for passing arguments and results between ! code generated by ! .Nm rpcgen ! and user written code. This option is useful for users who want to use threads in their code. ! . ! .It Fl N This option allows procedures to have multiple arguments. It also uses the style of parameter passing that closely resembles C. So, when passing an argument to a remote procedure, you do not have to pass a pointer to the argument, but can pass the argument itself. This behavior is different from the ! old style of code generated by ! .Nm . ! To maintain backward compatibility, this option is not the default. ! . ! .It Fl n Ar netid ! Compiles into server-side stubs for the transport specified by ! .Ar netid . ! There should be an entry for ! .Ar netid ! in the ! .Xr netconfig 4 ! database. This option can be specified more than once, so as to compile a server that serves multiple transports. ! . ! .It Fl o Ar outfile Specifies the name of the output file. If none is specified, standard output is ! used ! .Po ! .Fl c , h , l , m , n , s , "Sc" , "Sm" , "Ss" , ! and ! .Fl t ! modes only ! .Pc . ! . ! .It Fl s Ar netttype Compiles into server-side stubs for all the transports belonging to the class ! .Ar nettype . ! The supported classes are ! .Sy netpath , ! .Sy visible , ! .Sy circuit_n , ! .Sy circuit_v , ! .Sy datagram_n , ! .Sy datagram_v , ! .Sy tcp , ! and ! .Sy udp ! (see ! .Xr rpc 3NSL ! for the meanings associated with ! these classes). This option can be specified more than once. ! .Em Note: ! The transports are chosen at run time and not at compile time. ! . ! .It Fl "Sc" Generates sample client code that uses remote procedure calls. ! . ! .It Fl "Sm" Generates a sample Makefile which can be used for compiling the application. ! . ! .It Fl "Ss" Generates sample server code that uses remote procedure calls. ! . ! .It Fl t ! Compiles into RPC dispatch table. ! . ! .It Fl T ! Generates the code to support RPC dispatch tables. ! .Lp ! The options ! .Fl c , h , l , m , s R, "Sc" , "Sm" , "Ss" , ! and ! .Fl t ! are used exclusively to generate a ! particular type of file, while the options ! .Fl D ! and ! .Fl T ! are global and can be used with the other options. ! . ! .It Fl v Displays the version number. ! . ! .It Fl Y Ar pathname ! Gives the name of the directory where ! .Nm ! starts looking for the C preprocessor. ! .El ! .Sh OPERANDS The following operand is supported: ! .Bl -tag -width Ar ! . ! .It Ar infile input file ! .El ! .Sh EXIT STATUS ! .Ex -std ! .Sh EXAMPLES ! .Ss Example 1 Generating the output files and dispatch table The following entry ! .Lp ! .Dl example% rpcgen -T prot.x ! .Lp ! generates all the five files: ! .Pa prot.h , prot_clnt.c R, prot_svc.c , prot_xdr.c , ! and ! .Pa prot_tbl.i . ! . ! .Ss Example 2 Sending headers to standard output The following example sends the C data-definitions (header) to the standard output: ! .Lp ! .Dl example% rpcgen -h prot.x ! . ! .Ss Example 3 Sending a test version ! To send the test version of the ! .Fl DTEST , ! server side stubs for all the ! transport belonging to the class ! .Sy datagram_n ! to standard output, use: ! .Lp ! .Dl example% rpcgen -s datagram_n -DTEST prot.x ! . ! .Ss Example 4 Creating server side stubs ! To create the server side stubs for the transport indicated by ! .Ar netid ! .Sy tcp , ! use: ! .Lp ! .Dl example% rpcgen -n tcp -o prot_svc.c prot.x ! .Sh SEE ALSO ! .Xr inetd 1M , ! .Xr listen 1M , ! .Xr rpc 3NSL , ! .Xr rpc_control 3NSL , ! .Xr rpc_svc_calls 3NSL , ! .Xr syslog 3C , ! .Xr netconfig 4 , ! .Xr attributes 5 ! .Rs ! .%B ONC+ Developer\&'s Guide ! .Re