Job Management Partner 1/File Transmission Server/FTP Description, Reference and Operator's Guide
You use the JP1/FTP API library when you use the file transmission function of JP1/FTP from a user program.
The JP1/FTP API library enables you to do the following:
- Register transmission requests from a single user program to multiple JP1/FTPs that are running on different hosts (or on the same host)
- Select the transmission type when you register transmission requests:
Synchronous type: Waits until a transmission is completed and the termination result is obtained.
Asynchronous type: Performs registration only and does not wait for the termination results (obtains the termination results later).
Prerequisites for using the functions
To use the functions provided by JP1/FTP, you need the following:
- JP1/FTP API library
- Compiler: Visual C++
The following languages are supported for user programs:
- C
- C++
The JP1/FTP API library requires the following compilers:
Table 7-1 Compilers required by the JP1/FTP API library
OS Compiler Header file Import library Windows Server 2003 Visual C++ 4.0 apihead.h FTSFTP40.lib Visual C++ 5.0 apihead.h FTSFTP50.lib Visual C++ 6.0 apihead.h FTSFTP.lib Visual Studio 2005 (SP1) apihead.h FTSFTP80.lib Visual Studio 2008 apihead.h FTSFTP90.lib Windows Server 2003 (IPF) Platform SDK February 2003 apihead.h FTSFTP.lib Visual Studio 2005 (SP1) apihead.h FTSFTP80.lib Visual Studio 2008 apihead.h FTSFTP90.lib Windows Server 2008 Visual Studio 2005 (SP1) apihead.h FTSFTP80.lib Visual Studio 2008 apihead.h FTSFTP90.lib Windows Server 2008 (IPF) Visual Studio 2005 (SP1) apihead.h FTSFTP80.lib Visual Studio 2008 apihead.h FTSFTP90.lib For the header file and import library, use the files provided by JP1/FTP that are appropriate for your OS. For the storage locations, see A. List of Files and Directories.
Setting services
Set the JP1/FTP client's service name as ftsc. For details, see 2.2.2 Setting the port numbers.
Setting hosts
Set the host name and IP address of the host on which the client's JP1/FTP program is running. Specify this host name in the first argument of fts_ftp_open() and the transmission information structure.
Add the following line to OS-installation-directory\system32\drivers\etc\HOSTS:
xxx.xxx.xxx.xxx yyyyyy
- Legend:
- xxx.xxx.xxx.xxx: IP address
- yyyyyy: Host name
Specifying the transmission information
To register a file transmission request, you set the registered transmission card name and the address of the transmission information structure in the arguments of fts_ftp_syn_request_ex() and fts_ftp_asyn_request_ex().
- Using the card name to register transmission requests:
You can register a transmission request by specifying a transmission card name registered using Registration And Execution Of Transmission Requests.
- Using the transmission information structure to specify transmission information:
You can register a transmission request by specifying the information needed for transmission.
- Transmission information structure
typedef struct _FTS_FTP_API_DATA_EX { char cardname[20+1]; char host[256+1]; unsigned int portnum; char username[50+1]; char password[50+1]; int type; int cmd; int mode; char quote[300+1]; char localname[260+1]; char remotename[260+1]; char end_program[260+1]; char abend_program[260+1]; char comment[80+1]; int fsize; char reserve[1240]; /*Reserved area*/ } FTS_FTP_API_DATA_EX;
- Description of the transmission information structure members
- cardname
- Specifies the card name.
- host
- Specifies the FTP host name: ftp>open aaaa
- portnum
- Specifies the FTP port number: ftp>open aaaa bbbb
- username
- Specifies the login name: ftp>user aaaa
- password
- Specifies the password.
- type
- Specifies the transmission mode.
- FTS_TYPE_A: Interprets data as being in ASCII code and then sends it (ftp>ascii).
- FTS_TYPE_I: Interprets the data as an image and then sends it (ftp>binary).
- cmd
- Specifies the type of transmission.
- By using OR to specify single/multiple-file transmission, you can specify a combination of single-file transmission and multiple-file transmission. Note that this specification is applicable to reception only.
- Transmission types:
- FTS_CMD_SEND (send): ftp>put aaaa bbbb
- FTS_CMD_RECV (receive): ftp>get cccc ddddd
- FTS_CMD_APPE (send with append): ftp>append eeee fffff
- Single/multiple-file transmission:
- FTS_MLT_AUTO: Switch automatically between single-file and multiple-file transmission. This is the default.
- FTS_MLT_MULTIPLE: Perform multiple-file transmission.
- FTS_MLT_SINGLE: Perform single-file transmission.
- FTS_MLT_AUTO switches transmission automatically as follows:
- When sending
- The function checks whether * or ? is used in the local file name. If * or ? is used, multiple-file transmission is used. If neither of them is used, single-file transmission is used.
- When receiving
- The function checks whether * or ? is used in the remote file name. If * or ? is used, multiple-file transmission is used. If neither of them is used, single-file transmission is used.
- Example
- Receiving a single file:
- cmd = FTS_CMD_RECV|FTS_MLT_SINGLE;
- mode
- Specifies compressed transmission.
- FTS_MODE_S: Does not perform compressed transmission.
- FTS_MODE_C: Performs compressed transmission.
- quote
- Specifies the FTP command to execute.
- This structure member is a character string consisting of commands, such as CWD and SITE, delimited by semicolons (;) (the character string must end with \0).
- localname
- Specifies the local file name.
- Examples
- ftp>put aaaa bbbb
- ftp>get cccc dddd
- remotename
- Specifies the remote file name.
- Examples
- ftp>put aaaa bbbb
- ftp>get cccc dddd
- end_program
- Specifies the full path name of the program to start when transmission ends normally.
- abend_program
- Specifies the full path name of the program to start when transmission ends abnormally.
- comment
- Specifies any character string.
- fsize
- Specifies whether to check the file size after transmission.
- FTS_FSIZE_TRUE: Checks the size.
- FTS_FSIZE_FALSE: Does not check the size.
- Note
- Make sure that a char-type variable value ends with \0.
Obtaining transmission-end information
You can obtain the termination information for transmission requests registered by fts_ftp_syn_request_ex() and fts_ftp_asyn_request_ex().
- When fts_ftp_syn_request_ex() is used to register requests:
Specify the address of the transmission-end information structure in the fourth argument of fts_ftp_syn_request_ex().
- When fts_ftp_asyn_request_ex() is used to register requests:
Specify the address of the transmission-end information structure in the second argument of fts_ftp_event_ex().
- Transmission-end information structure (applicable to non-IPF versions)
typedef struct _FTS_FTP_API_RETDATA_EX { /* Data when transmission was successful */ int trans_status; /* Transmission end status: success (TRANS_SUCCESS) */ /* Transmission end status: failure (TRANS_FAILURE) */ char cardname[20+1]; /* Card name */ unsigned long trno; /* Transmission number */ unsigned long trcno; /* Connection number */ /* Data when transmission was successful */ unsigned long trans_size; /* Transmitted data size */ /* Data when transmission (compressed) was successful */ unsigned long trans_size_comp; /* Transmitted data size after compression */ /* Data when transmission failed */ int ab_kind; /* System call error (FTS_ERR_SYSTEM) */ /* Logical error (FTS_ERR_LOGIC) */ /* Protocol error (FTS_ERR_PROTOCOL) */ char ab_place[8]; /* Location of error */ char ab_func[32]; /* Name of module resulting in error */ char ab_system[32]; /* System call name */ int ab_syskind; /* System call type */ /* Win32 API(FTS_SYSKIND_WIN32) */ /* C runtime(FTS_SYSKIND_CRUNTIME) */ /* WinSock API(FTS_SYSKIND_WINSOCK) */ unsigned long ab_errno; /* Error number */ char ab_promes[256]; /* Protocol message (error) */ /* Data when transmission of more than 4 gigabytes of */ /* data was successful */ DWORD trans_size_Low; /* Transmitted data size (value of the trailing 32 bits). */ LONG trans_size_High; /* Transmitted data size (value of the leading 32 bits). */ /* Data when transmission of more than 4 gigabytes */ /* of data (compressed) was successful */ DWORD trans_size_comp_Low; /* Transmitted data size after compression (value of the leading 32 bits). */ LONG trans_size_comp_High; /* Transmitted data size after compression (value of the trailing 32 bits). */ char reserve[1668]; /* Reserved area */ } FTS_FTP_API_RETDATA_EX;
- Transmission-end information structure (applicable to IPF)
typedef struct _FTS_FTP_API_RETDATA_EX { /* Data when transmission was successful */ int trans_status; /* Transmission end status: success (TRANS_SUCCESS) */ /* Transmission end status: failure (TRANS_FAILURE) */ char cardname[20+1]; /* Card name */ unsigned long trno; /* Transmission number */ unsigned long trcno; /* Connection number */ /* Data when transmission was successful */ __int64 trans_size; /* Transmitted data size */ /* Data when transmission (compressed) was successful */ __int64 trans_size_comp; /* Transmitted data size after compression */ /* Data when transmission failed */ int ab_kind; /* System call error (FTS_ERR_SYSTEM) */ /* Logical error (FTS_ERR_LOGIC) */ /* Protocol error (FTS_ERR_PROTOCOL) */ char ab_place[8]; /* Location of error */ char ab_func[32]; /* Name of module resulting in error */ char ab_system[32]; /* System call name */ int ab_syskind; /* System call type */ /* Win32 API(FTS_SYSKIND_WIN32) */ /* C runtime(FTS_SYSKIND_CRUNTIME) */ /* WinSock API(FTS_SYSKIND_WINSOCK) */ unsigned long ab_errno; /* Error number */ char ab_promes[256]; /* Protocol message (error) */ char reserve[1684]; /* Reserved area */ } FTS_FTP_API_RETDATA_EX;
- Description of transmission-end information structure members
- trans_status
- Returns one of the following values indicating the termination status of transmission:
- TRANS_SUCCESS: Normal termination
- TRANS_FAILURE: Abnormal termination
- cardname
- Returns the transmission card name.
- trno
- Returns the transmission number.
- trcno
- Returns the connection number.
- trans_size (Applicable to normal termination only)
- Transmitted data size
- trans_size_comp (Applicable to normal termination only)
- Transmitted data size after compression
- ab_kind (Applicable to abnormal termination only)
- Returns the error type:
- FTS_ERR_SYSTEM: System call error
- FTS_ERR_LOGIC: Logical error
- FTS_ERR_PROTOCOL: Protocol error
- ab_place (Applicable to abnormal termination only)
- Returns the location of the error.
- ab_func (Applicable to abnormal termination only)
- Returns the name of module resulting in the error.
- ab_system (Applicable to abnormal termination only)
- Returns the system call name.
- ab_syskind (Applicable to abnormal termination only)
- Returns the system call type:
- FTS_SYSKIND_WIN32: Win32 API
- FTS_SYSKIND_CRUNTIME: C runtime
- FTS_SYSKIND_WINSOCK: WinSock API
- ab_errno (Applicable to abnormal termination only)
- Returns the system call error number.
- ab_promes (Applicable to abnormal termination only)
- Returns the protocol message sent from the FTP server.
- trans_size_Low (Applicable to normal termination only)
- Returns the value of the trailing 32 bits of the transmitted data size.
- trans_size_High (Applicable to normal termination only)
- Returns the value of the leading 32 bits of the transmitted data size.
- trans_size_comp_Low (Applicable to normal termination only)
- Returns the value of the trailing 32 bits of the transmitted data size after compression.
- trans_size_comp_High (Applicable to normal termination only)
- Returns the value of the leading 32 bits of the transmitted data size after compression.
- Notes about coding
Before and after you use the JP1/FTP API library functions, make sure that you call the following functions:
- Before calling
WSAStartUp(): Winsock library
- After calling
WSACleanUp(): Winsock library
If you do not call these functions, the library functions will not run correctly. For details about how to use these functions, see the winsock documentation.
The two parameters trans_size_Low and trans_size_High are combined to form a single 64-bit value.
The two parameters trans_size_comp_Low and trans_size_comp_High are combined to form a single 64-bit value.
When you create programs using the library functions, you must link FTSFTP.LIB.
- The following actions are not permitted:
- Issuing multiple fts_ftp_open() functions concurrently by multiple threads in a single process
- Issuing multiple fts_ftp_syn_request_ex() or fts_ftp_asyn_request_ex() functions concurrently in a single fts_ftp_open() function (issuing fts_ftp_syn_request_ex() or fts_ftp_asyn_request_ex() functions concurrently by multiple threads)
- When you upgrade JP1/FTP, you must recompile the program with new libraries and headers.
- If a wildcard is specified, fts_ftp_event_ex() can obtain the following transmission-end information:
When the wildcard transmission terminates normally: Transmission-end information for the last file transmitted
When the wildcard transmission terminates abnormally: Transmission-end information for the first file resulting in an error
All Rights Reserved. Copyright (C) 2010, Hitachi, Ltd.