summaryrefslogtreecommitdiff
path: root/monkey
diff options
context:
space:
mode:
Diffstat (limited to 'monkey')
-rw-r--r--monkey/401login.c52
-rw-r--r--monkey/Makefile.target65
-rw-r--r--monkey/bitmap.c128
-rw-r--r--monkey/browser.c418
-rw-r--r--monkey/browser.h42
-rw-r--r--monkey/cert.c54
-rw-r--r--monkey/download.c79
-rw-r--r--monkey/filetype.c227
-rw-r--r--monkey/filetype.h21
-rw-r--r--monkey/font.c96
-rw-r--r--monkey/main.c120
-rw-r--r--monkey/options.h77
-rw-r--r--monkey/plot.c97
-rw-r--r--monkey/poll.c108
l---------monkey/res1
-rw-r--r--monkey/schedule.c128
-rw-r--r--monkey/schedule.h25
-rw-r--r--monkey/system_colour.c284
-rw-r--r--monkey/thumbnail.c31
-rw-r--r--monkey/utils.c152
20 files changed, 2205 insertions, 0 deletions
diff --git a/monkey/401login.c b/monkey/401login.c
new file mode 100644
index 000000000..a079ef30d
--- /dev/null
+++ b/monkey/401login.c
@@ -0,0 +1,52 @@
+/*
+ * Copyright 2011 Daniel Silverstone <dsilvers@digital-scurf.org>
+ *
+ * This file is part of NetSurf, http://www.netsurf-browser.org/
+ *
+ * NetSurf is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * NetSurf is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "desktop/401login.h"
+#include "utils/ring.h"
+
+#include <stdlib.h>
+#include <stdio.h>
+
+typedef struct monkey401 {
+ struct monkey401 *r_next, *r_prev;
+ uint32_t num;
+ char *host; /* Ignore */
+ nserror (*cb)(bool,void*);
+ void *pw;
+} monkey401_t;
+
+static monkey401_t *m4_ring = NULL;
+static uint32_t m4_ctr = 0;
+
+void gui_401login_open(const char *url, const char *realm,
+ nserror (*cb)(bool proceed, void *pw), void *cbpw)
+{
+ monkey401_t *m4t = calloc(sizeof(*m4t), 1);
+ if (m4t == NULL)
+ cb(false, cbpw);
+ m4t->cb = cb;
+ m4t->pw = cbpw;
+ m4t->num = m4_ctr++;
+
+ RING_INSERT(m4_ring, m4t);
+
+ fprintf(stdout, "401LOGIN OPEN M4 %u URL %s REALM %s\n",
+ m4t->num, url, realm);
+}
+
+
diff --git a/monkey/Makefile.target b/monkey/Makefile.target
new file mode 100644
index 000000000..e4af5dbde
--- /dev/null
+++ b/monkey/Makefile.target
@@ -0,0 +1,65 @@
+# ----------------------------------------------------------------------------
+# Monkey flag setup (using pkg-config)
+# ----------------------------------------------------------------------------
+
+
+ LDFLAGS += $(shell $(PKG_CONFIG) --libs libxml-2.0 libcurl libhubbub libcss)
+ LDFLAGS += $(shell $(PKG_CONFIG) --libs openssl)
+
+ # define additional CFLAGS and LDFLAGS requirements for pkg-configed libs here
+ NETSURF_FEATURE_NSSVG_CFLAGS := -DWITH_NS_SVG
+ NETSURF_FEATURE_ROSPRITE_CFLAGS := -DWITH_NSSPRITE
+ NETSURF_FEATURE_BMP_CFLAGS := -DWITH_BMP
+ NETSURF_FEATURE_GIF_CFLAGS := -DWITH_GIF
+ NETSURF_FEATURE_PNG_CFLAGS := -DWITH_PNG
+ NETSURF_FEATURE_WEBP_CFLAGS := -DWITH_WEBP
+
+ # add a line similar to below for each optional pkg-configed lib here
+ $(eval $(call pkg_config_find_and_add,NSSVG,libsvgtiny,SVG))
+ $(eval $(call pkg_config_find_and_add,ROSPRITE,librosprite,Sprite))
+ $(eval $(call pkg_config_find_and_add,BMP,libnsbmp,BMP))
+ $(eval $(call pkg_config_find_and_add,GIF,libnsgif,GIF))
+ $(eval $(call pkg_config_find_and_add,PNG,libpng,PNG ))
+
+ # no pkg-config for this library
+ $(eval $(call feature_enabled,WEBP,-DWITH_WEBP,-lwebp -lvpx,WebP (libwebp)))
+
+ MONKEYCFLAGS := -std=c99 -Dmonkey -Dnsmonkey \
+ -D_GNU_SOURCE \
+ -D_BSD_SOURCE \
+ -D_XOPEN_SOURCE=600 \
+ -D_POSIX_C_SOURCE=200112L \
+ -D_NETBSD_SOURCE \
+ -DMONKEY_RESPATH=\"$(NETSURF_MONKEY_RESOURCES)\" \
+ $(WARNFLAGS) -I. -g \
+ $(shell $(PKG_CONFIG) --cflags glib-2.0) \
+ $(shell $(PKG_CONFIG) --cflags libhubbub libcurl) \
+ $(shell $(PKG_CONFIG) --cflags openssl) \
+ $(shell xml2-config --cflags)
+
+ MONKEYLDFLAGS := $(shell $(PKG_CONFIG) --cflags --libs glib-2.0 lcms)
+
+ CFLAGS += $(MONKEYCFLAGS) -Werror
+ LDFLAGS += $(MONKEYLDFLAGS)
+
+ # ---------------------------------------------------------------------------
+ # Windows flag setup
+ # ---------------------------------------------------------------------------
+
+ ifeq ($(HOST),Windows_NT)
+ CFLAGS += -U__STRICT_ANSI__
+ endif
+
+# ----------------------------------------------------------------------------
+# Source file setup
+# ----------------------------------------------------------------------------
+
+# S_MONKEY are sources purely for the MONKEY build
+S_MONKEY := main.c utils.c filetype.c schedule.c system_colour.c \
+ bitmap.c plot.c browser.c download.c thumbnail.c \
+ 401login.c cert.c font.c poll.c
+
+S_MONKEY := $(addprefix monkey/,$(S_MONKEY))
+
+SOURCES := $(S_COMMON) $(S_IMAGE) $(S_BROWSER) $(S_PDF) $(S_MONKEY)
+EXETARGET := nsmonkey
diff --git a/monkey/bitmap.c b/monkey/bitmap.c
new file mode 100644
index 000000000..92612081b
--- /dev/null
+++ b/monkey/bitmap.c
@@ -0,0 +1,128 @@
+/*
+ * Copyright 2011 Daniel Silverstone <dsilvers@digital-scurf.org>
+ *
+ * This file is part of NetSurf, http://www.netsurf-browser.org/
+ *
+ * NetSurf is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * NetSurf is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <stdbool.h>
+#include <stdio.h>
+
+#include "image/bitmap.h"
+
+struct bitmap {
+ void *ptr;
+ size_t rowstride;
+ int width;
+ int height;
+ unsigned int state;
+};
+
+void *bitmap_create(int width, int height, unsigned int state)
+{
+ struct bitmap *ret = calloc(sizeof(*ret), 1);
+ if (ret == NULL)
+ return NULL;
+
+ ret->width = width;
+ ret->height = height;
+ ret->state = state;
+
+ ret->ptr = calloc(width, height * 4);
+
+ if (ret->ptr == NULL) {
+ free(ret);
+ return NULL;
+ }
+
+ return ret;
+}
+
+void bitmap_destroy(void *bitmap)
+{
+ struct bitmap *bmap = bitmap;
+ free(bmap->ptr);
+ free(bmap);
+}
+
+void bitmap_set_opaque(void *bitmap, bool opaque)
+{
+ struct bitmap *bmap = bitmap;
+
+ if (opaque)
+ bmap->state |= (BITMAP_OPAQUE);
+ else
+ bmap->state &= ~(BITMAP_OPAQUE);
+}
+
+bool bitmap_test_opaque(void *bitmap)
+{
+ return false;
+}
+
+bool bitmap_get_opaque(void *bitmap)
+{
+ struct bitmap *bmap = bitmap;
+
+ return (bmap->state & BITMAP_OPAQUE) == BITMAP_OPAQUE;
+}
+
+unsigned char *bitmap_get_buffer(void *bitmap)
+{
+ struct bitmap *bmap = bitmap;
+
+ return (unsigned char *)(bmap->ptr);
+}
+
+size_t bitmap_get_rowstride(void *bitmap)
+{
+ struct bitmap *bmap = bitmap;
+ return bmap->width * 4;
+}
+
+size_t bitmap_get_bpp(void *bitmap)
+{
+ /* OMG?! */
+ return 4;
+}
+
+bool bitmap_save(void *bitmap, const char *path, unsigned flags)
+{
+ fprintf(stdout, "BITMAP_SAVE %s %08x\n", path, flags);
+ return true;
+}
+
+void bitmap_modified(void *bitmap)
+{
+ struct bitmap *bmap = bitmap;
+ bmap->state |= BITMAP_MODIFIED;
+}
+
+void bitmap_set_suspendable(void *bitmap, void *private_word,
+ void (*invalidate)(void *bitmap, void *private_word))
+{
+
+}
+
+int bitmap_get_width(void *bitmap)
+{
+ struct bitmap *bmap = bitmap;
+ return bmap->width;
+}
+
+int bitmap_get_height(void *bitmap)
+{
+ struct bitmap *bmap = bitmap;
+ return bmap->height;
+}
diff --git a/monkey/browser.c b/monkey/browser.c
new file mode 100644
index 000000000..b7afa658e
--- /dev/null
+++ b/monkey/browser.c
@@ -0,0 +1,418 @@
+/*
+ * Copyright 2011 Daniel Silverstone <dsilvers@digital-scurf.org>
+ *
+ * This file is part of NetSurf, http://www.netsurf-browser.org/
+ *
+ * NetSurf is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * NetSurf is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/* Browser-related callbacks */
+
+#include <stdio.h>
+
+
+#include "desktop/browser.h"
+#include "desktop/gui.h"
+#include "utils/ring.h"
+
+#include "monkey/browser.h"
+
+static uint32_t win_ctr = 0;
+
+static struct gui_window *gw_ring = NULL;
+
+struct gui_window *
+monkey_find_window_by_num(uint32_t win_num)
+{
+ struct gui_window *ret = NULL;
+
+ RING_ITERATE_START(struct gui_window, gw_ring, c_ring) {
+ if (c_ring->win_num == win_num) {
+ ret = c_ring;
+ RING_ITERATE_STOP(gw_ring, c_ring);
+ }
+ } RING_ITERATE_END(gw_ring, c_ring);
+
+ return ret;
+}
+
+struct gui_window *
+monkey_find_window_by_content(hlcache_handle *content)
+{
+ struct gui_window *ret = NULL;
+
+ RING_ITERATE_START(struct gui_window, gw_ring, c_ring) {
+ if (c_ring->bw->current_content == content) {
+ ret = c_ring;
+ RING_ITERATE_STOP(gw_ring, c_ring);
+ }
+ } RING_ITERATE_END(gw_ring, c_ring);
+
+ return ret;
+}
+
+void
+monkey_window_process_reformats(void)
+{
+ RING_ITERATE_START(struct gui_window, gw_ring, c_ring) {
+ if (c_ring == NULL)
+ RING_ITERATE_STOP(gw_ring, c_ring);
+ if (c_ring->bw->reformat_pending) {
+ browser_window_reformat(c_ring->bw,
+ c_ring->width,
+ c_ring->height);
+ }
+ } RING_ITERATE_END(gw_ring, c_ring);
+}
+
+
+struct gui_window *
+gui_create_browser_window(struct browser_window *bw,
+ struct browser_window *clone, bool new_tab)
+{
+ struct gui_window *ret = calloc(sizeof(*ret), 1);
+ if (ret == NULL)
+ return NULL;
+
+ ret->win_num = win_ctr++;
+ ret->bw = bw;
+
+ ret->width = 800;
+ ret->height = 600;
+
+ fprintf(stdout, "BROWSER_WINDOW NEW WIN %u FOR %p CLONE %p NEWTAB %s\n",
+ ret->win_num, bw, clone, new_tab ? "TRUE" : "FALSE");
+ fprintf(stdout, "BROWSER_WINDOW SIZE WIN %u WIDTH %d HEIGHT %d\n",
+ ret->win_num, ret->width, ret->height);
+
+ RING_INSERT(gw_ring, ret);
+
+ return ret;
+}
+
+struct browser_window *
+gui_window_get_browser_window(struct gui_window *g)
+{
+ return g->bw;
+}
+
+void
+gui_window_destroy(struct gui_window *g)
+{
+ fprintf(stdout, "BROWSER_WINDOW DESTROY WIN %u\n", g->win_num);
+ RING_REMOVE(gw_ring, g);
+ free(g);
+}
+
+void
+gui_window_set_title(struct gui_window *g, const char *title)
+{
+ fprintf(stdout, "BROWSER_WINDOW TITLE WIN %u STR %s\n", g->win_num, title);
+}
+
+void
+gui_window_redraw_window(struct gui_window *g)
+{
+ fprintf(stdout, "BROWSER_WINDOW REDRAW WIN %u\n", g->win_num);
+}
+
+void
+gui_launch_url(const char *url)
+{
+ fprintf(stdout, "GENERIC LAUNCH URL %s\n", url);
+}
+
+void
+gui_window_get_dimensions(struct gui_window *g, int *width, int *height,
+ bool scaled)
+{
+ fprintf(stdout, "BROWSER_WINDOW GET_DIMENSIONS WIN %u WIDTH %d HEIGHT %d\n",
+ g->win_num, g->width, g->height);
+ *width = g->width;
+ *height = g->height;
+}
+
+void
+gui_window_new_content(struct gui_window *g)
+{
+ fprintf(stdout, "BROWSER_WINDOW NEW_CONTENT WIN %u\n", g->win_num);
+}
+
+void
+gui_window_set_icon(struct gui_window *g, hlcache_handle *icon)
+{
+ fprintf(stdout, "BROWSER_WINDOW NEW_ICON WIN %u\n", g->win_num);
+}
+
+void
+gui_window_start_throbber(struct gui_window *g)
+{
+ fprintf(stdout, "BROWSER_WINDOW START_THROBBER WIN %u\n", g->win_num);
+}
+
+void
+gui_window_stop_throbber(struct gui_window *g)
+{
+ fprintf(stdout, "BROWSER_WINDOW STOP_THROBBER WIN %u\n", g->win_num);
+}
+
+void
+gui_window_set_scroll(struct gui_window *g, int sx, int sy)
+{
+ g->scrollx = sx;
+ g->scrolly = sy;
+ fprintf(stdout, "BROWSER_WINDOW SET_SCROLL WIN %u X %d Y %d\n", g->win_num, sx, sy);
+}
+
+void
+gui_window_update_box(struct gui_window *g,
+ const union content_msg_data *data)
+{
+ fprintf(stdout, "BROWSER_WINDOW UPDATE_BOX WIN %u X %d Y %d WIDTH %d HEIGHT %d\n",
+ g->win_num, data->redraw.x, data->redraw.y,
+ data->redraw.width, data->redraw.height);
+
+}
+
+void
+gui_window_update_extent(struct gui_window *g)
+{
+ if (!g->bw->current_content)
+ return;
+
+ fprintf(stdout, "BROWSER_WINDOW UPDATE_EXTENT WIN %u WIDTH %d HEIGHT %d\n",
+ g->win_num,
+ content_get_width(g->bw->current_content),
+ content_get_height(g->bw->current_content));
+}
+
+void
+gui_window_set_status(struct gui_window *g, const char *text)
+{
+ fprintf(stdout, "BROWSER_WINDOW SET_STATUS WIN %u STR %s\n", g->win_num, text);
+}
+
+void
+gui_window_set_pointer(struct gui_window *g, gui_pointer_shape shape)
+{
+ const char *ptr_name = "UNKNOWN";
+
+ switch (shape) {
+ case GUI_POINTER_POINT:
+ ptr_name = "POINT";
+ break;
+ case GUI_POINTER_CARET:
+ ptr_name = "CARET";
+ break;
+ case GUI_POINTER_UP:
+ ptr_name = "UP";
+ break;
+ case GUI_POINTER_DOWN:
+ ptr_name = "DOWN";
+ break;
+ case GUI_POINTER_LEFT:
+ ptr_name = "LEFT";
+ break;
+ case GUI_POINTER_RIGHT:
+ ptr_name = "RIGHT";
+ break;
+ case GUI_POINTER_LD:
+ ptr_name = "LD";
+ break;
+ case GUI_POINTER_RD:
+ ptr_name = "RD";
+ break;
+ case GUI_POINTER_LU:
+ ptr_name = "LU";
+ break;
+ case GUI_POINTER_RU:
+ ptr_name = "RU";
+ break;
+ case GUI_POINTER_CROSS:
+ ptr_name = "CROSS";
+ break;
+ case GUI_POINTER_MOVE:
+ ptr_name = "MOVE";
+ break;
+ case GUI_POINTER_WAIT:
+ ptr_name = "WAIT";
+ break;
+ case GUI_POINTER_HELP:
+ ptr_name = "HELP";
+ break;
+ case GUI_POINTER_MENU:
+ ptr_name = "MENU";
+ break;
+ case GUI_POINTER_PROGRESS:
+ ptr_name = "PROGRESS";
+ break;
+ case GUI_POINTER_NO_DROP:
+ ptr_name = "NO_DROP";
+ break;
+ case GUI_POINTER_NOT_ALLOWED:
+ ptr_name = "NOT_ALLOWED";
+ break;
+ case GUI_POINTER_DEFAULT:
+ ptr_name = "DEFAULT";
+ break;
+ default:
+ break;
+ }
+ fprintf(stdout, "BROWSER_WINDOW SET_POINTER WIN %u POINTER %s\n", g->win_num, ptr_name);
+}
+
+void
+gui_window_set_scale(struct gui_window *g, float scale)
+{
+ fprintf(stdout, "BROWSER_WINDOW SET_SCALE WIN %u SCALE %f\n", g->win_num, scale);
+}
+
+void
+gui_window_set_url(struct gui_window *g, const char *url)
+{
+ fprintf(stdout, "BROWSER_WINDOW SET_URL WIN %u URL %s\n", g->win_num, url);
+}
+
+void
+gui_drag_save_object(gui_save_type type, hlcache_handle *c,
+ struct gui_window *g)
+{
+ /* Ignore? */
+}
+
+bool
+gui_window_get_scroll(struct gui_window *g, int *sx, int *sy)
+{
+ fprintf(stdout, "BROWSER_WINDOW GET_SCROLL WIN %u X %d Y %d\n",
+ g->win_num, g->scrollx, g->scrolly);
+ *sx = g->scrollx;
+ *sy = g->scrolly;
+ return true;
+}
+
+bool
+gui_window_scroll_start(struct gui_window *g)
+{
+ fprintf(stdout, "BROWSER_WINDOW SCROLL_START WIN %u\n", g->win_num);
+ g->scrollx = g->scrolly = 0;
+ return true;
+}
+
+void
+gui_window_position_frame(struct gui_window *g, int x0, int y0,
+ int x1, int y1)
+{
+ fprintf(stdout, "BROWSER_WINDOW POSITION_FRAME WIN %u X0 %d Y0 %d X1 %d Y1 %d\n",
+ g->win_num, x0, y0, x1, y1);
+}
+
+bool
+gui_window_frame_resize_start(struct gui_window *g)
+{
+ return true;
+}
+
+void
+gui_window_set_search_ico(hlcache_handle *ico)
+{
+}
+
+void
+gui_window_scroll_visible(struct gui_window *g, int x0, int y0,
+ int x1, int y1)
+{
+ fprintf(stdout, "BROWSER_WINDOW SCROLL_VISIBLE WIN %u X0 %d Y0 %d X1 %d Y1 %d\n",
+ g->win_num, x0, y0, x1, y1);
+}
+
+void
+gui_drag_save_selection(struct selection *s, struct gui_window *g)
+{
+}
+
+void
+gui_start_selection(struct gui_window *g)
+{
+}
+
+void
+gui_clear_selection(struct gui_window *g)
+{
+}
+
+void
+gui_paste_from_clipboard(struct gui_window *g, int x, int y)
+{
+}
+
+bool
+gui_empty_clipboard(void)
+{
+ return true;
+}
+
+bool
+gui_add_to_clipboard(const char *text, size_t length, bool space)
+{
+ return true;
+}
+
+bool
+gui_commit_clipboard(void)
+{
+ return true;
+}
+
+bool
+gui_copy_to_clipboard(struct selection *s)
+{
+ return true;
+}
+
+void
+gui_window_place_caret(struct gui_window *g, int x, int y, int height)
+{
+ fprintf(stdout, "BROWSER_WINDOW PLACE_CARET WIN %u X %d Y %d HEIGHT %d\n",
+ g->win_num, x, y, height);
+}
+
+void
+gui_window_remove_caret(struct gui_window *g)
+{
+ fprintf(stdout, "BROWSER_WINDOW REMOVE_CARET WIN %u\n", g->win_num);
+}
+
+bool
+gui_window_box_scroll_start(struct gui_window *g,
+ int x0, int y0, int x1, int y1)
+{
+ fprintf(stdout, "BROWSER_WINDOW SCROLL_START WIN %u X0 %d Y0 %d X1 %d Y1 %d\n",
+ g->win_num, x0, y0, x1, y1);
+ return false;
+}
+
+void
+gui_create_form_select_menu(struct browser_window *bw,
+ struct form_control *control)
+{
+ fprintf(stdout, "BROWSER_WINDOW SELECT_MENU WIN %u\n",
+ bw->window->win_num);
+}
+
+void
+gui_window_save_link(struct gui_window *g, const char *url,
+ const char *title)
+{
+ fprintf(stdout, "BROWSER_WINDOW SAVE_LINK WIN %u URL %s TITLE %s\n",
+ g->win_num, url, title);
+}
diff --git a/monkey/browser.h b/monkey/browser.h
new file mode 100644
index 000000000..a8a565180
--- /dev/null
+++ b/monkey/browser.h
@@ -0,0 +1,42 @@
+/*
+ * Copyright 2011 Daniel Silverstone <dsilvers@digital-scurf.org>
+ *
+ * This file is part of NetSurf, http://www.netsurf-browser.org/
+ *
+ * NetSurf is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * NetSurf is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef NETSURF_MONKEY_BROWSER_H
+#define NETSURF_MONKEY_BROWSER_H
+
+#include "desktop/browser.h"
+#include "content/hlcache.h"
+
+struct gui_window {
+ struct gui_window *r_next;
+ struct gui_window *r_prev;
+
+ uint32_t win_num;
+ struct browser_window *bw;
+
+ int width, height;
+ int scrollx, scrolly;
+
+ char *host; /* Ignore this, it's in case RING*() gets debugging for fetchers */
+
+};
+
+struct gui_window *monkey_find_window_by_num(uint32_t win_num);
+struct gui_window *monkey_find_window_by_content(hlcache_handle *content);
+void monkey_window_process_reformats(void);
+#endif /* NETSURF_MONKEY_BROWSER_H */
diff --git a/monkey/cert.c b/monkey/cert.c
new file mode 100644
index 000000000..265a32678
--- /dev/null
+++ b/monkey/cert.c
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2011 Daniel Silverstone <dsilvers@digital-scurf.org>
+ *
+ * This file is part of NetSurf, http://www.netsurf-browser.org/
+ *
+ * NetSurf is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * NetSurf is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "desktop/gui.h"
+#include "utils/ring.h"
+
+#include <stdlib.h>
+#include <stdio.h>
+
+typedef struct monkey_cert {
+ struct monkey_cert *r_next, *r_prev;
+ uint32_t num;
+ char *host; /* Ignore */
+ nserror (*cb)(bool,void*);
+ void *pw;
+} monkey_cert_t;
+
+static monkey_cert_t *cert_ring = NULL;
+static uint32_t cert_ctr = 0;
+
+void
+gui_cert_verify(const char *url, const struct ssl_cert_info *certs,
+ unsigned long num, nserror (*cb)(bool proceed, void *pw),
+ void *cbpw)
+{
+ monkey_cert_t *m4t = calloc(sizeof(*m4t), 1);
+ if (m4t == NULL)
+ cb(false, cbpw);
+ m4t->cb = cb;
+ m4t->pw = cbpw;
+ m4t->num = cert_ctr++;
+
+ RING_INSERT(cert_ring, m4t);
+
+ fprintf(stdout, "SSLCERT VERIFY CERT %u URL %s\n",
+ m4t->num, url);
+}
+
+
diff --git a/monkey/download.c b/monkey/download.c
new file mode 100644
index 000000000..d706dd6e0
--- /dev/null
+++ b/monkey/download.c
@@ -0,0 +1,79 @@
+/*
+ * Copyright 2011 Daniel Silverstone <dsilvers@digital-scurf.org>
+ *
+ * This file is part of NetSurf, http://www.netsurf-browser.org/
+ *
+ * NetSurf is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * NetSurf is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "desktop/browser.h"
+#include "monkey/browser.h"
+#include "utils/ring.h"
+
+#include <stdio.h>
+
+static uint32_t dwin_ctr = 0;
+
+struct gui_download_window {
+ struct gui_download_window *r_next;
+ struct gui_download_window *r_prev;
+ struct gui_window *g;
+ uint32_t dwin_num;
+ char *host; /* ignore */
+};
+
+static struct gui_download_window *dw_ring = NULL;
+
+struct gui_download_window *
+gui_download_window_create(download_context *ctx,
+ struct gui_window *parent)
+{
+ struct gui_download_window *ret = calloc(sizeof(*ret), 1);
+ if (ret == NULL)
+ return NULL;
+ ret->g = parent;
+ ret->dwin_num = dwin_ctr++;
+
+ RING_INSERT(dw_ring, ret);
+
+ fprintf(stdout, "DOWNLOAD_WINDOW CREATE DWIN %u WIN %u\n",
+ ret->dwin_num, parent->win_num);
+
+ return ret;
+}
+
+nserror
+gui_download_window_data(struct gui_download_window *dw,
+ const char *data, unsigned int size)
+{
+ fprintf(stdout, "DOWNLOAD_WINDOW DATA DWIN %u SIZE %u DATA %s\n",
+ dw->dwin_num, size, data);
+ return NSERROR_OK;
+}
+
+void
+gui_download_window_error(struct gui_download_window *dw,
+ const char *error_msg)
+{
+ fprintf(stdout, "DOWNLOAD_WINDOW ERROR DWIN %u ERROR %s\n",
+ dw->dwin_num, error_msg);
+}
+
+void
+gui_download_window_done(struct gui_download_window *dw)
+{
+ fprintf(stdout, "DOWNLOAD_WINDOW DONE DWIN %u\n",
+ dw->dwin_num);
+ RING_REMOVE(dw_ring, dw);
+ free(dw);
+}
diff --git a/monkey/filetype.c b/monkey/filetype.c
new file mode 100644
index 000000000..f89f2358c
--- /dev/null
+++ b/monkey/filetype.c
@@ -0,0 +1,227 @@
+/*
+ * Copyright 2007 Rob Kendrick <rjek@netsurf-browser.org>
+ * Copyright 2007 Vincent Sanders <vince@debian.org>
+ *
+ * This file is part of NetSurf, http://www.netsurf-browser.org/
+ *
+ * NetSurf is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * NetSurf is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <stdio.h>
+#include <stdbool.h>
+#include <string.h>
+#include <stdlib.h>
+#include <ctype.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+
+#include "gtk/filetype.h"
+#include "content/fetch.h"
+#include "utils/log.h"
+#include "utils/hashtable.h"
+
+static struct hash_table *mime_hash = NULL;
+
+void gtk_fetch_filetype_init(const char *mimefile)
+{
+ struct stat statbuf;
+ FILE *fh = NULL;
+
+ mime_hash = hash_create(117);
+
+ /* first, check to see if /etc/mime.types in preference */
+
+ if ((stat("/etc/mime.types", &statbuf) == 0) &&
+ S_ISREG(statbuf.st_mode)) {
+ mimefile = "/etc/mime.types";
+
+ }
+
+ fh = fopen(mimefile, "r");
+
+ /* Some OSes (mentioning no Solarises) have a worthlessly tiny
+ * /etc/mime.types that don't include essential things, so we
+ * pre-seed our hash with the essentials. These will get
+ * over-ridden if they are mentioned in the mime.types file.
+ */
+
+ hash_add(mime_hash, "css", "text/css");
+ hash_add(mime_hash, "htm", "text/html");
+ hash_add(mime_hash, "html", "text/html");
+ hash_add(mime_hash, "jpg", "image/jpeg");
+ hash_add(mime_hash, "jpeg", "image/jpeg");
+ hash_add(mime_hash, "gif", "image/gif");
+ hash_add(mime_hash, "png", "image/png");
+ hash_add(mime_hash, "jng", "image/jng");
+ hash_add(mime_hash, "mng", "image/mng");
+ hash_add(mime_hash, "webp", "image/webp");
+ hash_add(mime_hash, "spr", "image/x-riscos-sprite");
+
+ if (fh == NULL) {
+ LOG(("Unable to open a mime.types file, so using a minimal one for you."));
+ return;
+ }
+
+ while (!feof(fh)) {
+ char line[256], *ptr, *type, *ext;
+ if (fgets(line, 256, fh) == NULL)
+ break;
+ if (!feof(fh) && line[0] != '#') {
+ ptr = line;
+
+ /* search for the first non-whitespace character */
+ while (isspace(*ptr))
+ ptr++;
+
+ /* is this line empty other than leading whitespace? */
+ if (*ptr == '\n' || *ptr == '\0')
+ continue;
+
+ type = ptr;
+
+ /* search for the first non-whitespace char or NUL or
+ * NL */
+ while (*ptr && (!isspace(*ptr)) && *ptr != '\n')
+ ptr++;
+
+ if (*ptr == '\0' || *ptr == '\n') {
+ /* this mimetype has no extensions - read next
+ * line.
+ */
+ continue;
+ }
+
+ *ptr++ = '\0';
+
+ /* search for the first non-whitespace character which
+ * will be the first filename extenion */
+ while (isspace(*ptr))
+ ptr++;
+
+ while(true) {
+ ext = ptr;
+
+ /* search for the first whitespace char or
+ * NUL or NL which is the end of the ext.
+ */
+ while (*ptr && (!isspace(*ptr)) &&
+ *ptr != '\n')
+ ptr++;
+
+ if (*ptr == '\0' || *ptr == '\n') {
+ /* special case for last extension on
+ * the line
+ */
+ *ptr = '\0';
+ hash_add(mime_hash, ext, type);
+ break;
+ }
+
+ *ptr++ = '\0';
+ hash_add(mime_hash, ext, type);
+
+ /* search for the first non-whitespace char or
+ * NUL or NL, to find start of next ext.
+ */
+ while (*ptr && (isspace(*ptr)) && *ptr != '\n')
+ ptr++;
+ }
+ }
+ }
+
+ fclose(fh);
+}
+
+void gtk_fetch_filetype_fin(void)
+{
+ hash_destroy(mime_hash);
+}
+
+const char *fetch_filetype(const char *unix_path)
+{
+ struct stat statbuf;
+ char *ext;
+ const char *ptr;
+ char *lowerchar;
+ const char *type;
+ int l;
+
+ stat(unix_path, &statbuf);
+ if (S_ISDIR(statbuf.st_mode))
+ return "application/x-netsurf-directory";
+
+ l = strlen(unix_path);
+ if ((3 < l) && (strcasecmp(unix_path + l - 4, ",f79") == 0)) {
+ return "text/css";
+ }
+
+ if (strchr(unix_path, '.') == NULL) {
+ /* no extension anywhere! */
+ return "text/plain";
+ }
+
+ ptr = unix_path + strlen(unix_path);
+ while (*ptr != '.' && *ptr != '/')
+ ptr--;
+
+ if (*ptr != '.')
+ return "text/plain";
+
+ ext = strdup(ptr + 1); /* skip the . */
+
+ /* the hash table only contains lower-case versions - make sure this
+ * copy is lower case too.
+ */
+ lowerchar = ext;
+ while(*lowerchar) {
+ *lowerchar = tolower(*lowerchar);
+ lowerchar++;
+ }
+
+ type = hash_get(mime_hash, ext);
+ free(ext);
+
+ return type != NULL ? type : "text/plain";
+}
+
+char *fetch_mimetype(const char *unix_path)
+{
+ return strdup(fetch_filetype(unix_path));
+}
+
+#ifdef TEST_RIG
+
+int main(int argc, char *argv[])
+{
+ unsigned int c1, *c2;
+ const char *key;
+
+ gtk_fetch_filetype_init("./mime.types");
+
+ c1 = 0; c2 = 0;
+
+ while ( (key = hash_iterate(mime_hash, &c1, &c2)) != NULL) {
+ printf("%s ", key);
+ }
+
+ printf("\n");
+
+ if (argc > 1) {
+ printf("%s maps to %s\n", argv[1], fetch_filetype(argv[1]));
+ }
+
+ gtk_fetch_filetype_fin();
+}
+
+#endif
diff --git a/monkey/filetype.h b/monkey/filetype.h
new file mode 100644
index 000000000..8bf98db7c
--- /dev/null
+++ b/monkey/filetype.h
@@ -0,0 +1,21 @@
+/*
+ * Copyright 2007 Rob Kendrick <rjek@netsurf-browser.org>
+ * Copyright 2007 Vincent Sanders <vince@debian.org>
+ *
+ * This file is part of NetSurf, http://www.netsurf-browser.org/
+ *
+ * NetSurf is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * NetSurf is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+void gtk_fetch_filetype_init(const char *mimefile);
+void gtk_fetch_filetype_fin(void);
diff --git a/monkey/font.c b/monkey/font.c
new file mode 100644
index 000000000..759c3e935
--- /dev/null
+++ b/monkey/font.c
@@ -0,0 +1,96 @@
+/*
+ * Copyright 2011 Daniel Silverstone <dsilvers@digital-scurf.org>
+ *
+ * This file is part of NetSurf, http://www.netsurf-browser.org/
+ *
+ * NetSurf is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * NetSurf is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "css/css.h"
+#include "render/font.h"
+#include "desktop/options.h"
+#include "utils/utf8.h"
+
+
+static bool nsfont_width(const plot_font_style_t *fstyle,
+ const char *string, size_t length,
+ int *width)
+{
+ *width = (fstyle->size * utf8_bounded_length(string, length)) / FONT_SIZE_SCALE;
+ return true;
+}
+
+/**
+ * Find the position in a string where an x coordinate falls.
+ *
+ * \param fstyle style for this text
+ * \param string UTF-8 string to measure
+ * \param length length of string
+ * \param x x coordinate to search for
+ * \param char_offset updated to offset in string of actual_x, [0..length]
+ * \param actual_x updated to x coordinate of character closest to x
+ * \return true on success, false on error and error reported
+ */
+
+static bool nsfont_position_in_string(const plot_font_style_t *fstyle,
+ const char *string, size_t length,
+ int x, size_t *char_offset, int *actual_x)
+{
+ *char_offset = x / (fstyle->size / FONT_SIZE_SCALE);
+ if (*char_offset > length)
+ *char_offset = length;
+ *actual_x = *char_offset * (fstyle->size / FONT_SIZE_SCALE);
+ return true;
+}
+
+
+/**
+ * Find where to split a string to make it fit a width.
+ *
+ * \param fstyle style for this text
+ * \param string UTF-8 string to measure
+ * \param length length of string
+ * \param x width available
+ * \param char_offset updated to offset in string of actual_x, [0..length]
+ * \param actual_x updated to x coordinate of character closest to x
+ * \return true on success, false on error and error reported
+ *
+ * On exit, [char_offset == 0 ||
+ * string[char_offset] == ' ' ||
+ * char_offset == length]
+ */
+
+static bool nsfont_split(const plot_font_style_t *fstyle,
+ const char *string, size_t length,
+ int x, size_t *char_offset, int *actual_x)
+{
+
+ *char_offset = x / (fstyle->size / FONT_SIZE_SCALE);
+ if (*char_offset > length) {
+ *char_offset = length;
+ } else {
+ while (*char_offset > 0) {
+ if (string[*char_offset] == ' ')
+ break;
+ (*char_offset)--;
+ }
+ }
+ *actual_x = *char_offset * (fstyle->size / FONT_SIZE_SCALE);
+ return true;
+}
+
+const struct font_functions nsfont = {
+ nsfont_width,
+ nsfont_position_in_string,
+ nsfont_split
+};
diff --git a/monkey/main.c b/monkey/main.c
new file mode 100644
index 000000000..1da7e3608
--- /dev/null
+++ b/monkey/main.c
@@ -0,0 +1,120 @@
+/*
+ * Copyright 2011 Daniel Silverstone <dsilvers@digital-scurf.org>
+ *
+ * This file is part of NetSurf, http://www.netsurf-browser.org/
+ *
+ * NetSurf is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * NetSurf is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <glib.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "monkey/filetype.h"
+#include "monkey/options.h"
+
+#include "content/urldb.h"
+#include "content/fetchers/resource.h"
+#include "desktop/gui.h"
+#include "desktop/netsurf.h"
+#include "desktop/sslcert.h"
+#include "utils/resource.h"
+#include "utils/url.h"
+
+char *default_stylesheet_url = NULL;
+char *quirks_stylesheet_url = NULL;
+char *adblock_stylesheet_url = NULL;
+
+static char **respaths; /** resource search path vector */
+
+/* Stolen from gtk/gui.c */
+static char **
+nsmonkey_init_resource(const char *resource_path)
+{
+ const gchar * const *langv;
+ char **pathv; /* resource path string vector */
+ char **respath; /* resource paths vector */
+
+ pathv = resource_path_to_strvec(resource_path);
+
+ langv = g_get_language_names();
+
+ respath = resource_generate(pathv, langv);
+
+ resource_free_strvec(pathv);
+
+ return respath;
+}
+
+void gui_quit(void)
+{
+ urldb_save_cookies(option_cookie_jar);
+ urldb_save(option_url_file);
+ sslcert_cleanup();
+ free(default_stylesheet_url);
+ free(quirks_stylesheet_url);
+ free(adblock_stylesheet_url);
+ free(option_cookie_file);
+ free(option_cookie_jar);
+ gtk_fetch_filetype_fin();
+}
+
+char* gui_find_resource(const char *filename)
+{
+ char buf[PATH_MAX];
+ return path_to_url(resource_sfind(respaths, buf, filename));
+}
+
+int
+main(int argc, char **argv)
+{
+ char *messages;
+ char *options;
+ char buf[PATH_MAX];
+
+ /* Unbuffer stdin/out/err */
+ setbuf(stdin, NULL);
+ setbuf(stdout, NULL);
+ setbuf(stderr, NULL);
+
+ /* Prep the search paths */
+ respaths = nsmonkey_init_resource("${HOME}/.netsurf/:${NETSURFRES}:"MONKEY_RESPATH":./monkey/res");
+
+ options = resource_find(respaths, "Choices");
+ messages = resource_find(respaths, "Messages");
+
+ netsurf_init(&argc, &argv, options, messages);
+
+ free(messages);
+ free(options);
+
+ resource_sfinddef(respaths, buf, "mime.types", "/etc/");
+ gtk_fetch_filetype_init(buf);
+
+ default_stylesheet_url = strdup("resource:gtkdefault.css");
+ quirks_stylesheet_url = strdup("resource:quirks.css");
+ adblock_stylesheet_url = strdup("resource:adblock.css");
+
+ urldb_load(option_url_file);
+ urldb_load_cookies(option_cookie_file);
+
+ sslcert_init("content.png");
+
+ browser_window_create("http://www.netsurf-browser.org/welcome/", 0, 0, true, false);
+
+ netsurf_main_loop();
+
+ netsurf_exit();
+
+ return 0;
+}
diff --git a/monkey/options.h b/monkey/options.h
new file mode 100644
index 000000000..ac14259d8
--- /dev/null
+++ b/monkey/options.h
@@ -0,0 +1,77 @@
+/*
+ * Copyright 2006 Rob Kendrick <rjek@rjek.com>
+ *
+ * This file is part of NetSurf, http://www.netsurf-browser.org/
+ *
+ * NetSurf is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * NetSurf is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef _NETSURF_GTK_OPTIONS_H_
+#define _NETSURF_GTK_OPTIONS_H_
+
+#include "desktop/options.h"
+
+extern bool option_render_resample;
+extern bool option_downloads_clear;
+extern bool option_request_overwrite;
+extern char *option_downloads_directory;
+extern char *option_url_file;
+extern bool option_show_single_tab;
+extern int option_button_type;
+extern bool option_disable_popups;
+extern bool option_disable_plugins;
+extern int option_history_age;
+extern bool option_hover_urls;
+extern bool option_focus_new;
+extern bool option_new_blank;
+extern char *option_hotlist_path;
+extern bool option_source_tab;
+extern int option_current_theme;
+
+#define EXTRA_OPTION_DEFINE \
+bool option_render_resample = true; \
+bool option_downloads_clear = false; \
+bool option_request_overwrite = true; \
+char *option_downloads_directory = 0; \
+char *option_url_file = 0; \
+bool option_show_single_tab = false; \
+int option_button_type = 0; \
+bool option_disable_popups = false; \
+bool option_disable_plugins = false; \
+int option_history_age = 0; \
+bool option_hover_urls = false; \
+bool option_focus_new = false; \
+bool option_new_blank = false; \
+char *option_hotlist_path = NULL; \
+bool option_source_tab = false;\
+int option_current_theme = 0;
+
+#define EXTRA_OPTION_TABLE \
+{ "render_resample", OPTION_BOOL, &option_render_resample }, \
+{ "downloads_clear", OPTION_BOOL, &option_downloads_clear }, \
+{ "request_overwrite", OPTION_BOOL, &option_request_overwrite }, \
+{ "downloads_directory",OPTION_STRING, &option_downloads_directory }, \
+{ "url_file", OPTION_STRING, &option_url_file }, \
+{ "show_single_tab", OPTION_BOOL, &option_show_single_tab }, \
+{ "button_type", OPTION_INTEGER, &option_button_type}, \
+{ "disable_popups", OPTION_BOOL, &option_disable_popups}, \
+{ "disable_plugins", OPTION_BOOL, &option_disable_plugins}, \
+{ "history_age", OPTION_INTEGER, &option_history_age}, \
+{ "hover_urls", OPTION_BOOL, &option_hover_urls}, \
+{ "focus_new", OPTION_BOOL, &option_focus_new}, \
+{ "new_blank", OPTION_BOOL, &option_new_blank}, \
+{ "hotlist_path", OPTION_STRING, &option_hotlist_path}, \
+{ "source_tab", OPTION_BOOL, &option_source_tab},\
+{ "current_theme", OPTION_INTEGER, &option_current_theme}
+
+#endif
diff --git a/monkey/plot.c b/monkey/plot.c
new file mode 100644
index 000000000..539f41fbe
--- /dev/null
+++ b/monkey/plot.c
@@ -0,0 +1,97 @@
+/*
+ * Copyright 2011 Daniel Silverstone <dsilvers@digital-scurf.org>
+ *
+ * This file is part of NetSurf, http://www.netsurf-browser.org/
+ *
+ * NetSurf is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * NetSurf is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "desktop/plotters.h"
+
+static bool
+monkey_plot_disc(int x, int y, int radius, const plot_style_t *style)
+{
+ return true;
+}
+
+static bool
+monkey_plot_arc(int x, int y, int radius, int angle1, int angle2, const plot_style_t *style)
+{
+ return true;
+}
+
+static bool
+monkey_plot_polygon(const int *p, unsigned int n, const plot_style_t *style)
+{
+ return true;
+}
+
+
+static bool
+monkey_plot_text(int x, int y, const char *text, size_t length,
+ const plot_font_style_t *fstyle)
+{
+ return true;
+}
+
+static bool
+monkey_plot_bitmap(int x, int y,
+ int width, int height,
+ struct bitmap *bitmap, colour bg,
+ bitmap_flags_t flags)
+{
+ return true;
+}
+
+static bool
+monkey_plot_rectangle(int x0, int y0, int x1, int y1, const plot_style_t *style)
+{
+ return true;
+}
+
+static bool
+monkey_plot_line(int x0, int y0, int x1, int y1, const plot_style_t *style)
+{
+ return true;
+}
+
+
+static bool
+monkey_plot_path(const float *p,
+ unsigned int n,
+ colour fill,
+ float width,
+ colour c,
+ const float transform[6])
+{
+ return true;
+}
+
+static bool
+monkey_plot_clip(const struct rect *clip)
+{
+ return true;
+}
+
+struct plotter_table plot = {
+ .clip = monkey_plot_clip,
+ .arc = monkey_plot_arc,
+ .disc = monkey_plot_disc,
+ .line = monkey_plot_line,
+ .rectangle = monkey_plot_rectangle,
+ .polygon = monkey_plot_polygon,
+ .path = monkey_plot_path,
+ .bitmap = monkey_plot_bitmap,
+ .text = monkey_plot_text,
+ .option_knockout = true,
+};
diff --git a/monkey/poll.c b/monkey/poll.c
new file mode 100644
index 000000000..ee7a32d4a
--- /dev/null
+++ b/monkey/poll.c
@@ -0,0 +1,108 @@
+/*
+ * Copyright 2011 Daniel Silverstone <dsilvers@digital-scurf.org>
+ *
+ * This file is part of NetSurf, http://www.netsurf-browser.org/
+ *
+ * NetSurf is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * NetSurf is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <assert.h>
+
+#include "desktop/browser.h"
+#include "desktop/gui.h"
+#include "monkey/schedule.h"
+#include "monkey/browser.h"
+#include "content/fetchers/curl.h"
+
+#ifdef DEBUG_POLL_LOOP
+#include "utils/log.h"
+#else
+#define LOG(X)
+#endif
+
+
+#include <glib.h>
+
+void gui_poll(bool active)
+{
+ CURLMcode code;
+ fd_set read_fd_set, write_fd_set, exc_fd_set;
+ int max_fd;
+ GPollFD *fd_list[1000];
+ unsigned int fd_count = 0;
+ bool block = true;
+
+ if (browser_reformat_pending)
+ block = false;
+
+ if (active) {
+ FD_ZERO(&read_fd_set);
+ FD_ZERO(&write_fd_set);
+ FD_ZERO(&exc_fd_set);
+ code = curl_multi_fdset(fetch_curl_multi,
+ &read_fd_set,
+ &write_fd_set,
+ &exc_fd_set,
+ &max_fd);
+ assert(code == CURLM_OK);
+ LOG(("maxfd from curl is %d", max_fd));
+ for (int i = 0; i <= max_fd; i++) {
+ if (FD_ISSET(i, &read_fd_set)) {
+ GPollFD *fd = malloc(sizeof *fd);
+ fd->fd = i;
+ fd->events = G_IO_IN | G_IO_HUP | G_IO_ERR;
+ g_main_context_add_poll(0, fd, 0);
+ fd_list[fd_count++] = fd;
+ LOG(("Want to read %d", i));
+ }
+ if (FD_ISSET(i, &write_fd_set)) {
+ GPollFD *fd = malloc(sizeof *fd);
+ fd->fd = i;
+ fd->events = G_IO_OUT | G_IO_ERR;
+ g_main_context_add_poll(0, fd, 0);
+ fd_list[fd_count++] = fd;
+ LOG(("Want to write %d", i));
+ }
+ if (FD_ISSET(i, &exc_fd_set)) {
+ GPollFD *fd = malloc(sizeof *fd);
+ fd->fd = i;
+ fd->events = G_IO_ERR;
+ g_main_context_add_poll(0, fd, 0);
+ fd_list[fd_count++] = fd;
+ LOG(("Want to check %d", i));
+ }
+ }
+ }
+
+ LOG(("Iterate %sactive %sblocking", active?"":"in", block?"":"non-"));
+ if (block && !active) {
+ fprintf(stdout, "GENERIC POLL BLOCKING\n");
+ }
+ g_main_context_iteration(g_main_context_default(), block && !active);
+
+ for (unsigned int i = 0; i != fd_count; i++) {
+ g_main_context_remove_poll(0, fd_list[i]);
+ free(fd_list[i]);
+ }
+
+ schedule_run();
+
+ if (browser_reformat_pending)
+ monkey_window_process_reformats();
+}
+
+
+void gui_multitask(void)
+{
+ g_main_context_iteration(g_main_context_default(), false);
+}
diff --git a/monkey/res b/monkey/res
new file mode 120000
index 000000000..ea9dff35c
--- /dev/null
+++ b/monkey/res
@@ -0,0 +1 @@
+../gtk/res \ No newline at end of file
diff --git a/monkey/schedule.c b/monkey/schedule.c
new file mode 100644
index 000000000..9491ccb67
--- /dev/null
+++ b/monkey/schedule.c
@@ -0,0 +1,128 @@
+/*
+ * Copyright 2006-2007 Daniel Silverstone <dsilvers@digital-scurf.org>
+ *
+ * This file is part of NetSurf, http://www.netsurf-browser.org/
+ *
+ * NetSurf is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * NetSurf is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <glib.h>
+#include <stdlib.h>
+#include <stdbool.h>
+
+#include "desktop/browser.h"
+#include "gtk/schedule.h"
+
+#ifdef DEBUG_GTK_SCHEDULE
+#include "utils/log.h"
+#else
+#define LOG(X)
+#endif
+
+/** Killable callback closure embodiment. */
+typedef struct {
+ void (*callback)(void *); /**< The callback function. */
+ void *context; /**< The context for the callback. */
+ bool callback_killed; /**< Whether or not this was killed. */
+} _nsgtk_callback_t;
+
+/** List of callbacks which have occurred and are pending running. */
+static GList *pending_callbacks = NULL;
+/** List of callbacks which are queued to occur in the future. */
+static GList *queued_callbacks = NULL;
+/** List of callbacks which are about to be run in this ::schedule_run. */
+static GList *this_run = NULL;
+
+static gboolean
+nsgtk_schedule_generic_callback(gpointer data)
+{
+ _nsgtk_callback_t *cb = (_nsgtk_callback_t *)(data);
+ if (cb->callback_killed) {
+ /* This callback instance has been killed. */
+ LOG(("CB at %p already dead.", cb));
+ }
+ queued_callbacks = g_list_remove(queued_callbacks, cb);
+ pending_callbacks = g_list_append(pending_callbacks, cb);
+ return FALSE;
+}
+
+static void
+nsgtk_schedule_kill_callback(void *_target, void *_match)
+{
+ _nsgtk_callback_t *target = (_nsgtk_callback_t *)_target;
+ _nsgtk_callback_t *match = (_nsgtk_callback_t *)_match;
+ if ((target->callback == match->callback) &&
+ (target->context == match->context)) {
+ LOG(("Found match for %p(%p), killing.",
+ target->callback, target->context));
+ target->callback = NULL;
+ target->context = NULL;
+ target->callback_killed = true;
+ }
+}
+
+void
+schedule_remove(void (*callback)(void *p), void *p)
+{
+ _nsgtk_callback_t cb_match = {
+ .callback = callback,
+ .context = p,
+ };
+
+ g_list_foreach(queued_callbacks,
+ nsgtk_schedule_kill_callback, &cb_match);
+ g_list_foreach(pending_callbacks,
+ nsgtk_schedule_kill_callback, &cb_match);
+ g_list_foreach(this_run,
+ nsgtk_schedule_kill_callback, &cb_match);
+}
+
+void
+schedule(int t, void (*callback)(void *p), void *p)
+{
+ const int msec_timeout = t * 10;
+ _nsgtk_callback_t *cb = malloc(sizeof(_nsgtk_callback_t));
+ /* Kill any pending schedule of this kind. */
+ schedule_remove(callback, p);
+ cb->callback = callback;
+ cb->context = p;
+ cb->callback_killed = false;
+ /* Prepend is faster right now. */
+ queued_callbacks = g_list_prepend(queued_callbacks, cb);
+ g_timeout_add(msec_timeout, nsgtk_schedule_generic_callback, cb);
+}
+
+bool
+schedule_run(void)
+{
+ /* Capture this run of pending callbacks into the list. */
+ this_run = pending_callbacks;
+
+ if (this_run == NULL)
+ return false; /* Nothing to do */
+
+ /* Clear the pending list. */
+ pending_callbacks = NULL;
+
+ LOG(("Captured a run of %d callbacks to fire.", g_list_length(this_run)));
+
+ /* Run all the callbacks which made it this far. */
+ while (this_run != NULL) {
+ _nsgtk_callback_t *cb = (_nsgtk_callback_t *)(this_run->data);
+ this_run = g_list_remove(this_run, this_run->data);
+ if (!cb->callback_killed)
+ cb->callback(cb->context);
+ free(cb);
+ }
+ return true;
+}
diff --git a/monkey/schedule.h b/monkey/schedule.h
new file mode 100644
index 000000000..c63215e88
--- /dev/null
+++ b/monkey/schedule.h
@@ -0,0 +1,25 @@
+/*
+ * Copyright 2006 Daniel Silverstone <dsilvers@digital-scurf.org>
+ *
+ * This file is part of NetSurf, http://www.netsurf-browser.org/
+ *
+ * NetSurf is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * NetSurf is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef NETSURF_GTK_CALLBACK_H
+#define NETSURF_GTK_CALLBACK_H 1
+
+typedef void (*gtk_callback)(void *p);
+bool schedule_run(void);
+
+#endif /* NETSURF_GTK_CALLBACK_H */
diff --git a/monkey/system_colour.c b/monkey/system_colour.c
new file mode 100644
index 000000000..b58717492
--- /dev/null
+++ b/monkey/system_colour.c
@@ -0,0 +1,284 @@
+/*
+ * Copyright 2011 Vincent Sanders <vince@netsurf-browser.org>
+ *
+ * This file is part of NetSurf, http://www.netsurf-browser.org/
+ *
+ * NetSurf is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * NetSurf is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/** \file
+ * System colour handling
+ *
+ */
+
+#include "utils/utils.h"
+#include "utils/log.h"
+#include "desktop/gui.h"
+#include "desktop/options.h"
+
+struct gui_system_colour_ctx {
+ const char *name;
+ int length;
+ css_color colour;
+ colour *option_colour;
+ lwc_string *lwcstr;
+};
+
+static struct gui_system_colour_ctx colour_list[] = {
+ {
+ "ActiveBorder",
+ SLEN("ActiveBorder"),
+ 0xff000000,
+ &option_sys_colour_ActiveBorder,
+ NULL
+ }, {
+ "ActiveCaption",
+ SLEN("ActiveCaption"),
+ 0xffdddddd,
+ &option_sys_colour_ActiveCaption,
+ NULL
+ }, {
+ "AppWorkspace",
+ SLEN("AppWorkspace"),
+ 0xffeeeeee,
+ &option_sys_colour_AppWorkspace,
+ NULL
+ }, {
+ "Background",
+ SLEN("Background"),
+ 0xff0000aa,
+ &option_sys_colour_Background,
+ NULL
+ }, {
+ "ButtonFace",
+ SLEN("ButtonFace"),
+ 0xffaaaaaa,
+ &option_sys_colour_ButtonFace,
+ NULL
+ }, {
+ "ButtonHighlight",
+ SLEN("ButtonHighlight"),
+ 0xffdddddd,
+ &option_sys_colour_ButtonHighlight,
+ NULL
+ }, {
+ "ButtonShadow",
+ SLEN("ButtonShadow"),
+ 0xffbbbbbb,
+ &option_sys_colour_ButtonShadow,
+ NULL
+ }, {
+ "ButtonText",
+ SLEN("ButtonText"),
+ 0xff000000,
+ &option_sys_colour_ButtonText,
+ NULL
+ }, {
+ "CaptionText",
+ SLEN("CaptionText"),
+ 0xff000000,
+ &option_sys_colour_CaptionText,
+ NULL
+ }, {
+ "GrayText",
+ SLEN("GrayText"),
+ 0xffcccccc,
+ &option_sys_colour_GrayText,
+ NULL
+ }, {
+ "Highlight",
+ SLEN("Highlight"),
+ 0xff0000ee,
+ &option_sys_colour_Highlight,
+ NULL
+ }, {
+ "HighlightText",
+ SLEN("HighlightText"),
+ 0xff000000,
+ &option_sys_colour_HighlightText,
+ NULL
+ }, {
+ "InactiveBorder",
+ SLEN("InactiveBorder"),
+ 0xffffffff,
+ &option_sys_colour_InactiveBorder,
+ NULL
+ }, {
+ "InactiveCaption",
+ SLEN("InactiveCaption"),
+ 0xffffffff,
+ &option_sys_colour_InactiveCaption,
+ NULL
+ }, {
+ "InactiveCaptionText",
+ SLEN("InactiveCaptionText"),
+ 0xffcccccc,
+ &option_sys_colour_InactiveCaptionText,
+ NULL
+ }, {
+ "InfoBackground",
+ SLEN("InfoBackground"),
+ 0xffaaaaaa,
+ &option_sys_colour_InfoBackground,
+ NULL
+ }, {
+ "InfoText",
+ SLEN("InfoText"),
+ 0xff000000,
+ &option_sys_colour_InfoText,
+ NULL
+ }, {
+ "Menu",
+ SLEN("Menu"),
+ 0xffaaaaaa,
+ &option_sys_colour_Menu,
+ NULL
+ }, {
+ "MenuText",
+ SLEN("MenuText"),
+ 0xff000000,
+ &option_sys_colour_MenuText,
+ NULL
+ }, {
+ "Scrollbar",
+ SLEN("Scrollbar"),
+ 0xffaaaaaa,
+ &option_sys_colour_Scrollbar,
+ NULL
+ }, {
+ "ThreeDDarkShadow",
+ SLEN("ThreeDDarkShadow"),
+ 0xff555555,
+ &option_sys_colour_ThreeDDarkShadow,
+ NULL
+ }, {
+ "ThreeDFace",
+ SLEN("ThreeDFace"),
+ 0xffdddddd,
+ &option_sys_colour_ThreeDFace,
+ NULL
+ }, {
+ "ThreeDHighlight",
+ SLEN("ThreeDHighlight"),
+ 0xffaaaaaa,
+ &option_sys_colour_ThreeDHighlight,
+ NULL
+ }, {
+ "ThreeDLightShadow",
+ SLEN("ThreeDLightShadow"),
+ 0xff999999,
+ &option_sys_colour_ThreeDLightShadow,
+ NULL
+ }, {
+ "ThreeDShadow",
+ SLEN("ThreeDShadow"),
+ 0xff777777,
+ &option_sys_colour_ThreeDShadow,
+ NULL
+ }, {
+ "Window",
+ SLEN("Window"),
+ 0xffaaaaaa,
+ &option_sys_colour_Window,
+ NULL
+ }, {
+ "WindowFrame",
+ SLEN("WindowFrame"),
+ 0xff000000,
+ &option_sys_colour_WindowFrame,
+ NULL
+ }, {
+
+ "WindowText",
+ SLEN("WindowText"),
+ 0xff000000,
+ &option_sys_colour_WindowText,
+ NULL
+ },
+
+};
+
+#define colour_list_len (sizeof(colour_list) / sizeof(struct gui_system_colour_ctx))
+
+static struct gui_system_colour_ctx *gui_system_colour_pw = NULL;
+
+
+bool gui_system_colour_init(void)
+{
+ unsigned int ccount;
+
+ if (gui_system_colour_pw != NULL)
+ return false;
+
+ /* Intern colour strings */
+ for (ccount = 0; ccount < colour_list_len; ccount++) {
+ if (lwc_intern_string(colour_list[ccount].name,
+ colour_list[ccount].length,
+ &(colour_list[ccount].lwcstr)) != lwc_error_ok) {
+ return false;
+ }
+ }
+
+ /* pull in options if set (ie not transparent) */
+ for (ccount = 0; ccount < colour_list_len; ccount++) {
+ if (*(colour_list[ccount].option_colour) != 0) {
+ colour_list[ccount].colour = *(colour_list[ccount].option_colour);
+ }
+ }
+
+ gui_system_colour_pw = colour_list;
+
+ return true;
+}
+
+void gui_system_colour_finalize(void)
+{
+ unsigned int ccount;
+
+ for (ccount = 0; ccount < colour_list_len; ccount++) {
+ lwc_string_unref(colour_list[ccount].lwcstr);
+ }
+}
+
+colour gui_system_colour_char(char *name)
+{
+ colour ret = 0xff00000;
+ unsigned int ccount;
+
+ for (ccount = 0; ccount < colour_list_len; ccount++) {
+ if (strncasecmp(name,
+ colour_list[ccount].name,
+ colour_list[ccount].length) == 0) {
+ ret = colour_list[ccount].colour;
+ break;
+ }
+ }
+ return ret;
+}
+
+css_error gui_system_colour(void *pw, lwc_string *name, css_color *colour)
+{
+ unsigned int ccount;
+ bool match;
+
+ for (ccount = 0; ccount < colour_list_len; ccount++) {
+ if (lwc_string_caseless_isequal(name,
+ colour_list[ccount].lwcstr,
+ &match) == lwc_error_ok && match) {
+ *colour = colour_list[ccount].colour;
+ return CSS_OK;
+ }
+ }
+
+ return CSS_INVALID;
+}
diff --git a/monkey/thumbnail.c b/monkey/thumbnail.c
new file mode 100644
index 000000000..29d32fc87
--- /dev/null
+++ b/monkey/thumbnail.c
@@ -0,0 +1,31 @@
+/*
+ * Copyright 2011 Daniel Silverstone <dsilvers@digital-scurf.org>
+ *
+ * This file is part of NetSurf, http://www.netsurf-browser.org/
+ *
+ * NetSurf is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * NetSurf is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "monkey/browser.h"
+#include "desktop/thumbnail.h"
+
+bool thumbnail_create(hlcache_handle *content, struct bitmap *bitmap,
+ const char *url)
+{
+ struct gui_window *win = monkey_find_window_by_content(content);
+ if (win == NULL) {
+ fprintf(stdout, "GENERIC THUMBNAIL URL %s\n", url);
+ }
+ fprintf(stdout, "BROWSER_WINDOW THUMBNAIL WIN %u URL %s\n", win->win_num, url);
+ return false;
+}
diff --git a/monkey/utils.c b/monkey/utils.c
new file mode 100644
index 000000000..fba79184f
--- /dev/null
+++ b/monkey/utils.c
@@ -0,0 +1,152 @@
+/*
+ * Copyright 2011 Daniel Silverstone <dsilvers@digital-scurf.org>
+ *
+ * This file is part of NetSurf, http://www.netsurf-browser.org/
+ *
+ * NetSurf is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * NetSurf is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "desktop/save_complete.h"
+#include "desktop/tree_url_node.h"
+
+#include "utils/utils.h"
+#include "utils/url.h"
+#include "utils/utf8.h"
+
+char *path_to_url(const char *path)
+{
+ int urllen;
+ char *url;
+
+ if (path == NULL) {
+ return NULL;
+ }
+
+ urllen = strlen(path) + FILE_SCHEME_PREFIX_LEN + 1;
+
+ url = malloc(urllen);
+ if (url == NULL) {
+ return NULL;
+ }
+
+ if (*path == '/') {
+ path++; /* file: paths are already absolute */
+ }
+
+ snprintf(url, urllen, "%s%s", FILE_SCHEME_PREFIX, path);
+
+ return url;
+}
+
+char *url_to_path(const char *url)
+{
+ char *path;
+ char *respath;
+ url_func_result res; /* result from url routines */
+
+ res = url_path(url, &path);
+ if (res != URL_FUNC_OK) {
+ return NULL;
+ }
+
+ res = url_unescape(path, &respath);
+ free(path);
+ if (res != URL_FUNC_OK) {
+ return NULL;
+ }
+
+ return respath;
+}
+
+/**
+ * Return the filename part of a full path
+ *
+ * \param path full path and filename
+ * \return filename (will be freed with free())
+ */
+
+char *filename_from_path(char *path)
+{
+ char *leafname;
+
+ leafname = strrchr(path, '/');
+ if (!leafname)
+ leafname = path;
+ else
+ leafname += 1;
+
+ return strdup(leafname);
+}
+
+/**
+ * Add a path component/filename to an existing path
+ *
+ * \param path buffer containing path + free space
+ * \param length length of buffer "path"
+ * \param newpart string containing path component to add to path
+ * \return true on success
+ */
+
+bool path_add_part(char *path, int length, const char *newpart)
+{
+ if(path[strlen(path) - 1] != '/')
+ strncat(path, "/", length);
+
+ strncat(path, newpart, length);
+
+ return true;
+}
+
+void warn_user(const char *warning, const char *detail)
+{
+ fprintf(stderr, "WARN %s %s\n", warning, detail);
+}
+
+void die(const char * const error)
+{
+ fprintf(stderr, "DIE %s\n", error);
+ exit(EXIT_FAILURE);
+}
+
+utf8_convert_ret
+utf8_to_local_encoding(const char *string, size_t len,
+ char **result)
+{
+ *result = strndup(string, len);
+ return (*result == NULL) ? UTF8_CONVERT_NOMEM : UTF8_CONVERT_OK;
+}
+
+bool
+save_complete_gui_save(const char *path, const char *filename,
+ size_t len, const char *sourcedata, content_type type)
+{
+ return true;
+}
+
+int
+save_complete_htmlSaveFileFormat(const char *path, const char *filename,
+ xmlDocPtr cur, const char *encoding, int format)
+{
+ return 0;
+}
+
+void
+tree_icon_name_from_content_type(char *buffer, content_type type)
+{
+ sprintf(buffer, "%s", "content.png");
+}
+