NetSurf
|
file extension to mimetype mapping for the monkey frontend More...
#include <stdio.h>
#include <stdbool.h>
#include <stdint.h>
#include <string.h>
#include <strings.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include "utils/log.h"
#include "utils/ascii.h"
#include "utils/hashtable.h"
#include "monkey/filetype.h"
Go to the source code of this file.
Macros | |
#define | HASH_SIZE 117 |
#define | MAX_LINE_LEN 256 |
Functions | |
void | monkey_fetch_filetype_init (const char *mimefile) |
void | monkey_fetch_filetype_fin (void) |
const char * | monkey_fetch_filetype (const char *unix_path) |
Determine the MIME type of a local file. More... | |
Variables | |
static struct hash_table * | mime_hash = NULL |
file extension to mimetype mapping for the monkey frontend
allows monkey frontend to map file extension to mime types using a default builtin list and /etc/mime.types file if present.
mime type and content type handling is derived from the BNF in RFC822 section 3.3, RFC2045 section 5.1 and RFC6838 section 4.2. Upshot is their charset and parsing is all a strict subset of ASCII hence not using locale dependant ctype functions for parsing.
Definition in file filetype.c.
#define HASH_SIZE 117 |
Definition at line 49 of file filetype.c.
#define MAX_LINE_LEN 256 |
Definition at line 50 of file filetype.c.
const char * monkey_fetch_filetype | ( | const char * | unix_path | ) |
Determine the MIME type of a local file.
unix_path | Unix style path to file on disk |
Definition at line 182 of file filetype.c.
References ascii_to_lower(), hash_get(), mime_hash, and type.
void monkey_fetch_filetype_fin | ( | void | ) |
Definition at line 168 of file filetype.c.
References hash_destroy(), and mime_hash.
Referenced by monkey_quit().
void monkey_fetch_filetype_init | ( | const char * | mimefile | ) |
Definition at line 54 of file filetype.c.
References ascii_is_space(), hash_add(), hash_create(), HASH_SIZE, line(), MAX_LINE_LEN, mime_hash, NSLOG, and type.
Referenced by main().
|
static |
Definition at line 52 of file filetype.c.
Referenced by monkey_fetch_filetype(), monkey_fetch_filetype_fin(), and monkey_fetch_filetype_init().