]> git.wh0rd.org - chrome-ext/crftp.git/blob - pnacl/ftplib/ftplib.h
init
[chrome-ext/crftp.git] / pnacl / ftplib / ftplib.h
1 /***************************************************************************/
2 /* */
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 */
6 /* */
7 /* This library is free software. You can redistribute it and/or */
8 /* modify it under the terms of the Artistic License 2.0. */
9 /* */
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. */
14 /* */
15 /* See the file LICENSE or */
16 /* http://www.perlfoundation.org/artistic_license_2_0 */
17 /* */
18 /***************************************************************************/
19
20 #if !defined(__FTPLIB_H)
21 #define __FTPLIB_H
22
23 #if defined(__unix__) || defined(VMS)
24 #define GLOBALDEF
25 #define GLOBALREF extern
26 #elif defined(_WIN32)
27 #if defined BUILDING_LIBRARY
28 #define GLOBALDEF __declspec(dllexport)
29 #define GLOBALREF __declspec(dllexport)
30 #else
31 #define GLOBALREF __declspec(dllimport)
32 #endif
33 #endif
34
35 #include <limits.h>
36 #include <inttypes.h>
37
38 /* FtpAccess() type codes */
39 #define FTPLIB_DIR 1
40 #define FTPLIB_DIR_VERBOSE 2
41 #define FTPLIB_FILE_READ 3
42 #define FTPLIB_FILE_WRITE 4
43
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
49
50 /* connection modes */
51 #define FTPLIB_PASSIVE 1
52 #define FTPLIB_PORT 2
53
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
60
61 #ifdef __cplusplus
62 extern "C" {
63 #endif
64
65 #if defined(__UINT64_MAX)
66 typedef uint64_t fsz_t;
67 #else
68 typedef uint32_t fsz_t;
69 #endif
70
71 typedef struct NetBuf netbuf;
72 typedef int (*FtpCallback)(netbuf *nControl, fsz_t xfered, void *arg);
73
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 */
79 } FtpCallbackOptions;
80
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 *);
85
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,
95 netbuf **nData);
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);
111 #endif
112 GLOBALREF int FtpModDate(const char *path, char *dt, int max, netbuf *nControl);
113 GLOBALREF int FtpGet(FtpDataCallback cb, const char *path, char mode,
114 netbuf *nControl);
115 GLOBALREF int FtpPut(FtpDataCallback cb, const char *path, char mode,
116 netbuf *nControl);
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);
120
121 #ifdef __cplusplus
122 };
123 #endif
124
125 #endif /* __FTPLIB_H */