A code-generating tool for creating programming skeletons that implement the RPC mechanism. NOTE RPCGEN runs the C preprocessor, CC/DECC/PREPROCESSOR, on all input files before actually interpreted the files. Therefore, all the preprocessor directives are legal within an RPCGEN input file. For each type of output file, RPCGEN defines a special preprocessor symbol for use by the RPCGEN programmer: RPC_HDR Defined when compiling into header files. RPC_XDR Defined when compiling into XDR routines. RPC_SVC Defined when compiling into server skeletons. RPC_CLNT Defined when compiling into client skeletons. RPC_TBL Defined when compiling into RPC dispatch table. In addition, RPCGEN does a little preprocessing of its own. RPCGEN passes any line beginning with a percent sign (%) directly into the output file, without interpreting the line. Format
1 – Parameters
infile The input file to RPCGEN. The input file contains ONC RPC programming language. This language is very similar to the C language. By default, RPCGEN uses the name of the input file to create the four default output files as follows: o infile.H-the header file o infile_CLNT.C-the client skeleton o infile_SVC.C-the server skeleton with support for both UDP and TCP transports o infile_XDR.C-the XDR routines If you specify the /DISPATCH_TABLE qualifier, RPCGEN uses the default name infile_TBL.I for the dispatch table.
2 – Qualifiers
2.1 /CLIENT_STUBS_FILE
Optional. UNIX equivalent: -l Default: Create a client skeleton file. Creates the client skeleton file. Mutually exclusive with the /DISPATCH_TABLE, /HEADER_FILE, /SERVER_STUBS_FILE, /TRANSPORT, and XDR_FILE qualifiers.
2.2 /DEFINE
/DEFINE = (name[=value][,....]) Optional. UNIX equivalent: -D Default: No definitions. Defines one or more symbol names. Equivalent to one or more #define directives. Names are defined as they appear in the argument to the qualifier. For example, /DEFINE=TEST=1 creates the line #define TEST=1 in the output files. If you omit the value, RPCGEN defines the name with the value 1.
2.3 /DISPATCH_TABLE
Optional. UNIX equivalent: -t Default: No dispatch file created. Creates the server dispatch table file. An RPCGEN dispatch table contains: o Pointers to the service routines corresponding to a procedure o A pointer to the input and output arguments o The size of these routines A server can use the dispatch table to check authorization and then to execute the service routine; a client may use it to deal with the details of storage management and XDR data conversion. Mutually exclusive with the /CLIENT_STUBS_FILE, /HEADER_FILE, /SERVER_STUBS_FILE, /TRANSPORT, and XDR_FILE qualifiers.
2.4 /ERRLOG
Optional. UNIX equivalent: -L Default: Logging to stderr. Specifies that servers should log errors to the operator console instead of using fprintf with stderr. You must install servers with OPER privilege in order to use this feature.
2.5 /HEADER_FILE
Optional. UNIX equivalent: -h Default: Create a header file. Creates the C data definitions header file. Use the /TABLE qualifier in conjunction with this qualifier to generate a header file that supports dispatch tables. Mutually exclusive with the /CLIENT_STUBS_FILE, /DISPATCH_TABLE, /SERVER_STUBS_FILE, /TRANSPORT, and XDR_FILE qualifiers.
2.6 /INET_SERVICE
Optional. UNIX equivalent: -I Default: No INETd support. Compiles support for INETd in the server side stubs. You can start servers yourself or you can have INETd start them. Servers started by INETd log all error messages to the operator console. If there are no pending client requests, the INETd servers exit after 120 seconds (default). You can change this default with the /TIMEOUT_SECONDS qualifier. When RPCGEN creates servers with INETd support, it defines two global variables: _rpcpmstart and rpcfdtype. The runtime value of _rpcpmstart is 1 or 0 depending on whether INDEd started the server program. The value of rpcfdtype should be SOCK_STREAM or SOCK_DGRAM depending on the type of the connection.
2.7 /OUTPUT
/OUTPUT = file Optional. UNIX equivalent: -o Default: Direct output to one of the standard default files. Use this qualifier to direct the output of the /CLIENT_STUBS_ FILE, /DISPATCH_TABLE, /HEADER_FILE, /SERVER_STUBS_FILE, /TRANSPORT, and /XDR_FILE qualifiers.
2.8 /SERVER_STUBS_FILE
Optional. UNIX equivalent: -m Default: Create a server skeleton file. Creates a server skeleton file without the main routine. Use this qualifier to generate a server skeleton when you wish to create your own main routine. This option is useful for programs that have callback routines and for programs that have customized initialization requirements. Mutually exclusive with the /CLIENT_STUBS_FILE, /DISPATCH_TABLE, /HEADER_FILE, /TRANSPORT, and XDR_FILE qualifiers.
2.9 /TABLE
Optional. UNIX equivalent: -T Default: No dispatch table code created. Creates the code in the header file to support an RPCGEN dispatch table. You can use this qualifier only when you are generating all files (the default) or when you are using the /HEADER_FILE qualifier to generate the header file. This /TABLE qualifier includes a definition of the dispatch table structure in the header file; it does not modify the server routine to use the table.
2.10 /TRANSPORT
/TRANSPORT [= (TCP, UDP)] Optional. UNIX equivalent: -s Default: Create a server skeleton that supports both protocols. Creates a server skeleton that includes a main routine that uses the given transport. The supported transports are UDP and TCP. To compile a server that supports multiple transports, specify both.
2.11 /TIMEOUT_SECONDS
/TIMEOUT_SECONDS=seconds Optional. UNIX equivalent: -K Default: 120 seconds. If INETd starts the server, this option specifies the time (in seconds) after which the server should exit if there is no further activity. By default, if there are no pending client requests, INETd servers exit after 120 seconds. This option is useful for customization. If seconds is 0, the server exits after serving a request. If seconds is -1, the server never exits after being started by INETd.
2.12 /XDR_FILE
Optional. UNIX equivalent: -c Default: Create an XDR file. You can customize some of your XDR routines by leaving those data types undefined. For every data type that is undefined, RPCGEN assumes that there exists a routine with the name xdr_ prepended to the name of the undefined type. Mutually exclusive with the /CLIENT_STUBS_FILE, /DISPATCH_TABLE, /HEADER_FILE, /TRANSPORT, and /SERVER_STUBS_FILE qualifiers.
3 – Examples
1.RPCGEN /ERRLOG /TABLE PROTO.X This example generates all of the five possible files using the default file names: PROTO.H, PROTO_CLNT.C, PROTO_SVC.C, PROTO_ XDR.C, and PROTO_TBL.I. The PROTO_SVC.C code supports the use of the dispatch table found in PROTO_TBL.I. The server error messages are logged to the operator console instead of being sent to the standard error. 2.RPCGEN /INET_SERVICE /TIMEOUT_SECONDS=20 PROTO.X This example generates four output files using the default file names: PROTO.H, PROTO_CLNT.C, PROTO_SVC.C, and PROTO_XDR.C. INETd starts the server and the server exits after 20 seconds of inactivity. 3.RPCGEN /HEADER_FILE /TABLE PROTO.X This example sends the header file (with support for dispatch tables) to the default output file PROTO.H. 4.RPCGEN /TRANSPORT=TCP PROTO.X This example sends the server skeleton file for the transport TCP to the default output file PROTO_SVC.C. 5.RPCGEN /HEADER_FILE /TABLE /OUTPUT=PROTO_TABLE.H PROTO.X This example sends the header file (with support for dispatch tables) to the output file PROTO_TABLE.H.