]> sjero.net Git - wget/blob - src/convert.h
[svn] Merge of fix for bugs 20341 and 20410.
[wget] / src / convert.h
1 /* Declarations for convert.c
2    Copyright (C) 2003-2006 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 3 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, see <http://www.gnu.org/licenses/>.
18
19 In addition, as a special exception, the Free Software Foundation
20 gives permission to link the code of its release of Wget with the
21 OpenSSL project's "OpenSSL" library (or with modified versions of it
22 that use the same license as the "OpenSSL" library), and distribute
23 the linked executables.  You must obey the GNU General Public License
24 in all respects for all of the code used other than "OpenSSL".  If you
25 modify this file, you may extend this exception to your version of the
26 file, but you are not obligated to do so.  If you do not wish to do
27 so, delete this exception statement from your version.  */
28
29 #ifndef CONVERT_H
30 #define CONVERT_H
31
32 struct hash_table;              /* forward decl */
33 extern struct hash_table *dl_url_file_map;
34 extern struct hash_table *downloaded_html_set;
35
36 enum convert_options {
37   CO_NOCONVERT = 0,             /* don't convert this URL */
38   CO_CONVERT_TO_RELATIVE,       /* convert to relative, e.g. to
39                                    "../../otherdir/foo.gif" */
40   CO_CONVERT_TO_COMPLETE,       /* convert to absolute, e.g. to
41                                    "http://orighost/somedir/bar.jpg". */
42   CO_NULLIFY_BASE               /* change to empty string. */
43 };
44
45 struct url;
46
47 /* A structure that defines the whereabouts of a URL, i.e. its
48    position in an HTML document, etc.  */
49
50 struct urlpos {
51   struct url *url;              /* the URL of the link, after it has
52                                    been merged with the base */
53   char *local_name;             /* local file to which it was saved
54                                    (used by convert_links) */
55
56   /* reserved for special links such as <base href="..."> which are
57      used when converting links, but ignored when downloading.  */
58   unsigned int ignore_when_downloading  :1;
59
60   /* Information about the original link: */
61
62   unsigned int link_relative_p  :1; /* the link was relative */
63   unsigned int link_complete_p  :1; /* the link was complete (had host name) */
64   unsigned int link_base_p      :1; /* the url came from <base href=...> */
65   unsigned int link_inline_p    :1; /* needed to render the page */
66   unsigned int link_expect_html :1; /* expected to contain HTML */
67
68   unsigned int link_refresh_p   :1; /* link was received from
69                                        <meta http-equiv=refresh content=...> */
70   int refresh_timeout;          /* for reconstructing the refresh. */
71
72   /* Conversion requirements: */
73   enum convert_options convert; /* is conversion required? */
74
75   /* URL's position in the buffer. */
76   int pos, size;
77
78   struct urlpos *next;          /* next list element */
79 };
80
81 /* downloaded_file() takes a parameter of this type and returns this type. */
82 typedef enum
83 {
84   /* Return enumerators: */
85   FILE_NOT_ALREADY_DOWNLOADED = 0,
86
87   /* Return / parameter enumerators: */
88   FILE_DOWNLOADED_NORMALLY,
89   FILE_DOWNLOADED_AND_HTML_EXTENSION_ADDED,
90
91   /* Parameter enumerators: */
92   CHECK_FOR_FILE
93 } downloaded_file_t;
94
95 downloaded_file_t downloaded_file (downloaded_file_t, const char *);
96
97 void register_download (const char *, const char *);
98 void register_redirection (const char *, const char *);
99 void register_html (const char *, const char *);
100 void register_delete_file (const char *);
101 void convert_all_links (void);
102 void convert_cleanup (void);
103
104 char *html_quote_string (const char *);
105
106 #endif /* CONVERT_H */