FTAM/9000 Programmer's Guide
Chapter 10 393
Example Programs
Common Code Example
/*
** Free memory.
*/
res = ft_dfdcb((Octet *)wri_inout_dcb, & outcome);
if (res != SUCCESS)
error_handler(outcome, diag);
/*
** Replace the contents of destination file with the contents
** of source file.
*/
done = FALSE;
while ( ! done ) {
/*
** Read from the source file.
**
** Get the parameters for ft_rdata.
** Call ft_rdata and verify the outcome.
*/
rda_parm_in(& des_requested, & return_event_name, & rda_inout_dcb);
res = ft_rdata(conn_id[SRC], des_requested, return_event_name,
& rda_inout_dcb);
if (res != SUCCESS)
error_handler(rda_inout_dcb-result,
rda_inout_dcb-diagnostic);
/*
** If a cancel indication returned, stop
** transferring data.
*/
data_unit = rda_inout_dcb-data_unit;
for (index = 1; index %< rda_inout_dcb-des_received; index++)
data_unit = data_unit-next;
if (data_unit-structure_id == FT_CANCEL_IND) {
rda_inout_dcb -data_unit = NULL;
done = TRUE;
}
/*
** If only a data end indication was returned,
** stop transfering data.
*/
if (rda_inout_dcb-des_received == 1 & &
rda_inout_dcb-data_unit-structure_id == FT_DATA_END_IND) {
rda_inout_dcb -data_unit = NULL;
done = TRUE;
}
/*
** Move the data_element next pointer to the next to the
** last data_element and check for a data end indication
** on the last data_element. If one exists, set the next pointer
** to NULL so the last data_element is not written
** during the ft_sdata call.
*/
if ( ! done ) {
data_unit = rda_inout_dcb-data_unit;
for (index = 2; index %< rda_inout_dcb-des_received; index ++)
data_unit = data_unit-next;
if (data_unit-next-structure_id == FT_DATA_END_IND) {
data_unit-next = NULL;
done = TRUE;
}
}