############################################################# ftp32(.dll) API Reference ############################################################# Here is Common Archiver Project Compatible API's. other low level api(these may more easy to understand) is in "ftp32.h". general information: URL: ftp://[[:]@][:] ================================================================== FUNCTIONS ================================================================== --------------------------------------------------------------------- int WINAPI _export Ftp(const HWND hWnd,LPCSTR szCmdLine,LPSTR szOutput,const DWORD wSize); Execute ftp command specified by szCmdLine. Command output to szOutpub(length=wSize) buffer. hWnd is Parent Window Handle.(WIN32) please see ftp32cmd.txt. ex) char outbuf[1000]; Ftp(NULL,"-l ftp://ftp.iij.ad.jp/",outbuf,1000); RETURN CODE: 0 SUCCESS other FAILED(Error code defined in ftp32api.h) ------------------------------------------------------------------ WORD WINAPI _export FtpGetVersion(VOID); Get Version. RETURN CODE: 1 Ver0.01 100 Ver1.00 ------------------------------------------------------------------ BOOL WINAPI _export FtpCheckArchive(LPCSTR szFileName,const int iMode); check szFileName is match to URL syntax. iMode is ignored. ------------------------------------------------------------------ BOOL WINAPI _export FtpConfigDialog(const HWND hwnd,LPSTR szOption,const int iMode); Display FTP32 Configuration Dialog.(WIN32) iMode is ignored. ------------------------------------------------------------------ BOOL WINAPI _export FtpQueryFunctionList(const int iFunction); Return whether iFunction is supported or not. ex) ret = FtpQuetyFunctionList(ISARC_GET_VERSION); ------------------------------------------------------------------ HARC WINAPI _export FtpOpenArchive(const HWND hWnd,LPCSTR url,const DWORD dwMode); Open specified URL directory. ARGUMENTS hWnd Parent Window Handle(WIN32 only) url URL(directory) dwMode mode M_INIT_FILE_USE use registory settings.(DEFAULT) M_REGARDLESS_INIT_FILE not use registory settings. RETURN CODE: !=0 SUCCESS =0 FAILED ex) /* Get files' informations of directory */ /* INDIVIDUALINFO info; HARC harc; int ret; harc = FtpOpenArchive(hwnd,"ftp://ftp.iij.ad.jp/pub/",0); if(harc==NULL) ERROR; ret = FtpFindFirst(harc,"",&info); while(ret!=-1){ PRINT_OUT(&info); // or FtpGetFileName etc... ret = FtpFindNext(harc,&info); } FtpCloseArchive(harc); */ ------------------------------------------------------- int WINAPI _export FtpCloseArchive(HARC harc); close... ------------------------------------------------------- int WINAPI _export FtpFindFirst(HARC harc,LPCSTR szWildName,LPINDIVIDUALINFO lpSubInfo); int WINAPI _export FtpFindNext(HARC harc,LPINDIVIDUALINFO lpSubInfo); Get Directory & File Information. Please see OpenArchive() example. -------------------------------------------------------- /* rwmode: combination of "r"(get),"w"(put),"b"(binary),"t"(text) */ int WINAPI _export FtpOpenFile(HARC harc,LPCSTR szFileName,LPCSTR rwmode,DWORD dwMode); int WINAPI _export FtpRead(HARC harc,char *buff,int len); int WINAPI _export FtpWrite(HARC harc,const char *buff,int len); int WINAPI _export FtpCloseFile(HARC harc); Read/Write File Contents. ex) /* HARC harc; int ret; int n; harc = FtpOpenArchive(hwnd,"ftp://ftp.iij.ad.jp/pub/RFC/",0); if(harc==NULL) ERROR; ret = FtpOpenFile(harc,"rfc959.txt","r",0); if(ret==-1){ FtpCloseArchive(harc);ERROR;} while((n=FtpRead(harc,buff,1000))>0){ write(1,buff,n); } FtpCloseFile(harc); FtpCloseArchive(harc); */ --------------------------------------------------------------- int WINAPI _export FtpExtract(HARC harc,LPCSTR remotefn,LPCSTR localfn,DWORD dwMode); int WINAPI _export FtpAdd(HARC harc,LPCSTR remotefn,LPCSTR localfn,DWORD dwMode); int WINAPI _export FtpMove(HARC harc,LPCSTR from,LPCSTR to,DWORD dwMode); int WINAPI _export FtpDelete(HARC harc,LPCSTR szFileName,DWORD dwMode); int WINAPI _export FtpMkDir(HARC harc,LPCSTR szFileName,DWORD dwMode); int WINAPI _export FtpRmDir(HARC harc,LPCSTR szFileName,DWORD dwMode); extract,add,move,delete,mkdir,rmdir.... please use these API's after FtpOpenArchive() Call. --------------------------------------------------------------- int WINAPI _export FtpRestart(HARC harc,int pos); Restart(Resume) from Specified Offset(pos) at next ftpopenfile()/ftpget()/ftpput().Ignored if FtpSetResumeGetMode(,1) is called. --------------------------------------------------------------- int WINAPI _export FtpSetResumeGetMode(HARC harc,int onoff) Automatically Resume at next ftpget() API. If you set ResumeGetMode to ON(1), you neednot and cannnot set FtpRestart() API. --------------------------------------------------------------- int WINAPI _export FtpGetArcFileName(HARC harc,LPSTR lpBuffer,const int nSize); DWORD WINAPI _export FtpGetArcFileSize(HARC harc); DWORD WINAPI _export FtpGetArcOriginalSize(HARC harc); DWORD WINAPI _export FtpGetArcCompressedSize(HARC harc); WORD WINAPI _export FtpGetArcRatio(HARC harc); WORD WINAPI _export FtpGetArcDate(HARC harc); WORD WINAPI _export FtpGetArcTime(HARC harc); UINT WINAPI _export FtpGetArcOSType(HARC harc); Get URL Directory Informations. ---------------------------------------------------------------- /* file information of current FindFirst/FindNext*/ int WINAPI _export FtpGetFileName(HARC harc,LPSTR lpBuffer,const int nSize); int WINAPI _export FtpGetMethod(HARC harc,LPSTR lpBuffer,const int nSize);/* "-ftp- */ DWORD WINAPI _export FtpGetOriginalSize(HARC harc); DWORD WINAPI _export FtpGetCompressedSize(HARC harc); /* = OriginalSize */ WORD WINAPI _export FtpGetRatio(HARC harc); /* always 1000 (100%) */ WORD WINAPI _export FtpGetDate(HARC harc); WORD WINAPI _export FtpGetTime(HARC harc); DWORD WINAPI _export FtpGetWriteTime(HARC harc); DWORD WINAPI _export FtpGetAccessTime(HARC harc); DWORD WINAPI _export FtpGetCreateTime(HARC harc); DWORD WINAPI _export FtpGetCRC(HARC harc); int WINAPI _export FtpGetAttribute(HARC harc); /*AND of attributes(FA_RDONLY,FA_HIDDEN,FA_SYSTEM,FA_LABEL,FA_DIREC,FA_ARCH) */ UINT WINAPI _export FtpGetOSType(HARC harc); /* added by ftp32 */ int WINAPI _export FtpGetLinkName(HARC harc,LPSTR lpbuffer,const int nSize); int WINAPI _export FtpGetUserName(HARC harc,LPSTR lpbuffer,const int nSize); int WINAPI _export FtpGetGroupName(HARC harc,LPSTR lpbuffer,const int nSize); DWORD WINAPI _export FtpGetFileMode(HARC harc); Get File information. please call these API after each FtpFindFirst()/FtpFindNext() API. for more detail,please see INDIVIDUALINFO structure information. ----------------------------------------------------------------------- BOOL WINAPI _export FtpSetDataConnectionMode(HARC harc,const int mode); Set Data Connection Mode mode 0: active 1:passive 2:auto select(passive->active) / DEFAULT please call this API after FtpOpenArchive() API ================================================================== STRUCTURE ================================================================== INDIVIDUALINFO typedef struct { DWORD dwOriginalSize; /* file size */ DWORD dwCompressedSize; /* file size compressed(ignored)*/ DWORD dwCRC; /* checksum/CRC (ignored)*/ UINT uFlag; /* process result */ UINT uOSType; /* OS */ /* 0: MS-DOS 2: UNIX 5: OS/2 10: Other */ WORD wRatio; /* compress ratio(permili) */ WORD wDate; /* date */ /* ------------------------------------------------------------------ | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 || 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | ------------------------------------------------------------------ | year from 1980 | Month | Day of Month | ------------------------------------------------------------------ */ WORD wTime; /* time */ /* ------------------------------------------------------------------ | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 || 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | ------------------------------------------------------------------ | hour | minutes | Second / 2 | ------------------------------------------------------------------ */ char szFileName[FNAME_MAX32 + 1];/* file name */ char dummy1[3]; char szAttribute[8]; /* attribute */ /* szAttribute[0]= (attr & FA_ARCH) ? 'A' : '-'; /* Archive */ szAttribute[1]= (attr & FA_SYSTEM) ? 'S' : '-'; /* System */ szAttribute[2]= (attr & FA_HIDDEN) ? 'H' : '-'; /* Hide */ szAttribute[3]= (attr & FA_RDONLY) ? 'R' : '-'; /* Read Only*/ szAttribute[4]='\0'; */ char szMode[8]; /* mode */ } INDIVIDUALINFO; ----------------------------------------------------------------- ================================================================== REGISTRY ================================================================== By using FtpConfigDialog(), you can set registry. HKEY_CURRENT_USER\Software\ArchiverDLL\FTP32 EMailAddress: REG_SZ E-MailAddress. Password for user "anonymous". (DEFAULT:"") FtpCtrlPort: DWORD Ftp Control Session Port Number. (DEFAULT:21) PassiveMode: DWORD Select Data Session Mode 0: Active FTP 1: Passive FTP 2: Auto Select (DEFAULT: 2) DefaultDir: REG_SZ Set Default Download Folder. ProxyType: DWORD Proxy Server Type 0: NONE 1: USER user@hostname 2: OPEN hostname 3: open hostname (DEFAULT: 0) ProxyHost: REG_SZ Proxy Server Hostname ProxyPort: DWORD Proxy Server Portnumber (DEFAULT 21) ResumeGetMode: DWORD Auto Resume mode. 1: ON 0: OFF