summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAshish Gupta <ashmew2@gmail.com>2017-04-21 21:18:15 (GMT)
committer Ashish Gupta <ashmew2@gmail.com>2017-06-10 06:25:29 (GMT)
commitdbe64238302aab07de75d520f9a85fa2856e8ce7 (patch)
tree7380272e351b5f146c9331a712978c95502434f6
parentefdd93541042bcae19fb09d56d2a0a61252d0fd2 (diff)
downloadnetsurf-dbe64238302aab07de75d520f9a85fa2856e8ce7.tar.gz
netsurf-dbe64238302aab07de75d520f9a85fa2856e8ce7.tar.bz2
Move port for kolibrios ahead.
Look at diff from master and reconcile.
-rw-r--r--Makefile4
-rw-r--r--content/fetch.c18
-rw-r--r--content/fetchers/Makefile1
-rw-r--r--frontends/kolibrios/Makefile6
-rw-r--r--frontends/kolibrios/Makefile.defaults3
-rw-r--r--frontends/kolibrios/fb/framebuffer.c5
-rw-r--r--frontends/kolibrios/fb/gui.c84
-rw-r--r--frontends/kolibrios/kolibri_debug.c3
-rw-r--r--frontends/kolibrios/kolibri_http.c1
-rw-r--r--frontends/kolibrios/kolibri_http.h6
-rw-r--r--frontends/kolibrios/loadboxlib.objbin1075 -> 0 bytes
-rw-r--r--frontends/kolibrios/loadhttp.asm2
-rw-r--r--frontends/kolibrios/loadhttp.objbin1254 -> 0 bytes
-rw-r--r--frontends/kolibrios/main.c314
-rw-r--r--utils/log.c12
-rw-r--r--utils/nsoption.h3
16 files changed, 98 insertions, 364 deletions
diff --git a/Makefile b/Makefile
index 2fd35da..fd62802 100644
--- a/Makefile
+++ b/Makefile
@@ -529,7 +529,7 @@ ifneq ($(TARGET),kolibrios)
else
KOL_LIBC := $(HOME)/kolibrios/contrib/sdk/sources/newlib/libc/include/
KOL_LIB_DIR := $(HOME)/kolibrios/contrib/sdk/lib
- LIB_LDFLAGS := -L$(KOL_LIB_DIR) -lfreetype
+ LIB_LDFLAGS := -L$(KOL_LIB_DIR) -lfreetype -lpng16
OS_LDFLAGS := -static -S -Tapp-dynamic.lds --image-base 0
NS_INCLUDE := $(PREFIX)/include
@@ -701,7 +701,7 @@ OBJECTS := $(sort $(addprefix $(OBJROOT)/,$(subst /,_,$(patsubst %.c,%.o,$(patsu
IFLAGS = $(addprefix -I,$(INCLUDE_DIRS))
ifeq ($(TARGET),kolibrios)
- KOLOBJECTS = $(HOME)/kolibrios/programs/develop/libraries/iconv/iconv.o $(HOME)/kolibrios/programs/fs/unzip60/kolibri/dirent.o $(HOME)/NETSURFLIBS/netsurf/font_internal.o
+ KOLOBJECTS = $(HOME)/kolibrios/programs/fs/unzip60/kolibri/dirent.o $(HOME)/NETSURFLIBS/netsurf/font_internal.o $(HOME)/NETSURFLIBS/netsurf/frontends/kolibrios/asmobj/http.obj $(HOME)/NETSURFLIBS/netsurf/frontends/kolibrios/asmobj/loadhttp.obj $(HOME)/kolibrios/programs/develop/libraries/iconv/iconv.o
endif
$(EXETARGET): $(OBJECTS) $(RESOURCES) $(MESSAGES)
diff --git a/content/fetch.c b/content/fetch.c
index bfc84ea..666b9e3 100644
--- a/content/fetch.c
+++ b/content/fetch.c
@@ -54,22 +54,23 @@
#include "content/fetchers.h"
#include "content/fetchers/resource.h"
#include "content/fetchers/about.h"
-#if defined(_TARGET_IS_KOLIBRIOS)
-#include "content/fetchers/http_kolibri.h"
-#else
+#ifdef WITH_CURL
#include "content/fetchers/curl.h"
#endif
+#if defined(_TARGET_IS_KOLIBRIOS)
+#include "content/fetchers/httplib_kolibri.h"
+#endif
#include "content/fetchers/data.h"
#include "content/fetchers/file.h"
#include "javascript/fetcher.h"
#include "content/urldb.h"
/* Define this to turn on verbose fetch logging */
-#undef DEBUG_FETCH_VERBOSE
+#define DEBUG_FETCH_VERBOSE
/** Verbose fetcher logging */
#ifdef DEBUG_FETCH_VERBOSE
-#define FETCH_LOG(x...) LOG(x...)
+#define FETCH_LOG(x...) debug_board_printf(x); debug_board_printf("\n");
#else
#define FETCH_LOG(x...)
#endif
@@ -299,7 +300,12 @@ nserror fetcher_init(void)
return ret;
}
#endif
-
+#ifdef _TARGET_IS_KOLIBRIOS
+ ret = fetch_httplib_kolibri_register();
+ if (ret != NSERROR_OK) {
+ return ret;
+ }
+#endif
ret = fetch_data_register();
if (ret != NSERROR_OK) {
return ret;
diff --git a/content/fetchers/Makefile b/content/fetchers/Makefile
index 9c84793..5d9b7ad 100644
--- a/content/fetchers/Makefile
+++ b/content/fetchers/Makefile
@@ -3,6 +3,7 @@
S_FETCHERS_YES := data.c file.c about.c resource.c
S_FETCHERS_NO :=
S_FETCHERS_$(NETSURF_USE_CURL) += curl.c
+S_FETCHERS_$(NETSURF_USE_KOLIBRI_HTTPLIB) += httplib_kolibri.c
S_FETCHERS := $(addprefix content/fetchers/,$(S_FETCHERS_YES))
diff --git a/frontends/kolibrios/Makefile b/frontends/kolibrios/Makefile
index 1cf0698..cec54d2 100644
--- a/frontends/kolibrios/Makefile
+++ b/frontends/kolibrios/Makefile
@@ -7,11 +7,14 @@ CFLAGS += $(KOL_OTHER_INCLUDES) $(DMACROS) -std=c99 -g
CFLAGS += '-DNETSURF_KOLIBRI_FONTPATH="$(NETSURF_KOLIBRI_FONTPATH)"'
CFLAGS += '-DKOLIBRIOS_RESPATH="$(NETSURF_KOLIBRI_RESPATH)"'
-
+CFLAGS += '-DNETSURF_USE_KOLIBRI_HTTPLIB'
##########################################################################
# Only for FB compat with kolibri. Get rid soon.
CFLAGS += '-DKOLIBRI_RUNTIME_RESPATH="$(NETSURF_KOLIBRI_RESPATH)"'
+# Enable PNG and others from here (no pkg config for now)
+CFLAGS += '-DWITH_PNG'
+
# compile time font locations
CFLAGS += '-DNETSURF_FB_FONTPATH="$(NETSURF_KOLIBRI_FONTPATH)"'
CFLAGS += '-DKOLIBRI_FONT_FREETYPE_SANS_SERIF="$(NETSURF_KOLIBRI_FONT_SANS_SERIF)"'
@@ -146,6 +149,7 @@ DESTDIR := $(PREFIX)/bin
DESTRESDIR := $(PREFIX)/res
KOLIBRI_RES_DIR := $(HOME)/NETSURFLIBS/netsurf/frontends/kolibrios/res
+# make install is buggy with -jN when it cannot find the EXETARGET as it tries to install it before it is created.
install-kolibrios:
$(Q)$(MKDIR) -p $(DESTDIR)
$(Q)install $(EXETARGET) $(DESTDIR)/netsurf-kolibrios
diff --git a/frontends/kolibrios/Makefile.defaults b/frontends/kolibrios/Makefile.defaults
index 8344638..fe76851 100644
--- a/frontends/kolibrios/Makefile.defaults
+++ b/frontends/kolibrios/Makefile.defaults
@@ -38,3 +38,6 @@ NETSURF_FRAMEBUFFER_RESOURCES := $(PREFIX)/share/netsurf/
# Res path when running on KolibriOS
NETSURF_KOLIBRI_RESPATH := /usbhd0/1/res
+# KolibriOS does not need curl. It has it's own HTTP library.
+NETSURF_USE_CURL := NO
+NETSURF_USE_KOLIBRI_HTTPLIB := YES
diff --git a/frontends/kolibrios/fb/framebuffer.c b/frontends/kolibrios/fb/framebuffer.c
index eae6a06..5b209f4 100644
--- a/frontends/kolibrios/fb/framebuffer.c
+++ b/frontends/kolibrios/fb/framebuffer.c
@@ -581,13 +581,8 @@ framebuffer_initialise(const char *fename, int width, int height, int bpp)
return NULL;
}
- fprintf(stderr, "Our: %s\n", fename);
-
- __asm__ __volatile__("int3");
-
fbtype = nsfb_type_from_name(fename);
if (fbtype == NSFB_SURFACE_NONE) {
- fprintf(stderr, "Got fucked here because nsfb_type_from_name failed for : %s\n", fename);
LOG("The %s surface is not available from libnsfb\n", fename);
return NULL;
}
diff --git a/frontends/kolibrios/fb/gui.c b/frontends/kolibrios/fb/gui.c
index ab2b981..453ade6 100644
--- a/frontends/kolibrios/fb/gui.c
+++ b/frontends/kolibrios/fb/gui.c
@@ -23,6 +23,7 @@
#include <string.h>
#include <stdbool.h>
#include <stdlib.h>
+#include <unistd.h>
#include <nsutils/time.h>
#include <libnsfb.h>
@@ -57,6 +58,11 @@
#define NSFB_TOOLBAR_DEFAULT_LAYOUT "blfsrutc"
+/* #undef LOG */
+/* #define LOG(format, args...) \ */
+/* debug_board_printf(format, ##args); \ */
+/* debug_board_printf("\n"); \ */
+
fbtk_widget_t *fbtk;
static bool fb_complete = false;
@@ -457,11 +463,11 @@ static const char *feurl;
static bool
process_cmdline(int argc, char** argv)
{
- int opt;
- int option_index;
- static struct option long_options[] = {
- {0, 0, 0, 0 }
- }; /* no long options */
+ /* int opt; */
+ /* int option_index; */
+ /* static struct option long_options[] = { */
+ /* {0, 0, 0, 0 } */
+ /* }; /\* no long options *\/ */
LOG("argc %d, argv %p", argc, argv);
@@ -484,6 +490,8 @@ process_cmdline(int argc, char** argv)
feurl = NETSURF_HOMEPAGE;
}
+ /* NS on KolibriOS does not support option parsing (yet) */
+
/* while((opt = getopt_long(argc, argv, "f:b:w:h:", */
/* long_options, &option_index)) != -1) { */
/* switch (opt) { */
@@ -519,7 +527,7 @@ process_cmdline(int argc, char** argv)
}
/**
- * Set option defaults for framebuffer frontend
+ * Set option defaults for kolibrios framebuffer frontend
*
* @param defaults The option table to update.
* @return error status.
@@ -586,6 +594,8 @@ static void framebuffer_run(void)
nsfb_event_t event;
int timeout; /* timeout in miliseconds */
+ LOG("framebuffer_run() executing!");
+
while (fb_complete != true) {
/* run the scheduler and discover how long to wait for
* the next event.
@@ -1232,9 +1242,6 @@ create_toolbar(struct gui_window *gw,
(*itmtype != 0) &&
(xdir !=0)) {
- LOG("toolbar adding %c", *itmtype);
-
-
switch (*itmtype) {
case 'b': /* back */
@@ -1383,8 +1390,6 @@ create_toolbar(struct gui_window *gw,
xpos += (xdir * (fbtk_get_width(widget) + padding));
}
- LOG("xpos is %d", xpos);
-
itmtype += xdir;
}
@@ -1640,6 +1645,7 @@ create_normal_browser_window(struct gui_window *gw, int furniture_width)
/* fill bottom right area */
if (nsoption_bool(fb_osk) == true) {
+
widget = fbtk_create_text_button(gw->window,
fbtk_get_width(gw->window) - furniture_width,
fbtk_get_height(gw->window) - furniture_width,
@@ -1648,6 +1654,7 @@ create_normal_browser_window(struct gui_window *gw, int furniture_width)
FB_FRAME_COLOUR, FB_COLOUR_BLACK,
fb_osk_click,
NULL);
+
widget = fbtk_create_button(gw->window,
fbtk_get_width(gw->window) - furniture_width,
fbtk_get_height(gw->window) - furniture_width,
@@ -1657,7 +1664,9 @@ create_normal_browser_window(struct gui_window *gw, int furniture_width)
&osk_image,
fb_osk_click,
NULL);
+
} else {
+
widget = fbtk_create_fill(gw->window,
fbtk_get_width(gw->window) - furniture_width,
fbtk_get_height(gw->window) - furniture_width,
@@ -1671,6 +1680,7 @@ create_normal_browser_window(struct gui_window *gw, int furniture_width)
gw->bottom_right = widget;
/* create vertical scrollbar */
+
gw->vscroll = fbtk_create_vscroll(gw->window,
fbtk_get_width(gw->window) - furniture_width,
toolbar_height,
@@ -2090,6 +2100,7 @@ main(int argc, char** argv)
nsurl *url;
nserror ret;
nsfb_t *nsfb;
+
struct netsurf_table framebuffer_table = {
.misc = &framebuffer_misc_table,
.window = &framebuffer_window_table,
@@ -2100,23 +2111,43 @@ main(int argc, char** argv)
.layout = framebuffer_layout_table,
};
- ret = netsurf_register(&framebuffer_table);
- if (ret != NSERROR_OK) {
- die("NetSurf operation table failed registration");
- }
-
- respaths = fb_init_resource(NETSURF_FB_RESPATH":"NETSURF_FB_FONTPATH);
-
- /* initialise logging. Not fatal if it fails but not much we
- * can do about it either.
- */
- nslog_init(nslog_stream_configure, &argc, argv);
+ ret = netsurf_register(&framebuffer_table);
+ if (ret != NSERROR_OK) {
+ die("NetSurf operation table failed registration");
+ }
+
+ /* The only restriction is that the kolibrios netsurf binary should be in the same
+ directory as another "res" directory */
+ /* On Kolibrios, argv[0] is the absolute path to the binary */
+ char *respath = strdup(argv[0]);
+ int i;
+ for(i = strlen(respath) - 1; i > 0; i--) {
+ if(respath[i] == '/') {
+ respath[i+1] = 'r';
+ respath[i+2] = 'e';
+ respath[i+3] = 's';
+ respath[i+4] = '\0';
+ break;
+ }
+ }
+ assert(i!=0);
+
+ debug_board_printf(" --- argv[0] : %s\n\n", argv[0]);
+ debug_board_printf(" --- respath : %s\n\n", respath);
+ respaths = fb_init_resource(respath);
+
+ /* initialise logging. Abort on failure for KolibriOS. */
+ ret = nslog_init(nslog_stream_configure, &argc, argv);
+ if (ret != NSERROR_OK) {
+ die("Logging failed to initialise. This is required to run on KolibriOS.");
+ }
/* user options setup */
ret = nsoption_init(set_defaults, &nsoptions, &nsoptions_default);
if (ret != NSERROR_OK) {
die("Options failed to initialise");
}
+
options = filepath_find(respaths, "Choices");
nsoption_read(options, nsoptions);
free(options);
@@ -2165,19 +2196,19 @@ main(int argc, char** argv)
urldb_load_cookies(nsoption_charp(cookie_file));
/* create an initial browser window */
-
- LOG("calling browser_window_create");
+ LOG("calling browser_window_create with Size(hxw)=%dx%d\n", feheight, fewidth);
+ LOG("calling browser_window_create with URL=%s\n", feurl);
ret = nsurl_create(feurl, &url);
if (ret == NSERROR_OK) {
- ret = browser_window_create(BW_CREATE_HISTORY,
+
+ ret = browser_window_create(BW_CREATE_HISTORY,
url,
NULL,
NULL,
&bw);
nsurl_unref(url);
}
-
if (ret != NSERROR_OK) {
fb_warn_user(messages_get_errorcode(ret), 0);
} else {
@@ -2230,3 +2261,4 @@ void gui_resize(fbtk_widget_t *root, int width, int height)
* c-basic-offset:8
* End:
*/
+
diff --git a/frontends/kolibrios/kolibri_debug.c b/frontends/kolibrios/kolibri_debug.c
index 5e97d40..f5cbefc 100644
--- a/frontends/kolibrios/kolibri_debug.c
+++ b/frontends/kolibrios/kolibri_debug.c
@@ -1,9 +1,6 @@
#include "kolibrios/kolibri_debug.h"
#include <stdarg.h>
-/* Write a printf() like function (variable argument list) for
- writing to debug board TODO*/
-
void debug_board_write_byte(const char ch){
__asm__ __volatile__(
"int $0x40"
diff --git a/frontends/kolibrios/kolibri_http.c b/frontends/kolibrios/kolibri_http.c
index dda28a6..ddfd911 100644
--- a/frontends/kolibrios/kolibri_http.c
+++ b/frontends/kolibrios/kolibri_http.c
@@ -26,7 +26,6 @@ void http_send(struct http_msg *handle, char *data, int remaining_length) {
continue;
else {
debug_board_write_str("ERROR: HTTP LIBRARY : Could not send data.\n");
- __asm__ __volatile__("int3");
}
}
diff --git a/frontends/kolibrios/kolibri_http.h b/frontends/kolibrios/kolibri_http.h
index c53ef9a..9c9fea1 100644
--- a/frontends/kolibrios/kolibri_http.h
+++ b/frontends/kolibrios/kolibri_http.h
@@ -31,7 +31,7 @@ struct http_msg{
char * content_ptr;
unsigned int content_length;
unsigned int content_received;
- unsigned int http_header;
+ char http_header;
};
/* C - assembly wrapper to initialize and load the http.obj DLL at runtime */
@@ -43,7 +43,7 @@ extern int (*http_receive_asm)(struct http_msg *) __attribute__((__stdcall__));
extern void (*http_disconnect_asm)(struct http_msg *) __attribute__((__stdcall__));
extern void (*http_free_asm)(struct http_msg *) __attribute__((__stdcall__));
extern struct http_msg* (*http_head_asm)(char *, struct http_msg *, unsigned int, char *) __attribute__((__stdcall__));
-extern struct http_post* (*http_post_asm)(char *, struct http_msg *, unsigned int, char *, char *, unsigned int) __attribute__((__stdcall__));
+extern struct http_msg* (*http_post_asm)(char *, struct http_msg *, unsigned int, char *, char *, unsigned int) __attribute__((__stdcall__));
extern int (*http_send_asm)(struct http_msg *, char *, unsigned int) __attribute__((__stdcall__));
extern char * (*http_find_header_field_asm)(struct http_msg *, char *) __attribute__((__stdcall__));
extern char * (*http_escape_asm)(char *, unsigned int) __attribute__((__stdcall__));
@@ -75,6 +75,8 @@ int kolibri_http_init(void);
#define HTTP_TIMEOUT_ERROR 1 << 19
#define HTTP_TRANSFER_FAILED 1 << 20
+#define HTTP_ERRORS 0x001F0000 /* (1 << 16) | (1 << 17) | (1 << 18) | (1 << 19) | (1 << 20) */
+
void http_send(struct http_msg *handle, char *data, int remaining_length);
#endif /* KOLIBRI_HTTP_H */
diff --git a/frontends/kolibrios/loadboxlib.obj b/frontends/kolibrios/loadboxlib.obj
deleted file mode 100644
index 8746f7f..0000000
--- a/frontends/kolibrios/loadboxlib.obj
+++ b/dev/null
Binary files differ
diff --git a/frontends/kolibrios/loadhttp.asm b/frontends/kolibrios/loadhttp.asm
index 0a38c22..859f56d 100644
--- a/frontends/kolibrios/loadhttp.asm
+++ b/frontends/kolibrios/loadhttp.asm
@@ -27,7 +27,7 @@ proc init_network
stdcall dll.Load, @IMPORT
test eax, eax
jnz error
-
+
mov eax, 0
ret
diff --git a/frontends/kolibrios/loadhttp.obj b/frontends/kolibrios/loadhttp.obj
deleted file mode 100644
index 8e38835..0000000
--- a/frontends/kolibrios/loadhttp.obj
+++ b/dev/null
Binary files differ
diff --git a/frontends/kolibrios/main.c b/frontends/kolibrios/main.c
deleted file mode 100644
index 818e5b0..0000000
--- a/frontends/kolibrios/main.c
+++ b/dev/null
@@ -1,314 +0,0 @@
-#include <stdbool.h>
-#include <sys/types.h>
-
-#include "kolibrios/kolibri_debug.h"
-#include "kolibrios/kolibri_gui.h"
-
-#include "utils/errors.h"
-
-#include "utils/messages.h"
-#include "utils/filepath.h"
-#include "utils/nsoption.h"
-#include "utils/nsurl.h"
-
-#include "netsurf/window.h"
-#include "netsurf/misc.h"
-#include "netsurf/netsurf.h"
-#include "netsurf/bitmap.h"
-#include "netsurf/plot_style.h"
-
-#include "utils/file.h"
-#include "netsurf/utf8.h"
-#include "netsurf/search.h"
-#include "content/backing_store.h"
-
-#include "kolibrios/kolibri_http.h"
-#include <libnsfb.h>
-#include <libnsfb_plot.h>
-#include <libnsfb_event.h>
-
-#include "utils/utils.h"
-#include "utils/nsoption.h"
-#include "utils/filepath.h"
-#include "utils/log.h"
-#include "utils/messages.h"
-#include "desktop/textinput.h"
-#include "desktop/browser_history.h"
-
-#include "kolibrios/fb/gui.h"
-#include "kolibrios/fb/fbtk.h"
-#include "kolibrios/fb/framebuffer.h"
-#include "kolibrios/fb/schedule.h"
-#include "kolibrios/fb/findfile.h"
-#include "kolibrios/fb/image_data.h"
-#include "kolibrios/fb/font.h"
-#include "kolibrios/fb/clipboard.h"
-#include "kolibrios/fb/fetch.h"
-#include "kolibrios/fb/bitmap.h"
-
-/**************************************************
-Make life easier with these path specifiers here.
-***************************************************/
-/* #define KOLIBRI_FONTFILE "/usbhd0/1/kolibrios/res/sans.ttf" */
-/* #define KOLIBRI_RESPATH "/usbhd0/1/kolibrios/res/" */
-/* #define FILE_KOLIBRI_RESPATH "file:///usbhd0/1/kolibrios/res/" */
-/************************************************/
-
-char **respaths; /** resource search path vector */
-
-extern struct gui_browser_table framebuffer_browser_table;
-extern struct gui_window_table framebuffer_window_table ;
-extern struct gui_clipboard_table *framebuffer_clipboard_table ;
-extern struct gui_fetch_table *framebuffer_fetch_table ;
-extern struct gui_utf8_table *framebuffer_utf8_table ;
-extern struct gui_bitmap_table *framebuffer_bitmap_table ;
-
-extern const char *fename;
-extern int febpp;
-extern int fewidth;
-extern int feheight;
-extern const char *feurl;
-extern bool nslog_stream_configure(FILE *fptr);
-extern struct fbtk_bitmap pointer_image;
-extern fbtk_widget_t *fbtk;
-
-static void die(const char *error)
-{
- debug_board_write_str(error);
- debug_board_write_str('\n');
- exit(1);
-}
-
-/* Inspired from monkey, but without the GTK bloat */
-static char **nskolibri_init_resource(const char *resource_path)
-{
- char **langv = {"de", "en_US", "en", "C"};
- char **pathv; /* resource path string vector */
- char **respath; /* resource paths vector */
-
- pathv = filepath_path_to_strvec(resource_path);
- respath = filepath_generate(pathv, langv);
- filepath_free_strvec(pathv);
-
- return respath;
-}
-
-static nserror set_defaults(struct nsoption_s *defaults)
-{
- /* Set defaults for absent option strings */
- nsoption_setnull_charp(cookie_file, *respaths);
- nsoption_setnull_charp(cookie_jar, *respaths);
- //TODO: This creates an nsoptions error in macro expansion...
-
- return NSERROR_OK;
-}
-
-/**
- * Main entry point from Kolibri OS.
- */
-extern struct http_msg;
-
-static struct gui_misc_table framebuffer_misc_table = {
- .schedule = framebuffer_schedule,
- .warning = fb_warn_user,
-
- .quit = gui_quit,
-};
-
-int
-main(int argc, char** argv)
-{
- struct browser_window *bw;
- char *options;
- char *messages;
- nsurl *url;
- nserror ret;
- nsfb_t *nsfb;
-
- struct netsurf_table kolibrios_table = {
- .misc = &kolibrios_misc_table,
- .window = &kolibrios_window_table,
- .clipboard = kolibrios_clipboard_table,
- .fetch = kolibrios_fetch_table,
- .utf8 = kolibrios_utf8_table,
- .bitmap = kolibrios_bitmap_table,
- .layout = kolibrios_layout_table,
- };
-
- /* Initialize HTTP Library */
- ret = kolibri_http_init();
- if (ret == 0)
- debug_board_write_str("Netsurf: KolibriOS HTTP Library Initialized.\n");
- else {
- debug_board_write_str("Netsurf: HTTP Library initialization failed..\n");
- return ret;
- }
-
- /* Initialize BoxLib Library for GUI textboxes, etc */
- ret = kolibri_gui_init();
- if (ret == 0)
- debug_board_write_str("Netsurf: KolibriOS BOXLIB Library Initialized.\n");
- else {
- debug_board_write_str("Netsurf: BOXLIB Library initialization failed..\n");
- return ret;
- }
-
- /* End of KolibriOS specific libraries initialization phase */
- debug_board_write_str("Netsurf: Trying to register nskolibri_table.\n");
-
- ret = netsurf_register(&kolibrios_table);
- if (ret != NSERROR_OK) {
- die("NetSurf operation table failed registration");
- }
-
- /* Drop the last slash if caller provided it. */
-
- char current_dir[100];
- int i = 0;
-
- for(i = strlen(argv[0]); i>=0; i--)
- {
- if(argv[0][i]=='/') {
- strncpy(current_dir, argv[0], i+1);
- i++;
- current_dir[i++] = 'r';
- current_dir[i++] = 'e';
- current_dir[i++] = 's';
- current_dir[i++] = '\0';
- break;
- }
- }
-
-
- respaths = (char **) malloc(sizeof(char **));
- *respaths = malloc(i);
- strcpy(*respaths, current_dir);
-
- debug_board_write_str("\nCWD: ");
- debug_board_write_str(*respaths);
- debug_board_write_str("\n");
-
- /* __asm__ __volatile__("int3"); */
-
- /* initialise logging. Not fatal if it fails but not much we
- * can do about it either.
- */
- nslog_init(nslog_stream_configure, &argc, argv);
-
- /* user options setup */
- ret = nsoption_init(set_defaults, &nsoptions, &nsoptions_default);
- if (ret != NSERROR_OK) {
- die("Options failed to initialise");
- }
- options = filepath_find(respaths, "Choices");
- nsoption_read(options, nsoptions);
- free(options);
- nsoption_commandline(&argc, argv, nsoptions);
-
- /* message init */
- messages = filepath_find(respaths, "Messages");
- ret = messages_add_from_file(messages);
- free(messages);
- if (ret != NSERROR_OK) {
- debug_board_write_str("Message translations failed to load\n");
- }
-
- /* common initialisation */
- ret = netsurf_init(NULL);
- if (ret != NSERROR_OK) {
- die("NetSurf failed to initialise");
- }
-
- /* Override, since we have no support for non-core SELECT menu */
- nsoption_set_bool(core_select_menu, true);
- /* Do we really need to parse command line in KolibriOS?
- Most users will use the GUI to trigger NS .
- TODO: Look at this later.
- */
-
- /* if (process_cmdline(argc,argv) != true) */
- /* die("unable to process command line.\n"); */
-
- /* Move the initialization stuff from process_cmdline() to here */
- /* fename = "sdl"; */
-
- extern nsfb_surface_rtns_t kolibri_rtns;
- _nsfb_register_surface(NSFB_SURFACE_KOLIBRI, &kolibri_rtns, "kolibri");
-
- extern nsfb_surface_rtns_t ram_rtns;
- _nsfb_register_surface(NSFB_SURFACE_RAM, &ram_rtns, "ram");
-
- /* fewidth = nsoption_int(window_width); */
- /* if (fewidth <= 0) { */
- /* fewidth = 800; */
- /* } */
-
- /* feheight = nsoption_int(window_height); */
- /* if (feheight <= 0) { */
- /* feheight = 600; */
- /* } */
-
- fename = "kolibri";
- febpp = 32;
- fewidth = 800;
- feheight = 600;
-
- // feurl = "board.kolibrios.org/ucp.php?i=pm&mode=compose";
- feurl = "ashmew2.me";
- /* feurl = "kolibrios.org"; */
- /* feurl = "file://usbhd0/1/kolibrios/res/welcome.html"; */
- nsfb = framebuffer_initialise(fename, fewidth, feheight, febpp);
- if (nsfb == NULL)
- die("Unable to initialise framebuffer");
-
- framebuffer_set_cursor(&pointer_image);
-
- if (fb_font_init() == false)
- die("Unable to initialise the font system");
-
- fbtk = fbtk_init(nsfb);
-
- fbtk_enable_oskb(fbtk);
-
- urldb_load_cookies(nsoption_charp(cookie_file));
-
- /* create an initial browser window */
-
- debug_board_write_str("calling browser_window_create\n");
-
- ret = nsurl_create(feurl, &url);
- if (ret == NSERROR_OK) {
- ret = browser_window_create(BW_CREATE_HISTORY,
- url,
- NULL,
- NULL,
- &bw);
- nsurl_unref(url);
- }
-
- if (ret != NSERROR_OK) {
- warn_user(messages_get_errorcode(ret), 0);
- } else {
- debug_board_write_str("calling framebuffer run\n");
-
- framebuffer_run();
-
- debug_board_write_str("framebuffer run returned. \n");
-
- debug_board_write_str("Killing browser window.\n");
- browser_window_destroy(bw);
- }
-
- debug_board_write_str("Calling netsurf_exit()\n");
- netsurf_exit();
-
- if (fb_font_finalise() == false)
- LOG("Font finalisation failed.");
-
- /* finalise options */
- nsoption_finalise(nsoptions, nsoptions_default);
-
- free(*respaths);
- free(respaths);
- return 0;
-}
diff --git a/utils/log.c b/utils/log.c
index 15a7a9e..f544303 100644
--- a/utils/log.c
+++ b/utils/log.c
@@ -173,6 +173,7 @@ static const char *nslog_gettime(void)
void nslog_log(const char *file, const char *func, int ln, const char *format, ...)
{
+#ifndef _TARGET_IS_KOLIBRIOS
va_list ap;
fprintf(logfile, "%s %s:%i %s: ", nslog_gettime(), file, ln, func);
@@ -184,6 +185,17 @@ void nslog_log(const char *file, const char *func, int ln, const char *format, .
va_end(ap);
fputc('\n', logfile);
+#else
+ va_list ap;
+ char message[1000];
+
+ va_start(ap, format);
+ vsprintf(message, format, ap);
+ va_end(ap);
+
+ debug_board_printf(message);
+ debug_board_printf("\n");
+#endif
}
#endif
diff --git a/utils/nsoption.h b/utils/nsoption.h
index dc23a70..113efce 100644
--- a/utils/nsoption.h
+++ b/utils/nsoption.h
@@ -56,9 +56,6 @@
#define NSOPTION_UINT(NAME, DEFAULT)
#define NSOPTION_COLOUR(NAME, DEFAULT)
-#ifndef _TARGET_IS_KOLIBRIOS
-#define _TARGET_IS_KOLIBRIOS
-#endif
#ifdef _TARGET_IS_KOLIBRIOS
#define nskolibrios
#endif