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