diff options
author | Ashish Gupta <ashmew2@gmail.com> | 2017-05-11 17:14:01 +0200 |
---|---|---|
committer | Ashish Gupta <ashmew2@gmail.com> | 2017-06-10 08:25:29 +0200 |
commit | 839c2e8e6342dae087b73812ffeffda47af2094a (patch) | |
tree | e5ff3a7bc8b2e4bf6364cfb4508b3e383b1213c5 | |
parent | 5aeb8eb5583d7d088c8132d3dca0dc3c34d8c565 (diff) | |
download | netsurf-839c2e8e6342dae087b73812ffeffda47af2094a.tar.gz netsurf-839c2e8e6342dae087b73812ffeffda47af2094a.tar.bz2 |
Tidy up some things.
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | content/fetchers/httplib_kolibri.c | 29 | ||||
-rw-r--r-- | frontends/kolibrios/fb/gui.c | 8 | ||||
-rw-r--r-- | frontends/kolibrios/loadhttp.asm | 19 |
4 files changed, 32 insertions, 26 deletions
@@ -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/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 + KOLOBJECTS = $(HOME)/kolibrios/programs/fs/unzip60/kolibri/dirent.o $(HOME)/NETSURFLIBS/netsurf/font_internal.o $(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/fetchers/httplib_kolibri.c b/content/fetchers/httplib_kolibri.c index 0f9bcb7c4..6800cab13 100644 --- a/content/fetchers/httplib_kolibri.c +++ b/content/fetchers/httplib_kolibri.c @@ -85,16 +85,16 @@ void remove_from_poll(struct http_msg *donehttp) { bool init_fetcher(lwc_string *scheme) { bool supported_scheme; assert(lwc_string_isequal(scheme, corestring_lwc_http, &supported_scheme) == lwc_error_ok); - kolibri_http_init(); - /* if(supported_scheme) { */ - /* if(kolibri_http_init() == 0) */ - /* debug_board_printf("[INFO] Loaded http.obj library successfully.\n"); */ - /* else { */ - /* debug_board_printf("[ERROR] Could not load http.obj library.\n"); */ - /* return false; */ - /* } */ - /* } */ + LOG("Initializing http library!"); + debug_board_printf("fetcher_init: Initializing http library!\n"); + if(kolibri_http_init() == 0) + LOG("[INFO] Loaded http.obj library successfully.\n"); + else { + LOG("[ERROR] Could not load http.obj library.\n"); + assert(0 && 1); + return false; + } return supported_scheme; } @@ -138,14 +138,17 @@ void *setup_fetch(struct fetch *parent_fetch, struct nsurl *url, request = http_get_asm(nsurl_access(url), NULL, 0, *headers); } - LOG("Address of request : 0x%x", request); - assert(request != NULL); - if(request == NULL) { - LOG("[ERROR] Cannot allocate more memory for http library handle creation."); + LOG("Failed to allocate http buffer. Could be multiple reasons for failure (like DNS resolution)", request); return NULL; } + /* This assert is tricky beacause the http library may fail when it fails to resolve the hostname. + There is no sane way to understand that the hostname is wrong or needs to be fixed. + assert leads to a crash for no reason. Disabling it, and the code should handle this from now. + Returning NuLL from here should just force a BadURL to the user. + */ + struct httpfetcher *newfetcher = (struct httpfetcher *) malloc(sizeof(struct httpfetcher)); assert(newfetcher); diff --git a/frontends/kolibrios/fb/gui.c b/frontends/kolibrios/fb/gui.c index d12bdfcf0..ebd3a3d3b 100644 --- a/frontends/kolibrios/fb/gui.c +++ b/frontends/kolibrios/fb/gui.c @@ -30,6 +30,8 @@ #include <libnsfb_plot.h> #include <libnsfb_event.h> +#include <kos32sys.h> + #include "utils/utils.h" #include "utils/nsoption.h" #include "utils/filepath.h" @@ -491,7 +493,7 @@ process_cmdline(int argc, char** argv) } /* Remove me! */ - feurl = "http://www.kolibrios.org"; + feurl = "http://board.kolibrios.org"; /* NS on KolibriOS does not support option parsing (yet) */ @@ -2124,6 +2126,10 @@ int main(int argc, char** argv) .layout = framebuffer_layout_table, }; + /* Initialize heap so that we can do memory allocations */ + unsigned int heapsize = heap_init(); + debug_board_printf("[SYSTEM] Initialized heap (Size = %u bytes)\n", heapsize); + assert(heapsize != 0); /* fix args */ #define MKARGV(i,opt) argv[i] = (char *) malloc(strlen(opt) + 1); strcpy(argv[i], opt); diff --git a/frontends/kolibrios/loadhttp.asm b/frontends/kolibrios/loadhttp.asm index 859f56db1..3aa7b27a1 100644 --- a/frontends/kolibrios/loadhttp.asm +++ b/frontends/kolibrios/loadhttp.asm @@ -21,27 +21,24 @@ public init_network as '_init_network_asm' ;;; Returns 0 on success. -1 on failure. proc init_network - - mcall 68,11 - stdcall dll.Load, @IMPORT - test eax, eax - jnz error + test eax, eax + jnz error mov eax, 0 ret - -error: + +error: mov eax, -1 ret -endp - +endp + @IMPORT: library lib_http, 'http.obj' import lib_http, \ - HTTP_get , 'get' , \ + HTTP_get , 'get' , \ HTTP_head , 'head' , \ HTTP_post , 'post' , \ HTTP_find_header_field , 'find_header_field' , \ @@ -51,7 +48,7 @@ import lib_http, \ HTTP_free , 'free' , \ HTTP_escape , 'escape' , \ HTTP_unescape , 'unescape' - + public HTTP_get as '_http_get_asm' public HTTP_head as '_http_head_asm' public HTTP_post as '_http_post_asm' |