1 /* Declarations for url.c.
2 Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
4 This file is part of Wget.
6 This program 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 This program 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 this program; if not, write to the Free Software
18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
23 /* Default port definitions */
24 #define DEFAULT_HTTP_PORT 80
25 #define DEFAULT_FTP_PORT 21
26 #define DEFAULT_HTTPS_PORT 443
29 /* Structure containing info on a URL. */
32 char *url; /* Unchanged URL */
33 uerr_t proto; /* URL protocol */
34 char *host; /* Extracted hostname */
37 char *path, *dir, *file, *qstring;
38 /* Path, dir, file, and query string
40 char *user, *passwd; /* Username and password */
41 struct urlinfo *proxy; /* The exact string to pass to proxy
43 char *referer; /* The source from which the request
45 char *local; /* The local filename of the URL
49 enum convert_options {
50 CO_NOCONVERT = 0, /* don't convert this URL */
51 CO_CONVERT_TO_RELATIVE, /* convert to relative, e.g. to
52 "../../otherdir/foo.gif" */
53 CO_CONVERT_TO_COMPLETE /* convert to absolute, e.g. to
54 "http://orighost/somedir/bar.jpg". */
57 /* A structure that defines the whereabouts of a URL, i.e. its
58 position in an HTML document, etc. */
60 typedef struct _urlpos
62 char *url; /* linked URL, after it has been
63 merged with the base */
64 char *local_name; /* Local file to which it was saved */
66 /* Information about the original link: */
67 int link_relative_p; /* was the link relative? */
68 int link_complete_p; /* was the link complete (with the
71 /* Conversion requirements: */
72 enum convert_options convert; /* is conversion required? */
74 /* URL's position in the buffer. */
77 struct _urlpos *next; /* Next struct in list */
80 /* downloaded_file() takes a parameter of this type and returns this type. */
83 /* Return enumerators: */
84 FILE_NOT_ALREADY_DOWNLOADED = 0,
86 /* Return / parameter enumerators: */
87 FILE_DOWNLOADED_NORMALLY,
88 FILE_DOWNLOADED_AND_HTML_EXTENSION_ADDED,
90 /* Parameter enumerators: */
94 /* Function declarations */
96 char *encode_string PARAMS ((const char *));
98 struct urlinfo *newurl PARAMS ((void));
99 void freeurl PARAMS ((struct urlinfo *, int));
100 uerr_t urlproto PARAMS ((const char *));
101 int skip_proto PARAMS ((const char *));
102 int has_proto PARAMS ((const char *));
103 int skip_uname PARAMS ((const char *));
105 uerr_t parseurl PARAMS ((const char *, struct urlinfo *, int));
106 char *str_url PARAMS ((const struct urlinfo *, int));
107 int url_equal PARAMS ((const char *, const char *));
109 urlpos *get_urls_file PARAMS ((const char *));
110 urlpos *get_urls_html PARAMS ((const char *, const char *, int, int *));
111 void free_urlpos PARAMS ((urlpos *));
113 char *uri_merge PARAMS ((const char *, const char *));
115 void rotate_backups PARAMS ((const char *));
116 int mkalldirs PARAMS ((const char *));
117 char *url_filename PARAMS ((const struct urlinfo *));
118 void opt_url PARAMS ((struct urlinfo *));
120 char *getproxy PARAMS ((uerr_t));
121 int no_proxy_match PARAMS ((const char *, const char **));
123 void convert_links PARAMS ((const char *, urlpos *));
124 urlpos *add_url PARAMS ((urlpos *, const char *, const char *));
126 downloaded_file_t downloaded_file PARAMS ((downloaded_file_t, const char *));