From c9bd6fa9fce386526ea1327adea56128648f3355 Mon Sep 17 00:00:00 2001 From: John Mark Bell Date: Mon, 9 Aug 2004 16:11:58 +0000 Subject: [project @ 2004-08-09 16:11:58 by jmb] Rework the interface of the URL handing module to allow for multiple error types. Modify save_complete URL rewriting appropriately. svn path=/import/netsurf/; revision=1206 --- desktop/browser.c | 27 +++++++++++++++------------ desktop/loginlist.c | 16 ++++++++++------ 2 files changed, 25 insertions(+), 18 deletions(-) (limited to 'desktop') diff --git a/desktop/browser.c b/desktop/browser.c index 6e797a97e..36b6a9245 100644 --- a/desktop/browser.c +++ b/desktop/browser.c @@ -149,11 +149,12 @@ void browser_window_go_post(struct browser_window *bw, const char *url, struct content *c; char *url2; char *hash; + url_func_result res; LOG(("bw %p, url %s", bw, url)); - url2 = url_normalize(url); - if (!url2) { + res = url_normalize(url, &url2); + if (res != URL_FUNC_OK) { LOG(("failed to normalize url %s", url)); return; } @@ -602,6 +603,7 @@ void browser_window_mouse_click_html(struct browser_window *bw, struct content *content = c; struct content *gadget_content = c; struct form_control *gadget = 0; + url_func_result res; /* search the box tree for a link, imagemap, or form control */ while ((box = box_at_point(box, x, y, &box_x, &box_y, &content))) { @@ -664,10 +666,10 @@ void browser_window_mouse_click_html(struct browser_window *bw, /* drop through */ case GADGET_SUBMIT: if (gadget->form) { - url = url_join(gadget->form->action, base_url); + res = url_join(gadget->form->action, base_url, &url); snprintf(status_buffer, sizeof status_buffer, messages_get("FormSubmit"), - url ? url : + (res == URL_FUNC_OK) ? url : gadget->form->action); status = status_buffer; pointer = GUI_POINTER_POINT; @@ -713,8 +715,8 @@ void browser_window_mouse_click_html(struct browser_window *bw, } } else if (href) { - url = url_join(href, base_url); - if (!url) + res = url_join(href, base_url, &url); + if (res != URL_FUNC_OK) return; if (title) { @@ -1634,6 +1636,7 @@ void browser_form_submit(struct browser_window *bw, struct form *form, { char *data = 0, *url = 0, *url1 = 0, *base; struct form_successful_control *success; + url_func_result res; assert(form); assert(bw->current_content->type == CONTENT_HTML); @@ -1659,8 +1662,8 @@ void browser_form_submit(struct browser_window *bw, struct form *form, else { sprintf(url, "%s?%s", form->action, data); } - url1 = url_join(url, base); - if (!url1) + res = url_join(url, base, &url1); + if (res != URL_FUNC_OK) break; browser_window_go(bw, url1); break; @@ -1672,15 +1675,15 @@ void browser_form_submit(struct browser_window *bw, struct form *form, warn_user("NoMemory", 0); return; } - url = url_join(form->action, base); - if (!url) + res = url_join(form->action, base, &url); + if (res != URL_FUNC_OK) break; browser_window_go_post(bw, url, data, 0, true); break; case method_POST_MULTIPART: - url = url_join(form->action, base); - if (!url) + res = url_join(form->action, base, &url); + if (res != URL_FUNC_OK) break; browser_window_go_post(bw, url, 0, success, true); break; diff --git a/desktop/loginlist.c b/desktop/loginlist.c index 1baab81ac..3161bbd11 100644 --- a/desktop/loginlist.c +++ b/desktop/loginlist.c @@ -31,10 +31,13 @@ static struct login *loginlist = &login; void login_list_add(char *host, char* logindets) { struct login *nli = xcalloc(1, sizeof(*nli)); - char *temp = url_host(host); + char *temp; char *i; + url_func_result res; - assert(temp); + res = url_host(host, &temp); + + assert(res == URL_FUNC_OK); /* Go back to the path base ie strip the document name * eg. http://www.blah.com/blah/test.htm becomes @@ -75,6 +78,7 @@ struct login *login_list_get(char *url) { char *temp, *host; char *i; int reached_scheme = 0; + url_func_result res; if (url == NULL) return NULL; @@ -83,8 +87,8 @@ struct login *login_list_get(char *url) { (strncasecmp(url, "https://", 8) != 0)) return NULL; - host = url_host(url); - if (host == 0 || strlen(host) == 0) return NULL; + res = url_host(url, &host); + if (res != URL_FUNC_OK || strlen(host) == 0) return NULL; temp = xstrdup(url); @@ -93,8 +97,8 @@ struct login *login_list_get(char *url) { */ if (strlen(host) > strlen(temp)) { xfree(temp); - temp = url_host(url); - if (temp == 0 || strlen(temp) == 0) { + res = url_host(url, &temp); + if (res != URL_FUNC_OK || strlen(temp) == 0) { xfree(host); return NULL; } -- cgit v1.2.3