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