]> sjero.net Git - wget/blob - src/url.h
[svn] Skip `:port' in the host header if it is the DEFAULT_HTTPS_PORT when
[wget] / src / url.h
1 /* Declarations for url.c.
2    Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
3
4 This file is part of Wget.
5
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.
10
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.
15
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.  */
19
20 #ifndef URL_H
21 #define URL_H
22
23 /* Default port definitions */
24 #define DEFAULT_HTTP_PORT 80
25 #define DEFAULT_FTP_PORT 21
26 #define DEFAULT_HTTPS_PORT 443
27
28
29 /* If the string contains unsafe characters, duplicate it with
30    encode_string, otherwise just copy it with strdup.  */
31 #define CLEANDUP(x) (contains_unsafe (x) ? encode_string (x) : xstrdup (x))
32
33 /* Structure containing info on a URL.  */
34 struct urlinfo
35 {
36   char *url;                    /* Unchanged URL */
37   uerr_t proto;                 /* URL protocol */
38   char *host;                   /* Extracted hostname */
39   unsigned short port;
40   char ftp_type;
41   char *path, *dir, *file, *qstring;    
42                                 /* Path, dir, file, and query string
43                                    (properly decoded) */
44   char *user, *passwd;          /* Username and password */
45   struct urlinfo *proxy;        /* The exact string to pass to proxy
46                                    server */
47   char *referer;                /* The source from which the request
48                                    URI was obtained */
49   char *local;                  /* The local filename of the URL
50                                    document */
51 };
52
53 enum convert_options {
54   CO_NOCONVERT = 0,             /* don't convert this URL */
55   CO_CONVERT_TO_RELATIVE,       /* convert to relative, e.g. to
56                                    "../../otherdir/foo.gif" */
57   CO_CONVERT_TO_COMPLETE        /* convert to absolute, e.g. to
58                                    "http://orighost/somedir/bar.jpg". */
59 };
60
61 /* A structure that defines the whereabouts of a URL, i.e. its
62    position in an HTML document, etc.  */
63
64 typedef struct _urlpos
65 {
66   char *url;                    /* linked URL, after it has been
67                                    merged with the base */
68   char *local_name;             /* Local file to which it was saved */
69
70   /* Information about the original link: */
71   int link_relative_p;          /* was the link relative? */
72   int link_complete_p;          /* was the link complete (with the
73                                    host name, etc.) */
74
75   /* Conversion requirements: */
76   enum convert_options convert; /* is conversion required? */
77
78   /* URL's position in the buffer. */
79   int pos, size;
80
81   struct _urlpos *next;         /* Next struct in list */
82 } urlpos;
83
84 /* downloaded_file() takes a parameter of this type and returns this type. */
85 typedef enum
86 {
87   /* Return enumerators: */
88   FILE_NOT_ALREADY_DOWNLOADED = 0,
89
90   /* Return / parameter enumerators: */
91   FILE_DOWNLOADED_NORMALLY,
92   FILE_DOWNLOADED_AND_HTML_EXTENSION_ADDED,
93
94   /* Parameter enumerators: */
95   CHECK_FOR_FILE
96 } downloaded_file_t;
97
98 /* Function declarations */
99
100 int skip_url PARAMS ((const char *));
101
102 int contains_unsafe PARAMS ((const char *));
103 char *encode_string PARAMS ((const char *));
104
105 struct urlinfo *newurl PARAMS ((void));
106 void freeurl PARAMS ((struct urlinfo *, int));
107 uerr_t urlproto PARAMS ((const char *));
108 int skip_proto PARAMS ((const char *));
109 int has_proto PARAMS ((const char *));
110 int skip_uname PARAMS ((const char *));
111
112 uerr_t parseurl PARAMS ((const char *, struct urlinfo *, int));
113 char *str_url PARAMS ((const struct urlinfo *, int));
114 int url_equal PARAMS ((const char *, const char *));
115
116 urlpos *get_urls_file PARAMS ((const char *));
117 urlpos *get_urls_html PARAMS ((const char *, const char *, int, int *));
118 void free_urlpos PARAMS ((urlpos *));
119
120 char *url_concat PARAMS ((const char *, const char *));
121
122 void rotate_backups PARAMS ((const char *));
123 int mkalldirs PARAMS ((const char *));
124 char *url_filename PARAMS ((const struct urlinfo *));
125 void opt_url PARAMS ((struct urlinfo *));
126
127 char *getproxy PARAMS ((uerr_t));
128 int no_proxy_match PARAMS ((const char *, const char **));
129
130 void convert_links PARAMS ((const char *, urlpos *));
131 urlpos *add_url PARAMS ((urlpos *, const char *, const char *));
132
133 downloaded_file_t downloaded_file PARAMS ((downloaded_file_t, const char *));
134
135 #endif /* URL_H */