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 struct ftp_op {
18         int op;
19         char *arg;
20 };
21
22 struct ftp_dirent {
23         char *name;
24         int type;
25 };
26
27 struct ftp {
28         int ctl, data;  /* sockets */
29
30         int status;
31         char *user, *pass;
32
33         void (*cproc)(struct ftp *ftp, int code, const char *buf, void *cls);
34         void (*dproc)(struct ftp *ftp, const char *buf, int sz, void *cls);
35         void *cproc_cls, *dproc_cls;
36
37         char crecv[256];
38         int num_crecv;
39         char drecv[256];
40         int num_drecv;
41
42         char *curdir_rem, *curdir_loc;
43         struct ftp_dirent *dent;
44         int num_dent;
45
46         int modified;
47 };
48
49 struct ftp *ftp_alloc(void);
50 void ftp_free(struct ftp *ftp);
51
52 void ftp_auth(const char *user, const char *pass);
53
54 int ftp_connect(struct ftp *ftp, const char *host, int port);
55 void ftp_close(struct ftp *ftp);
56
57 int ftp_sockets(struct ftp *ftp, int *sockv, int maxsize);
58 int ftp_pending(struct ftp *ftp);
59
60 int ftp_handle(struct ftp *ftp, int s);
61
62 int ftp_update(struct ftp *ftp);
63 int ftp_pwd(struct ftp *ftp);
64 int ftp_chdir(struct ftp *ftp, const char *dirname);
65
66
67 #endif  /* FTP_H_ */