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 struct ftp_op {
24         int op;
25         char *arg;
26
27         struct ftp_op *next;
28 };
29
30 struct ftp_dirent {
31         char *name;
32         int type;
33 };
34
35 struct ftp {
36         int ctl, lis, data;     /* sockets */
37         int lis_port;
38
39         int status;
40         char *user, *pass;
41
42         struct ftp_op *qhead, *qtail;
43
44         int (*cproc)(struct ftp *ftp, int code, const char *buf, void *cls);
45         void (*dproc)(struct ftp *ftp, const char *buf, int sz, void *cls);
46         void *cproc_cls, *dproc_cls;
47
48         char crecv[256];
49         int num_crecv;
50         char drecv[256];
51
52         char *curdir_rem, *curdir_loc;
53         struct ftp_dirent *dent_rem, *dent_loc;
54
55         int last_resp;
56         int modified;
57 };
58
59 struct ftp *ftp_alloc(void);
60 void ftp_free(struct ftp *ftp);
61
62 void ftp_auth(const char *user, const char *pass);
63
64 int ftp_connect(struct ftp *ftp, const char *host, int port);
65 void ftp_close(struct ftp *ftp);
66
67 int ftp_sockets(struct ftp *ftp, int *sockv, int maxsize);
68
69 int ftp_handle(struct ftp *ftp, int s);
70
71 int ftp_queue(struct ftp *ftp, int op, const char *arg);
72 int ftp_waitresp(struct ftp *ftp, time_t timeout);
73
74 int ftp_update(struct ftp *ftp);
75 int ftp_pwd(struct ftp *ftp);
76 int ftp_chdir(struct ftp *ftp, const char *dirname);
77 int ftp_mkdir(struct ftp *ftp, const char *dirname);
78 int ftp_rmdir(struct ftp *ftp, const char *dirname);
79 int ftp_delete(struct ftp *ftp, const char *fname);
80 int ftp_list(struct ftp *ftp);
81 int ftp_retrieve(struct ftp *ftp, const char *fname);
82 int ftp_store(struct ftp *ftp, const char *fname);
83
84
85 #endif  /* FTP_H_ */