]> sjero.net Git - wget/blob - src/url.h
[svn] Minor fixes and cosmetic changes.
[wget] / src / url.h
1 /* Declarations for url.c.
2    Copyright (C) 1995, 1996, 1997 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 URL_H
31 #define URL_H
32
33 /* Default port definitions */
34 #define DEFAULT_HTTP_PORT 80
35 #define DEFAULT_FTP_PORT 21
36 #define DEFAULT_HTTPS_PORT 443
37
38 /* Note: the ordering here is related to the order of elements in
39    `supported_schemes' in url.c.  */
40
41 enum url_scheme {
42   SCHEME_HTTP,
43 #ifdef HAVE_SSL
44   SCHEME_HTTPS,
45 #endif
46   SCHEME_FTP,
47   SCHEME_INVALID
48 };
49
50 /* Structure containing info on a URL.  */
51 struct url
52 {
53   char *url;                    /* Original URL */
54   enum url_scheme scheme;       /* URL scheme */
55
56   char *host;                   /* Extracted hostname */
57   int port;                     /* Port number */
58
59   /* URL components (URL-quoted). */
60   char *path;
61   char *params;
62   char *query;
63   char *fragment;
64
65   /* Extracted path info (unquoted). */
66   char *dir;
67   char *file;
68
69   /* Username and password (unquoted). */
70   char *user;
71   char *passwd;
72 };
73
74 enum convert_options {
75   CO_NOCONVERT = 0,             /* don't convert this URL */
76   CO_CONVERT_TO_RELATIVE,       /* convert to relative, e.g. to
77                                    "../../otherdir/foo.gif" */
78   CO_CONVERT_TO_COMPLETE,       /* convert to absolute, e.g. to
79                                    "http://orighost/somedir/bar.jpg". */
80   CO_NULLIFY_BASE               /* change to empty string. */
81 };
82
83 /* A structure that defines the whereabouts of a URL, i.e. its
84    position in an HTML document, etc.  */
85
86 struct urlpos {
87   struct url *url;              /* the URL of the link, after it has
88                                    been merged with the base */
89   char *local_name;             /* local file to which it was saved
90                                    (used by convert_links) */
91
92   /* reserved for special links such as <base href="..."> which are
93      used when converting links, but ignored when downloading.  */
94   unsigned int ignore_when_downloading  :1;
95
96   /* Information about the original link: */
97
98   unsigned int link_relative_p  :1; /* was the link relative? */
99   unsigned int link_complete_p  :1; /* was the link complete (with the
100                                        host name, etc.) */
101   unsigned int link_base_p      :1; /* was the link <base href=...> */
102   unsigned int link_inline_p    :1; /* needed to render the page. */
103
104   unsigned int link_refresh_p   :1; /* link was received from
105                                        <meta http-equiv=refresh content=...> */
106   int refresh_timeout;          /* for reconstructing the refresh. */
107
108   /* Conversion requirements: */
109   enum convert_options convert; /* is conversion required? */
110
111   /* URL's position in the buffer. */
112   int pos, size;
113
114   struct urlpos *next;          /* next list element */
115 };
116
117 /* downloaded_file() takes a parameter of this type and returns this type. */
118 typedef enum
119 {
120   /* Return enumerators: */
121   FILE_NOT_ALREADY_DOWNLOADED = 0,
122
123   /* Return / parameter enumerators: */
124   FILE_DOWNLOADED_NORMALLY,
125   FILE_DOWNLOADED_AND_HTML_EXTENSION_ADDED,
126
127   /* Parameter enumerators: */
128   CHECK_FOR_FILE
129 } downloaded_file_t;
130
131 /* Function declarations */
132
133 char *url_escape PARAMS ((const char *));
134
135 struct url *url_parse PARAMS ((const char *, int *));
136 const char *url_error PARAMS ((int));
137 char *url_full_path PARAMS ((const struct url *));
138 void url_set_dir PARAMS ((struct url *, const char *));
139 void url_set_file PARAMS ((struct url *, const char *));
140 void url_free PARAMS ((struct url *));
141
142 enum url_scheme url_scheme PARAMS ((const char *));
143 int url_has_scheme PARAMS ((const char *));
144 int scheme_default_port PARAMS ((enum url_scheme));
145 void scheme_disable PARAMS ((enum url_scheme));
146
147 char *url_string PARAMS ((const struct url *, int));
148
149 struct urlpos *get_urls_file PARAMS ((const char *));
150 struct urlpos *get_urls_html PARAMS ((const char *, const char *, int *));
151 void free_urlpos PARAMS ((struct urlpos *));
152
153 char *uri_merge PARAMS ((const char *, const char *));
154
155 void rotate_backups PARAMS ((const char *));
156 int mkalldirs PARAMS ((const char *));
157 char *url_file_name PARAMS ((const struct url *));
158
159 char *getproxy PARAMS ((struct url *));
160 int no_proxy_match PARAMS ((const char *, const char **));
161
162 void convert_links PARAMS ((const char *, struct urlpos *));
163
164 downloaded_file_t downloaded_file PARAMS ((downloaded_file_t, const char *));
165
166 char *rewrite_shorthand_url PARAMS ((const char *));
167
168 int schemes_are_similar_p PARAMS ((enum url_scheme a, enum url_scheme b));
169
170 #endif /* URL_H */