]> sjero.net Git - wget/blob - src/ftp.h
[svn] Removed ftpparse dependencies. New parser for VMS listings. MacOS
[wget] / src / ftp.h
1 /* Declarations for FTP support.
2    Copyright (C) 1995, 1996, 1997, 2000 Free Software Foundation, Inc.
3
4    This program is free software; you can redistribute it and/or modify
5    it under the terms of the GNU General Public License as published by
6    the Free Software Foundation; either version 2 of the License, or
7    (at your option) any later version.
8
9    This program is distributed in the hope that it will be useful,
10    but WITHOUT ANY WARRANTY; without even the implied warranty of
11    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12    GNU General Public License for more details.
13
14    You should have received a copy of the GNU General Public License
15    along with this program; if not, write to the Free Software
16    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
17
18 #ifndef FTP_H
19 #define FTP_H
20
21 /* Need it for struct rbuf.  */
22 #include "rbuf.h"
23
24 /* System types. */
25 enum stype
26 {
27   ST_UNIX,
28   ST_VMS,
29   ST_WINNT,
30   ST_MACOS,
31   ST_OTHER
32 };
33   
34 uerr_t ftp_response PARAMS ((struct rbuf *, char **));
35 uerr_t ftp_login PARAMS ((struct rbuf *, const char *, const char *));
36 uerr_t ftp_port PARAMS ((struct rbuf *));
37 uerr_t ftp_pasv PARAMS ((struct rbuf *, unsigned char *));
38 uerr_t ftp_type PARAMS ((struct rbuf *, int));
39 uerr_t ftp_cwd PARAMS ((struct rbuf *, const char *));
40 uerr_t ftp_retr PARAMS ((struct rbuf *, const char *));
41 uerr_t ftp_rest PARAMS ((struct rbuf *, long));
42 uerr_t ftp_list PARAMS ((struct rbuf *, const char *));
43 uerr_t ftp_syst PARAMS ((struct rbuf *, enum stype *));
44 uerr_t ftp_pwd PARAMS ((struct rbuf *, char **));
45
46 struct urlinfo;
47
48 /* File types.  */
49 enum ftype
50 {
51   FT_PLAINFILE,
52   FT_DIRECTORY,
53   FT_SYMLINK,
54   FT_UNKNOWN
55 };
56
57
58 /* Globbing (used by ftp_retrieve_glob).  */
59 enum
60 {
61   GLOBALL, GETALL, GETONE
62 };
63
64 /* Information about one filename in a linked list.  */
65 struct fileinfo
66 {
67   enum ftype type;              /* file type */
68   char *name;                   /* file name */
69   long size;                    /* file size */
70   long tstamp;                  /* time-stamp */
71   int perms;                    /* file permissions */
72   char *linkto;                 /* link to which file points */
73   struct fileinfo *prev;        /* previous... */
74   struct fileinfo *next;        /* ...and next structure. */
75 };
76
77 /* Commands for FTP functions.  */
78 enum wget_ftp_command
79 {
80   DO_LOGIN      = 0x0001,       /* Connect and login to the server.  */
81   DO_CWD        = 0x0002,       /* Change current directory.  */
82   DO_RETR       = 0x0004,       /* Retrieve the file.  */
83   DO_LIST       = 0x0008,       /* Retrieve the directory list.  */
84   LEAVE_PENDING = 0x0010        /* Do not close the socket.  */
85 };
86
87 enum wget_ftp_fstatus
88 {
89   NOTHING       = 0x0000,       /* Nothing done yet.  */
90   ON_YOUR_OWN   = 0x0001,       /* The ftp_loop_internal sets the
91                                    defaults.  */
92   DONE_CWD      = 0x0002        /* The current working directory is
93                                    correct.  */
94 };
95
96 typedef struct
97 {
98   int st;                       /* connection status */
99   int cmd;                      /* command code */
100   struct rbuf rbuf;             /* control connection buffer */
101   long dltime;                  /* time of the download */
102   enum stype rs;                /* remote system reported by ftp server */ 
103   char *id;                     /* initial directory */
104 } ccon;
105
106 struct fileinfo *ftp_parse_ls PARAMS ((const char *, enum stype));
107 uerr_t ftp_loop PARAMS ((struct urlinfo *, int *));
108
109 uerr_t ftp_index (const char *, struct urlinfo *, struct fileinfo *);
110
111 #endif /* FTP_H */