| 1 |
/* Declarations for FTP support. |
| 2 |
Copyright (C) 1996-2011, 2015, 2018-2024 Free Software Foundation, |
| 3 |
Inc. |
| 4 |
|
| 5 |
This file is part of GNU Wget. |
| 6 |
|
| 7 |
GNU Wget is free software; you can redistribute it and/or modify |
| 8 |
it under the terms of the GNU General Public License as published by |
| 9 |
the Free Software Foundation; either version 3 of the License, or |
| 10 |
(at your option) any later version. |
| 11 |
|
| 12 |
GNU Wget is distributed in the hope that it will be useful, |
| 13 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 |
GNU General Public License for more details. |
| 16 |
|
| 17 |
You should have received a copy of the GNU General Public License |
| 18 |
along with Wget. If not, see <http://www.gnu.org/licenses/>. |
| 19 |
|
| 20 |
Additional permission under GNU GPL version 3 section 7 |
| 21 |
|
| 22 |
If you modify this program, or any covered work, by linking or |
| 23 |
combining it with the OpenSSL project's OpenSSL library (or a |
| 24 |
modified version of that library), containing parts covered by the |
| 25 |
terms of the OpenSSL or SSLeay licenses, the Free Software Foundation |
| 26 |
grants you additional permission to convey the resulting work. |
| 27 |
Corresponding Source for a non-source form of such a combination |
| 28 |
shall include the source code for the parts of OpenSSL used as well |
| 29 |
as that of the covered work. */ |
| 30 |
|
| 31 |
#ifndef FTP_H |
| 32 |
#define FTP_H |
| 33 |
|
| 34 |
#include <stdio.h> |
| 35 |
#include <stdbool.h> |
| 36 |
|
| 37 |
#include "host.h" |
| 38 |
#include "url.h" |
| 39 |
|
| 40 |
/* System types. */ |
| 41 |
enum stype |
| 42 |
{ |
| 43 |
ST_UNIX, |
| 44 |
ST_VMS, |
| 45 |
ST_WINNT, |
| 46 |
ST_MACOS, |
| 47 |
ST_OS400, |
| 48 |
ST_OTHER |
| 49 |
}; |
| 50 |
|
| 51 |
/* Extensions of the ST_UNIX */ |
| 52 |
enum ustype |
| 53 |
{ |
| 54 |
UST_TYPE_L8, |
| 55 |
UST_MULTINET, |
| 56 |
UST_OTHER |
| 57 |
}; |
| 58 |
|
| 59 |
#ifdef HAVE_SSL |
| 60 |
/* Data channel protection levels (to be used with PBSZ) */ |
| 61 |
enum prot_level |
| 62 |
{ |
| 63 |
PROT_CLEAR = 'C', |
| 64 |
PROT_SAFE = 'S', |
| 65 |
PROT_CONFIDENTIAL = 'E', |
| 66 |
PROT_PRIVATE = 'P' |
| 67 |
}; |
| 68 |
#endif |
| 69 |
|
| 70 |
uerr_t ftp_response (int, char **); |
| 71 |
uerr_t ftp_greeting (int); |
| 72 |
uerr_t ftp_login (int, const char *, const char *); |
| 73 |
uerr_t ftp_port (int, int *); |
| 74 |
uerr_t ftp_pasv (int, ip_address *, int *); |
| 75 |
#ifdef HAVE_SSL |
| 76 |
uerr_t ftp_auth (int, enum url_scheme); |
| 77 |
uerr_t ftp_pbsz (int, int); |
| 78 |
uerr_t ftp_prot (int, enum prot_level); |
| 79 |
#endif |
| 80 |
#ifdef ENABLE_IPV6 |
| 81 |
uerr_t ftp_lprt (int, int *); |
| 82 |
uerr_t ftp_lpsv (int, ip_address *, int *); |
| 83 |
uerr_t ftp_eprt (int, int *); |
| 84 |
uerr_t ftp_epsv (int, ip_address *, int *); |
| 85 |
#endif |
| 86 |
uerr_t ftp_type (int, int); |
| 87 |
uerr_t ftp_cwd (int, const char *); |
| 88 |
uerr_t ftp_retr (int, const char *); |
| 89 |
uerr_t ftp_rest (int, wgint); |
| 90 |
uerr_t ftp_list (int, const char *, bool, bool, bool *); |
| 91 |
uerr_t ftp_syst (int, enum stype *, enum ustype *); |
| 92 |
uerr_t ftp_pwd (int, char **); |
| 93 |
uerr_t ftp_size (int, const char *, wgint *); |
| 94 |
|
| 95 |
#ifdef ENABLE_OPIE |
| 96 |
const char *skey_response (int, const char *, const char *); |
| 97 |
#endif |
| 98 |
|
| 99 |
struct url; |
| 100 |
|
| 101 |
/* File types. */ |
| 102 |
enum ftype |
| 103 |
{ |
| 104 |
FT_PLAINFILE, |
| 105 |
FT_DIRECTORY, |
| 106 |
FT_SYMLINK, |
| 107 |
FT_UNKNOWN |
| 108 |
}; |
| 109 |
|
| 110 |
|
| 111 |
/* Globbing (used by ftp_retrieve_glob). */ |
| 112 |
enum |
| 113 |
{ |
| 114 |
GLOB_GLOBALL, GLOB_GETALL, GLOB_GETONE |
| 115 |
}; |
| 116 |
|
| 117 |
/* Used by to test if time parsed includes hours and minutes. */ |
| 118 |
enum parsetype |
| 119 |
{ |
| 120 |
TT_HOUR_MIN, TT_DAY |
| 121 |
}; |
| 122 |
|
| 123 |
|
| 124 |
/* Information about one filename in a linked list. */ |
| 125 |
struct fileinfo |
| 126 |
{ |
| 127 |
enum ftype type; /* file type */ |
| 128 |
char *name; /* file name */ |
| 129 |
wgint size; /* file size */ |
| 130 |
long tstamp; /* time-stamp */ |
| 131 |
enum parsetype ptype; /* time parsing */ |
| 132 |
int perms; /* file permissions */ |
| 133 |
char *linkto; /* link to which file points */ |
| 134 |
struct fileinfo *prev; /* previous... */ |
| 135 |
struct fileinfo *next; /* ...and next structure. */ |
| 136 |
}; |
| 137 |
|
| 138 |
/* Commands for FTP functions. */ |
| 139 |
enum wget_ftp_command |
| 140 |
{ |
| 141 |
DO_LOGIN = 0x0001, /* Connect and login to the server. */ |
| 142 |
DO_CWD = 0x0002, /* Change current directory. */ |
| 143 |
DO_RETR = 0x0004, /* Retrieve the file. */ |
| 144 |
DO_LIST = 0x0008, /* Retrieve the directory list. */ |
| 145 |
LEAVE_PENDING = 0x0010 /* Do not close the socket. */ |
| 146 |
}; |
| 147 |
|
| 148 |
enum wget_ftp_fstatus |
| 149 |
{ |
| 150 |
NOTHING = 0x0000, /* Nothing done yet. */ |
| 151 |
ON_YOUR_OWN = 0x0001, /* The ftp_loop_internal sets the |
| 152 |
defaults. */ |
| 153 |
DONE_CWD = 0x0002, /* The current working directory is |
| 154 |
correct. */ |
| 155 |
|
| 156 |
/* 2013-10-17 Andrea Urbani (matfanjol) |
| 157 |
For more information about the following entries, please, |
| 158 |
look at ftp.c, function getftp, text "__LIST_A_EXPLANATION__". */ |
| 159 |
AVOID_LIST_A = 0x0004, /* It tells us if during this |
| 160 |
session we have to avoid the use |
| 161 |
of "LIST -a".*/ |
| 162 |
AVOID_LIST = 0x0008, /* It tells us if during this |
| 163 |
session we have to avoid to use |
| 164 |
"LIST". */ |
| 165 |
LIST_AFTER_LIST_A_CHECK_DONE = 0x0010, |
| 166 |
/* It tells us if we have already |
| 167 |
checked "LIST" after the first |
| 168 |
"LIST -a" to handle the case of |
| 169 |
file/folders named "-a". */ |
| 170 |
DATA_CHANNEL_SECURITY = 0x0020 /* Establish a secure data channel */ |
| 171 |
}; |
| 172 |
|
| 173 |
struct fileinfo *ftp_parse_ls (const char *, const enum stype); |
| 174 |
struct fileinfo *ftp_parse_ls_fp (FILE *, const enum stype); |
| 175 |
void freefileinfo(struct fileinfo *); |
| 176 |
uerr_t ftp_loop (struct url *, struct url *, char **, int *, struct url *, |
| 177 |
bool, bool); |
| 178 |
|
| 179 |
uerr_t ftp_index (const char *, struct url *, struct fileinfo *); |
| 180 |
|
| 181 |
char ftp_process_type (const char *); |
| 182 |
|
| 183 |
|
| 184 |
#endif /* FTP_H */ |