]> sjero.net Git - wget/blob - src/url.h
[svn] Implemented the item I formerly had in the TODO: When -K and -N are used
[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;      /* Path, as well as dir and file
36                                    (properly decoded) */
37   char *user, *passwd;          /* Username and password */
38   struct urlinfo *proxy;        /* The exact string to pass to proxy
39                                    server */
40   char *referer;                /* The source from which the request
41                                    URI was obtained */
42   char *local;                  /* The local filename of the URL
43                                    document */
44 };
45
46 enum uflags
47 {
48   URELATIVE     = 0x0001,      /* Is URL relative? */
49   UNOPROTO      = 0x0002,      /* Is URL without a protocol? */
50   UABS2REL      = 0x0004,      /* Convert absolute to relative? */
51   UREL2ABS      = 0x0008       /* Convert relative to absolute? */
52 };
53
54 /* A structure that defines the whereabouts of a URL, i.e. its
55    position in an HTML document, etc.  */
56 typedef struct _urlpos
57 {
58   char *url;                   /* URL */
59   char *local_name;            /* Local file to which it was saved */
60   enum uflags flags;           /* Various flags */
61   int pos, size;               /* Relative position in the buffer */
62   struct _urlpos *next;        /* Next struct in list */
63 } urlpos;
64
65 /* Controls how downloaded_file() behaves. */
66 typedef enum
67 {
68   ADD_FILE,
69   CHECK_FOR_FILE
70 } downloaded_file_t;
71
72 /* Function declarations */
73
74 int skip_url PARAMS ((const char *));
75
76 int contains_unsafe PARAMS ((const char *));
77 char *encode_string PARAMS ((const char *));
78
79 struct urlinfo *newurl PARAMS ((void));
80 void freeurl PARAMS ((struct urlinfo *, int));
81 uerr_t urlproto PARAMS ((const char *));
82 int skip_proto PARAMS ((const char *));
83 int skip_uname PARAMS ((const char *));
84
85 uerr_t parseurl PARAMS ((const char *, struct urlinfo *, int));
86 char *str_url PARAMS ((const struct urlinfo *, int));
87 int url_equal PARAMS ((const char *, const char *));
88
89 urlpos *get_urls_file PARAMS ((const char *));
90 urlpos *get_urls_html PARAMS ((const char *, const char *, int));
91 void free_urlpos PARAMS ((urlpos *));
92
93 void rotate_backups PARAMS ((const char *));
94 int mkalldirs PARAMS ((const char *));
95 char *url_filename PARAMS ((const struct urlinfo *));
96 void opt_url PARAMS ((struct urlinfo *));
97
98 char *getproxy PARAMS ((uerr_t));
99 int no_proxy_match PARAMS ((const char *, const char **));
100
101 void convert_links PARAMS ((const char *, urlpos *));
102 urlpos *add_url PARAMS ((urlpos *, const char *, const char *));
103
104 boolean downloaded_file PARAMS ((downloaded_file_t, const char *));
105
106 #endif /* URL_H */