50#define MAX_LINE_LEN 256
82 if ((stat(
"/etc/mime.types", &statbuf) == 0) &&
83 S_ISREG(statbuf.st_mode)) {
84 mimefile =
"/etc/mime.types";
88 fh = fopen(mimefile,
"r");
92 "Unable to open a mime.types file, so using a minimal one for you.");
100 if (!feof(fh) &&
line[0] !=
'#') {
108 if (*ptr ==
'\n' || *ptr ==
'\0')
118 if (*ptr ==
'\0' || *ptr ==
'\n') {
141 if (*ptr ==
'\0' || *ptr ==
'\n') {
191 if (stat(unix_path, &statbuf) != 0) {
198 if (S_ISDIR(statbuf.st_mode)) {
199 return "application/x-netsurf-directory";
202 l = strlen(unix_path);
203 if ((3 < l) && (strcasecmp(unix_path + l - 4,
",f79") == 0)) {
207 if (strchr(unix_path,
'.') == NULL) {
212 ptr = unix_path + strlen(unix_path);
213 while (*ptr !=
'.' && *ptr !=
'/')
220 ext = strdup(ptr + 1);
234 return type != NULL ?
type :
"text/plain";
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.
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.
#define NSLOG(catname, level, logmsg, args...)
void monkey_fetch_filetype_fin(void)
void monkey_fetch_filetype_init(const char *mimefile)
const char * monkey_fetch_filetype(const char *unix_path)
Determine the MIME type of a local file.
static struct hash_table * mime_hash
Interface to utility string handling.
static nserror line(const struct redraw_context *ctx, const plot_style_t *style, const struct rect *line)
Plots a line.