diff options
Diffstat (limited to 'frontends/monkey')
-rw-r--r-- | frontends/monkey/401login.c | 2 | ||||
-rw-r--r-- | frontends/monkey/Makefile | 2 | ||||
-rw-r--r-- | frontends/monkey/Makefile.defaults | 1 | ||||
-rw-r--r-- | frontends/monkey/Makefile.tools | 15 | ||||
-rw-r--r-- | frontends/monkey/bitmap.c | 47 | ||||
-rw-r--r-- | frontends/monkey/browser.c | 4 | ||||
-rw-r--r-- | frontends/monkey/cert.c | 149 | ||||
-rw-r--r-- | frontends/monkey/cert.h | 31 | ||||
-rw-r--r-- | frontends/monkey/dispatch.c | 2 | ||||
-rw-r--r-- | frontends/monkey/download.c | 5 | ||||
-rw-r--r-- | frontends/monkey/main.c | 94 | ||||
-rw-r--r-- | frontends/monkey/options.h | 6 | ||||
-rw-r--r-- | frontends/monkey/output.c | 1 | ||||
-rw-r--r-- | frontends/monkey/output.h | 1 |
14 files changed, 123 insertions, 237 deletions
diff --git a/frontends/monkey/401login.c b/frontends/monkey/401login.c index 1629425f6..9c3b21f1f 100644 --- a/frontends/monkey/401login.c +++ b/frontends/monkey/401login.c @@ -56,7 +56,7 @@ gui_401login_open(struct nsurl *url, { struct monkey401 *m401_ctx; - m401_ctx = calloc(sizeof(*m401_ctx), 1); + m401_ctx = calloc(1, sizeof(*m401_ctx)); if (m401_ctx == NULL) { return NSERROR_NOMEM; } diff --git a/frontends/monkey/Makefile b/frontends/monkey/Makefile index 85bc9b5ae..d2dae3e16 100644 --- a/frontends/monkey/Makefile +++ b/frontends/monkey/Makefile @@ -51,7 +51,7 @@ endif # S_MONKEY are sources purely for the MONKEY build S_FRONTEND := main.c output.c filetype.c schedule.c bitmap.c plot.c browser.c \ - download.c 401login.c cert.c layout.c dispatch.c fetch.c + download.c 401login.c layout.c dispatch.c fetch.c # This is the final source build list diff --git a/frontends/monkey/Makefile.defaults b/frontends/monkey/Makefile.defaults index d6a90a3dc..87b6f3ac4 100644 --- a/frontends/monkey/Makefile.defaults +++ b/frontends/monkey/Makefile.defaults @@ -9,5 +9,6 @@ NETSURF_USE_RSVG := NO NETSURF_USE_NSSVG := NO NETSURF_USE_ROSPRITE := NO NETSURF_USE_HARU_PDF := NO +NETSURF_FS_BACKING_STORE := YES CFLAGS += -O2 diff --git a/frontends/monkey/Makefile.tools b/frontends/monkey/Makefile.tools new file mode 100644 index 000000000..7546506ff --- /dev/null +++ b/frontends/monkey/Makefile.tools @@ -0,0 +1,15 @@ +# -*- mode: makefile-gmake -*- +## +## monkey target tool setup +## + +ifeq ($(origin GCCSDK_INSTALL_ENV),undefined) + PKG_CONFIG := pkg-config +else + PKG_CONFIG := PKG_CONFIG_LIBDIR="$(GCCSDK_INSTALL_ENV)/lib/pkgconfig" pkg-config +endif + +ifneq ($(origin GCCSDK_INSTALL_CROSSBIN),undefined) + CC := $(wildcard $(GCCSDK_INSTALL_CROSSBIN)/*gcc) + CXX := $(wildcard $(GCCSDK_INSTALL_CROSSBIN)/*g++) +endif diff --git a/frontends/monkey/bitmap.c b/frontends/monkey/bitmap.c index e53b565d1..cc13c8b8f 100644 --- a/frontends/monkey/bitmap.c +++ b/frontends/monkey/bitmap.c @@ -31,26 +31,26 @@ struct bitmap { size_t rowstride; int width; int height; - unsigned int state; + bool opaque; }; -static void *bitmap_create(int width, int height, unsigned int state) +static void *bitmap_create(int width, int height, enum gui_bitmap_flags flags) { - struct bitmap *ret = calloc(sizeof(*ret), 1); + struct bitmap *ret = calloc(1, sizeof(*ret)); if (ret == NULL) return NULL; - + ret->width = width; ret->height = height; - ret->state = state; - + ret->opaque = (flags & BITMAP_OPAQUE) == BITMAP_OPAQUE; + ret->ptr = calloc(width, height * 4); - + if (ret->ptr == NULL) { free(ret); return NULL; } - + return ret; } @@ -64,23 +64,15 @@ static void bitmap_destroy(void *bitmap) static void bitmap_set_opaque(void *bitmap, bool opaque) { struct bitmap *bmap = bitmap; - - if (opaque) - bmap->state |= (BITMAP_OPAQUE); - else - bmap->state &= ~(BITMAP_OPAQUE); -} -static bool bitmap_test_opaque(void *bitmap) -{ - return false; + bmap->opaque = opaque; } static bool bitmap_get_opaque(void *bitmap) { struct bitmap *bmap = bitmap; - - return (bmap->state & BITMAP_OPAQUE) == BITMAP_OPAQUE; + + return bmap->opaque; } static unsigned char *bitmap_get_buffer(void *bitmap) @@ -96,21 +88,9 @@ static size_t bitmap_get_rowstride(void *bitmap) return bmap->width * 4; } -static size_t bitmap_get_bpp(void *bitmap) -{ - /* OMG?! */ - return 4; -} - -static bool bitmap_save(void *bitmap, const char *path, unsigned flags) -{ - return true; -} - static void bitmap_modified(void *bitmap) { - struct bitmap *bmap = bitmap; - bmap->state |= BITMAP_MODIFIED; + return; } static int bitmap_get_width(void *bitmap) @@ -137,13 +117,10 @@ static struct gui_bitmap_table bitmap_table = { .destroy = bitmap_destroy, .set_opaque = bitmap_set_opaque, .get_opaque = bitmap_get_opaque, - .test_opaque = bitmap_test_opaque, .get_buffer = bitmap_get_buffer, .get_rowstride = bitmap_get_rowstride, .get_width = bitmap_get_width, .get_height = bitmap_get_height, - .get_bpp = bitmap_get_bpp, - .save = bitmap_save, .modified = bitmap_modified, .render = bitmap_render, }; diff --git a/frontends/monkey/browser.c b/frontends/monkey/browser.c index 49cc63c3b..5cd501189 100644 --- a/frontends/monkey/browser.c +++ b/frontends/monkey/browser.c @@ -75,7 +75,7 @@ gui_window_create(struct browser_window *bw, struct gui_window *existing, gui_window_create_flags flags) { - struct gui_window *ret = calloc(sizeof(*ret), 1); + struct gui_window *ret = calloc(1, sizeof(*ret)); if (ret == NULL) return NULL; @@ -631,7 +631,7 @@ monkey_window_handle_exec(int argc, char **argv) moutf(MOUT_ERROR, "WINDOW NUM BAD"); } else { /* Gather argv[4] onward into a string to pass to js_exec */ - int total = 0; + int total = 1; for (int i = 4; i < argc; ++i) { total += strlen(argv[i]) + 1; } diff --git a/frontends/monkey/cert.c b/frontends/monkey/cert.c deleted file mode 100644 index ddcd1137c..000000000 --- a/frontends/monkey/cert.c +++ /dev/null @@ -1,149 +0,0 @@ -/* - * 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 <stdlib.h> -#include <stdio.h> -#include <string.h> - -#include "utils/ring.h" -#include "utils/nsurl.h" -#include "content/urldb.h" - -#include "monkey/output.h" -#include "monkey/cert.h" - -struct monkey_cert { - struct monkey_cert *r_next, *r_prev; - uint32_t num; - nserror (*cb)(bool,void*); - void *cbpw; - nsurl *url; -}; - -static struct monkey_cert *cert_ring = NULL; -static uint32_t cert_ctr = 0; - -nserror -gui_cert_verify(nsurl *url, - const struct ssl_cert_info *certs, - unsigned long num, nserror (*cb)(bool proceed, void *pw), - void *cbpw) -{ - struct monkey_cert *mcrt_ctx; - - mcrt_ctx = calloc(sizeof(*mcrt_ctx), 1); - if (mcrt_ctx == NULL) { - return NSERROR_NOMEM; - } - - mcrt_ctx->cb = cb; - mcrt_ctx->cbpw = cbpw; - mcrt_ctx->num = cert_ctr++; - mcrt_ctx->url = nsurl_ref(url); - - RING_INSERT(cert_ring, mcrt_ctx); - - moutf(MOUT_SSLCERT, "VERIFY CWIN %u URL %s", - mcrt_ctx->num, nsurl_access(url)); - - return NSERROR_OK; -} - - -static struct monkey_cert * -monkey_find_sslcert_by_num(uint32_t sslcert_num) -{ - struct monkey_cert *ret = NULL; - - RING_ITERATE_START(struct monkey_cert, cert_ring, c_ring) { - if (c_ring->num == sslcert_num) { - ret = c_ring; - RING_ITERATE_STOP(cert_ring, c_ring); - } - } RING_ITERATE_END(cert_ring, c_ring); - - return ret; -} - -static void free_sslcert_context(struct monkey_cert *mcrt_ctx) { - moutf(MOUT_SSLCERT, "DESTROY CWIN %u", mcrt_ctx->num); - RING_REMOVE(cert_ring, mcrt_ctx); - if (mcrt_ctx->url) { - nsurl_unref(mcrt_ctx->url); - } - free(mcrt_ctx); -} - -static void -monkey_sslcert_handle_go(int argc, char **argv) -{ - struct monkey_cert *mcrt_ctx; - - if (argc != 3) { - moutf(MOUT_ERROR, "SSLCERT GO ARGS BAD"); - return; - } - - mcrt_ctx = monkey_find_sslcert_by_num(atoi(argv[2])); - if (mcrt_ctx == NULL) { - moutf(MOUT_ERROR, "SSLCERT NUM BAD"); - return; - } - - urldb_set_cert_permissions(mcrt_ctx->url, true); - - mcrt_ctx->cb(true, mcrt_ctx->cbpw); - - free_sslcert_context(mcrt_ctx); -} - -static void -monkey_sslcert_handle_destroy(int argc, char **argv) -{ - struct monkey_cert *mcrt_ctx; - - if (argc != 3) { - moutf(MOUT_ERROR, "SSLCERT DESTROY ARGS BAD"); - return; - } - - mcrt_ctx = monkey_find_sslcert_by_num(atoi(argv[2])); - if (mcrt_ctx == NULL) { - moutf(MOUT_ERROR, "SSLCERT NUM BAD"); - return; - } - - mcrt_ctx->cb(false, mcrt_ctx->cbpw); - - free_sslcert_context(mcrt_ctx); -} - -void -monkey_sslcert_handle_command(int argc, char **argv) -{ - if (argc == 1) - return; - - if (strcmp(argv[1], "DESTROY") == 0) { - monkey_sslcert_handle_destroy(argc, argv); - } else if (strcmp(argv[1], "GO") == 0) { - monkey_sslcert_handle_go(argc, argv); - } else { - moutf(MOUT_ERROR, "SSLCERT COMMAND UNKNOWN %s", argv[1]); - } -} diff --git a/frontends/monkey/cert.h b/frontends/monkey/cert.h deleted file mode 100644 index 56feea782..000000000 --- a/frontends/monkey/cert.h +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright 2012 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/>. - */ - -#ifndef NETSURF_MONKEY_CERT_H -#define NETSURF_MONKEY_CERT_H - -struct ssl_cert_info; - -nserror gui_cert_verify(nsurl *url, const struct ssl_cert_info *certs, - unsigned long num, nserror (*cb)(bool proceed, void *pw), - void *cbpw); - - -void monkey_sslcert_handle_command(int argc, char **argv); - -#endif diff --git a/frontends/monkey/dispatch.c b/frontends/monkey/dispatch.c index 08bd352d5..09d7e7331 100644 --- a/frontends/monkey/dispatch.c +++ b/frontends/monkey/dispatch.c @@ -38,7 +38,7 @@ static monkey_cmdhandler_t *handler_ring = NULL; nserror monkey_register_handler(const char *cmd, handle_command_fn fn) { - monkey_cmdhandler_t *ret = calloc(sizeof(*ret), 1); + monkey_cmdhandler_t *ret = calloc(1, sizeof(*ret)); if (ret == NULL) { NSLOG(netsurf, INFO, "Unable to allocate handler"); return NSERROR_NOMEM; diff --git a/frontends/monkey/download.c b/frontends/monkey/download.c index 1c516e367..1f7743941 100644 --- a/frontends/monkey/download.c +++ b/frontends/monkey/download.c @@ -34,6 +34,7 @@ struct gui_download_window { struct gui_download_window *r_next; struct gui_download_window *r_prev; struct gui_window *g; + download_context *dlctx; uint32_t dwin_num; char *host; /* ignore */ }; @@ -44,11 +45,12 @@ static struct gui_download_window * gui_download_window_create(download_context *ctx, struct gui_window *parent) { - struct gui_download_window *ret = calloc(sizeof(*ret), 1); + struct gui_download_window *ret = calloc(1, sizeof(*ret)); if (ret == NULL) return NULL; ret->g = parent; ret->dwin_num = dwin_ctr++; + ret->dlctx = ctx; RING_INSERT(dw_ring, ret); @@ -79,6 +81,7 @@ gui_download_window_done(struct gui_download_window *dw) { moutf(MOUT_DOWNLOAD, "DONE DWIN %u", dw->dwin_num); RING_REMOVE(dw_ring, dw); + download_context_destroy(dw->dlctx); free(dw); } diff --git a/frontends/monkey/main.c b/frontends/monkey/main.c index e1c2a382c..463f0bea6 100644 --- a/frontends/monkey/main.c +++ b/frontends/monkey/main.c @@ -24,6 +24,7 @@ #include <unistd.h> #include <string.h> #include <errno.h> +#include <signal.h> #include "utils/config.h" #include "utils/sys_time.h" @@ -37,11 +38,11 @@ #include "netsurf/url_db.h" #include "netsurf/cookie_db.h" #include "content/fetch.h" +#include "content/backing_store.h" #include "monkey/output.h" #include "monkey/dispatch.h" #include "monkey/browser.h" -#include "monkey/cert.h" #include "monkey/401login.h" #include "monkey/filetype.h" #include "monkey/fetch.h" @@ -72,7 +73,8 @@ static void die(const char * const error) exit(EXIT_FAILURE); } -/** obtain language from environment +/** + * obtain language from environment * * start with GNU extension LANGUAGE environment variable and then try * POSIX variables LC_ALL, LC_MESSAGES and LANG @@ -106,7 +108,8 @@ static const char *get_language(void) } -/** provide a string vector of languages in preference order +/** + * provide a string vector of languages in preference order * * environment variables are processed to aquire a colon separated * list of languages which are converted into a string vector. The @@ -173,7 +176,16 @@ static const char * const *get_languagev(void) return &langv[0]; } -/* Stolen from gtk/gui.c */ +/** + * Create an array of valid paths to search for resources. + * + * The idea is that all the complex path computation to find resources + * is performed here, once, rather than every time a resource is + * searched for. + * + * \param resource_path A shell style colon separated path list + * \return A string vector of valid paths where resources can be found + */ static char ** nsmonkey_init_resource(const char *resource_path) { @@ -205,6 +217,16 @@ static nserror gui_launch_url(struct nsurl *url) return NSERROR_OK; } +static nserror gui_present_cookies(const char *search_term) +{ + if (search_term != NULL) { + moutf(MOUT_GENERIC, "PRESENT_COOKIES %s", search_term); + } else { + moutf(MOUT_GENERIC, "PRESENT_COOKIES"); + } + return NSERROR_OK; +} + static void quit_handler(int argc, char **argv) { monkey_done = true; @@ -248,8 +270,8 @@ static struct gui_misc_table monkey_misc_table = { .quit = monkey_quit, .launch_url = gui_launch_url, - .cert_verify = gui_cert_verify, .login = gui_401login_open, + .present_cookies = gui_present_cookies, }; static void monkey_run(void) @@ -316,6 +338,53 @@ static void monkey_run(void) } } +#if (!defined(NDEBUG) && defined(HAVE_EXECINFO)) +#include <execinfo.h> +static void *backtrace_buffer[4096]; + +void +__assert_fail(const char *__assertion, const char *__file, + unsigned int __line, const char *__function) +{ + int frames; + fprintf(stderr, + "MONKEY: Assertion failure!\n" + "%s:%d: %s: Assertion `%s` failed.\n", + __file, __line, __function, __assertion); + + frames = backtrace(&backtrace_buffer[0], 4096); + if (frames > 0 && frames < 4096) { + fprintf(stderr, "Backtrace:\n"); + fflush(stderr); + backtrace_symbols_fd(&backtrace_buffer[0], frames, 2); + } + + abort(); +} + +static void +signal_handler(int sig) +{ + int frames; + fprintf(stderr, "Caught signal %s (%d)\n", + ((sig == SIGSEGV) ? "SIGSEGV" : + ((sig == SIGILL) ? "SIGILL" : + ((sig == SIGFPE) ? "SIGFPE" : + ((sig == SIGBUS) ? "SIGBUS" : + "unknown signal")))), + sig); + frames = backtrace(&backtrace_buffer[0], 4096); + if (frames > 0 && frames < 4096) { + fprintf(stderr, "Backtrace:\n"); + fflush(stderr); + backtrace_symbols_fd(&backtrace_buffer[0], frames, 2); + } + + abort(); +} + +#endif + int main(int argc, char **argv) { @@ -330,8 +399,18 @@ main(int argc, char **argv) .fetch = monkey_fetch_table, .bitmap = monkey_bitmap_table, .layout = monkey_layout_table, + .llcache = filesystem_llcache_table, }; +#if (!defined(NDEBUG) && defined(HAVE_EXECINFO)) + /* Catch segfault, illegal instructions and fp exceptions */ + signal(SIGSEGV, signal_handler); + signal(SIGILL, signal_handler); + signal(SIGFPE, signal_handler); + /* It's unlikely, but SIGBUS could happen on some platforms */ + signal(SIGBUS, signal_handler); +#endif + ret = netsurf_register(&monkey_table); if (ret != NSERROR_OK) { die("NetSurf operation table failed registration"); @@ -405,11 +484,6 @@ main(int argc, char **argv) die("login handler failed to register"); } - ret = monkey_register_handler("SSLCERT", monkey_sslcert_handle_command); - if (ret != NSERROR_OK) { - die("sslcert handler failed to register"); - } - moutf(MOUT_GENERIC, "STARTED"); monkey_run(); diff --git a/frontends/monkey/options.h b/frontends/monkey/options.h index 57cce7e1f..8f6dd8b42 100644 --- a/frontends/monkey/options.h +++ b/frontends/monkey/options.h @@ -16,14 +16,13 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#ifndef _NETSURF_MONKEY_OPTIONS_H_ -#define _NETSURF_MONKEY_OPTIONS_H_ +#ifndef NETSURF_MONKEY_OPTIONS_H_ +#define NETSURF_MONKEY_OPTIONS_H_ /* currently nothing here */ #endif -NSOPTION_BOOL(render_resample, true) NSOPTION_BOOL(downloads_clear, false) NSOPTION_BOOL(request_overwrite, true) NSOPTION_STRING(downloads_directory, NULL) @@ -31,7 +30,6 @@ NSOPTION_STRING(url_file, NULL) NSOPTION_BOOL(show_single_tab, false) NSOPTION_INTEGER(button_type, 0) NSOPTION_BOOL(disable_popups, false) -NSOPTION_BOOL(disable_plugins, false) NSOPTION_INTEGER(history_age, 0) NSOPTION_BOOL(hover_urls, false) NSOPTION_BOOL(focus_new, false) diff --git a/frontends/monkey/output.c b/frontends/monkey/output.c index a3390ea35..d7eb7cdb6 100644 --- a/frontends/monkey/output.c +++ b/frontends/monkey/output.c @@ -31,7 +31,6 @@ static const char *type_text[]={ "GENERIC", "WINDOW", "LOGIN", - "SSLCERT", "DOWNLOAD", "PLOT", }; diff --git a/frontends/monkey/output.h b/frontends/monkey/output.h index 5e77ab3ac..8e6a0abd6 100644 --- a/frontends/monkey/output.h +++ b/frontends/monkey/output.h @@ -26,7 +26,6 @@ enum monkey_output_type { MOUT_GENERIC, MOUT_WINDOW, MOUT_LOGIN, - MOUT_SSLCERT, MOUT_DOWNLOAD, MOUT_PLOT, }; |