21#include <unixlib/local.h>
22#include "oslib/mimemap.h"
23#include "oslib/osfile.h"
39 {0x188,
"application/x-shockwave-flash"},
41 {0x69c,
"image/x-ms-bmp"},
42 {0xa66,
"image/webp"},
43 {0xaad,
"image/svg+xml"},
44 {0xaff,
"image/x-drawfile"},
46 {0xc85,
"image/jpeg"},
47 {0xd94,
"image/x-artworks"},
50 {0xf81,
"application/javascript"},
53 {0xff9,
"image/x-riscos-sprite"},
54 {0xfff,
"text/plain"},
56#define TYPE_MAP_COUNT (sizeof(type_map) / sizeof(type_map[0]))
62static int cmp_type(
const void *x,
const void *y);
68 unsigned int len = strlen(unix_path) + 100;
69 char *
path = calloc(len, 1);
76 NSLOG(netsurf, INFO,
"Insufficient memory for calloc");
78 return "application/riscos";
82 r = __riscosify(unix_path, 0, __RISCOSIFY_NO_SUFFIX,
path, len, 0);
84 NSLOG(netsurf, INFO,
"__riscosify failed");
86 return "application/riscos";
89 error = xosfile_read_stamped_no_path(
path, &objtype, 0, 0, 0, 0,
93 "xosfile_read_stamped_no_path failed: %s",
96 return "application/riscos";
99 if (objtype == osfile_IS_DIR) {
100 sprintf(
type_buf,
"application/x-netsurf-directory");
108 char *slash = strrchr(
path,
'/');
110 error = xmimemaptranslate_extension_to_filetype(
115 "xmimemaptranslate_extension_to_filetype: ""0x%x %s",
135 NSLOG(netsurf, INFO,
"0x%x %s", error->errnum, error->errmess);
137 return "application/riscos";
157 bits filetype = 0, load;
159 char *mime = calloc(
BUF_SIZE,
sizeof(
char));
164 NSLOG(netsurf, INFO,
"Insufficient memory for calloc");
169 e = xosfile_read_no_path(ro_path, &objtype, &load, 0, 0, 0);
171 NSLOG(netsurf, INFO,
"xosfile_read_no_path: 0x%x: %s",
172 e->errnum, e->errmess);
177 if (objtype == osfile_IS_DIR) {
182 if ((load >> 20) & 0xFFF) {
183 filetype = (load>>8) & 0x000FFF;
192 slash = strrchr(ro_path,
'/');
193 if (slash && filetype == osfile_TYPE_TEXT) {
194 e = xmimemaptranslate_extension_to_filetype(slash+1, &load);
198 NSLOG(netsurf, INFO,
"0x%x %s", e->errnum, e->errmess);
213 e = xmimemaptranslate_filetype_to_mime_type(filetype, mime);
216 "xmimemaptranslate_filetype_to_mime_type: 0x%x: %s",
275 return osfile_TYPE_SPRITE;
278 return osfile_TYPE_DRAW;
283 return osfile_TYPE_DATA;
305 error = xmimemaptranslate_mime_type_to_filetype(
329 unsigned int len = strlen(unix_path) + 100;
330 char *
path = calloc(len, 1);
336 NSLOG(netsurf, INFO,
"Insufficient memory for calloc");
338 return osfile_TYPE_DATA;
342 r = __riscosify(unix_path, 0, __RISCOSIFY_NO_SUFFIX,
path, len, 0);
344 NSLOG(netsurf, INFO,
"__riscosify failed");
346 return osfile_TYPE_DATA;
349 error = xosfile_read_stamped_no_path(
path, 0, 0, 0, 0, 0,
353 "xosfile_read_stamped_no_path failed: %s",
356 return osfile_TYPE_DATA;
const char * fetch_filetype(const char *unix_path)
Determine the MIME type of a local file.
content_type
The type of a content.
@ CONTENT_CSS
content is CSS
@ CONTENT_HTML
content is HTML
@ CONTENT_TEXTPLAIN
content is plain text
Public content interface.
lwc_string * content_get_mime_type(struct hlcache_handle *h)
Retrieve mime-type of content.
content_type content_get_type(struct hlcache_handle *h)
Retrieve computed type of content.
#define NSLOG(catname, level, logmsg, args...)
int ro_content_filetype_from_mime_type(lwc_string *mime_type)
Determine the RISC OS filetype for a MIME type.
char * fetch_mimetype(const char *ro_path)
Find a MIME type for a local file.
static const struct type_entry type_map[]
bits ro_filetype_from_unix_path(const char *unix_path)
Determine the type of a local file.
int ro_content_filetype(struct hlcache_handle *c)
Determine the RISC OS filetype for a content.
static int cmp_type(const void *x, const void *y)
Comparison function for bsearch.
int ro_content_filetype_from_type(content_type type)
Determine the RISC OS filetype from a content type.
int ro_content_native_type(struct hlcache_handle *c)
Determine the native RISC OS filetype to export a content as.
static char type_buf[BUF_SIZE]
RISC OS filetpe interface.
nserror ro_warn_user(const char *warning, const char *detail)
Display a warning for a serious problem (eg memory exhaustion).
Interface to utility string handling.
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.