Annotation of src/usr.bin/ftp/ftp.h, Revision 1.2
1.2 ! jasper 1: /* $OpenBSD$ */
! 2:
1.1 kmos 3: /*
4: * Copyright (c) 2015 Sunil Nimmagadda <sunil@openbsd.org>
5: *
6: * Permission to use, copy, modify, and distribute this software for any
7: * purpose with or without fee is hereby granted, provided that the above
8: * copyright notice and this permission notice appear in all copies.
9: *
10: * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11: * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12: * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13: * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14: * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15: * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16: * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17: */
18:
19: #include <sys/types.h>
20:
21: #include <signal.h>
22: #include <stdarg.h>
23: #include <stdio.h>
24:
25: #define S_HTTP 0
26: #define S_FTP 1
27: #define S_FILE 2
28: #define S_HTTPS 3
29:
30: #define TMPBUF_LEN 131072
31: #define IMSG_OPEN 1
32:
33: #define P_PRE 100
34: #define P_OK 200
35: #define P_INTER 300
36: #define N_TRANS 400
37: #define N_PERM 500
38:
39: #ifndef nitems
40: #define nitems(_a) (sizeof((_a)) / sizeof((_a)[0]))
41: #endif
42:
43: struct imsg;
44: struct imsgbuf;
45:
46: struct url {
47: int scheme;
48: int ipliteral;
49: char *host;
50: char *port;
51: char *path;
52: char *basic_auth;
53:
54: char *fname;
55: int chunked;
56: };
57:
58: /* cmd.c */
59: void cmd(const char *, const char *, const char *);
60:
61: /* main.c */
62: extern struct imsgbuf child_ibuf;
63: extern const char *useragent;
64: extern int activemode, family, io_debug, verbose, progressmeter;
65: extern volatile sig_atomic_t interrupted;
66: extern FILE *msgout;
67:
68: /* file.c */
69: struct url *file_request(struct imsgbuf *, struct url *, off_t *, off_t *);
70: void file_save(struct url *, FILE *, off_t *);
71:
72: /* ftp.c */
73: void ftp_connect(struct url *, struct url *, int);
74: struct url *ftp_get(struct url *, struct url *, off_t *, off_t *);
75: void ftp_quit(struct url *);
76: void ftp_save(struct url *, FILE *, off_t *);
77: int ftp_auth(FILE *, const char *, const char *);
78: int ftp_command(FILE *, const char *, ...)
79: __attribute__((__format__ (printf, 2, 3)))
80: __attribute__((__nonnull__ (2)));
81: int ftp_eprt(FILE *);
82: int ftp_epsv(FILE *);
83: int ftp_getline(char **, size_t *, int, FILE *);
84: int ftp_size(FILE *, const char *, off_t *, char **);
85:
86: /* http.c */
87: void http_connect(struct url *, struct url *, int);
88: struct url *http_get(struct url *, struct url *, off_t *, off_t *);
89: void http_close(struct url *);
90: void http_save(struct url *, FILE *, off_t *);
91: void https_init(char *);
92:
93: /* progressmeter.c */
94: void start_progress_meter(const char *, const char *, off_t, off_t *);
95: void stop_progress_meter(void);
96:
97: /* url.c */
98: int scheme_lookup(const char *);
99: void url_connect(struct url *, struct url *, int);
100: char *url_encode(const char *);
101: void url_free(struct url *);
102: struct url *url_parse(const char *);
103: struct url *url_request(struct url *, struct url *, off_t *, off_t *);
104: void url_save(struct url *, FILE *, off_t *);
105: void url_close(struct url *);
106: char *url_str(struct url *);
107: void log_request(const char *, struct url *, struct url *);
108:
109: /* util.c */
110: int connect_wait(int);
111: void copy_file(FILE *, FILE *, off_t *);
112: int tcp_connect(const char *, const char *, int);
113: int fd_request(char *, int, off_t *);
114: int read_message(struct imsgbuf *, struct imsg *);
115: void send_message(struct imsgbuf *, int, uint32_t, void *, size_t, int);
116: void log_info(const char *, ...)
117: __attribute__((__format__ (printf, 1, 2)))
118: __attribute__((__nonnull__ (1)));