Syntax Notes
The following are keywords and cannot be used as identifiers:
- bool
- cas
- chas
- const
- default
- double
- enum
- float
- hyper
- int
- opaque
- quadruple
- string
- struct
- switch
- typedef
- union
- unassigned
- void
Only unsigned constants can be used as size specifications for arrays. If an identifier is used, it must have been declared previously as an unsigned constant in a const definition.
Constant and type identifiers within the scope of a specification are in the same namespace and must be declared uniquely within this scope.
Similarly, variable names must be unique within the scope of struct and union declarations. Nested struct and union declarations create new scopes.
The discriminant of a union must be of a type that evaluates to an integer. That is, it must be an int, an unsigned int, a bool, an enum type, or any typedef that evaluates to one of these. Also, the case values must be legal discriminant values. Finally, a case value cannot be specified more than once within the scope of a union declaration.
XDR Data Description
The following example is a short XDR data description of a file data structure that might be used to transfer files from one machine to another.
Example C-2 XDR File Data Structure
Suppose now that a user named linda wants to store her LISP program sillyprog that contains just the data "quit." Her file would be encoded as listed in the following table.
Table C-1 XDR Data Description Example
Offset | Hex Bytes | ASCII | Description |
---|---|---|---|
0 | 00 00 00 09 | - | Length of file name = 9 |
4 | 73 69 6c 6c | sill | File name characters |
8 | 79 70 72 6f | ypro | More characters |
12 | 67 00 00 00 | g | 3 zero-bytes of fill |
16 | 00 00 00 02 | - | Filekind is EXEC = 2 |
20 | 00 00 00 04 | - | Length of interpreter = 4 |
24 | 6c 69 73 70 | lisp | Interpreter characters |
28 | 00 00 00 04 | - | Length of owner = 4 |
32 | 6a 6f 68 6e | linda | Owner characters |
36 | 00 00 00 06 | - | Length of file data = 6 |
40 | 28 71 75 69 | (qu | File data bytes |
44 | 74 29 00 00 | t) | 2 zero-bytes of fill |
RPC Language Reference
The RPC language is an extension of the XDR language. The sole extension is the addition of the program and version types.
For a description of the RPC extensions to the XDR language, see Appendix B, RPC Protocol and Language Specification.