Apply Automated File Opening
Use the file open exit feature to override the values specified in the COPY statement. The file open exit is an initialization parameter (file.exit) that you can set to point to a user-written DLL. You can customize Connect:Direct® COPY operations by defining values in the file open exit DLL that override the COPY statement parameters.
Apply the File Open Exit
Connect:Direct file open support is implemented as a user exit called from the Connect:Direct session manager during Connect:Direct COPY statement execution. To enable the file open exit, change the value of the file.exit initialization parameter to the name or path name of the file open exit DLL.
Refer to Changing Connect:Direct for Microsoft Windows Settings in the IBM® Connect:Direct for Microsoft Windows System Guide or IBM Connect:Direct for Microsoft Windows Help for a description of the file.exit parameter. If the DLL is not in the search path of the server, then you must specify the fully qualified file name of the DLL.
The user's file open exit must contain the FileOpen() function. The parameters for this function are File_Open and File_Open_Reply. These parameters are pointers to corresponding structures in the userexit.h header file. The userexit.h header file is in the Connect:Direct samples directory.
File Open Exit Structures
The file open exit contains the following types of structures:
- FILE_OPEN: The FILE_OPEN structure contains the information that
implements the file open user exit. The FILE_OPEN structure contains
the following components:
- int oflag—Flags that Connect:Direct uses to open the file.
- int srcdstflag—Specifies whether the file is a source file (the file to read) or a destination file (the file to write to).
- char user_name[MAX_USER_NAME]—Specifies the name of the user that submitted the Process.
- COPY_T copy_ctl—Points to the Connect:Direct Copy Control Block data structure that contains information concerning the COPY operation about to be performed.
- COPY_SYSOPTS_T cp_sysopts—Points to the Sysopts data structure that contains a representation of all of the COPY operation sysopts that Connect:Direct supports. Refer to the Connect:Direct Process Language Reference Guide for more information about COPY sysopts.
- FILE_OPEN_REPLY: The FILE_OPEN_REPLY structure contains information
that specifies whether the file exit operation succeeded. The FILE_OPEN
structure contains the following components:
- HANDLE hFile—Contains a valid file handle if the file was opened successfully.
- char filename[MAX_FILE_NAME_LEN]—Contains the actual name of the file opened by the file open exit.
Access Sample Code
The following header file and sample code files for file open exit implementation are copied to X:\installation directory\Samples during Connect:Direct for Microsoft Windows installation.