annotate src/url.h @ 2104:3e7e5395f0bc

non-ASCII keybindings Alexander Voigt has kindly done some testing, and it seems that this makes bindings to most keys on a German keyboard possible -- except those that need AltGr don't work yet.
author corvid <corvid@lavabit.com>
date Thu, 23 Jun 2011 19:24:11 +0000
parents f4a6b351012d
children
rev   line source
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1 /*
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
2 * File : url.h - Dillo
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
3 *
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
4 * Copyright (C) 2001 Jorge Arellano Cid <jcid@dillo.org>
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
5 *
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
6 * Parse and normalize all URL's inside Dillo.
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
7 */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
8
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
9 #ifndef __URL_H__
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
10 #define __URL_H__
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
11
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
12 #include "d_size.h"
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
13 #include "../dlib/dlib.h"
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
14
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
15
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
16 #define DILLO_URL_HTTP_PORT 80
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
17 #define DILLO_URL_HTTPS_PORT 443
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
18 #define DILLO_URL_FTP_PORT 21
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
19 #define DILLO_URL_MAILTO_PORT 25
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
20 #define DILLO_URL_NEWS_PORT 119
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
21 #define DILLO_URL_TELNET_PORT 23
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
22 #define DILLO_URL_GOPHER_PORT 70
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
23
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
24
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
25 /*
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
26 * Values for DilloUrl->flags.
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
27 * Specifies which which action to perform with an URL.
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
28 */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
29 #define URL_Get (1 << 0)
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
30 #define URL_Post (1 << 1)
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
31 #define URL_ISindex (1 << 2)
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
32 #define URL_Ismap (1 << 3)
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
33 #define URL_RealmAccess (1 << 4)
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
34
210
2f05ce84df01 + Fixed a bug in the code that remembers the scrolling position.
jcid
parents: 157
diff changeset
35 #define URL_E2EQuery (1 << 5)
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
36 #define URL_ReloadImages (1 << 6)
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
37 #define URL_ReloadPage (1 << 7)
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
38 #define URL_ReloadFromCache (1 << 8)
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
39
1037
a72e5506e280 Implemented Instant client-side redirects (META refresh with delay=0)
Jorge Arellano Cid <jcid@dillo.org>
parents: 442
diff changeset
40 #define URL_IgnoreScroll (1 << 9)
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
41 #define URL_SpamSafe (1 << 10)
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
42
124
fe3bf1602630 + Added multipart/form-data encoding for form submission.
jcid
parents: 50
diff changeset
43 #define URL_MultipartEnc (1 << 11)
fe3bf1602630 + Added multipart/form-data encoding for form submission.
jcid
parents: 50
diff changeset
44
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
45 /*
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
46 * Access methods to fields inside DilloURL.
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
47 * (non '_'-ended macros MUST use these for initialization sake)
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
48 */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
49 /* these MAY return NULL: */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
50 #define URL_SCHEME_(u) u->scheme
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
51 #define URL_AUTHORITY_(u) u->authority
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
52 #define URL_PATH_(u) u->path
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
53 #define URL_QUERY_(u) u->query
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
54 #define URL_FRAGMENT_(u) u->fragment
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
55 #define URL_HOST_(u) a_Url_hostname(u)
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
56 #define URL_ALT_(u) u->alt
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
57 #define URL_STR_(u) a_Url_str(u)
157
49d4a18c4928 - Switched URL_DATA type from char* to a dStr.
jcid
parents: 124
diff changeset
58 /* this returns a Dstr* */
49d4a18c4928 - Switched URL_DATA type from char* to a dStr.
jcid
parents: 124
diff changeset
59 #define URL_DATA_(u) u->data
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
60 /* these return an integer */
339
b464ea4ae6d7 - Macro fix for readability.
jcid
parents: 338
diff changeset
61 #define URL_PORT_(u) (URL_HOST(u), u->port)
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
62 #define URL_FLAGS_(u) u->flags
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
63 #define URL_ILLEGAL_CHARS_(u) url->illegal_chars
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
64 #define URL_ILLEGAL_CHARS_SPC_(u) url->illegal_chars_spc
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
65
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
66 /*
157
49d4a18c4928 - Switched URL_DATA type from char* to a dStr.
jcid
parents: 124
diff changeset
67 * Access methods that never return NULL.
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
68 * When the "empty" and "undefined" concepts of RFC-2396 are irrelevant to
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
69 * the caller, and a string is required, use these methods instead:
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
70 */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
71 #define NPTR2STR(p) ((p) ? (p) : "")
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
72 #define URL_SCHEME(u) NPTR2STR(URL_SCHEME_(u))
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
73 #define URL_AUTHORITY(u) NPTR2STR(URL_AUTHORITY_(u))
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
74 #define URL_PATH(u) NPTR2STR(URL_PATH_(u))
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
75 #define URL_QUERY(u) NPTR2STR(URL_QUERY_(u))
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
76 #define URL_FRAGMENT(u) NPTR2STR(URL_FRAGMENT_(u))
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
77 #define URL_HOST(u) NPTR2STR(URL_HOST_(u))
157
49d4a18c4928 - Switched URL_DATA type from char* to a dStr.
jcid
parents: 124
diff changeset
78 #define URL_DATA(u) URL_DATA_(u)
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
79 #define URL_ALT(u) NPTR2STR(URL_ALT_(u))
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
80 #define URL_STR(u) NPTR2STR(URL_STR_(u))
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
81 #define URL_PORT(u) URL_PORT_(u)
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
82 #define URL_FLAGS(u) URL_FLAGS_(u)
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
83 #define URL_ILLEGAL_CHARS(u) URL_ILLEGAL_CHARS_(u)
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
84 #define URL_ILLEGAL_CHARS_SPC(u) URL_ILLEGAL_CHARS_SPC_(u)
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
85
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
86
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
87 typedef struct _DilloUrl DilloUrl;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
88
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
89 #ifdef __cplusplus
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
90 extern "C" {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
91 #endif /* __cplusplus */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
92
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
93 struct _DilloUrl {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
94 Dstr *url_string;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
95 const char *buffer;
442
68639eb89297 - Reduced warnings with gcc-4.3.
jcid
parents: 339
diff changeset
96 const char *scheme; /**/
68639eb89297 - Reduced warnings with gcc-4.3.
jcid
parents: 339
diff changeset
97 const char *authority; /**/
68639eb89297 - Reduced warnings with gcc-4.3.
jcid
parents: 339
diff changeset
98 const char *path; /* These are references only */
68639eb89297 - Reduced warnings with gcc-4.3.
jcid
parents: 339
diff changeset
99 const char *query; /* (no need to free them) */
68639eb89297 - Reduced warnings with gcc-4.3.
jcid
parents: 339
diff changeset
100 const char *fragment; /**/
68639eb89297 - Reduced warnings with gcc-4.3.
jcid
parents: 339
diff changeset
101 const char *hostname; /**/
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
102 int port;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
103 int flags;
157
49d4a18c4928 - Switched URL_DATA type from char* to a dStr.
jcid
parents: 124
diff changeset
104 Dstr *data; /* POST */
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
105 const char *alt; /* "alt" text (used by image maps) */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
106 int ismap_url_len; /* Used by server side image maps */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
107 int illegal_chars; /* number of illegal chars */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
108 int illegal_chars_spc; /* number of illegal space chars */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
109 };
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
110
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
111
334
619177c88430 - Forbid dpi GET and POST from non dpi-generated urls.
jcid
parents: 210
diff changeset
112 DilloUrl* a_Url_new(const char *url_str, const char *base_url);
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
113 void a_Url_free(DilloUrl *u);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
114 char *a_Url_str(const DilloUrl *url);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
115 const char *a_Url_hostname(const DilloUrl *u);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
116 DilloUrl* a_Url_dup(const DilloUrl *u);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
117 int a_Url_cmp(const DilloUrl *A, const DilloUrl *B);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
118 void a_Url_set_flags(DilloUrl *u, int flags);
157
49d4a18c4928 - Switched URL_DATA type from char* to a dStr.
jcid
parents: 124
diff changeset
119 void a_Url_set_data(DilloUrl *u, Dstr **data);
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
120 void a_Url_set_alt(DilloUrl *u, const char *alt);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
121 void a_Url_set_ismap_coords(DilloUrl *u, char *coord_str);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
122 char *a_Url_decode_hex_str(const char *str);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
123 char *a_Url_encode_hex_str(const char *str);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
124 char *a_Url_string_strip_delimiters(const char *str);
1644
2650456b8199 filter automatic requests
corvid <corvid@lavabit.com>
parents: 1186
diff changeset
125 const char *a_Url_host_find_public_suffix(const char *host);
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
126 #ifdef __cplusplus
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
127 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
128 #endif /* __cplusplus */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
129
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
130 #endif /* __URL_H__ */