56#define MAX_LINE_LEN 256
88 if ((stat(
"/etc/mime.types", &statbuf) == 0) &&
89 S_ISREG(statbuf.st_mode)) {
90 mimefile =
"/etc/mime.types";
93 fh = fopen(mimefile,
"r");
96 "Unable to open a mime.types file, so using a minimal one for you.");
100 while (feof(fh) == 0) {
103 if (fgets(
line,
sizeof(
line), fh) == NULL)
106 if ((feof(fh) == 0) &&
line[0] !=
'#') {
115 if (*ptr ==
'\n' || *ptr ==
'\0') {
127 if (*ptr ==
'\0' || *ptr ==
'\n') {
152 if (*ptr ==
'\0' || *ptr ==
'\n') {
194 if (stat(unix_path, &statbuf) == 0) {
197 if (S_ISDIR(statbuf.st_mode)) {
198 return "application/x-netsurf-directory";
202 l = strlen(unix_path);
205 if ((3 < l) && (strcasecmp(unix_path + l - 4,
",f79") == 0)) {
207 }
else if ((3 < l) && (strcasecmp(unix_path + l - 4,
",faf") == 0)) {
209 }
else if ((3 < l) && (strcasecmp(unix_path + l - 4,
",b60") == 0)) {
211 }
else if ((3 < l) && (strcasecmp(unix_path + l - 4,
",ff9") == 0)) {
212 return "image/x-riscos-sprite";
215 if (strchr(unix_path,
'.') == NULL) {
220 ptr = unix_path + strlen(unix_path);
221 while (*ptr !=
'.' && *ptr !=
'/') {
229 ext = strdup(ptr + 1);
257 if (strcmp(
path,
"favicon.ico") == 0) {
Helpers for ASCII string handling.
static char ascii_to_lower(char c)
Convert an upper case character to lower case.
static bool ascii_is_space(char c)
Test whether a character is a whitespace character.
char * filepath_sfind(char **respathv, char *filepath, const char *filename)
Searches an array of resource paths for a file.
Utility routines to obtain paths to file resources.
static struct gui_fetch_table fetch_table
static struct hash_table * mime_hash
void gtk_fetch_filetype_fin(void)
const char * fetch_filetype(const char *unix_path)
filetype – determine the MIME type of a local file
static nsurl * nsgtk_get_resource_url(const char *path)
void gtk_fetch_filetype_init(const char *mimefile)
struct gui_fetch_table * nsgtk_fetch_table
char ** respaths
resource search path vector
struct hash_table * hash_create(unsigned int chains)
Create a new hash table.
bool hash_add(struct hash_table *ht, const char *key, const char *value)
Adds a key/value pair to a hash table.
void hash_destroy(struct hash_table *ht)
Destroys a hash table.
const char * hash_get(struct hash_table *ht, const char *key)
Looks up a the value associated with with a key from a specific hash table.
Interface to Write-Once hash table for string to string mapping.
Interface to platform-specific fetcher operations.
#define NSLOG(catname, level, logmsg, args...)
NetSurf URL handling (interface).
nserror nsurl_create(const char *const url_s, nsurl **url)
Create a NetSurf URL object from a URL string.
struct nsurl nsurl
NetSurf URL object.
nserror nsgtk_data_from_resname(const char *resname, const uint8_t **data_out, size_t *data_size_out)
Get direct pointer to resource data.
Interface to gtk builtin resource handling.
Interface to utility string handling.
function table for fetcher operations.
const char *(* filetype)(const char *unix_path)
Determine the MIME type of a local file.
nserror netsurf_path_to_nsurl(const char *path, struct nsurl **url)
Create a nsurl from a path.
Default operations table for files.
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.
static nserror line(const struct redraw_context *ctx, const plot_style_t *style, const struct rect *line)
Plots a line.