OSI/TS Configuration and Management Manual

Programming Examples
OSI/TS Configuration and Management Manual424831-001
C-8
C Example File-Transfer Program, Responder
main ()
{
/* Reset the MCW */
buffer[0] = 0;
/* Copy the default subvol name */
strcpy((char *)&default_subvol[0],&s_subvol[0]);
/* Convert the TSP su name */
FNAMEEXPAND(&ext_dev_send[0],&osi_dev_send[0],
&default_subvol[0]);
/* Convert the source file name */
FNAMEEXPAND(&srcex_file_name[0],&source_file_name[0],
&default_subvol[0]);
/* Open the TSP su and send a connection request */
OPEN(&osi_dev_send[0], &osnum);
CONTROL(osnum,(int)17);
/* Open the unstructured source file */
OPEN(&source_file_name[0],&snum);
count_read = rec_len_send;
/* Assume more data */
buffer[0] = buffer[0] || MORE_DATA;
/* Transmit data in the source file until the EOT is
encountered */
while ( count_read == rec_len_send)
{
READ(snum,&buffer[1],rec_len_send,&count_read);
if (count_read < rec_len_send )
buffer[0] = buffer[0] && NOMORE_DATA;
WRITE(osnum,&buffer[0],count_read+2);
}
/* Close the source file */
CLOSE(snum);
/* Release the TSP connection */
CONTROL(osnum,(int)12);
/* Close the TSP su */
CLOSE(osnum);
}
C Example File-Transfer Program, Responder
Before running this program, your OSI/TS subsystem must be configured and running.
Before compiling the source code, you must first replace the file and process names with
names that reflect your environment, as described in the first comment box in the code.