]> sjero.net Git - wget/blob - src/ftp.h
e0ad7ccb946c820f80030cdcad75188558eae06f
[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 #ifndef FTP_H
21 #define FTP_H
22
23 /* Need it for struct rbuf.  */
24 #include "rbuf.h"
25
26 /* System types. */
27 enum stype
28 {
29   ST_UNIX,
30   ST_VMS,
31   ST_WINNT,
32   ST_MACOS,
33   ST_OTHER
34 };
35   
36 uerr_t ftp_response PARAMS ((struct rbuf *, char **));
37 uerr_t ftp_login PARAMS ((struct rbuf *, const char *, const char *));
38 uerr_t ftp_port PARAMS ((struct rbuf *));
39 uerr_t ftp_pasv PARAMS ((struct rbuf *, unsigned char *));
40 uerr_t ftp_type PARAMS ((struct rbuf *, int));
41 uerr_t ftp_cwd PARAMS ((struct rbuf *, const char *));
42 uerr_t ftp_retr PARAMS ((struct rbuf *, const char *));
43 uerr_t ftp_rest PARAMS ((struct rbuf *, long));
44 uerr_t ftp_list PARAMS ((struct rbuf *, const char *));
45 uerr_t ftp_syst PARAMS ((struct rbuf *, enum stype *));
46 uerr_t ftp_pwd PARAMS ((struct rbuf *, char **));
47 uerr_t ftp_size PARAMS ((struct rbuf *, const char *, long int *));
48
49 struct urlinfo;
50
51 /* File types.  */
52 enum ftype
53 {
54   FT_PLAINFILE,
55   FT_DIRECTORY,
56   FT_SYMLINK,
57   FT_UNKNOWN
58 };
59
60
61 /* Globbing (used by ftp_retrieve_glob).  */
62 enum
63 {
64   GLOBALL, GETALL, GETONE
65 };
66
67 /* Information about one filename in a linked list.  */
68 struct fileinfo
69 {
70   enum ftype type;              /* file type */
71   char *name;                   /* file name */
72   long size;                    /* file size */
73   long tstamp;                  /* time-stamp */
74   int perms;                    /* file permissions */
75   char *linkto;                 /* link to which file points */
76   struct fileinfo *prev;        /* previous... */
77   struct fileinfo *next;        /* ...and next structure. */
78 };
79
80 /* Commands for FTP functions.  */
81 enum wget_ftp_command
82 {
83   DO_LOGIN      = 0x0001,       /* Connect and login to the server.  */
84   DO_CWD        = 0x0002,       /* Change current directory.  */
85   DO_RETR       = 0x0004,       /* Retrieve the file.  */
86   DO_LIST       = 0x0008,       /* Retrieve the directory list.  */
87   LEAVE_PENDING = 0x0010,       /* Do not close the socket.  */
88   NO_TRUNCATE   = 0x0020        /* Don't truncate the file if REST
89                                    malfunctions. */
90 };
91
92 enum wget_ftp_fstatus
93 {
94   NOTHING       = 0x0000,       /* Nothing done yet.  */
95   ON_YOUR_OWN   = 0x0001,       /* The ftp_loop_internal sets the
96                                    defaults.  */
97   DONE_CWD      = 0x0002        /* The current working directory is
98                                    correct.  */
99 };
100
101 typedef struct
102 {
103   int st;                       /* connection status */
104   int cmd;                      /* command code */
105   struct rbuf rbuf;             /* control connection buffer */
106   long dltime;                  /* time of the download */
107   enum stype rs;                /* remote system reported by ftp server */ 
108   char *id;                     /* initial directory */
109 } ccon;
110
111 struct fileinfo *ftp_parse_ls PARAMS ((const char *, const enum stype));
112 uerr_t ftp_loop PARAMS ((struct urlinfo *, int *));
113
114 uerr_t ftp_index (const char *, struct urlinfo *, struct fileinfo *);
115
116 #endif /* FTP_H */