| 1 |
/* Declarations for convert.c |
| 2 |
Copyright (C) 2003-2006, 2009-2011, 2015, 2018-2024 Free Software |
| 3 |
Foundation, Inc. |
| 4 |
|
| 5 |
This file is part of GNU Wget. |
| 6 |
|
| 7 |
GNU Wget is free software; you can redistribute it and/or modify |
| 8 |
it under the terms of the GNU General Public License as published by |
| 9 |
the Free Software Foundation; either version 3 of the License, or |
| 10 |
(at your option) any later version. |
| 11 |
|
| 12 |
GNU Wget is distributed in the hope that it will be useful, |
| 13 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 |
GNU General Public License for more details. |
| 16 |
|
| 17 |
You should have received a copy of the GNU General Public License |
| 18 |
along with Wget. If not, see <http://www.gnu.org/licenses/>. |
| 19 |
|
| 20 |
Additional permission under GNU GPL version 3 section 7 |
| 21 |
|
| 22 |
If you modify this program, or any covered work, by linking or |
| 23 |
combining it with the OpenSSL project's OpenSSL library (or a |
| 24 |
modified version of that library), containing parts covered by the |
| 25 |
terms of the OpenSSL or SSLeay licenses, the Free Software Foundation |
| 26 |
grants you additional permission to convey the resulting work. |
| 27 |
Corresponding Source for a non-source form of such a combination |
| 28 |
shall include the source code for the parts of OpenSSL used as well |
| 29 |
as that of the covered work. */ |
| 30 |
|
| 31 |
#ifndef CONVERT_H |
| 32 |
#define CONVERT_H |
| 33 |
|
| 34 |
struct hash_table; /* forward decl */ |
| 35 |
extern struct hash_table *dl_url_file_map; |
| 36 |
extern struct hash_table *downloaded_html_set; |
| 37 |
extern struct hash_table *downloaded_css_set; |
| 38 |
|
| 39 |
enum convert_options { |
| 40 |
CO_NOCONVERT = 0, /* don't convert this URL */ |
| 41 |
CO_CONVERT_TO_RELATIVE, /* convert to relative, e.g. to |
| 42 |
"../../otherdir/foo.gif" */ |
| 43 |
CO_CONVERT_BASENAME_ONLY, /* convert the file portion only (basename) |
| 44 |
leaving the rest of the URL unchanged */ |
| 45 |
CO_CONVERT_TO_COMPLETE, /* convert to absolute, e.g. to |
| 46 |
"http://orighost/somedir/bar.jpg". */ |
| 47 |
CO_NULLIFY_BASE /* change to empty string. */ |
| 48 |
}; |
| 49 |
|
| 50 |
struct url; |
| 51 |
|
| 52 |
/* A structure that defines the whereabouts of a URL, i.e. its |
| 53 |
position in an HTML document, etc. */ |
| 54 |
|
| 55 |
struct urlpos { |
| 56 |
struct url *url; /* the URL of the link, after it has |
| 57 |
been merged with the base */ |
| 58 |
char *local_name; /* local file to which it was saved |
| 59 |
(used by convert_links) */ |
| 60 |
|
| 61 |
/* reserved for special links such as <base href="..."> which are |
| 62 |
used when converting links, but ignored when downloading. */ |
| 63 |
unsigned int ignore_when_downloading :1; |
| 64 |
|
| 65 |
/* Information about the original link: */ |
| 66 |
|
| 67 |
unsigned int link_relative_p :1; /* the link was relative */ |
| 68 |
unsigned int link_complete_p :1; /* the link was complete (had host name) */ |
| 69 |
unsigned int link_base_p :1; /* the url came from <base href=...> */ |
| 70 |
unsigned int link_inline_p :1; /* needed to render the page */ |
| 71 |
unsigned int link_css_p :1; /* the url came from CSS */ |
| 72 |
unsigned int link_noquote_html_p :1; /* from HTML, but doesn't need " */ |
| 73 |
unsigned int link_expect_html :1; /* expected to contain HTML */ |
| 74 |
unsigned int link_expect_css :1; /* expected to contain CSS */ |
| 75 |
|
| 76 |
unsigned int link_refresh_p :1; /* link was received from |
| 77 |
<meta http-equiv=refresh content=...> */ |
| 78 |
int refresh_timeout; /* for reconstructing the refresh. */ |
| 79 |
|
| 80 |
/* Conversion requirements: */ |
| 81 |
enum convert_options convert; /* is conversion required? */ |
| 82 |
|
| 83 |
/* URL's position in the buffer. */ |
| 84 |
int pos, size; |
| 85 |
|
| 86 |
struct urlpos *next; /* next list element */ |
| 87 |
}; |
| 88 |
|
| 89 |
/* downloaded_file() takes a parameter of this type and returns this type. */ |
| 90 |
typedef enum |
| 91 |
{ |
| 92 |
/* Return enumerators: */ |
| 93 |
FILE_NOT_ALREADY_DOWNLOADED = 0, |
| 94 |
|
| 95 |
/* Return / parameter enumerators: */ |
| 96 |
FILE_DOWNLOADED_NORMALLY, |
| 97 |
FILE_DOWNLOADED_AND_HTML_EXTENSION_ADDED, |
| 98 |
|
| 99 |
/* Parameter enumerators: */ |
| 100 |
CHECK_FOR_FILE |
| 101 |
} downloaded_file_t; |
| 102 |
|
| 103 |
downloaded_file_t downloaded_file (downloaded_file_t, const char *); |
| 104 |
|
| 105 |
void register_download (const char *, const char *); |
| 106 |
void register_redirection (const char *, const char *); |
| 107 |
void register_html (const char *); |
| 108 |
void register_css (const char *); |
| 109 |
void register_delete_file (const char *); |
| 110 |
void convert_all_links (void); |
| 111 |
void convert_cleanup (void); |
| 112 |
|
| 113 |
char *html_quote_string (const char *); |
| 114 |
|
| 115 |
#endif /* CONVERT_H */ |