]> sjero.net Git - wget/blob - src/ftp.h
[svn] Networking improvements: get rid of the MSOCK global variable,
[wget] / src / ftp.h
1 /* Declarations for FTP support.
2    Copyright (C) 1995, 1996, 1997, 2000 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 2 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, write to the Free Software
18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19
20 In addition, as a special exception, the Free Software Foundation
21 gives permission to link the code of its release of Wget with the
22 OpenSSL project's "OpenSSL" library (or with modified versions of it
23 that use the same license as the "OpenSSL" library), and distribute
24 the linked executables.  You must obey the GNU General Public License
25 in all respects for all of the code used other than "OpenSSL".  If you
26 modify this file, you may extend this exception to your version of the
27 file, but you are not obligated to do so.  If you do not wish to do
28 so, delete this exception statement from your version.  */
29
30 #ifndef FTP_H
31 #define FTP_H
32
33 /* Need it for struct rbuf.  */
34 #include "rbuf.h"
35
36 #include "host.h"
37
38 /* System types. */
39 enum stype
40 {
41   ST_UNIX,
42   ST_VMS,
43   ST_WINNT,
44   ST_MACOS,
45   ST_OS400,
46   ST_OTHER
47 };
48   
49 uerr_t ftp_response PARAMS ((struct rbuf *, char **));
50 uerr_t ftp_login PARAMS ((struct rbuf *, const char *, const char *));
51 uerr_t ftp_port PARAMS ((struct rbuf *, int *));
52 uerr_t ftp_pasv PARAMS ((struct rbuf *, ip_address *, int *));
53 #ifdef ENABLE_IPV6
54 uerr_t ftp_lprt PARAMS ((struct rbuf *, int *));
55 uerr_t ftp_lpsv PARAMS ((struct rbuf *, ip_address *, int *));
56 uerr_t ftp_eprt PARAMS ((struct rbuf *, int *));
57 uerr_t ftp_epsv PARAMS ((struct rbuf *, ip_address *, int *));
58 #endif
59 uerr_t ftp_type PARAMS ((struct rbuf *, int));
60 uerr_t ftp_cwd PARAMS ((struct rbuf *, const char *));
61 uerr_t ftp_retr PARAMS ((struct rbuf *, const char *));
62 uerr_t ftp_rest PARAMS ((struct rbuf *, long));
63 uerr_t ftp_list PARAMS ((struct rbuf *, const char *));
64 uerr_t ftp_syst PARAMS ((struct rbuf *, enum stype *));
65 uerr_t ftp_pwd PARAMS ((struct rbuf *, char **));
66 uerr_t ftp_size PARAMS ((struct rbuf *, const char *, long int *));
67
68 struct url;
69
70 /* File types.  */
71 enum ftype
72 {
73   FT_PLAINFILE,
74   FT_DIRECTORY,
75   FT_SYMLINK,
76   FT_UNKNOWN
77 };
78
79
80 /* Globbing (used by ftp_retrieve_glob).  */
81 enum
82 {
83   GLOBALL, GETALL, GETONE
84 };
85
86 /* Information about one filename in a linked list.  */
87 struct fileinfo
88 {
89   enum ftype type;              /* file type */
90   char *name;                   /* file name */
91   long size;                    /* file size */
92   long tstamp;                  /* time-stamp */
93   int perms;                    /* file permissions */
94   char *linkto;                 /* link to which file points */
95   struct fileinfo *prev;        /* previous... */
96   struct fileinfo *next;        /* ...and next structure. */
97 };
98
99 /* Commands for FTP functions.  */
100 enum wget_ftp_command
101 {
102   DO_LOGIN      = 0x0001,       /* Connect and login to the server.  */
103   DO_CWD        = 0x0002,       /* Change current directory.  */
104   DO_RETR       = 0x0004,       /* Retrieve the file.  */
105   DO_LIST       = 0x0008,       /* Retrieve the directory list.  */
106   LEAVE_PENDING = 0x0010,       /* Do not close the socket.  */
107   NO_TRUNCATE   = 0x0020        /* Don't truncate the file if REST
108                                    malfunctions. */
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 PARAMS ((const char *, const enum stype));
121 uerr_t ftp_loop PARAMS ((struct url *, int *, struct url *));
122
123 uerr_t ftp_index PARAMS ((const char *, struct url *, struct fileinfo *));
124
125 char ftp_process_type PARAMS ((const char *));
126
127
128 #endif /* FTP_H */