next up previous contents index
Next: Basic GRAPE XDR Functions Up: XDR Functions Previous: XDR Functions

Basic XDR Functions

Before discussing the GRAPE XDR utility routines and methods we will give a very short introduction to the XDR system, for more information you should consult the XDR manual pages.

The XDR library provides a single function for each basic data type (char, short, int, long, float, double) which is used for both writing and reading. The basic form of all functions is

bool_t xdr_type(XDR *xdrp, type *data)
where type stands for the data type. The functions return TRUE if they succeed and FALSE if they fail.

The first parameter of all XDR functions is the XDR stream handle xdrp, a pointer to an XDR structure. This XDR stream handle can be compared to a file pointer when writing or reading a file, amongst other data it contains information about the operation that is performed: xdrp->x_op is set to XDR_ENCODE resp. XDR_DECODE if the function is called for writing resp. writing.

For example the function for int is called xdr_int, it takes an int * as second parameter. For unsigned int the function is called xdr_u_int, this u_ prefix has to be added for all unsigned types. The pointer to the variable is necessary because the variable value has to be changed when the function is used for reading.

The XDR library also provides routines for handling arrays and strings. These functions -- besides xdr_vector for fixed length arrays -- are dangerous because they do their own memory management, see section 5.7.7.



SFB 256 Universität Bonn and IAM Universität Freiburg

Copyright © by the Sonderforschungsbereich 256 at the Institut für Angewandte Mathematik, Universität Bonn.