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