Runtime options, Sample program, Runtime options sample program – HP Integrity NonStop H-Series User Manual

Page 116

Advertising
background image

limit

maximum number of bytes the buffer area can hold.

tag

parameter to be used for the Guardian nowait operation initiated by FTPsystem_nw.

The return value is -1 if the routine fails. The error number is set accordingly.

Runtime Options

The routine FTPoption sets the runtime options for the FTP client.

#include "ftpexth"
void FTPoption(char *ftp_option)

ftp_option

While opening a connection, if runtime options need to be specified, FTPoption() must be called
before calling FTPopen(), FTPconnect(), FTPproxy(), and all no waited APIs.

Sample Program

This is a sample program that uses FTPAPI. The file is named FTPACIX.C.

/* FILE: FTPAPIX.C - FTPAPI Example - the FTPServer Address name, userid, password are hardcoded.

CISC Compile -

C /IN FTPAPIXC, OUT $S.#FTPAPIX/ FTPAPIXO; WIDE, SYMBOLS, RUNNABLE INSPECT, SEARCH "$SYSTEM.ZTCPIP.APILIB",
SSV0 "$PERM.MMFTPAPI", SSV1 "$SYSTEM.ZTCPIP", SSV2 "$SYSTEM.SYSTEM"

RISC Compile -

NMC /IN FTPAPIXC, OUT $S.#FTPAPIX/FTPAPIN; SYMBOLS, RUNNABLE, SEARCH "$SYSTEM.ZTCPIP.NAPILIB", SSV0
"$PERM.MMFTPAPI", SSV1 "$SYSTEM.ZTCPIP", SSV2 "$SYSTEM.SYSTEM"

*/

#include "ftpexth"
#include <stdio.h>
#include <errno.h>

extern int errno;

int main()

{
short hd1, nowait =0;
short hd2;

char buffer[1024];
char *cp;
int fd;
long tag=0;

char *opt=”-d –s <subnet Address>”;
/* Added for introducing FTPoption */
FTPoption(opt);

/* log messages directed to the terminal */
if ((hd1 = FTPopen("host1",-1,"user","passwd","","")) < 0)
{
printf("errno returned: %d\n",errno);
goto err;
}
printf("does this get printed immediately\n");
/* wait until I/O is completed */
for(; FTPio(&hd1,nowait,&cp,&tag) ==0;);
printf("open another connection\n");
/* log file directed to apilog */
if ((hd2 = FTPopen("host2",1234,"user","passwd","", "apilog")) < 0)
{
printf("errno returned: %d\n",errno);
goto err;
}
if (FTPproxy(hd1,"host3",-1,"user2","passwd","") < 0)
{
printf("errno returned: %d\n",errno);
goto err;
}
if (FTPpwd(hd1,PRIMARY,&buffer[0],511) < 0)
printf("errno returned: %d\n",errno);
else
printf("Pwd: %s\n",buffer);

116

FTP API External Specification

Advertising
This manual is related to the following products: