1 /* Declarations for url.c.
2 Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
4 This file is part of GNU Wget.
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.
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.
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.
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. */
33 /* Default port definitions */
34 #define DEFAULT_HTTP_PORT 80
35 #define DEFAULT_FTP_PORT 21
36 #define DEFAULT_HTTPS_PORT 443
38 /* Note: the ordering here is related to the order of elements in
39 `supported_schemes' in url.c. */
50 /* Structure containing info on a URL. */
53 char *url; /* Original URL */
54 enum url_scheme scheme; /* URL scheme */
56 char *host; /* Extracted hostname */
57 int port; /* Port number */
59 /* URL components (URL-quoted). */
65 /* Extracted path info (unquoted). */
69 /* Username and password (unquoted). */
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. */
83 /* A structure that defines the whereabouts of a URL, i.e. its
84 position in an HTML document, etc. */
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) */
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;
96 /* Information about the original link: */
98 unsigned int link_relative_p :1; /* was the link relative? */
99 unsigned int link_complete_p :1; /* was the link complete (with the
101 unsigned int link_base_p :1; /* was the link <base href=...> */
102 unsigned int link_inline_p :1; /* needed to render the page. */
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. */
108 /* Conversion requirements: */
109 enum convert_options convert; /* is conversion required? */
111 /* URL's position in the buffer. */
114 struct urlpos *next; /* next list element */
117 /* downloaded_file() takes a parameter of this type and returns this type. */
120 /* Return enumerators: */
121 FILE_NOT_ALREADY_DOWNLOADED = 0,
123 /* Return / parameter enumerators: */
124 FILE_DOWNLOADED_NORMALLY,
125 FILE_DOWNLOADED_AND_HTML_EXTENSION_ADDED,
127 /* Parameter enumerators: */
131 /* Function declarations */
133 char *encode_string PARAMS ((const char *));
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 *));
142 enum url_scheme url_scheme PARAMS ((const char *));
143 int url_skip_scheme PARAMS ((const char *));
144 int url_has_scheme PARAMS ((const char *));
145 int scheme_default_port PARAMS ((enum url_scheme));
146 void scheme_disable PARAMS ((enum url_scheme));
148 int url_skip_uname PARAMS ((const char *));
150 char *url_string PARAMS ((const struct url *, int));
152 struct urlpos *get_urls_file PARAMS ((const char *));
153 struct urlpos *get_urls_html PARAMS ((const char *, const char *, int *));
154 void free_urlpos PARAMS ((struct urlpos *));
156 char *uri_merge PARAMS ((const char *, const char *));
158 void rotate_backups PARAMS ((const char *));
159 int mkalldirs PARAMS ((const char *));
160 char *url_filename PARAMS ((const struct url *));
162 char *getproxy PARAMS ((struct url *));
163 int no_proxy_match PARAMS ((const char *, const char **));
165 void convert_links PARAMS ((const char *, struct urlpos *));
167 downloaded_file_t downloaded_file PARAMS ((downloaded_file_t, const char *));
169 char *rewrite_shorthand_url PARAMS ((const char *));
171 int schemes_are_similar_p PARAMS ((enum url_scheme a, enum url_scheme b));