NetSurf
|
file scheme URL handling. More...
#include "utils/config.h"
#include <stdlib.h>
#include <ctype.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <errno.h>
#include <stdbool.h>
#include <string.h>
#include <strings.h>
#include <time.h>
#include <stdio.h>
#include <stdarg.h>
#include <libwapcaplet/libwapcaplet.h>
#include "netsurf/inttypes.h"
#include "utils/nsurl.h"
#include "utils/dirent.h"
#include "utils/corestrings.h"
#include "utils/messages.h"
#include "utils/utils.h"
#include "utils/log.h"
#include "utils/ring.h"
#include "utils/file.h"
#include "netsurf/fetch.h"
#include "desktop/gui_internal.h"
#include "content/fetch.h"
#include "content/fetchers.h"
#include "dirlist.h"
#include "file.h"
Go to the source code of this file.
Data Structures | |
struct | fetch_file_context |
Context for a fetch. More... | |
Macros | |
#define | FETCH_FILE_MAX_BUF_SIZE (1024 * 1024) |
Functions | |
static bool | fetch_file_send_callback (const fetch_msg *msg, struct fetch_file_context *ctx) |
issue fetch callbacks with locking More... | |
static bool | fetch_file_send_header (struct fetch_file_context *ctx, const char *fmt,...) |
static bool | fetch_file_initialise (lwc_string *scheme) |
callback to initialise the file fetcher. More... | |
static void | fetch_file_finalise (lwc_string *scheme) |
callback to initialise the file fetcher. More... | |
static bool | fetch_file_can_fetch (const nsurl *url) |
static void * | fetch_file_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) |
callback to set up a file fetch context. More... | |
static void | fetch_file_free (void *ctx) |
callback to free a file fetch More... | |
static bool | fetch_file_start (void *ctx) |
callback to start a file fetch More... | |
static void | fetch_file_abort (void *ctx) |
callback to abort a file fetch More... | |
static int | fetch_file_errno_to_http_code (int error_no) |
static void | fetch_file_process_error (struct fetch_file_context *ctx, int code) |
static void | fetch_file_process_plain (struct fetch_file_context *ctx, struct stat *fdstat) |
Process object as a regular file. More... | |
static char * | gen_nice_title (char *path) |
static nserror | process_dir_ent (struct fetch_file_context *ctx, struct dirent *ent, bool even, char *buffer, size_t buffer_len) |
Generate an output row of the directory listing. More... | |
static int | dir_sort_alpha (const struct dirent **d1, const struct dirent **d2) |
Comparison function for sorting directories. More... | |
static void | fetch_file_process_dir (struct fetch_file_context *ctx, struct stat *fdstat) |
static void | fetch_file_process (struct fetch_file_context *ctx) |
static void | fetch_file_poll (lwc_string *scheme) |
callback to poll for additional file fetch contents More... | |
nserror | fetch_file_register (void) |
Register file scheme handler. More... | |
Variables | |
static struct fetch_file_context * | ring = NULL |
file scheme URL handling.
Based on the data fetcher by Rob Kendrick
output dates and directory ordering are affected by the current locale
Definition in file file.c.
|
static |
Comparison function for sorting directories.
Correctly orders non zero-padded numerical parts. ie. produces "file1, file2, file10" rather than "file1, file10, file2".
d1 | first directory entry |
d2 | second directory entry |
Definition at line 632 of file file.c.
Referenced by fetch_file_process_dir().
|
static |
callback to abort a file fetch
Definition at line 208 of file file.c.
References fetch_file_context::aborted.
Referenced by fetch_file_register().
|
static |
Definition at line 130 of file file.c.
Referenced by fetch_file_register().
|
static |
Definition at line 219 of file file.c.
Referenced by fetch_file_process(), fetch_file_process_dir(), and fetch_file_process_plain().
|
static |
callback to initialise the file fetcher.
Definition at line 126 of file file.c.
Referenced by fetch_file_register().
|
static |
callback to free a file fetch
Definition at line 193 of file file.c.
References nsurl_unref(), fetch_file_context::path, and fetch_file_context::url.
Referenced by fetch_file_register().
|
static |
callback to initialise the file fetcher.
Definition at line 120 of file file.c.
Referenced by fetch_file_register().
|
static |
callback to poll for additional file fetch contents
Definition at line 801 of file file.c.
References fetch_file_context::aborted, fetch_file_process(), fetch_free(), fetch_remove_from_queues(), fetch_file_context::fetchh, fetch_file_context::locked, ring, RING_INSERT, and RING_REMOVE.
Referenced by fetch_file_register().
|
static |
< The objects stat
Definition at line 773 of file file.c.
References fetch_file_errno_to_http_code(), fetch_file_process_dir(), fetch_file_process_error(), fetch_file_process_plain(), and fetch_file_context::path.
Referenced by fetch_file_poll().
|
static |
Definition at line 665 of file file.c.
References fetch_file_context::aborted, fetch_msg::buf, buffer, fetch_msg::data, dir_sort_alpha(), dirlist_generate_bottom(), dirlist_generate_headings(), dirlist_generate_parent_link(), dirlist_generate_title(), dirlist_generate_top(), FETCH_DATA, fetch_file_errno_to_http_code(), fetch_file_process_error(), fetch_file_send_callback(), fetch_file_send_header(), FETCH_FINISHED, fetch_set_http_code(), fetch_file_context::fetchh, gen_nice_title(), fetch_msg::header_or_data, fetch_msg::len, NSERROR_OK, nsurl_access(), nsurl_compare(), NSURL_COMPLETE, nsurl_parent(), nsurl_unref(), fetch_file_context::path, process_dir_ent(), scandir(), fetch_msg::type, and fetch_file_context::url.
Referenced by fetch_file_process().
|
static |
Definition at line 235 of file file.c.
References fetch_msg::buf, buffer, fetch_msg::data, FETCH_DATA, fetch_file_send_callback(), fetch_file_send_header(), FETCH_FINISHED, fetch_set_http_code(), fetch_file_context::fetchh, fetch_msg::header_or_data, fetch_msg::len, messages_get(), nsurl_access(), fetch_msg::type, and fetch_file_context::url.
Referenced by fetch_file_process(), fetch_file_process_dir(), and fetch_file_process_plain().
|
static |
Process object as a regular file.
Definition at line 282 of file file.c.
References fetch_file_context::aborted, fetch_msg::buf, fetch_msg::data, fetch_msg::error, netsurf_table::fetch, FETCH_DATA, FETCH_ERROR, fetch_file_errno_to_http_code(), FETCH_FILE_MAX_BUF_SIZE, fetch_file_process_error(), fetch_file_send_callback(), fetch_file_send_header(), FETCH_FINISHED, FETCH_NOTMODIFIED, fetch_set_http_code(), fetch_file_context::fetchh, fetch_file_context::file_etag, gui_fetch_table::filetype, guit, fetch_msg::header_or_data, fetch_msg::len, fetch_file_context::path, PRId64, PRIsizet, and fetch_msg::type.
Referenced by fetch_file_process().
nserror fetch_file_register | ( | void | ) |
Register file scheme handler.
Definition at line 839 of file file.c.
References fetch_file_abort(), fetch_file_can_fetch(), fetch_file_finalise(), fetch_file_free(), fetch_file_initialise(), fetch_file_poll(), fetch_file_setup(), fetch_file_start(), fetcher_add(), and fetcher_operation_table::initialise.
Referenced by fetcher_init().
|
inlinestatic |
issue fetch callbacks with locking
Definition at line 86 of file file.c.
References fetch_file_context::aborted, fetch_send_callback(), fetch_file_context::fetchh, and fetch_file_context::locked.
Referenced by fetch_file_process_dir(), fetch_file_process_error(), fetch_file_process_plain(), and fetch_file_send_header().
|
static |
Definition at line 96 of file file.c.
References fetch_msg::buf, fetch_msg::data, fetch_file_send_callback(), FETCH_HEADER, fetch_msg::header_or_data, fetch_msg::len, and fetch_msg::type.
Referenced by fetch_file_process_dir(), fetch_file_process_error(), and fetch_file_process_plain().
|
static |
callback to set up a file fetch context.
Definition at line 137 of file file.c.
References fetch_file_context::fetchh, netsurf_table::file, fetch_file_context::file_etag, guit, nsc_snptimet(), NSERROR_OK, NSLOG, nsurl_ref(), gui_file_table::nsurl_to_path, fetch_file_context::path, ring, RING_INSERT, SLEN, and fetch_file_context::url.
Referenced by fetch_file_register().
|
static |
callback to start a file fetch
Definition at line 202 of file file.c.
Referenced by fetch_file_register().
|
static |
Definition at line 470 of file file.c.
References messages_get(), path(), and SLEN.
Referenced by fetch_file_process_dir().
|
static |
Generate an output row of the directory listing.
ctx | The file fetching context. |
ent | current directory entry. |
even | is the row an even row. |
buffer | The output buffer. |
buffer_len | The space available in the output buffer. |
Definition at line 534 of file file.c.
References buffer, dirlist_generate_row(), netsurf_table::fetch, netsurf_table::file, gui_fetch_table::filetype, guit, messages_get(), netsurf_mkpath(), NSERROR_BAD_PARAMETER, NSERROR_OK, nsurl_unref(), fetch_file_context::path, and gui_file_table::path_to_nsurl.
Referenced by fetch_file_process_dir().
|
static |
Definition at line 83 of file file.c.
Referenced by fetch_file_poll(), and fetch_file_setup().