NetSurf
fetch.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
21 *
22 * Interface to platform-specific fetcher operations.
23 */
24
25#ifndef _NETSURF_FETCH_H_
26#define _NETSURF_FETCH_H_
27
28struct nsurl;
29
30/**
31 * function table for fetcher operations.
32 */
34 /* Mandantory entries */
35
36 /**
37 * Determine the MIME type of a local file.
38 *
39 * @note used in file fetcher
40 *
41 * \param unix_path Unix style path to file on disk
42 * \return Pointer to MIME type string (should not be freed) -
43 * invalidated on next call to fetch_filetype.
44 */
45 const char *(*filetype)(const char *unix_path);
46
47 /* Optional entries */
48
49 /**
50 * Translate resource to full url.
51 *
52 * @note Only used in resource protocol fetcher
53 *
54 * Transforms a resource protocol path into a full URL. The returned URL
55 * is used as the target for a redirect. The caller takes ownership of
56 * the returned nsurl including unrefing it when finished with it.
57 *
58 * \param path The path of the resource to locate.
59 * \return A netsurf url object containing the full URL of the resource
60 * path or NULL if a suitable resource URL can not be generated.
61 */
62 struct nsurl* (*get_resource_url)(const char *path);
63
64 /**
65 * Translate resource to source data.
66 *
67 * @note Only used in resource fetcher
68 *
69 * Obtains the data for a resource directly
70 *
71 * \param path The path of the resource to locate.
72 * \param data Pointer to recive data into
73 * \param data_len Pointer to length of returned data
74 * \return NSERROR_OK and the data and length values updated
75 * else appropriate error code.
76 */
77 nserror (*get_resource_data)(const char *path, const uint8_t **data, size_t *data_len);
78
79 /**
80 * Releases source data.
81 *
82 * @note Only used in resource fetcher
83 *
84 * Releases source data obtained from get_resource_data()
85 *
86 * \param data The value returned from a previous get_resource_data call
87 * \return NSERROR_OK on success else appropriate error code.
88 */
89 nserror (*release_resource_data)(const uint8_t *data);
90
91 /**
92 * Find a MIME type for a local file
93 *
94 * @note only used in curl fetcher in form file controls on
95 * RISC OS otherwise its a strdup of a filetype call.
96 *
97 * \param ro_path RISC OS style path to file on disk
98 * \return MIME type string (on heap, caller should free), or NULL
99 */
100 char *(*mimetype)(const char *ro_path);
101
102 /**
103 * Open a socket
104 *
105 * \param domain Communication domain
106 * \param type Socket type
107 * \param protocol Protocol
108 * \return Socket descriptor on success, -1 on error and errno set
109 */
110 int (*socket_open)(int domain, int type, int protocol);
111
112 /**
113 * Close a socket
114 *
115 * \param socket Socket descriptor
116 * \return 0 on success, -1 on error and errno set
117 */
118 int (*socket_close)(int socket);
119};
120
121#endif
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
function table for fetcher operations.
Definition: fetch.h:33
nserror(* release_resource_data)(const uint8_t *data)
Releases source data.
Definition: fetch.h:89
nserror(* get_resource_data)(const char *path, const uint8_t **data, size_t *data_len)
Translate resource to source data.
Definition: fetch.h:77
int(* socket_close)(int socket)
Close a socket.
Definition: fetch.h:118
int(* socket_open)(int domain, int type, int protocol)
Open a socket.
Definition: fetch.h:110
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