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. Caution is required because rpcgen does not always place the lines where you intend. Check the output source file and, if needed, edit it.
Table 3-1 rpcgen Preprocessing Directives
Symbol |
Use |
---|---|
Header file output |
|
XDR routine output |
|
Server stub output |
|
Client stub output |
|
Index table output |
Example 3-7 is a simple rpcgen example. Note the use of rpcgen`s pre-processing features.
/* * 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