Dillo v3.1.1-98-g318d1f14
Loading...
Searching...
No Matches
url.h
Go to the documentation of this file.
1/*
2 * File : url.h - Dillo
3 *
4 * Copyright (C) 2001 Jorge Arellano Cid <jcid@dillo.org>
5 *
6 */
7
12#ifndef __URL_H__
13#define __URL_H__
14
15#include "d_size.h"
16#include "../dlib/dlib.h"
17
18
19#define URL_HTTP_PORT 80
20#define URL_HTTPS_PORT 443
21
22/* for a_Url_host_type() */
23#define URL_HOST_ERROR -1
24#define URL_HOST_NAME 0
25#define URL_HOST_IPV4 1
26#define URL_HOST_IPV6 2
27
28/*
29 * Values for DilloUrl->flags.
30 * Specifies which which action to perform with an URL.
31 */
32#define URL_Get (1 << 0)
33#define URL_Post (1 << 1)
34
35#define URL_E2EQuery (1 << 5)
36#define URL_ReloadPage (1 << 7)
37#define URL_ReloadFromCache (1 << 8)
38
39#define URL_IgnoreScroll (1 << 9)
40#define URL_SpamSafe (1 << 10)
41
42#define URL_MultipartEnc (1 << 11)
43
44/*
45 * Access methods to fields inside DilloURL.
46 * (non '_'-ended macros MUST use these for initialization sake)
47 */
48/* these MAY return NULL: */
49#define URL_SCHEME_(u) (u)->scheme
50#define URL_AUTHORITY_(u) (u)->authority
51#define URL_PATH_(u) (u)->path
52#define URL_QUERY_(u) (u)->query
53#define URL_FRAGMENT_(u) (u)->fragment
54#define URL_HOST_(u) a_Url_hostname(u)
55#define URL_STR_(u) a_Url_str(u)
56/* this returns a Dstr* */
57#define URL_DATA_(u) (u)->data
58/* these return an integer */
59#define URL_PORT_(u) (URL_HOST(u), (u)->port)
60#define URL_FLAGS_(u) (u)->flags
61#define URL_ILLEGAL_CHARS_(u) (u)->illegal_chars
62#define URL_ILLEGAL_CHARS_SPC_(u) (u)->illegal_chars_spc
63
64/*
65 * Access methods that never return NULL.
66 * When the "empty" and "undefined" concepts of RFC-2396 are irrelevant to
67 * the caller, and a string is required, use these methods instead:
68 */
69#define NPTR2STR(p) ((p) ? (p) : "")
70#define URL_SCHEME(u) NPTR2STR(URL_SCHEME_(u))
71#define URL_AUTHORITY(u) NPTR2STR(URL_AUTHORITY_(u))
72#define URL_PATH(u) NPTR2STR(URL_PATH_(u))
73#define URL_QUERY(u) NPTR2STR(URL_QUERY_(u))
74#define URL_FRAGMENT(u) NPTR2STR(URL_FRAGMENT_(u))
75#define URL_HOST(u) NPTR2STR(URL_HOST_(u))
76#define URL_STR(u) NPTR2STR(URL_STR_(u))
77#define URL_DATA(u) URL_DATA_(u)
78#define URL_PORT(u) URL_PORT_(u)
79#define URL_FLAGS(u) URL_FLAGS_(u)
80#define URL_ILLEGAL_CHARS(u) URL_ILLEGAL_CHARS_(u)
81#define URL_ILLEGAL_CHARS_SPC(u) URL_ILLEGAL_CHARS_SPC_(u)
82
83
84#ifdef __cplusplus
85extern "C" {
86#endif /* __cplusplus */
87
88typedef struct {
90 const char *buffer;
91 const char *scheme;
92 const char *authority;
93 const char *path; /* These are references only */
94 const char *query; /* (no need to free them) */
95 const char *fragment;
96 const char *hostname;
97 int port;
98 int flags;
103} DilloUrl;
104
105
106DilloUrl* a_Url_new(const char *url_str, const char *base_url);
107void a_Url_free(DilloUrl *u);
108char *a_Url_str(const DilloUrl *url);
109const char *a_Url_hostname(const DilloUrl *u);
110DilloUrl* a_Url_dup(const DilloUrl *u);
111int a_Url_cmp(const DilloUrl *A, const DilloUrl *B);
112void a_Url_set_flags(DilloUrl *u, int flags);
113void a_Url_set_data(DilloUrl *u, Dstr **data);
114void a_Url_set_ismap_coords(DilloUrl *u, char *coord_str);
115char *a_Url_decode_hex_str(const char *str);
116char *a_Url_encode_hex_str(const char *str);
117char *a_Url_string_strip_delimiters(const char *str);
118int a_Url_host_type(const char *host);
119bool_t a_Url_same_organization(const DilloUrl *u1, const DilloUrl *u2);
120#ifdef __cplusplus
121}
122#endif /* __cplusplus */
123
124#endif /* __URL_H__ */
unsigned char bool_t
Definition d_size.h:21
Definition url.h:88
int illegal_chars_spc
number of illegal space chars
Definition url.h:102
const char * buffer
Definition url.h:90
Dstr * data
POST.
Definition url.h:99
int ismap_url_len
Used by server side image maps.
Definition url.h:100
const char * fragment
Definition url.h:95
const char * query
Definition url.h:94
int illegal_chars
number of illegal chars
Definition url.h:101
const char * path
Definition url.h:93
Dstr * url_string
Definition url.h:89
const char * hostname
Definition url.h:96
int port
Definition url.h:97
const char * scheme
Definition url.h:91
const char * authority
Definition url.h:92
int flags
Definition url.h:98
Definition dlib.h:102
char * a_Url_string_strip_delimiters(const char *str)
RFC-3986 suggests this stripping when "importing" URLs from other media.
Definition url.c:658
void a_Url_set_flags(DilloUrl *u, int flags)
Set DilloUrl flags.
Definition url.c:527
char * a_Url_encode_hex_str(const char *str)
Urlencode 'str'.
Definition url.c:620
int a_Url_cmp(const DilloUrl *A, const DilloUrl *B)
Compare two Url's to check if they're the same, or which one is bigger.
Definition url.c:506
bool_t a_Url_same_organization(const DilloUrl *u1, const DilloUrl *u2)
Definition url.c:798
void a_Url_set_ismap_coords(DilloUrl *u, char *coord_str)
Set DilloUrl ismap coordinates.
Definition url.c:549
void a_Url_set_data(DilloUrl *u, Dstr **data)
Set DilloUrl data (like POST info, etc.)
Definition url.c:536
const char * a_Url_hostname(const DilloUrl *u)
Return the hostname as a string.
Definition url.c:98
void a_Url_free(DilloUrl *u)
Free a DilloUrl.
Definition url.c:208
char * a_Url_decode_hex_str(const char *str)
Parse possible hexadecimal octets in the URI path.
Definition url.c:586
DilloUrl * a_Url_new(const char *url_str, const char *base_url)
Transform (and resolve) an URL string into the respective DilloURL.
Definition url.c:371
char * a_Url_str(const DilloUrl *url)
Return the url as a string.
Definition url.c:66
int a_Url_host_type(const char *host)
What type of host is this?
Definition url.c:683
DilloUrl * a_Url_dup(const DilloUrl *u)
Duplicate a Url structure.
Definition url.c:477