NetSurf
fetchers.h
Go to the documentation of this file.
1/*
2 * Copyright 2014 Vincent Sanders <vince@netsurf-browser.org>
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 content/fetchers.h
21 *
22 * Interface for fetchers factory.
23 */
24
25#ifndef _NETSURF_DESKTOP_FETCHERS_H_
26#define _NETSURF_DESKTOP_FETCHERS_H_
27
28#include "utils/inet.h" /* this is necessary for the fd_set definition */
29#include <libwapcaplet/libwapcaplet.h>
30
31struct nsurl;
33struct fetch;
34
35/**
36 * Fetcher operations API
37 *
38 * These are the operations a fetcher must implement.
39 *
40 * Each fetcher is called once for initialisaion and finalisation.
41 * The poll entry point will be called to allow all active fetches to progress.
42 * The flow of a fetch operation is:
43 * URL is checked for aceptability.
44 * setup with all applicable data.
45 * start is called before the first poll
46 * after completion or abort it is freed
47 *
48 */
50 /**
51 * The initialiser for the fetcher.
52 *
53 * Called once to initialise the fetcher.
54 */
55 bool (*initialise)(lwc_string *scheme);
56
57 /**
58 * Can this fetcher accept a url.
59 *
60 * \param url the URL to check
61 * \return true if the fetcher can handle the url else false.
62 */
63 bool (*acceptable)(const struct nsurl *url);
64
65 /**
66 * Setup a fetch
67 */
68 void *(*setup)(struct fetch *parent_fetch, struct nsurl *url,
69 bool only_2xx, bool downgrade_tls, const char *post_urlenc,
70 const struct fetch_multipart_data *post_multipart,
71 const char **headers);
72
73 /**
74 * start a fetch.
75 */
76 bool (*start)(void *fetch);
77
78 /**
79 * abort a fetch.
80 */
81 void (*abort)(void *fetch);
82
83 /**
84 * free a fetch allocated through the setup method.
85 */
86 void (*free)(void *fetch);
87
88 /**
89 * poll a fetcher to let it make progress.
90 */
91 void (*poll)(lwc_string *scheme);
92
93 /**
94 * update an fdset with the FDs needed to poll cleanly
95 */
96 int (*fdset)(lwc_string *scheme, fd_set *read_set, fd_set *write_set,
97 fd_set *error_set);
98
99 /**
100 * Finalise the fetcher.
101 */
102 void (*finalise)(lwc_string *scheme);
103};
104
105
106/**
107 * Register a fetcher for a scheme
108 *
109 * \param scheme The scheme fetcher is for (caller relinquishes ownership)
110 * \param ops The operations for the fetcher.
111 * \return NSERROR_OK or appropriate error code.
112 */
113nserror fetcher_add(lwc_string *scheme, const struct fetcher_operation_table *ops);
114
115
116/**
117 * Initialise all registered fetchers.
118 *
119 * \return NSERROR_OK or error code
120 */
122
123
124/**
125 * Clean up for quit.
126 *
127 * Must be called before exiting.
128 */
129void fetcher_quit(void);
130
131
132#endif
nserror
Enumeration of error codes.
Definition: errors.h:29
void fetcher_quit(void)
Clean up for quit.
Definition: fetch.c:322
nserror fetcher_add(lwc_string *scheme, const struct fetcher_operation_table *ops)
Register a fetcher for a scheme.
Definition: fetch.c:357
nserror fetcher_init(void)
Initialise all registered fetchers.
Definition: fetch.c:285
static nserror fetch(nsurl *url, enum backing_store_flags bsflags, uint8_t **data_out, size_t *datalen_out)
Retrieve an object from the backing store.
internet structures and defines
struct nsurl nsurl
NetSurf URL object.
Definition: nsurl.h:31
Fetch POST multipart data.
Definition: fetch.h:109
Information for a single fetch.
Definition: fetch.c:89
Fetcher operations API.
Definition: fetchers.h:49
bool(* start)(void *fetch)
start a fetch.
Definition: fetchers.h:76
void(* free)(void *fetch)
free a fetch allocated through the setup method.
Definition: fetchers.h:86
void(* finalise)(lwc_string *scheme)
Finalise the fetcher.
Definition: fetchers.h:102
int(* fdset)(lwc_string *scheme, fd_set *read_set, fd_set *write_set, fd_set *error_set)
update an fdset with the FDs needed to poll cleanly
Definition: fetchers.h:96
void(* abort)(void *fetch)
abort a fetch.
Definition: fetchers.h:81
bool(* initialise)(lwc_string *scheme)
The initialiser for the fetcher.
Definition: fetchers.h:55
void(* poll)(lwc_string *scheme)
poll a fetcher to let it make progress.
Definition: fetchers.h:91
bool(* acceptable)(const struct nsurl *url)
Can this fetcher accept a url.
Definition: fetchers.h:63