]> sjero.net Git - wget/blob - src/ftp.h
064e6354fdc8940aa14f16d9b97c890d311d46e2
[wget] / src / ftp.h
1 /* Declarations for FTP support.
2    Copyright (C) 1995, 1996, 1997 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 uerr_t ftp_response PARAMS ((struct rbuf *, char **));
25 uerr_t ftp_login PARAMS ((struct rbuf *, const char *, const char *));
26 uerr_t ftp_port PARAMS ((struct rbuf *));
27 uerr_t ftp_pasv PARAMS ((struct rbuf *, unsigned char *));
28 uerr_t ftp_type PARAMS ((struct rbuf *, int));
29 uerr_t ftp_cwd PARAMS ((struct rbuf *, const char *));
30 uerr_t ftp_retr PARAMS ((struct rbuf *, const char *));
31 uerr_t ftp_rest PARAMS ((struct rbuf *, long));
32 uerr_t ftp_list PARAMS ((struct rbuf *, const char *));
33
34 struct urlinfo;
35
36 /* File types.  */
37 enum ftype
38 {
39   FT_PLAINFILE,
40   FT_DIRECTORY,
41   FT_SYMLINK,
42   FT_UNKNOWN
43 };
44
45
46 /* Globbing (used by ftp_retrieve_glob).  */
47 enum
48 {
49   GLOBALL, GETALL, GETONE
50 };
51
52 /* Information about one filename in a linked list.  */
53 struct fileinfo
54 {
55   enum ftype type;              /* file type */
56   char *name;                   /* file name */
57   long size;                    /* file size */
58   long tstamp;                  /* time-stamp */
59   int perms;                    /* file permissions */
60   char *linkto;                 /* link to which file points */
61   struct fileinfo *prev;        /* previous... */
62   struct fileinfo *next;        /* ...and next structure. */
63 };
64
65 /* Commands for FTP functions.  */
66 enum command
67 {
68   DO_LOGIN      = 0x0001,       /* Connect and login to the server.  */
69   DO_CWD        = 0x0002,       /* Change current directory.  */
70   DO_RETR       = 0x0004,       /* Retrieve the file.  */
71   DO_LIST       = 0x0008,       /* Retrieve the directory list.  */
72   LEAVE_PENDING = 0x0010        /* Do not close the socket.  */
73 };
74
75 enum fstatus
76 {
77   NOTHING       = 0x0000,       /* Nothing done yet.  */
78   ON_YOUR_OWN   = 0x0001,       /* The ftp_loop_internal sets the
79                                    defaults.  */
80   DONE_CWD      = 0x0002        /* The current working directory is
81                                    correct.  */
82 };
83
84 typedef struct
85 {
86   int st;                       /* connection status */
87   int cmd;                      /* command code */
88   struct rbuf rbuf;             /* control connection buffer */
89   long dltime;                  /* time of the download */
90 } ccon;
91
92 struct fileinfo *ftp_parse_ls PARAMS ((const char *));
93 uerr_t ftp_loop PARAMS ((struct urlinfo *, int *));
94
95 uerr_t ftp_index (const char *, struct urlinfo *, struct fileinfo *);
96
97 #endif /* FTP_H */