summaryrefslogtreecommitdiff
path: root/riscos
diff options
context:
space:
mode:
authorJames Bursa <james@netsurf-browser.org>2003-03-15 15:53:20 +0000
committerJames Bursa <james@netsurf-browser.org>2003-03-15 15:53:20 +0000
commit91f8a679db6211b883ce2a7499728ee2b6a5f2af (patch)
treec210a7dbf57352499bda4d5ea97ae24df49d4b5e /riscos
parente517a39dfbaf633ec449dab351bca094e6be4239 (diff)
downloadnetsurf-91f8a679db6211b883ce2a7499728ee2b6a5f2af.tar.gz
netsurf-91f8a679db6211b883ce2a7499728ee2b6a5f2af.tar.bz2
[project @ 2003-03-15 15:53:20 by bursa]
MIME types for local files, new test files. svn path=/import/netsurf/; revision=107
Diffstat (limited to 'riscos')
-rw-r--r--riscos/filetype.c72
-rw-r--r--riscos/gui.c7
2 files changed, 76 insertions, 3 deletions
diff --git a/riscos/filetype.c b/riscos/filetype.c
new file mode 100644
index 000000000..daa10d842
--- /dev/null
+++ b/riscos/filetype.c
@@ -0,0 +1,72 @@
+/**
+ * $Id: filetype.c,v 1.1 2003/03/15 15:53:20 bursa Exp $
+ */
+
+#include <stdlib.h>
+#include <unixlib/local.h>
+#include "oslib/osfile.h"
+#include "netsurf/content/fetch.h"
+#include "netsurf/utils/log.h"
+#include "netsurf/utils/utils.h"
+
+/* type_map must be in sorted order by file_type */
+struct type_entry {
+ bits file_type;
+ char mime_type[16];
+};
+static const struct type_entry type_map[] = {
+ {0xc85, "image/jpeg"},
+ {0xfaf, "text/html"},
+ {0xfff, "text/plain"},
+};
+#define TYPE_MAP_COUNT (sizeof(type_map) / sizeof(type_map[0]))
+
+
+static int cmp_type(const void *x, const void *y);
+
+
+/**
+ * filetype -- determine the MIME type of a local file
+ */
+
+const char *fetch_filetype(const char *unix_path)
+{
+ struct type_entry *t;
+ unsigned int len = strlen(unix_path) + 100;
+ char *path = xcalloc(len, 1);
+ char *r;
+ os_error *error;
+ bits file_type;
+
+ LOG(("unix_path = '%s'", unix_path));
+
+ /* convert path to RISC OS format and read file type */
+ r = __riscosify(unix_path, 0, 0, path, len, 0);
+ if (r == 0) {
+ LOG(("__riscosify failed"));
+ return "application/riscos";
+ }
+ LOG(("riscos path '%s'", path));
+
+ error = xosfile_read_stamped_no_path(path, 0, 0, 0, 0, 0, &file_type);
+ if (error != 0) {
+ LOG(("xosfile_read_stamped_no_path failed: %s", error->errmess));
+ return "application/riscos";
+ }
+
+ /* search for MIME type */
+ t = bsearch(&file_type, type_map, TYPE_MAP_COUNT, sizeof(type_map[0]), cmp_type);
+ if (t == 0)
+ return "application/riscos";
+ LOG(("mime type '%s'", t->mime_type));
+ return t->mime_type;
+}
+
+
+int cmp_type(const void *x, const void *y)
+{
+ const bits *p = x;
+ const struct type_entry *q = y;
+ return *p < q->file_type ? -1 : (*p == q->file_type ? 0 : +1);
+}
+
diff --git a/riscos/gui.c b/riscos/gui.c
index 524fa2896..7fa307e19 100644
--- a/riscos/gui.c
+++ b/riscos/gui.c
@@ -1,5 +1,5 @@
/**
- * $Id: gui.c,v 1.21 2003/03/08 20:26:31 bursa Exp $
+ * $Id: gui.c,v 1.22 2003/03/15 15:53:20 bursa Exp $
*/
#include "netsurf/riscos/font.h"
@@ -23,7 +23,7 @@
int gadget_subtract_x;
int gadget_subtract_y;
#define browser_menu_flags (wimp_ICON_TEXT | wimp_ICON_FILLED | (wimp_COLOUR_BLACK << wimp_ICON_FG_COLOUR_SHIFT) | (wimp_COLOUR_WHITE << wimp_ICON_BG_COLOUR_SHIFT))
-const char* HOME_URL = "file:///%3CNetSurf$Dir%3E/Resources/intro.html\0";
+const char* HOME_URL = "file:///%3CNetSurf$Dir%3E/Resources/intro";
wimp_MENU(2) netsurf_iconbar_menu =
{
@@ -1085,7 +1085,8 @@ void gui_init(int argc, char** argv)
void ro_gui_throb(void)
{
gui_window* g = netsurf_gui_windows;
- float nowtime = (float) (clock() + 0) / CLOCKS_PER_SEC; /* workaround compiler warning */
+ //float nowtime = (float) (clock() + 0) / CLOCKS_PER_SEC; /* workaround compiler warning */
+ float nowtime = (float) clock() / CLOCKS_PER_SEC;
while (g != NULL)
{