NetSurf
urldb.h
Go to the documentation of this file.
1/*
2 * Copyright 2006 John M Bell <jmb202@ecs.soton.ac.uk>
3 *
4 * This file is part of NetSurf, http://www.netsurf-browser.org/
5 *
6 * NetSurf 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; version 2 of the License.
9 *
10 * NetSurf is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19/**
20 * \file
21 * Unified URL information database internal interface.
22 */
23
24#ifndef NETSURF_CONTENT_URLDB_H
25#define NETSURF_CONTENT_URLDB_H
26
27#include <libwapcaplet/libwapcaplet.h>
28
29#include "netsurf/url_db.h"
30#include "netsurf/cookie_db.h"
31
32/**
33 * Destroy urldb
34 */
35void urldb_destroy(void);
36
37
38/**
39 * Set the cross-session persistence of the entry for an URL
40 *
41 * \param url Absolute URL to persist
42 * \param persist True to persist, false otherwise
43 * \return NSERROR_OK on success or NSERROR_NOT_FOUND if url not in database
44 */
45nserror urldb_set_url_persistence(struct nsurl *url, bool persist);
46
47
48/**
49 * Insert an URL into the database
50 *
51 * \param url Absolute URL to insert
52 * \return true on success, false otherwise
53 */
54bool urldb_add_url(struct nsurl *url);
55
56
57/**
58 * Set an URL's title string, replacing any existing one
59 *
60 * \param url The URL to look for
61 * \param title The title string to use (copied)
62 * \return NSERROR_OK on success otherwise appropriate error code
63 */
64nserror urldb_set_url_title(struct nsurl *url, const char *title);
65
66
67/**
68 * Set an URL's content type
69 *
70 * \param url The URL to look for
71 * \param type The type to set
72 * \return NSERROR_OK on success or NSERROR_NOT_FOUND if url not in database
73 */
75
76
77/**
78 * Set authentication data for an URL
79 *
80 * \param url The URL to consider
81 * \param realm The authentication realm
82 * \param auth The authentication details (in form username:password)
83 */
84void urldb_set_auth_details(struct nsurl *url, const char *realm, const char *auth);
85
86
87/**
88 * Look up authentication details in database
89 *
90 * \param url Absolute URL to search for
91 * \param realm When non-NULL, it is realm which can be used to determine
92 * the protection space when that's not been done before for given URL.
93 * \return Pointer to authentication details, or NULL if not found
94 */
95const char *urldb_get_auth_details(struct nsurl *url, const char *realm);
96
97
98/**
99 * Update an URL's visit data
100 *
101 * \param url The URL to update
102 * \return NSERROR_OK on success or NSERROR_NOT_FOUND if url not in database
103 */
105
106
107/**
108 * Reset an URL's visit statistics
109 *
110 * \param url The URL to reset
111 */
112void urldb_reset_url_visit_data(struct nsurl *url);
113
114
115/**
116 * Extract an URL from the db
117 *
118 * \param url URL to extract
119 * \return Pointer to database's copy of URL or NULL if not found
120 */
121struct nsurl *urldb_get_url(struct nsurl *url);
122
123
124/**
125 * Retrieve certificate verification permissions from database
126 *
127 * \param url Absolute URL to search for
128 * \return true to permit connections to hosts with invalid certificates,
129 * false otherwise.
130 */
131bool urldb_get_cert_permissions(struct nsurl *url);
132
133
134/**
135 * Parse Set-Cookie header and insert cookie(s) into database
136 *
137 * \param header Header to parse, with Set-Cookie: stripped
138 * \param url URL being fetched
139 * \param referrer Referring resource, or 0 for verifiable transaction
140 * \return true on success, false otherwise
141 */
142bool urldb_set_cookie(const char *header, struct nsurl *url, struct nsurl *referrer);
143
144
145/**
146 * Retrieve cookies for an URL
147 *
148 * \param url URL being fetched
149 * \param include_http_only Whether to include HTTP(S) only cookies.
150 * \return Cookies string for libcurl (on heap), or NULL on error/no cookies
151 */
152char *urldb_get_cookie(struct nsurl *url, bool include_http_only);
153
154
155/**
156 * Set HSTS policy for an URL
157 *
158 * \param url URL being fetched
159 * \param header Strict-Transport-Security header value
160 * \return true on success, false otherwise
161 */
162bool urldb_set_hsts_policy(struct nsurl *url, const char *header);
163
164
165/**
166 * Determine if HSTS policy is enabled for an URL
167 *
168 * \param url URL being fetched
169 * \return true if HSTS policy is enabled, false otherwise
170 */
171bool urldb_get_hsts_enabled(struct nsurl *url);
172
173#endif
content_type
The type of a content.
Definition: content_type.h:53
Unified cookie database public interface.
nserror
Enumeration of error codes.
Definition: errors.h:29
const char * type
Definition: filetype.cpp:44
struct nsurl nsurl
NetSurf URL object.
Definition: nsurl.h:31
Unified URL information database public interface.
void urldb_destroy(void)
Destroy urldb.
Definition: urldb.c:2847
bool urldb_add_url(struct nsurl *url)
Insert an URL into the database.
Definition: urldb.c:3140
nserror urldb_set_url_title(struct nsurl *url, const char *title)
Set an URL's title string, replacing any existing one.
Definition: urldb.c:3226
struct nsurl * urldb_get_url(struct nsurl *url)
Extract an URL from the db.
Definition: urldb.c:3327
nserror urldb_update_url_visit_data(struct nsurl *url)
Update an URL's visit data.
Definition: urldb.c:3274
bool urldb_get_hsts_enabled(struct nsurl *url)
Determine if HSTS policy is enabled for an URL.
Definition: urldb.c:3573
void urldb_set_auth_details(struct nsurl *url, const char *realm, const char *auth)
Set authentication data for an URL.
Definition: urldb.c:3342
void urldb_reset_url_visit_data(struct nsurl *url)
Reset an URL's visit statistics.
Definition: urldb.c:3293
bool urldb_set_hsts_policy(struct nsurl *url, const char *header)
Set HSTS policy for an URL.
Definition: urldb.c:3502
char * urldb_get_cookie(struct nsurl *url, bool include_http_only)
Retrieve cookies for an URL.
Definition: urldb.c:3997
const char * urldb_get_auth_details(struct nsurl *url, const char *realm)
Look up authentication details in database.
Definition: urldb.c:3405
nserror urldb_set_url_content_type(struct nsurl *url, content_type type)
Set an URL's content type.
Definition: urldb.c:3256
bool urldb_set_cookie(const char *header, struct nsurl *url, struct nsurl *referrer)
Parse Set-Cookie header and insert cookie(s) into database.
Definition: urldb.c:3734
nserror urldb_set_url_persistence(struct nsurl *url, bool persist)
Set the cross-session persistence of the entry for an URL.
Definition: urldb.c:3122
bool urldb_get_cert_permissions(struct nsurl *url)
Retrieve certificate verification permissions from database.
Definition: urldb.c:3480