summaryrefslogtreecommitdiff
path: root/content/urldb.h
blob: adf13c11baf0d8811668d61057454a95dd2bde88 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
/*
 * This file is part of NetSurf, http://netsurf-browser.org/
 * Licensed under the GNU General Public License,
 *                http://www.opensource.org/licenses/gpl-license
 * Copyright 2006 John M Bell <jmb202@ecs.soton.ac.uk>
 */

/** \file
 * Unified URL information database (interface)
 */

#ifndef _NETSURF_CONTENT_URLDB_H_
#define _NETSURF_CONTENT_URLDB_H_

#include <stdbool.h>
#include <time.h>
#include "netsurf/content/content.h"
#include "netsurf/content/content_type.h"

typedef enum {
	COOKIE_NETSCAPE = 0,
	COOKIE_RFC2109 = 1,
	COOKIE_RFC2965 = 2
} cookie_version;

struct url_data {
	const char *title;		/**< Resource title */
	unsigned int visits;		/**< Visit count */
	time_t last_visit;		/**< Last visit time */
	content_type type;		/**< Type of resource */
};

struct cookie_data {
	const char *name;		/**< Cookie name */
	const char *value;		/**< Cookie value */
	const char *comment;		/**< Cookie comment */
	const bool domain_from_set;	/**< Domain came from Set-Cookie: header */
	const char *domain;		/**< Domain */
	const bool path_from_set;	/**< Path came from Set-Cookie: header */
	const char *path;		/**< Path */
	const time_t expires;		/**< Expiry timestamp, or 1 for session */
	const time_t last_used;		/**< Last used time */
	const bool secure;		/**< Only send for HTTPS requests */
	cookie_version version;		/**< Specification compliance */
	const bool no_destroy;		/**< Never destroy this cookie,
				 	* unless it's expired */

	const struct cookie_data *prev;	/**< Previous in list */
	const struct cookie_data *next;	/**< Next in list */
};

struct bitmap;

/* Destruction */
void urldb_destroy(void);

/* Persistence support */
void urldb_load(const char *filename);
void urldb_save(const char *filename);
void urldb_set_url_persistence(const char *url, bool persist);

/* URL insertion */
bool urldb_add_url(const char *url);

/* URL data modification / lookup */
void urldb_set_url_title(const char *url, const char *title);
void urldb_set_url_content_type(const char *url, content_type type);
void urldb_update_url_visit_data(const char *url);
void urldb_reset_url_visit_data(const char *url);
const struct url_data *urldb_get_url_data(const char *url);
const char *urldb_get_url(const char *url);

/* Authentication modification / lookup */
void urldb_set_auth_details(const char *url, const char *realm,
		const char *auth);
const char *urldb_get_auth_details(const char *url);

/* SSL certificate permissions */
void urldb_set_cert_permissions(const char *url, bool permit);
bool urldb_get_cert_permissions(const char *url);

/* Thumbnail handling */
void urldb_set_thumbnail(const char *url, struct bitmap *bitmap);
const struct bitmap *urldb_get_thumbnail(const char *url);

/* URL completion */
void urldb_iterate_partial(const char *prefix,
		bool (*callback)(const char *url,
		const struct url_data *data));

/* Iteration */
void urldb_iterate_entries(bool (*callback)(const char *url,
		const struct url_data *data));
void urldb_iterate_cookies(bool (*callback)(const char *domain,
		const struct cookie_data *cookie));

/* Debug */
void urldb_dump(void);

/* Cookies */
bool urldb_set_cookie(const char *header, const char *url,
		const char *referer);
char *urldb_get_cookie(const char *url);
void urldb_delete_cookie(const char *domain, const char *path, const char *name);
void urldb_load_cookies(const char *filename);
void urldb_save_cookies(const char *filename);

/* Cache */
bool urldb_set_cache_data(const char *url, const struct content *content);
char *urldb_get_cache_data(const char *url);

#endif