#define DIR_OUTBOUND 0
#define DIR_INBOUND 1

#define BUF_SIZE 512

struct fd_ll {
	int fd;
	void (*handle)(struct fd_ll *);
	char *buf;
	void *data;
	struct fd_ll *next;
};

struct ftpproxy_t {
	char *user;
	char *pass;
	char *host;
	struct in_addr host_ip;
	int port;
	int locfd;
	int remfd;
	char auth_ok;
	int loccontrolport;
	int remdataport;
};

int readln(int, char *);
void handle_incoming(struct fd_ll *fd);
struct fd_ll *make_listener();
struct fd_ll *open_socket(char *, int, void *);
int get_secure_port(struct ftpproxy_t *, char *, int, int, int);
int writeln(int fd, const char *, ...);
void split(unsigned char *, unsigned char *, int);
void handle_remote(struct fd_ll *);
