DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 
Programming with Remote Procedure Calls (RPC)

Declarations

In RPC/XDR, there are four kinds of declarations.

   declaration:
   	simple-declaration
   	fixed-array-declaration
   	variable-array-declaration
   	pointer-declaration
Simple declarations are just like simple C declarations.
   simple-declaration:
   	type-ident variable-ident
For example:
   colortype color;
is converted to:
   colortype color;
Fixed-length array declarations are just like C array declarations:
   fixed-array-declaration:
   	type-ident variable-ident [ value ]
For example:
   colortype palette[8];
is converted to:
   colortype palette[8];
Variable-length array declarations have no explicit syntax in C. The RPC/XDR does have a syntax; it uses angle-brackets.
   variable-array-declaration:
   	type-ident variable-ident < value >
   	type-ident variable-ident < >
The maximum size is specified between the angle brackets. The size may be omitted, indicating that the array may be of any size.
   int heights<12>;   /* at most 12 items */
   int widths<>;          /* any number of items */
Because variable-length arrays have no explicit syntax in C, these declarations are compiled into struct declarations. For example, the heights declaration gets compiled into the following struct:
   struct {
   	u_int heights_len;      /* # of items in array */
   	int *heights_val;       /* pointer to array */
   } heights;
Note that the number of items in the array is stored in the _len component and the pointer to the array is stored in the _val component. The first part of each of these component's names is the same as the name of the declared RPC/XDR variable.

Pointer declarations are made in RPC/XDR exactly as they are in C. Address pointers cannot really be sent over the network, but RPC/XDR pointers are useful for sending recursive data types such as lists and trees. The type is actually called ``optional-data,'' not ``pointer,'' in XDR language.

   pointer-declaration:
   	type-ident *variable-ident
For example:
   listitem *next;
is converted to:
   listitem *next;

© 2004 The SCO Group, Inc. All rights reserved.
UnixWare 7 Release 7.1.4 - 27 April 2004