OSI/TS Configuration and Management Manual

Programming Examples
OSI/TS Configuration and Management Manual424831-001
C-10
C Example File-Transfer Program, Responder
strcpy((char *)&default_subvol[0],&s_subvol[0]);
/* Convert the external TSP su device name into an internal
name */
FNAMEEXPAND(&ext_dev_rcv[0],&osi_dev_rcv[0],
&default_subvol[0]);
/* Convert the external destination file name into an
internal name */
FNAMEEXPAND(&dsex_file_name[0],&dest_file_name[0],
&default_subvol[0]);
/* Open the TSP su and waiting for a connection request */
OPEN(&osi_dev_rcv[0], &ornum);
SETMODENOWAIT(ornum,(int)30,(int)1);
CONTROL(ornum,(int)11);
/* Purge the existing destination file and create a
unstructured file */
PURGE(&dest_file_name[0]);
CREATE(&dest_file_name[0],100,100,20, , rec_len_rcv);
OPEN(&dest_file_name[0],&dnum,(int)0, (int)1);
/* Copy data until the EOT is encountered */
while(buffer[0] != 0 )
{
READ(ornum,&buffer[0],rec_len_rcv+2,&count_read);
AWAITIO(&ornum);
WRITE(dnum,&buffer[1],count_read-2);
}
/* Close the destination file */
CLOSE(dnum);
/* Release the TSP connection */
CONTROL(ornum,(int)12);
/* Close the TSP su */
CLOSE(ornum);
}