From 91f8a679db6211b883ce2a7499728ee2b6a5f2af Mon Sep 17 00:00:00 2001 From: James Bursa Date: Sat, 15 Mar 2003 15:53:20 +0000 Subject: [project @ 2003-03-15 15:53:20 by bursa] MIME types for local files, new test files. svn path=/import/netsurf/; revision=107 --- !NetSurf/Resources/bugs.html | 17 ---------- !NetSurf/Resources/intro,faf | 70 ++++++++++++++++++++++++++++++++++++++++ !NetSurf/Resources/intro.html | 30 ------------------ !NetSurf/Resources/jpeg,c85 | Bin 0 -> 9900 bytes !NetSurf/Resources/test1,faf | 23 ++++++++++++++ !NetSurf/Resources/text | 1 + content/fetch.c | 23 +++++++------- content/fetch.h | 3 +- makefile | 4 +-- render/textplain.c | 7 ++-- riscos/filetype.c | 72 ++++++++++++++++++++++++++++++++++++++++++ riscos/gui.c | 7 ++-- 12 files changed, 190 insertions(+), 67 deletions(-) delete mode 100644 !NetSurf/Resources/bugs.html create mode 100644 !NetSurf/Resources/intro,faf delete mode 100644 !NetSurf/Resources/intro.html create mode 100644 !NetSurf/Resources/jpeg,c85 create mode 100644 !NetSurf/Resources/test1,faf create mode 100644 !NetSurf/Resources/text create mode 100644 riscos/filetype.c diff --git a/!NetSurf/Resources/bugs.html b/!NetSurf/Resources/bugs.html deleted file mode 100644 index 325d7f38a..000000000 --- a/!NetSurf/Resources/bugs.html +++ /dev/null @@ -1,17 +0,0 @@ - - - Bugs in NetSurf - - -

Known bugs

-

Memory usage

-

NetSurf soon runs out of memory. This is because the memory claimed for the parsed HTML and box structures is not released when another page is requested. To get around this drag the Next bar in the Task Manager up to something ridiculous before running NetSurf. When NetSurf runs out of memory it will quit without warning.

-

Relative links

-

Following a relative link does not work if the current URL does not end with a leafname or a slash. Eg: http://www.riscos.com would cause problems whereas http://www.riscos.com/ would not.

-

Multiple fetches

-

Multiple fetches (in different windows) don't seem to work yet.

-

Possibly fixed bugs

-

This version includes new table code that should allow NetSurf to work with pages containing malformed tables.

-

Return to the main page

- - diff --git a/!NetSurf/Resources/intro,faf b/!NetSurf/Resources/intro,faf new file mode 100644 index 000000000..254008216 --- /dev/null +++ b/!NetSurf/Resources/intro,faf @@ -0,0 +1,70 @@ + + +Welcome to NetSurf + + + +

NetSurf - the RISC OS web +browser

+

NetSurf is a new web browser for computers +running RISC OS.

+ +
+

Test Pages

+ +
+ +

Currently Implemented

+ + +

In Progress

+ + +
+ +

Links

+ + +

Mailing List

+

There is a mailing +list where you can discuss development (from a user's +perspective as well as a programmer's) or point out any bugs you have +spotted.

+ +

Libraries

+

NetSurf currently uses the following libraries:

+ + + + + + + +
libxml(XML and HTML parser)
libcurl(HTTP, etc.)
OSLib(C interface to RISC OS SWIs)
+ + + diff --git a/!NetSurf/Resources/intro.html b/!NetSurf/Resources/intro.html deleted file mode 100644 index 9e8e45c2c..000000000 --- a/!NetSurf/Resources/intro.html +++ /dev/null @@ -1,30 +0,0 @@ - -Welcome to NetSurf - -

 

-

NetSurf - the RISC OS web browser

-

 

-

NetSurf is a new web browser for computers running RISC OS. - This welcome page needs more work. In the mean time, why not visit the SourceForge development area?

-

To use NetSurf, type in a http:// or file:/ URL at the top of the window, then hit Return. Drag with Select or Adjust to highlight text; clicking Select clears any current selection. Click on a link with Select to follow it, or with Adjust to open it in a new window. Links are currently shown in bold and italic rather than the traditional underlined blue.

-

You can now quit NetSurf using the icon bar menu.

-

 

- - -
-

Mailing list

-

There is a mailing list where you can discuss development (from a user's perspective as well as a programmer's) or point out any bugs you have spotted.

-

To subscribe, send a message to netsurf-develop-request@lists.sourceforge.net with the subject subscribe password, replacing password with an identification of your choice. (The password is only used for subsequently configuring your account; it is not secure).

-
-

Test pages

-

Test JPEG image

-

Test for Unicode support

-

 

-

Known bugs

-

Please see the known bugs page.

-

 

-

Contacting the developers

-

Details are available from the development area. -

- - diff --git a/!NetSurf/Resources/jpeg,c85 b/!NetSurf/Resources/jpeg,c85 new file mode 100644 index 000000000..cda96192d Binary files /dev/null and b/!NetSurf/Resources/jpeg,c85 differ diff --git a/!NetSurf/Resources/test1,faf b/!NetSurf/Resources/test1,faf new file mode 100644 index 000000000..368afe249 --- /dev/null +++ b/!NetSurf/Resources/test1,faf @@ -0,0 +1,23 @@ + + +Test 1 + + + +

Heading 1

+

Heading 2

+

Heading 3

+

Heading 4

+
Heading 5
+
Heading 6
+ +

Left aligned paragraph. Left aligned paragraph. Left aligned paragraph. Left aligned paragraph. Left aligned paragraph. Left aligned paragraph. Left aligned paragraph. Left aligned paragraph. Left aligned paragraph. Left aligned paragraph.

+ +

Centered paragraph. Centered paragraph. Centered paragraph. Centered paragraph. Centered paragraph. Centered paragraph. Centered paragraph. Centered paragraph. Centered paragraph.

+ +

Right aligned paragraph. Right aligned paragraph. Right aligned paragraph. Right aligned paragraph. Right aligned paragraph. Right aligned paragraph. Right aligned paragraph. Right aligned paragraph. Right aligned paragraph. Right aligned paragraph.

+ + + + diff --git a/!NetSurf/Resources/text b/!NetSurf/Resources/text new file mode 100644 index 000000000..b5da95dfd --- /dev/null +++ b/!NetSurf/Resources/text @@ -0,0 +1 @@ +This is a plain text file. diff --git a/content/fetch.c b/content/fetch.c index 6e6e50ce3..9314bedeb 100644 --- a/content/fetch.c +++ b/content/fetch.c @@ -1,8 +1,9 @@ /** - * $Id: fetch.c,v 1.2 2003/02/25 21:00:27 bursa Exp $ + * $Id: fetch.c,v 1.3 2003/03/15 15:53:20 bursa Exp $ */ #include +#include #include #include "curl/curl.h" #include "netsurf/content/fetch.h" @@ -112,13 +113,6 @@ struct fetch * fetch_start(char *url, char *referer, codem = curl_multi_add_handle(curl_multi, fetch->curl_handle); assert(codem == CURLM_OK || codem == CURLM_CALL_MULTI_PERFORM); - /* do any possible work on the fetch */ - while (codem == CURLM_CALL_MULTI_PERFORM) { - int running; - codem = curl_multi_perform(curl_multi, &running); - assert(codem == CURLM_OK || codem == CURLM_CALL_MULTI_PERFORM); - } - return fetch; } @@ -212,14 +206,21 @@ size_t fetch_curl_data(void * data, size_t size, size_t nmemb, struct fetch *f) if (!f->had_headers) { /* find the content type and inform the caller */ - char *type; + const char *type; CURLcode code; code = curl_easy_getinfo(f->curl_handle, CURLINFO_CONTENT_TYPE, &type); assert(code == CURLE_OK); - if (type == 0) - type = "text/html"; /* TODO: find type of file: urls */ + if (type == 0) { + type = "text/html"; + if (strncmp(f->url, "file:///", 8) == 0) { + char *url_path; + url_path = curl_unescape(f->url + 8, (int) strlen(f->url) - 8); + type = fetch_filetype(url_path); + free(url_path); + } + } LOG(("FETCH_TYPE, '%s'", type)); f->callback(FETCH_TYPE, f->p, type, 0); diff --git a/content/fetch.h b/content/fetch.h index 171bf33cb..ab3029b23 100644 --- a/content/fetch.h +++ b/content/fetch.h @@ -1,5 +1,5 @@ /** - * $Id: fetch.h,v 1.1 2003/02/09 12:58:14 bursa Exp $ + * $Id: fetch.h,v 1.2 2003/03/15 15:53:20 bursa Exp $ */ #ifndef _NETSURF_DESKTOP_FETCH_H_ @@ -16,5 +16,6 @@ struct fetch * fetch_start(char *url, char *referer, void fetch_abort(struct fetch *f); void fetch_poll(void); void fetch_quit(void); +const char *fetch_filetype(const char *unix_path); #endif diff --git a/makefile b/makefile index 441da31aa..ddb67311e 100644 --- a/makefile +++ b/makefile @@ -1,4 +1,4 @@ -# $Id: makefile,v 1.14 2003/02/25 21:00:27 bursa Exp $ +# $Id: makefile,v 1.15 2003/03/15 15:53:20 bursa Exp $ all: !NetSurf/!RunImage,ff8 clean: @@ -24,7 +24,7 @@ OBJECTS = \ render/arm-riscos-aof/layout.o render/arm-riscos-aof/textplain.o \ riscos/arm-riscos-aof/font.o riscos/arm-riscos-aof/gui.o \ riscos/arm-riscos-aof/theme.o riscos/arm-riscos-aof/jpeg.o \ - utils/arm-riscos-aof/utils.o + riscos/arm-riscos-aof/filetype.o utils/arm-riscos-aof/utils.o HEADERS = \ content/cache.h content/content.h content/fetch.h content/fetchcache.h \ desktop/browser.h desktop/gui.h desktop/netsurf.h render/box.h \ diff --git a/render/textplain.c b/render/textplain.c index 84875804c..f6e157466 100644 --- a/render/textplain.c +++ b/render/textplain.c @@ -1,5 +1,5 @@ /** - * $Id: textplain.c,v 1.2 2003/02/25 21:00:27 bursa Exp $ + * $Id: textplain.c,v 1.3 2003/03/15 15:53:20 bursa Exp $ */ #include @@ -8,6 +8,7 @@ #include "libxml/HTMLparser.h" #include "netsurf/render/html.h" #include "netsurf/render/textplain.h" +#include "netsurf/utils/log.h" static const char header[] = "
";
@@ -17,7 +18,7 @@ static const char footer[] = "
"; void textplain_create(struct content *c) { html_create(c); - htmlParseChunk(c->data.html.parser, header, sizeof(header), 0); + htmlParseChunk(c->data.html.parser, header, sizeof(header) - 1, 0); } @@ -29,7 +30,7 @@ void textplain_process_data(struct content *c, char *data, unsigned long size) int textplain_convert(struct content *c, unsigned int width, unsigned int height) { - htmlParseChunk(c->data.html.parser, footer, sizeof(footer), 0); + htmlParseChunk(c->data.html.parser, footer, sizeof(footer) - 1, 0); c->type = CONTENT_HTML; return html_convert(c, width, height); } 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 +#include +#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) { -- cgit v1.2.3