ONC+ Developer's Guide

Preprocessing Directives

rpcgen supports C and other preprocessing features. C preprocessing is performed on rpcgen input files before they are compiled. All standard C preprocessing directives are allowed in the.x source files. Depending on the type of output file being generated, five symbols are defined by rpcgen.

rpcgen provides an additional preprocessing feature: any line that begins with a percent sign (%) is passed directly to the output file, with no action on the line's content. Use caution because rpcgen does not always place the lines where you intend. Check the output source file and, if needed, edit it.

rpcgen uses the preprocessing directives listed in the following table.

Table 3–1 rpcgen Preprocessing Directives

Symbol 

Use 

RPC_HDR

Header file output 

RPC_XDR

XDR routine output 

RPC_SVC

Server stub output 

RPC_CLNT

Client stub output 

RPC_TBL

Index table output 

The following code example is a simple rpcgen example. Note the use of rpcgen`s pre-processing features.


Example 3–7 Time Protocol rpcgen Source

/*
 * time.x: Remote time protocol
 */
program TIMEPROG {
	version TIMEVERS {
			unsigned int TIMEGET() = 1;
	} = 1;
} = 0x20000044;

#ifdef RPC_SVC
%int *
%timeget_1()
%{
%	static int thetime;
%
%	thetime = time(0);
%	return (&thetime);
%}
#endif