TPFxd_write: Write to an external device
This function is used to write data from the malloc area to an external device. The maximum write size is 32,000 bytes.
Format
#include <tpf/c_tpxd.h>
int TPFxd_write (TPFxd_extToken *token,
u_char *data,
int *dataLength); - token
- The returned token from the TPFxd_archiveStart or TPFxd_open request.
- data
- The pointer to the start of the data to write.
- dataLength
- The pointer to the length of the data to write.
Normal return
A return code of 1 indicates a normal return.
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
- The TPFxd_open function must be called before this request.
- If the TPFxd_write function returns a TPFxd_ERROR_EOVwarning return code, a TPFxd_close request will cause the tape to be closed and removed. A subsequent TPFxd_open request would result in a new tape being mounted and, consequently, the volume serial number (VOLSER) would be changed.
- If a TPFxd_ERROR_EOVwarning return code is received, the record has been successfully written but the amount of space remaining on that volume is limited. Additional TPFxd_write requests will be allowed and will receive a TPFxd_ERROR_EOVwarning return code.
Examples
The following example writes a
core area to an external device.
#include <tpf/c_tpxd.h>
int example()
{
TPFxd_extToken *token;
TPFxd_locationMap wherefirst;
enum tpxd_mode mode;
enum tpxd_opts access;
long howbigitis;
long howlongtowait;
char *message;
long returncode;
char *stufftowrite;
howlongtowait = 60;
howbigitis = 32000;
message = NULL;
token = NULL;
mode = WT;
access = IMMEDIATE;
TPFxd_archiveStart (&token, mode, access);
TPFxd_open (&token,
&wherefirst,
howbigitis,
howlongtowait,
message,
mode );
stufftowrite = malloc(howbigitis);
⋮
returncode = TPFxd_write(token,stufftowrite,&howbigitis);
printf("write complete with return code %i\n",returncode);
free(stufftowrite);
⋮
}Related information
- close: Shut down a socket
- TPFxd_getPosition: Retrieve current positioning information
- TPFxd_getPrevPosition: Retrieve previous positioning information
- TPFxd_nextVolume: Advance to the next volume when reading or writing
- TPFxd_open: Fulfill any mount or positioning required
- read: Read data on a socket
- TPFxd_readBlock: Read into a core block from an external device
- TPFxd_sync: Verify queued information
- TPFxd_writeBlock: Write core block images to the external device.
See External device support overview for more information about this function and z/TPF C/C++ language support.