ONC+ Developer's Guide

Special Cases

There are several exceptions to the RPC language rules.

C-style Mode

In the new features section we talked about the features of the C-style mode of rpcgen. These features have implications with regard to the passing of void arguments. No arguments need be passed if their value is void.

Booleans

C has no built-in boolean type. However, the RPC library uses a boolean type called bool_t that is either TRUE or FALSE. Parameters declared as type bool in XDR language are compiled into bool_t in the output header file.

Example:

bool married; --> bool_t married;

Strings

The C language has no built-in string type, but instead uses the null-terminated char * convention. In C, strings are usually treated as null- terminated single-dimensional arrays.

In XDR language, strings are declared using the string keyword, and compiled into type char * in the output header file. The maximum size contained in the angle brackets specifies the maximum number of characters allowed in the strings (not counting the NULL character). The maximum size may be omitted, indicating a string of arbitrary length.

Examples:

string name<32>;   --> char *name;
string longname<>; --> char *longname;

Note -

NULL strings cannot be passed; however, a zero-length string (that is, just the terminator or NULL byte) can be passed.


Opaque Data

Opaque data is used in XDR to describe untyped data, that is, sequences of arbitrary bytes. It may be declared either as a fixed length or variable length array. Examples:

opaque diskblock[512]; --> char diskblock[512];
opaque filedata<1024>; --> struct {
                           u_int filedata_len;
                           char *filedata_val;
                     } filedata;

Voids

In a void declaration, the variable is not named. The declaration is just void and nothing else. Void declarations can only occur in two places: union definitions and program definitions (as the argument or result of a remote procedure, for example no arguments are passed.)