[ Previous | Next | Contents | Search ]
3270 Host Connection Program 2.1 and 1.3.3 for AIX: Guide and Reference

VM/CMS File Transfer Program Example

The following program illustrates the file transfer process using the file transfer program interface on VM/CMS. To upload the file to an MVS/TSO host, the host option flag FXC_CMS must be changed to FXC_TSO and the host file name must be in MVS/TSO format. To upload the file to a CICS host, the host option flag FXC_CMS must be changed to FXC_CICS, and the file name must be in CICS format. To upload the file to a VSE host, the host option flag FXC_CMS must be changed to FXC_VSE, and the file name must be in VSE format.

/************************************************************
Program Name : cname - transfers a file using the file
                       transfer Program Interface
Module Name  : cname.c
Description  : The following program uploads a file from the
               operating system to the VM/CMS host.The file is
               translated from ASCII to EBCDIC using the
               translation tables of the language specified in
               the session profile.   The file overwrites the
               host file, if it exists. The transfer is performed
               via manual logon;  that is, the user must
               establish a host session by logging on to the host
               and running the application from the e789
               subshell.
*************************************************************/

#include <stdio.h>
#include <sys/types.h>
#include <fxfer.h>
#include <memory.h>
#include <time.h>
main()
{
     extern  char*malloc();
     extern  void free();
     extern  void exit();
     extern  unsigned int sleep();
     struct fxc *xfer;
     struct fxs sxfer;
     timer_t tmptime;
     char *c_time;
     register int LOOP;  /* indicates status not available yet */
     LOOP = 0;
     xfer = (struct fxc *) malloc (1024);
     xfer->fxc_src = "samplefile";  /* Sys file to be uploaded */
     xfer->fxc_dst = "test file a"; /* VM/CMS Host file name  */
     /***********************************************************
                       Set the transfer flags
     ***********************************************************/
     xfer->fxc_opts.f_flags = 0;
     xfer->fxc_opts.f_flags | = FXC_UP;    /* Upload file flag */
     xfer->fxc_opts.f_flags | = FXC_TNL;   /* Translate--EBCDIC */
     xfer->fxc_opts.f_flags | = FXC_REPL;  /* Replace host file if
                                              it exists   */
     xfer->fxc_opts.f_flags | = FXC_QUEUE; /* Transfer file, 
                                              asynchronously  */
     xfer->fxc_opts.f_flags | = FXC_VAR;   /* Variable host record
                                              format   */
     xfer->fxc_opts.f_flags | = FXC_CMS;   /* VM/CMS host     */
     xfer->fxc_opts.f_logonid = (char *)0; /* Explicit  file 
                                              transfer      */
     xfer->fxc_opts.f_inputfld = (char *)0;/* VSE and CICS 
                                              input field    */
     xfer->fxc_opts.aix_codepg = (char *)0;/* Alternate aix 
                                              codeset        */
     xfer->fxc_opts.f_lrecl = 132;         /* Logical record
                                              length        */
/* from subshell of an  already logged on emulator session */
   
     if ( fxfer(xfer,(void *)0) == 0) {    /* Send file transfer 
                                              request   */
       for (;;) {
          switch(cfxfer(&sxfer)) {         /* Check status   */
            case -1:
                   LOOP = 0;
                   printf("Status file not available due to\n");
                   printf(" status file I/O error\n");
/* Check the $HOME/hconerrors file for possible cause of error */
                   break;
            case 0:
                   LOOP = 0;
                   printf("Source file:%s\n", sxfer.fxs_src);
                   printf("Destination file:%s\n", 
                                                  sxfer.fxs_dst);
                   printf("Byte Count:%d\n", sxfer.fxs_bytcnt);
                   printf("MSG No:%d\n", sxfer.fxs_stat);
                   printf("ERROR if any:%d\n", sxfer.fxs_errno);
                   printf ("Destination file creation time:%s\n",
                                                  sxfer.fxs_ctime);
                   break;
            case -2:
                   LOOP = 1;
                   sleep(15);
                   printf("Status not available yet\n");
                   break;
           }
           if ( !LOOP  ) {
                 break;
           }
     }
  }
  free(xfer);
  exit(1);
}


[ Previous | Next | Contents | Search ]