30#include <libwapcaplet/libwapcaplet.h>
47#define DIRECT_ETAG_VALUE 123456
64 "icons/directory.png",
65 "icons/directory2.png",
66 "icons/hotlist-add.png",
67 "icons/hotlist-rmv.png",
119 const char *fmt, ...)
127 len = vsnprintf(header,
sizeof header, fmt, ap);
130 if (len >= (
int)
sizeof(header) || len < 0) {
184 goto fetch_resource_data_aborted;
190 goto fetch_resource_data_aborted;
196 goto fetch_resource_data_aborted;
201 "Cache-Control: max-age=31536000")) {
202 goto fetch_resource_data_aborted;
215fetch_resource_data_aborted:
233 goto fetch_resource_notfound_handler_aborted;
235 snprintf(key,
sizeof key,
"HTTP%03d", code);
241 "<link rel=\"stylesheet\" type=\"text/css\" "
242 "href=\"resource:internal.css\">\n"
244 "<body class=\"ns-even-bg ns-even-fg ns-border\" "
245 "id =\"fetcherror\">\n"
246 "<h1 class=\"ns-border ns-odd-fg-bad\">%s</h1>\n"
247 "<p>%s %d %s %s</p>\n"
248 "</body>\n</html>\n",
257 goto fetch_resource_notfound_handler_aborted;
262fetch_resource_notfound_handler_aborted:
282 &e->
path) != lwc_error_ok) {
296 NSLOG(netsurf, INFO,
"direct data for %s",
302 lwc_string_unref(e->
path);
304 NSLOG(netsurf, INFO,
"redirect url for %s",
342 const char *post_urlenc,
344 const char **headers)
351 ctx = calloc(1,
sizeof(*ctx));
363 if (lwc_string_isequal(
path,
365 &match) == lwc_error_ok && match) {
377 lwc_string_unref(
path);
383 for (i = 0; headers[i] != NULL; i++) {
384 if (strncasecmp(headers[i],
"If-None-Match:",
385 SLEN(
"If-None-Match:")) != 0) {
390 const char *d = headers[i] +
SLEN(
"If-None-Match:");
393 while (*d !=
'\0' && (*d <
'0' ||
'9' < *d))
401 "Bad If-None-Match value");
446 while (
ring != NULL) {
481 lwc_string *scheme = lwc_string_ref(corestring_lwc_resource);
static osspriteop_area * buffer
The buffer characteristics.
void fetch_set_http_code(struct fetch *fetch, long http_code)
set the http code of a fetch
nserror fetcher_add(lwc_string *scheme, const struct fetcher_operation_table *ops)
Register a fetcher for a scheme.
void fetch_send_callback(const fetch_msg *msg, struct fetch *fetch)
send message to fetch
void fetch_free(struct fetch *f)
Free a fetch structure and associated resources.
void fetch_remove_from_queues(struct fetch *fetch)
remove a queued fetch
Fetching of data from a URL (interface).
Useful interned string pointers (interface).
nserror
Enumeration of error codes.
Interface for fetchers factory.
#define NOF_ELEMENTS(array)
struct netsurf_table * guit
The global interface table.
Interface to core interface table.
Interface to platform-specific fetcher operations.
Netsurf additional integer type formatting macros.
#define PRIsizet
c99 standard printf formatting for size_t type
#define NSLOG(catname, level, logmsg, args...)
const char * messages_get(const char *key)
Fast lookup of a message by key from the standard Messages hash.
Localised message support (interface).
NetSurf URL handling (interface).
void nsurl_unref(nsurl *url)
Drop a reference to a NetSurf URL object.
const char * nsurl_access(const nsurl *url)
Access a NetSurf URL object as a string.
nsurl * nsurl_ref(nsurl *url)
Increment the reference count to a NetSurf URL object.
lwc_string * nsurl_get_component(const nsurl *url, nsurl_component part)
Get part of a URL as a lwc_string, from a NetSurf URL object.
struct nsurl nsurl
NetSurf URL object.
static bool fetch_resource_send_header(struct fetch_resource_context *ctx, const char *fmt,...)
static void fetch_resource_poll(lwc_string *scheme)
callback to poll for additional resource fetch contents
static struct fetch_resource_map_entry fetch_resource_map[NOF_ELEMENTS(fetch_resource_paths)]
static void fetch_resource_finalise(lwc_string *scheme)
callback to finalise the resource fetcher.
static bool fetch_resource_start(void *ctx)
callback to start a resource fetch
bool(* fetch_resource_handler)(struct fetch_resource_context *)
static void fetch_resource_free(void *ctx)
callback to free a resource fetch
static bool fetch_resource_notfound_handler(struct fetch_resource_context *ctx)
static void fetch_resource_abort(void *ctx)
callback to abort a resource fetch
static void * fetch_resource_setup(struct fetch *fetchh, nsurl *url, bool only_2xx, bool downgrade_tls, const char *post_urlenc, const struct fetch_multipart_data *post_multipart, const char **headers)
set up a resource fetch context.
static bool fetch_resource_data_handler(struct fetch_resource_context *ctx)
static bool fetch_resource_can_fetch(const nsurl *url)
static struct fetch_resource_context * ring
nserror fetch_resource_register(void)
Register the resource scheme.
static uint32_t fetch_resource_path_count
static bool fetch_resource_initialise(lwc_string *scheme)
callback to initialise the resource fetcher.
static bool fetch_resource_send_callback(const fetch_msg *msg, struct fetch_resource_context *ctx)
issue fetch callbacks with locking
static bool fetch_resource_redirect_handler(struct fetch_resource_context *ctx)
resource handler that results in a redirect to another url.
#define DIRECT_ETAG_VALUE
static const char * fetch_resource_paths[]
Valid resource paths.
resource URL scheme handler interface.
#define RING_REMOVE(ring, element)
Remove the given element from the specified ring.
#define RING_INSERT(ring, element)
Insert the given item into the specified ring.
Interface to utility string handling.
struct fetch_msg::@118::@119 header_or_data
union fetch_msg::@118 data
Fetch POST multipart data.
Context for an resource fetch.
struct fetch_resource_map_entry * entry
resource map entry
bool aborted
Flag indicating fetch has been aborted.
bool locked
Flag indicating entry is already entered.
fetch_resource_handler handler
struct fetch_resource_context * r_next
struct fetch * fetchh
Handle for this fetch.
struct fetch_resource_context * r_prev
map of resource scheme paths to redirect urls
const uint8_t * data
direct pointer to data
size_t data_len
length of direct data
nsurl * redirect_url
url to redirect to
lwc_string * path
resource scheme path
Information for a single fetch.
bool(* initialise)(lwc_string *scheme)
The initialiser for the fetcher.
const char *(* filetype)(const char *unix_path)
Determine the MIME type of a local file.
nserror(* release_resource_data)(const uint8_t *data)
Releases source data.
nserror(* get_resource_data)(const char *path, const uint8_t **data, size_t *data_len)
Translate resource to source data.
struct nsurl *(* get_resource_url)(const char *path)
Translate resource to full url.
struct gui_fetch_table * fetch
Fetcher table.
nserror nsc_snptimet(const char *str, size_t size, time_t *timep)
Parse time in seconds since epoc.
Interface to time operations.
Interface to a number of general purpose functionality.
#define SLEN(x)
Calculate length of constant C string.
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.