Convert RPC Source (RPCGEN)

The Convert RPC Source (RPCGEN) command generates C code from an input file written in the Remote Procedure Call (RPC) Language. The generated C code can be used to implement an RPC protocol.

This command is equivalent to running the rpcgen utility on a UNIX system.

This command can also be issued using the following alternative command name:

Restrictions:

Parameters

Keyword Description Choices Notes
FROMFILE From file Path name Required, Positional 1
OPTION Option *ALL, *XDR, *HDR, *CLTSTUB, *SVRSTUB, *CLTSAMP, *SVRSAMP, *NOSAMP Optional
PROTOCOL Protocol Values (up to 2 repetitions): *NONE, *TCP, *UDP Optional
TOFILE To file Path name Optional

From file (FROMFILE)

Specifies the path name of the input source file written in the Remote Procedure Call (RPC) Language. The input source file must be a file in the "root" (/) or QOpenSys file system.

For more information on specifying path names, refer to "Object naming rules" in the CL topic collection in the Programming category in the IBM i Information Center at http://www.ibm.com/systems/i/infocenter/.

Option (OPTION)

Specifies the compile options.

*NOSAMP
All file types except the sample files (*CLTSAMP and *SVRSAMP) are generated.
*ALL
All file types are generated.
*XDR
The input file is compiled into XDR (eXternal Data Representation) routines.
*HDR
The input file is compiled into C data-definitions (a header file).
*CLTSTUB
The input file is compiled into client-side stub procedures.
*SVRSTUB
The input file is compiled into server-side stub procedures. However, no "main" routine is generated.
*CLTSAMP
Sample client code that uses remote procedure calls is generated. The file can be customized for the application.
*SVRSAMP
Sample server code that uses remote procedure calls is generated. The file can be customized for the application.

Protocol (PROTOCOL)

Compiles into server-side stub procedures for the transport that is specified. The specified value must be present in the /etc/netconfig file at the time the server application is run. This parameter is only valid when OPTION(*SVRSTUB) is specified. One or more of the following options may be specified:

*NONE
Compile server-side stub procedures for all transports that are in the /etc/netconfig file.
*TCP
Compile server-side stub procedures for the TCP transport.
*UDP
Compile server-side stubs for the UDP transport.

To file (TOFILE)

Specifies the path name of the output file. This option is only allowed if OPTION(*ALL) or OPTION(*NOSAMP) is not specified. When OPTION(*ALL) or OPTION(*NOSAMP) is specified, or if the TOFILE parameter is not specified when using another option, the From file (FROMFILE) parameter is used to generate the TOFILE name as follows, where filename is the name of the input file name from the FROMFILE parameter.

The output file or files for sample code must not exist; if any of the sample output files exist, the command will fail. Other output files will be overwritten if they exist.

'to-file-path name'
Specify a path name to be used to generate the TOFILE name or names.

For more information on specifying path names, refer to "Object naming rules" in the CL topic collection in the Programming category in the IBM i Information Center at http://www.ibm.com/systems/i/infocenter/.

Examples

The alternative command name for RPCGEN is CVTRPCSRC. The following examples use the alternative command name, but RPCGEN can be replaced directly for CVTRPCSRC in all of them.

Example 1: Convert RPC Source to Default Files

CVTRPCSRC   FROMFILE('/myrpc')  OPTION(*ALL)

This converts the RPC language file '/myrpc' into all four file types, *XDR, *HDR, *CLTSTUB and *SVRSTUB. The default PROTOCOL(*TCP) is used to generate the server-side stub programs. The files are placed into the following file names:

Example 2: Convert RPC Source to Client Stubs Only

CVTRPCSRC   FROMFILE('/myrpc2')  OPTION(*CLTSTUB)
            TOFILE('/myclnt.c')

This converts the RPC language file '/myrpc2' into client-side stub procedures. The results are placed into the file '/myclnt.c' as specified.

Error messages

*ESCAPE Messages

CPFB416
CVTRPCSRC or RPCGEN command failed.