/* * Copyright (c) 2015 Sunil Nimmagadda * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #ifndef FTP_H #define FTP_H #include #include #include #define S_HTTP 0 #define S_FTP 1 #define S_FILE 2 #define S_HTTPS 3 #define TMPBUF_LEN 131072 #define P_PRE 100 #define P_OK 200 #define P_INTER 300 #define N_TRANS 400 #define N_PERM 500 #ifndef nitems #define nitems(_a) (sizeof((_a)) / sizeof((_a)[0])) #endif /* nitems */ struct url { int scheme; int ip_literal; char *host; char *port; char *path; char *basic_auth; }; /* main.c */ extern volatile sig_atomic_t interrupted; extern struct url *ftp_proxy, *http_proxy; extern const char *useragent; extern char *oarg; extern int activemode, family, io_debug, verbose, progressmeter; int fd_request(char *, int, off_t *); /* cmd.c */ void cmd(const char *, const char *, const char *); /* file.c */ struct url *file_get(struct url *, off_t *, off_t *); void file_save(struct url *, FILE *, off_t *); /* ftp.c */ void ftp_connect(struct url *, int); struct url *ftp_get(struct url *, off_t *, off_t *); void ftp_close(struct url *); void ftp_save(struct url *, FILE *, off_t *); int ftp_auth(FILE *, const char *, const char *); int ftp_command(FILE *, const char *, ...) __attribute__((__format__ (printf, 2, 3))) __attribute__((__nonnull__ (2))); int ftp_eprt(FILE *); int ftp_epsv(FILE *); int ftp_getline(char **, size_t *, int, FILE *); int ftp_size(FILE *, const char *, off_t *, char **); /* http.c */ void http_connect(struct url *, int); struct url *http_get(struct url *, off_t *, off_t *); void http_close(struct url *); void http_save(struct url *, FILE *, off_t *); void https_init(char *); /* progressmeter.c */ void start_progress_meter(const char *, const char *, off_t, off_t *); void stop_progress_meter(void); /* url.c */ int url_scheme_lookup(const char *); void url_connect(struct url *, int); char *url_encode(const char *); void url_free(struct url *); struct url *xurl_parse(const char *); struct url *url_parse(const char *); struct url *url_request(struct url *, off_t *, off_t *); void url_save(struct url *, FILE *, off_t *); void url_close(struct url *); char *url_str(struct url *); const char *url_scheme_str(int); const char *url_port_str(int); /* util.c */ int connect_wait(int); void copy_file(FILE *, FILE *, off_t *); int tcp_connect(const char *, const char *, int); void log_request(const char *, struct url *, struct url *); void log_info(const char *, ...) __attribute__((__format__ (printf, 1, 2))) __attribute__((__nonnull__ (1))); #endif /* FTP_H */