foo
[oftp] / src / ftp.h
1 #ifndef FTP_H_
2 #define FTP_H_
3
4 enum {FTP_DIR, FTP_FILE};       /* ftp_dirent type */
5
6 enum {
7         FTP_PWD,
8         FTP_CHDIR,
9         FTP_MKDIR,
10         FTP_RMDIR,
11         FTP_DEL,
12         FTP_LIST,
13         FTP_RETR,
14         FTP_STORE
15 };
16
17 enum {
18         FTP_DISC,
19         FTP_CONN_PASV,
20         FTP_CONN_ACT
21 };
22
23 enum {
24         FTP_MOD_REMDIR  = 0x100,
25         FTP_MOD_LOCDIR  = 0x200
26 };
27
28 struct ftp_op {
29         int op;
30         char *arg;
31
32         struct ftp_op *next;
33 };
34
35 struct ftp_dirent {
36         char *name;
37         int type;
38         long size;
39
40         struct ftp_dirent *next;
41 };
42
43 struct ftp {
44         int ctl, lis, data;     /* sockets */
45         int lis_port;
46
47         int status;
48         char *user, *pass;
49
50         struct ftp_op *qhead, *qtail;
51
52         int (*cproc)(struct ftp *ftp, int code, const char *buf, void *cls);
53         void (*dproc)(struct ftp *ftp, const char *buf, int sz, void *cls);
54         void *cproc_cls, *dproc_cls;
55
56         char crecv[256];
57         int num_crecv;
58         char drecv[256];
59
60         char *curdir_rem, *curdir_loc;
61         struct ftp_dirent *dent_rem, *dent_loc;
62
63         int last_resp;
64         int modified;
65 };
66
67 struct ftp *ftp_alloc(void);
68 void ftp_free(struct ftp *ftp);
69
70 void ftp_auth(const char *user, const char *pass);
71
72 int ftp_connect(struct ftp *ftp, const char *host, int port);
73 void ftp_close(struct ftp *ftp);
74
75 int ftp_sockets(struct ftp *ftp, int *sockv, int maxsize);
76
77 int ftp_handle(struct ftp *ftp, int s);
78
79 int ftp_queue(struct ftp *ftp, int op, const char *arg);
80 int ftp_waitresp(struct ftp *ftp, time_t timeout);
81
82 int ftp_update(struct ftp *ftp);
83 int ftp_pwd(struct ftp *ftp);
84 int ftp_chdir(struct ftp *ftp, const char *dirname);
85 int ftp_mkdir(struct ftp *ftp, const char *dirname);
86 int ftp_rmdir(struct ftp *ftp, const char *dirname);
87 int ftp_delete(struct ftp *ftp, const char *fname);
88 int ftp_list(struct ftp *ftp);
89 int ftp_retrieve(struct ftp *ftp, const char *fname);
90 int ftp_store(struct ftp *ftp, const char *fname);
91
92
93 #endif  /* FTP_H_ */