]> sjero.net Git - wget/blob - src/ftp.h
[svn] Merge of fix for bugs 20341 and 20410.
[wget] / src / ftp.h
1 /* Declarations for FTP support.
2    Copyright (C) 1996-2006 Free Software Foundation, Inc.
3
4 This file is part of GNU Wget.
5
6 GNU Wget is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or
9 (at your option) any later version.
10
11 GNU Wget is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with Wget.  If not, see <http://www.gnu.org/licenses/>.
18
19 In addition, as a special exception, the Free Software Foundation
20 gives permission to link the code of its release of Wget with the
21 OpenSSL project's "OpenSSL" library (or with modified versions of it
22 that use the same license as the "OpenSSL" library), and distribute
23 the linked executables.  You must obey the GNU General Public License
24 in all respects for all of the code used other than "OpenSSL".  If you
25 modify this file, you may extend this exception to your version of the
26 file, but you are not obligated to do so.  If you do not wish to do
27 so, delete this exception statement from your version.  */
28
29 #ifndef FTP_H
30 #define FTP_H
31
32 #include "host.h"
33
34 /* System types. */
35 enum stype
36 {
37   ST_UNIX,
38   ST_VMS,
39   ST_WINNT,
40   ST_MACOS,
41   ST_OS400,
42   ST_OTHER
43 };
44
45 extern char ftp_last_respline[];
46
47 uerr_t ftp_response (int, char **);
48 uerr_t ftp_login (int, const char *, const char *);
49 uerr_t ftp_port (int, int *);
50 uerr_t ftp_pasv (int, ip_address *, int *);
51 #ifdef ENABLE_IPV6
52 uerr_t ftp_lprt (int, int *);
53 uerr_t ftp_lpsv (int, ip_address *, int *);
54 uerr_t ftp_eprt (int, int *);
55 uerr_t ftp_epsv (int, ip_address *, int *);
56 #endif
57 uerr_t ftp_type (int, int);
58 uerr_t ftp_cwd (int, const char *);
59 uerr_t ftp_retr (int, const char *);
60 uerr_t ftp_rest (int, wgint);
61 uerr_t ftp_list (int, const char *);
62 uerr_t ftp_syst (int, enum stype *);
63 uerr_t ftp_pwd (int, char **);
64 uerr_t ftp_size (int, const char *, wgint *);
65
66 #ifdef ENABLE_OPIE
67 const char *skey_response (int, const char *, const char *);
68 #endif
69
70 struct url;
71
72 /* File types.  */
73 enum ftype
74 {
75   FT_PLAINFILE,
76   FT_DIRECTORY,
77   FT_SYMLINK,
78   FT_UNKNOWN
79 };
80
81
82 /* Globbing (used by ftp_retrieve_glob).  */
83 enum
84 {
85   GLOB_GLOBALL, GLOB_GETALL, GLOB_GETONE
86 };
87
88 /* Information about one filename in a linked list.  */
89 struct fileinfo
90 {
91   enum ftype type;              /* file type */
92   char *name;                   /* file name */
93   wgint size;                   /* file size */
94   long tstamp;                  /* time-stamp */
95   int perms;                    /* file permissions */
96   char *linkto;                 /* link to which file points */
97   struct fileinfo *prev;        /* previous... */
98   struct fileinfo *next;        /* ...and next structure. */
99 };
100
101 /* Commands for FTP functions.  */
102 enum wget_ftp_command
103 {
104   DO_LOGIN      = 0x0001,       /* Connect and login to the server.  */
105   DO_CWD        = 0x0002,       /* Change current directory.  */
106   DO_RETR       = 0x0004,       /* Retrieve the file.  */
107   DO_LIST       = 0x0008,       /* Retrieve the directory list.  */
108   LEAVE_PENDING = 0x0010        /* Do not close the socket.  */
109 };
110
111 enum wget_ftp_fstatus
112 {
113   NOTHING       = 0x0000,       /* Nothing done yet.  */
114   ON_YOUR_OWN   = 0x0001,       /* The ftp_loop_internal sets the
115                                    defaults.  */
116   DONE_CWD      = 0x0002        /* The current working directory is
117                                    correct.  */
118 };
119
120 struct fileinfo *ftp_parse_ls (const char *, const enum stype);
121 uerr_t ftp_loop (struct url *, int *, struct url *, bool, bool);
122
123 uerr_t ftp_index (const char *, struct url *, struct fileinfo *);
124
125 char ftp_process_type (const char *);
126
127
128 #endif /* FTP_H */