Node:Simple Data Types, Next:, Previous:Notation, Up:Fundamentals



Simple Data Types

Integers

INT32, INT16, INT8 and BOOL are non-negative integers which must fit in 32, 16, 8 and 1 bits, respectively. They are transmitted to the server in ASCII-encoded decimal notation.

Floating point numbers

FLOAT are floating point numbers. They are represented as if printed via printf("%g", val); in C. See 7.19.6.1 The fprintf function in ISO/IEC 9899:1999 Programming languages - C for the details. See The %g conversion, if you don't have the C standard handy.

Strings

HOLLERITH denotes character strings of arbitrary length. They are transmitted as nHtext where text is the string and n is the number of characters in text in decimal notation. All byte values are allowed in the string itself, including nulls.

Long live FORTRAN!

The character set used in the strings is not yet specified by Protocol A. In the future, some Unicode encoding will probably be used, but it is not yet decided which one or how the transition will be handled. Bug 99 is about the need for a Unicode roadmap; check that bug for the current state of the plans.

For now, which character set to use is a local policy of each server installation. There is not yet any way in the protocol to specify the character set that a certain server uses. Most clients currently assume that ISO 8859-1 (Latin-1) is used, and the default collate table of lyskomd also assumes ISO 8859-1. Conference names must currently use an 8-bit character set encoding where whitespace is defined as in ASCII, or conference matching won't work. get-collate-table contains some more information about character set issues.

Bit Strings

BITSTRING is a string of bits, commonly used for a set of boolean-valued flags. Bit strings are denoted as

        BITSTRING ( name-1; name-2; name-3; ... )

in this specification. They are transmitted as a sequence of ASCII ones and zeroes in the order the fields are listed.

For instance, given the specification

        shape-of-world ::= BITSTRING (
                is-flat;
                is-round;
                is-2d;
                is-3d;
        )

most peoples idea of shape-of-world would be sent as 0101 (round and three-dimensional.)

Enumerations

ENUMERATION is an integer constant. It is transmitted as an INT32, but only fixed values are permitted. Clients should be prepared to receive numbers outside the enumeration and either handle this gracefully as an error or use a reasonable default value in place of an invalid enumeration value.

An enumeration is specified as

        ENUMERATION (
                name-1=value-1;
                name-2=value-2;
                name-3=value-3;
                ...
        )

This specification states that name-1 is represented by the integer value-1, name-2 is represented by value-2 and name-3 is represented by value-3.

An enumeration can also be inherited from a SELECTION data type:

        Info-type ::= ENUMERATION-OF(Misc-Info)

This means that Info-type is an enumeration, that contains the same keys and values as the SELECTION Misc-Info.

For example, in the following specification, the constant guwal will be transmitted as the integer 2, ciokwe as the integer 3, and hopi as the integer 5.

      language ::= ENUMERATION ( hakka      = 1;
                                 guwal      = 2;
                                 ciokwe     = 3;
                                 yoruba     = 4;
                                 hopi       = 5;
                )

Arrays

ARRAY is a list of a fixed number of elements of a single type. The specification for an array is ARRAY type where type is the type of the array elements.

Arrays are transmitted as an n { element element ... } where n is the number of elements and each element is an element of the array. A special case is when the array is empty, in which case the server transmits it as 0 *. Note that the client must always transmit empty arrays as 0 { }.

In some calls the client can ask the server not to send the array contents, only its length. In these cases the array is transmitted as n * where n is the number of elements in the array.

Selection

SELECTION is tagged data. It consists of an INT32 selector followed by a tail of an arbitrary type and is specified as

        SELECTION (
                n=name        tail : type;
                n=name        tail : type;
                ...
        )

where each n is the selector value, name the selector name and tail the name of the selector tail and type its type. name and tail are often very similar, such as sent-by and sender.

When transmitted, the selector is transmitted as an INT32 followed by the tail belonging to that selector. For instance, given the specification

        description ::= SELECTION (
               1=name           the_name : HOLLERITH;
               2=age            years    : INT32;
        )

two legal messages of the type description are 1 4HJohn and 2 18.

RPC

RPC is a notation used to specify calls to the server. An RPC specification has the following form:

        RPC (
                call [n] ( request ) -> ( reply ) ;
                call [n] ( request ) -> ( reply ) ;
        )

where each call is the name of a call, n is the call number, request is a single data element sent as a request and reply is a single data element sent in reply from the server.

RPC calls are transmitted as n request where n and request have the same meaning as above. Note that in the client-server dialog a reference number must also be supplied with each request. This reference number is not part of the RPC itself, but is required for communications; see Client-Server Dialog.

Structure

Structures are collections of several data items. In the specification they are written as

        ( name : type ;
          name : type ;
          ...
        )

where each name is the name of a data field and the corresponding type is its type.

Structures are transmitted as a sequence of their fields.