1 /***************************************************************************/
3 /* ftplib.h - header file for callable ftp access routines */
4 /* Copyright (C) 1996-2001, 2013 Thomas Pfau, tfpfau@gmail.com */
5 /* 1407 Thomas Ave, North Brunswick, NJ, 08902 */
7 /* This library is free software. You can redistribute it and/or */
8 /* modify it under the terms of the Artistic License 2.0. */
10 /* This library is distributed in the hope that it will be useful, */
11 /* but WITHOUT ANY WARRANTY; without even the implied warranty of */
12 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
13 /* Artistic License 2.0 for more details. */
15 /* See the file LICENSE or */
16 /* http://www.perlfoundation.org/artistic_license_2_0 */
18 /***************************************************************************/
20 #if !defined(__FTPLIB_H)
23 #if defined(__unix__) || defined(VMS)
25 #define GLOBALREF extern
27 #if defined BUILDING_LIBRARY
28 #define GLOBALDEF __declspec(dllexport)
29 #define GLOBALREF __declspec(dllexport)
31 #define GLOBALREF __declspec(dllimport)
38 /* FtpAccess() type codes */
40 #define FTPLIB_DIR_VERBOSE 2
41 #define FTPLIB_FILE_READ 3
42 #define FTPLIB_FILE_WRITE 4
44 /* FtpAccess() mode codes */
45 #define FTPLIB_ASCII 'A'
46 #define FTPLIB_IMAGE 'I'
47 #define FTPLIB_TEXT FTPLIB_ASCII
48 #define FTPLIB_BINARY FTPLIB_IMAGE
50 /* connection modes */
51 #define FTPLIB_PASSIVE 1
54 /* connection option names */
55 #define FTPLIB_CONNMODE 1
56 #define FTPLIB_CALLBACK 2
57 #define FTPLIB_IDLETIME 3
58 #define FTPLIB_CALLBACKARG 4
59 #define FTPLIB_CALLBACKBYTES 5
65 #if defined(__UINT64_MAX)
66 typedef uint64_t fsz_t
;
68 typedef uint32_t fsz_t
;
71 typedef struct NetBuf netbuf
;
72 typedef int (*FtpCallback
)(netbuf
*nControl
, fsz_t xfered
, void *arg
);
74 typedef struct FtpCallbackOptions
{
75 FtpCallback cbFunc
; /* function to call */
76 void *cbArg
; /* argument to pass to function */
77 unsigned int bytesXferred
; /* callback if this number of bytes transferred */
78 unsigned int idleTime
; /* callback if this many milliseconds have elapsed */
81 typedef int (*FtpDataCallback
)(char *, int);
82 typedef int (*FtpResponseCallback
)(netbuf
*nControl
, const char *resp
);
83 GLOBALREF
int FtpSetResponseCallback(FtpResponseCallback
, netbuf
*);
84 GLOBALDEF
int FtpSetSendCmdCallback(FtpResponseCallback
, netbuf
*);
86 GLOBALREF
int ftplib_debug
;
87 GLOBALREF
void FtpInit(void);
88 GLOBALREF
char *FtpLastResponse(netbuf
*nControl
);
89 GLOBALREF
int FtpConnect(const char *host
, FtpResponseCallback respcb
, netbuf
**nControl
);
90 GLOBALREF
int FtpOptions(int opt
, long val
, netbuf
*nControl
);
91 GLOBALREF
int FtpSetCallback(const FtpCallbackOptions
*opt
, netbuf
*nControl
);
92 GLOBALREF
int FtpClearCallback(netbuf
*nControl
);
93 GLOBALREF
int FtpLogin(const char *user
, const char *pass
, netbuf
*nControl
);
94 GLOBALREF
int FtpAccess(const char *path
, int typ
, int mode
, netbuf
*nControl
,
96 GLOBALREF
int FtpRead(void *buf
, int max
, netbuf
*nData
);
97 GLOBALREF
int FtpWrite(const void *buf
, int len
, netbuf
*nData
);
98 GLOBALREF
int FtpClose(netbuf
*nData
);
99 GLOBALREF
int FtpSite(const char *cmd
, netbuf
*nControl
);
100 GLOBALREF
int FtpSysType(char *buf
, int max
, netbuf
*nControl
);
101 GLOBALREF
int FtpMkdir(const char *path
, netbuf
*nControl
);
102 GLOBALREF
int FtpChdir(const char *path
, netbuf
*nControl
);
103 GLOBALREF
int FtpCDUp(netbuf
*nControl
);
104 GLOBALREF
int FtpRmdir(const char *path
, netbuf
*nControl
);
105 GLOBALREF
int FtpPwd(char *path
, int max
, netbuf
*nControl
);
106 GLOBALREF
int FtpNlst(FtpDataCallback cb
, const char *path
, netbuf
*nControl
);
107 GLOBALREF
int FtpDir(FtpDataCallback cb
, const char *path
, netbuf
*nControl
);
108 GLOBALREF
int FtpSize(const char *path
, unsigned int *size
, char mode
, netbuf
*nControl
);
109 #if defined(__UINT64_MAX)
110 GLOBALREF
int FtpSizeLong(const char *path
, fsz_t
*size
, char mode
, netbuf
*nControl
);
112 GLOBALREF
int FtpModDate(const char *path
, char *dt
, int max
, netbuf
*nControl
);
113 GLOBALREF
int FtpGet(FtpDataCallback cb
, const char *path
, char mode
,
115 GLOBALREF
int FtpPut(FtpDataCallback cb
, const char *path
, char mode
,
117 GLOBALREF
int FtpRename(const char *src
, const char *dst
, netbuf
*nControl
);
118 GLOBALREF
int FtpDelete(const char *fnm
, netbuf
*nControl
);
119 GLOBALREF
int FtpQuit(netbuf
*nControl
);
125 #endif /* __FTPLIB_H */