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