]> git.wh0rd.org - chrome-ext/crftp.git/blame - pnacl/ftplib/ftplib.h
init
[chrome-ext/crftp.git] / pnacl / ftplib / ftplib.h
CommitLineData
769a03c3
MF
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
62extern "C" {
63#endif
64
65#if defined(__UINT64_MAX)
66typedef uint64_t fsz_t;
67#else
68typedef uint32_t fsz_t;
69#endif
70
71typedef struct NetBuf netbuf;
72typedef int (*FtpCallback)(netbuf *nControl, fsz_t xfered, void *arg);
73
74typedef 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
81typedef int (*FtpDataCallback)(char *, int);
82typedef int (*FtpResponseCallback)(netbuf *nControl, const char *resp);
83GLOBALREF int FtpSetResponseCallback(FtpResponseCallback, netbuf *);
84GLOBALDEF int FtpSetSendCmdCallback(FtpResponseCallback, netbuf *);
85
86GLOBALREF int ftplib_debug;
87GLOBALREF void FtpInit(void);
88GLOBALREF char *FtpLastResponse(netbuf *nControl);
89GLOBALREF int FtpConnect(const char *host, FtpResponseCallback respcb, netbuf **nControl);
90GLOBALREF int FtpOptions(int opt, long val, netbuf *nControl);
91GLOBALREF int FtpSetCallback(const FtpCallbackOptions *opt, netbuf *nControl);
92GLOBALREF int FtpClearCallback(netbuf *nControl);
93GLOBALREF int FtpLogin(const char *user, const char *pass, netbuf *nControl);
94GLOBALREF int FtpAccess(const char *path, int typ, int mode, netbuf *nControl,
95 netbuf **nData);
96GLOBALREF int FtpRead(void *buf, int max, netbuf *nData);
97GLOBALREF int FtpWrite(const void *buf, int len, netbuf *nData);
98GLOBALREF int FtpClose(netbuf *nData);
99GLOBALREF int FtpSite(const char *cmd, netbuf *nControl);
100GLOBALREF int FtpSysType(char *buf, int max, netbuf *nControl);
101GLOBALREF int FtpMkdir(const char *path, netbuf *nControl);
102GLOBALREF int FtpChdir(const char *path, netbuf *nControl);
103GLOBALREF int FtpCDUp(netbuf *nControl);
104GLOBALREF int FtpRmdir(const char *path, netbuf *nControl);
105GLOBALREF int FtpPwd(char *path, int max, netbuf *nControl);
106GLOBALREF int FtpNlst(FtpDataCallback cb, const char *path, netbuf *nControl);
107GLOBALREF int FtpDir(FtpDataCallback cb, const char *path, netbuf *nControl);
108GLOBALREF int FtpSize(const char *path, unsigned int *size, char mode, netbuf *nControl);
109#if defined(__UINT64_MAX)
110GLOBALREF int FtpSizeLong(const char *path, fsz_t *size, char mode, netbuf *nControl);
111#endif
112GLOBALREF int FtpModDate(const char *path, char *dt, int max, netbuf *nControl);
113GLOBALREF int FtpGet(FtpDataCallback cb, const char *path, char mode,
114 netbuf *nControl);
115GLOBALREF int FtpPut(FtpDataCallback cb, const char *path, char mode,
116 netbuf *nControl);
117GLOBALREF int FtpRename(const char *src, const char *dst, netbuf *nControl);
118GLOBALREF int FtpDelete(const char *fnm, netbuf *nControl);
119GLOBALREF int FtpQuit(netbuf *nControl);
120
121#ifdef __cplusplus
122};
123#endif
124
125#endif /* __FTPLIB_H */