gtpc2misC/C++ Language Support User's Guide

TPFxd_read-Read from an External Device into a Buffer

This function is used to read data from an external device into a buffer in the malloc area. The maximum read size is 32 000 bytes.

Format

#include <c$tpxd.h>
long TPFxd_read (TPFxd_extToken *token,
                 u_char         *buffer,
                 long           *bufferLength);

token
The returned token from the TPFxd_archiveStart or TPFxd_open request.

buffer
The pointer to the start of the buffer in which to read the data.

bufferLength
The pointer to the length of the buffer that the data will be read into. The buffer should be large enough to hold the data to be returned plus 16 additional bytes for a header.

Normal Return

The normal return is a positive value; it is the number of bytes read.

Error Return

An error return is indicated by a negative return code. For a list of error codes applicable to this function, see Error Codes.

Programming Considerations

Examples

The following example reads the first record from the position indicated.

#include <c$tpxd.h>
long example(TPFxd_locationMap wherefirst)
{
TPFxd_extToken    *token;
enum              tpxd_mode mode;
long              howbigitis;
long              howlongtowait;
char              *message;
char              *whatWasRead;
long              returncode;
 
howlongtowait = 60;
howbigitis = 32000;
message = NULL;
token = NULL;
mode = RD;
TPFxd_open (&token,
            &wherefirst,
            howbigitis,
            howlongtowait,
            message,
            mode );
malloc (whatWasRead,howbigitis);
returncode = TPFxd_read (token,
                         whatWasRead);

  ·
  ·
  ·
}

Related Information