NetSurf
cookie_db.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 cookie database public interface.
22 */
23
24#ifndef _NETSURF_COOKIE_DB_H_
25#define _NETSURF_COOKIE_DB_H_
26
27#include <stdbool.h>
28#include <time.h>
29
30/**
31 * Version of cookie
32 *
33 * RFC2109 and RFC2965 "HTTP State Management Mechanism" defined
34 * alternative versions of cookies. Nothing used them and these RFC
35 * are now obsoleted by RFC6265 which completely removes the
36 * alternative versions.
37 */
42};
43
45 const struct cookie_data *prev; /**< Previous in list */
46 const struct cookie_data *next; /**< Next in list */
47
48 const char *name; /**< Cookie name */
49 const char *value; /**< Cookie value */
50 const bool value_was_quoted; /**< Value was quoted in Set-Cookie: */
51 const char *comment; /**< Cookie comment */
52 const bool domain_from_set; /**< Domain came from Set-Cookie: header */
53 const char *domain; /**< Domain */
54 const bool path_from_set; /**< Path came from Set-Cookie: header */
55 const char *path; /**< Path */
56 const time_t expires; /**< Expiry timestamp, or 1 for session */
57 const time_t last_used; /**< Last used time */
58 const bool secure; /**< Only send for HTTPS requests */
59 const bool http_only; /**< Only expose to HTTP(S) requests */
60 enum cookie_version version; /**< Specification compliance */
61
62 /** Never destroy this cookie, unless it's expired */
63 const bool no_destroy;
64};
65
66/**
67 * Iterate over all cookies in database
68 *
69 * \param callback Function to callback for each entry
70 */
71void urldb_iterate_cookies(bool (*callback)(const struct cookie_data *cookie));
72
73/**
74 * Delete a cookie
75 *
76 * \param domain The cookie's domain
77 * \param path The cookie's path
78 * \param name The cookie's name
79 */
80void urldb_delete_cookie(const char *domain, const char *path, const char *name);
81
82/**
83 * Load a cookie file into the database
84 *
85 * \param filename File to load
86 */
87void urldb_load_cookies(const char *filename);
88
89/**
90 * Save persistent cookies to file
91 *
92 * \param filename Path to save to
93 */
94void urldb_save_cookies(const char *filename);
95
96
97
98#endif
void urldb_save_cookies(const char *filename)
Save persistent cookies to file.
Definition: urldb.c:4448
void urldb_iterate_cookies(bool(*callback)(const struct cookie_data *cookie))
Iterate over all cookies in database.
cookie_version
Version of cookie.
Definition: cookie_db.h:38
@ COOKIE_RFC2109
Definition: cookie_db.h:40
@ COOKIE_RFC2965
Definition: cookie_db.h:41
@ COOKIE_NETSCAPE
Definition: cookie_db.h:39
void urldb_delete_cookie(const char *domain, const char *path, const char *name)
Delete a cookie.
Definition: urldb.c:4273
void urldb_load_cookies(const char *filename)
Load a cookie file into the database.
Definition: urldb.c:4281
const char * comment
Cookie comment.
Definition: cookie_db.h:51
const struct cookie_data * prev
Previous in list.
Definition: cookie_db.h:45
const struct cookie_data * next
Next in list.
Definition: cookie_db.h:46
const char * name
Cookie name.
Definition: cookie_db.h:48
const bool path_from_set
Path came from Set-Cookie: header.
Definition: cookie_db.h:54
const bool http_only
Only expose to HTTP(S) requests.
Definition: cookie_db.h:59
const bool value_was_quoted
Value was quoted in Set-Cookie:
Definition: cookie_db.h:50
const time_t last_used
Last used time.
Definition: cookie_db.h:57
const char * domain
Domain.
Definition: cookie_db.h:53
enum cookie_version version
Specification compliance.
Definition: cookie_db.h:60
const bool domain_from_set
Domain came from Set-Cookie: header.
Definition: cookie_db.h:52
const bool secure
Only send for HTTPS requests.
Definition: cookie_db.h:58
const char * value
Cookie value.
Definition: cookie_db.h:49
const bool no_destroy
Never destroy this cookie, unless it's expired.
Definition: cookie_db.h:63
const char * path
Path.
Definition: cookie_db.h:55
const time_t expires
Expiry timestamp, or 1 for session.
Definition: cookie_db.h:56
Interface to time operations.
static nserror path(const struct redraw_context *ctx, const plot_style_t *pstyle, const float *p, unsigned int n, const float transform[6])
Plots a path.
Definition: plot.c:821