Author: jmb
Date: Wed Oct 14 19:15:10 2009
New Revision: 9634
URL:
http://source.netsurf-browser.org?rev=9634&view=rev
Log:
Replace form_successful_control with fetch_multipart_data
Modified:
branches/jmb/new-cache/amiga/fetch_file.c
branches/jmb/new-cache/beos/beos_fetch_rsrc.cpp
branches/jmb/new-cache/content/fetch.c
branches/jmb/new-cache/content/fetch.h
branches/jmb/new-cache/content/fetchcache.c
branches/jmb/new-cache/content/fetchcache.h
branches/jmb/new-cache/content/fetchers/fetch_curl.c
branches/jmb/new-cache/content/fetchers/fetch_data.c
branches/jmb/new-cache/content/llcache.c
branches/jmb/new-cache/content/llcache.h
branches/jmb/new-cache/desktop/browser.c
branches/jmb/new-cache/desktop/browser.h
branches/jmb/new-cache/render/form.c
branches/jmb/new-cache/render/form.h
branches/jmb/new-cache/render/html.c
branches/jmb/new-cache/render/html.h
Modified: branches/jmb/new-cache/amiga/fetch_file.c
URL:
http://source.netsurf-browser.org/branches/jmb/new-cache/amiga/fetch_file...
==============================================================================
--- branches/jmb/new-cache/amiga/fetch_file.c (original)
+++ branches/jmb/new-cache/amiga/fetch_file.c Wed Oct 14 19:15:10 2009
@@ -56,7 +56,7 @@
static void ami_fetch_file_finalise(const char *scheme);
static void * ami_fetch_file_setup(struct fetch *parent_fetch, const char *url,
bool only_2xx, const char *post_urlenc,
- struct form_successful_control *post_multipart,
+ struct fetch_multipart_data *post_multipart,
const char **headers);
static bool ami_fetch_file_start(void *vfetch);
static void ami_fetch_file_abort(void *vf);
@@ -135,7 +135,7 @@
void * ami_fetch_file_setup(struct fetch *parent_fetch, const char *url,
bool only_2xx, const char *post_urlenc,
- struct form_successful_control *post_multipart,
+ struct fetch_multipart_data *post_multipart,
const char **headers)
{
struct ami_file_fetch_info *fetch;
Modified: branches/jmb/new-cache/beos/beos_fetch_rsrc.cpp
URL:
http://source.netsurf-browser.org/branches/jmb/new-cache/beos/beos_fetch_...
==============================================================================
--- branches/jmb/new-cache/beos/beos_fetch_rsrc.cpp (original)
+++ branches/jmb/new-cache/beos/beos_fetch_rsrc.cpp Wed Oct 14 19:15:10 2009
@@ -83,7 +83,7 @@
static void *fetch_rsrc_setup(struct fetch *parent_fetch, const char *url,
bool only_2xx, const char *post_urlenc,
- struct form_successful_control *post_multipart,
+ struct fetch_multipart_data *post_multipart,
const char **headers)
{
struct fetch_rsrc_context *ctx;
Modified: branches/jmb/new-cache/content/fetch.c
URL:
http://source.netsurf-browser.org/branches/jmb/new-cache/content/fetch.c?...
==============================================================================
--- branches/jmb/new-cache/content/fetch.c (original)
+++ branches/jmb/new-cache/content/fetch.c Wed Oct 14 19:15:10 2009
@@ -214,7 +214,7 @@
struct fetch * fetch_start(const char *url, const char *referer,
fetch_callback callback,
void *p, bool only_2xx, const char *post_urlenc,
- struct form_successful_control *post_multipart,
+ struct fetch_multipart_data *post_multipart,
bool verifiable, struct content *parent,
char *headers[])
{
@@ -599,6 +599,78 @@
return fetch->verifiable;
}
+/**
+ * Clone a linked list of fetch_multipart_data.
+ *
+ * \param list List to clone
+ * \return Pointer to head of cloned list, or NULL on failure
+ */
+struct fetch_multipart_data *fetch_multipart_data_clone(
+ const struct fetch_multipart_data *list)
+{
+ struct fetch_multipart_data *clone, *last = NULL;
+ struct fetch_multipart_data *result = NULL;
+
+ for (; list != NULL; list = list->next) {
+ clone = malloc(sizeof(struct fetch_multipart_data));
+ if (clone == NULL) {
+ if (result != NULL)
+ fetch_multipart_data_destroy(result);
+
+ return NULL;
+ }
+
+ clone->file = list->file;
+
+ clone->name = strdup(list->name);
+ if (clone->name == NULL) {
+ free(clone);
+ if (result != NULL)
+ fetch_multipart_data_destroy(result);
+
+ return NULL;
+ }
+
+ clone->value = strdup(list->value);
+ if (clone->value == NULL) {
+ free(clone->name);
+ free(clone);
+ if (result != NULL)
+ fetch_multipart_data_destroy(result);
+
+ return NULL;
+ }
+
+ clone->next = NULL;
+
+ if (result == NULL)
+ result = clone;
+ else
+ last->next = clone;
+
+ last = clone;
+ }
+
+ return result;
+}
+
+/**
+ * Free a linked list of fetch_multipart_data.
+ *
+ * \param list Pointer to head of list to free
+ */
+void fetch_multipart_data_destroy(struct fetch_multipart_data *list)
+{
+ struct fetch_multipart_data *next;
+
+ for (; list != NULL; list = next) {
+ next = list->next;
+ free(list->name);
+ free(list->value);
+ free(list);
+ }
+}
+
void
fetch_send_callback(fetch_msg msg, struct fetch *fetch, const void *data,
unsigned long size)
Modified: branches/jmb/new-cache/content/fetch.h
URL:
http://source.netsurf-browser.org/branches/jmb/new-cache/content/fetch.h?...
==============================================================================
--- branches/jmb/new-cache/content/fetch.h (original)
+++ branches/jmb/new-cache/content/fetch.h Wed Oct 14 19:15:10 2009
@@ -42,7 +42,15 @@
struct content;
struct fetch;
-struct form_successful_control;
+
+/** Fetch POST multipart data */
+struct fetch_multipart_data {
+ bool file; /**< Item is a file */
+ char *name; /**< Name of item */
+ char *value; /**< Item value */
+
+ struct fetch_multipart_data *next; /**< Next in linked list */
+};
struct ssl_cert_info {
long version; /**< Certificate version */
@@ -65,7 +73,7 @@
struct fetch * fetch_start(const char *url, const char *referer,
fetch_callback callback,
void *p, bool only_2xx, const char *post_urlenc,
- struct form_successful_control *post_multipart,
+ struct fetch_multipart_data *post_multipart,
bool verifiable, struct content *parent,
char *headers[]);
void fetch_abort(struct fetch *f);
@@ -82,12 +90,16 @@
struct content *fetch_get_parent(struct fetch *fetch);
bool fetch_get_verifiable(struct fetch *fetch);
+void fetch_multipart_data_destroy(struct fetch_multipart_data *list);
+struct fetch_multipart_data *fetch_multipart_data_clone(
+ const struct fetch_multipart_data *list);
+
/* API for fetchers themselves */
typedef bool (*fetcher_initialise)(const char *);
typedef void* (*fetcher_setup_fetch)(struct fetch *, const char *,
bool, const char *,
- struct form_successful_control *,
+ struct fetch_multipart_data *,
const char **);
typedef bool (*fetcher_start_fetch)(void *);
typedef void (*fetcher_abort_fetch)(void *);
Modified: branches/jmb/new-cache/content/fetchcache.c
URL:
http://source.netsurf-browser.org/branches/jmb/new-cache/content/fetchcac...
==============================================================================
--- branches/jmb/new-cache/content/fetchcache.c (original)
+++ branches/jmb/new-cache/content/fetchcache.c Wed Oct 14 19:15:10 2009
@@ -94,7 +94,7 @@
int width, int height,
bool no_error_pages,
char *post_urlenc,
- struct form_successful_control *post_multipart,
+ struct fetch_multipart_data *post_multipart,
bool verifiable,
bool download)
{
@@ -242,7 +242,7 @@
intptr_t p1, intptr_t p2,
int width, int height,
char *post_urlenc,
- struct form_successful_control *post_multipart,
+ struct fetch_multipart_data *post_multipart,
bool verifiable, struct content *parent)
{
char error_message[500];
Modified: branches/jmb/new-cache/content/fetchcache.h
URL:
http://source.netsurf-browser.org/branches/jmb/new-cache/content/fetchcac...
==============================================================================
--- branches/jmb/new-cache/content/fetchcache.h (original)
+++ branches/jmb/new-cache/content/fetchcache.h Wed Oct 14 19:15:10 2009
@@ -30,7 +30,7 @@
#include <stdint.h>
#include "content/content.h"
-struct form_successful_control;
+struct fetch_multipart_data;
void fetchcache_init(void);
struct content * fetchcache(const char *url,
@@ -40,7 +40,7 @@
int width, int height,
bool no_error_pages,
char *post_urlenc,
- struct form_successful_control *post_multipart,
+ struct fetch_multipart_data *post_multipart,
bool verifiable,
bool download);
void fetchcache_go(struct content *content, const char *referer,
@@ -49,7 +49,7 @@
intptr_t p1, intptr_t p2,
int width, int height,
char *post_urlenc,
- struct form_successful_control *post_multipart,
+ struct fetch_multipart_data *post_multipart,
bool verifiable, struct content *parent);
#endif
Modified: branches/jmb/new-cache/content/fetchers/fetch_curl.c
URL:
http://source.netsurf-browser.org/branches/jmb/new-cache/content/fetchers...
==============================================================================
--- branches/jmb/new-cache/content/fetchers/fetch_curl.c (original)
+++ branches/jmb/new-cache/content/fetchers/fetch_curl.c Wed Oct 14 19:15:10 2009
@@ -105,7 +105,7 @@
static void fetch_curl_finalise(const char *scheme);
static void * fetch_curl_setup(struct fetch *parent_fetch, const char *url,
bool only_2xx, const char *post_urlenc,
- struct form_successful_control *post_multipart,
+ struct fetch_multipart_data *post_multipart,
const char **headers);
static bool fetch_curl_start(void *vfetch);
static bool fetch_curl_initiate_fetch(struct curl_fetch_info *fetch,
@@ -133,7 +133,7 @@
void *_f);
static bool fetch_curl_process_headers(struct curl_fetch_info *f);
static struct curl_httppost *fetch_curl_post_convert(
- struct form_successful_control *control);
+ struct fetch_multipart_data *control);
static int fetch_curl_verify_callback(int preverify_ok,
X509_STORE_CTX *x509_ctx);
static int fetch_curl_cert_verify_callback(X509_STORE_CTX *x509_ctx,
@@ -295,7 +295,7 @@
void * fetch_curl_setup(struct fetch *parent_fetch, const char *url,
bool only_2xx, const char *post_urlenc,
- struct form_successful_control *post_multipart,
+ struct fetch_multipart_data *post_multipart,
const char **headers)
{
char *host;
@@ -1183,11 +1183,11 @@
/**
- * Convert a list of struct ::form_successful_control to a list of
+ * Convert a list of struct ::fetch_multipart_data to a list of
* struct curl_httppost for libcurl.
*/
struct curl_httppost *
-fetch_curl_post_convert(struct form_successful_control *control)
+fetch_curl_post_convert(struct fetch_multipart_data *control)
{
struct curl_httppost *post = 0, *last = 0;
CURLFORMcode code;
Modified: branches/jmb/new-cache/content/fetchers/fetch_data.c
URL:
http://source.netsurf-browser.org/branches/jmb/new-cache/content/fetchers...
==============================================================================
--- branches/jmb/new-cache/content/fetchers/fetch_data.c (original)
+++ branches/jmb/new-cache/content/fetchers/fetch_data.c Wed Oct 14 19:15:10 2009
@@ -79,7 +79,7 @@
static void *fetch_data_setup(struct fetch *parent_fetch, const char *url,
bool only_2xx, const char *post_urlenc,
- struct form_successful_control *post_multipart,
+ struct fetch_multipart_data *post_multipart,
const char **headers)
{
struct fetch_data_context *ctx = calloc(1, sizeof(*ctx));
Modified: branches/jmb/new-cache/content/llcache.c
URL:
http://source.netsurf-browser.org/branches/jmb/new-cache/content/llcache....
==============================================================================
--- branches/jmb/new-cache/content/llcache.c (original)
+++ branches/jmb/new-cache/content/llcache.c Wed Oct 14 19:15:10 2009
@@ -686,7 +686,7 @@
nserror llcache_object_refetch(llcache_object *object)
{
const char *urlenc = NULL;
- struct form_successful_control *multipart = NULL;
+ struct fetch_multipart_data *multipart = NULL;
if (object->fetch.post != NULL) {
if (object->fetch.post->type == LLCACHE_POST_URL_ENCODED)
@@ -760,7 +760,7 @@
if (object->fetch.post->type == LLCACHE_POST_URL_ENCODED) {
free(object->fetch.post->data.urlenc);
} else {
- form_free_successful(
+ fetch_multipart_data_destroy(
object->fetch.post->data.multipart);
}
@@ -1036,8 +1036,8 @@
return NSERROR_NOMEM;
}
} else {
- post_clone->data.multipart =
- form_clone_successful(orig->data.multipart);
+ post_clone->data.multipart = fetch_multipart_data_clone(
+ orig->data.multipart);
if (post_clone->data.multipart == NULL) {
free(post_clone);
Modified: branches/jmb/new-cache/content/llcache.h
URL:
http://source.netsurf-browser.org/branches/jmb/new-cache/content/llcache....
==============================================================================
--- branches/jmb/new-cache/content/llcache.h (original)
+++ branches/jmb/new-cache/content/llcache.h Wed Oct 14 19:15:10 2009
@@ -30,7 +30,7 @@
#include "utils/errors.h"
struct ssl_cert_info;
-struct form_successful_control;
+struct fetch_multipart_data;
/** Type of low-level cache object */
typedef struct llcache_object llcache_object;
@@ -46,8 +46,7 @@
} type; /**< Type of POST data */
union {
char *urlenc; /**< URL encoded data */
- /** \todo Need to abstract this away from HTML forms. */
- struct form_successful_control *multipart; /**< Multipart data */
+ struct fetch_multipart_data *multipart; /**< Multipart data */
} data; /**< POST data content */
} llcache_post_data;
Modified: branches/jmb/new-cache/desktop/browser.c
URL:
http://source.netsurf-browser.org/branches/jmb/new-cache/desktop/browser....
==============================================================================
--- branches/jmb/new-cache/desktop/browser.c (original)
+++ branches/jmb/new-cache/desktop/browser.c Wed Oct 14 19:15:10 2009
@@ -77,7 +77,7 @@
static void browser_window_go_post(struct browser_window *bw,
const char *url, char *post_urlenc,
- struct form_successful_control *post_multipart,
+ struct fetch_multipart_data *post_multipart,
bool add_to_history, const char *referer, bool download,
bool verifiable, struct content *parent);
static void browser_window_callback(content_msg msg, struct content *c,
@@ -276,7 +276,7 @@
void browser_window_go_post(struct browser_window *bw, const char *url,
char *post_urlenc,
- struct form_successful_control *post_multipart,
+ struct fetch_multipart_data *post_multipart,
bool add_to_history, const char *referer, bool download,
bool verifiable, struct content *parent)
{
@@ -2479,11 +2479,12 @@
* Collect controls and submit a form.
*/
-void browser_form_submit(struct browser_window *bw, struct browser_window *target,
+void browser_form_submit(struct browser_window *bw,
+ struct browser_window *target,
struct form *form, struct form_control *submit_button)
{
char *data = 0, *url = 0;
- struct form_successful_control *success;
+ struct fetch_multipart_data *success;
assert(form);
assert(bw->current_content->type == CONTENT_HTML);
@@ -2497,14 +2498,14 @@
case method_GET:
data = form_url_encode(form, success);
if (!data) {
- form_free_successful(success);
+ fetch_multipart_data_destroy(success);
warn_user("NoMemory", 0);
return;
}
url = calloc(1, strlen(form->action) +
strlen(data) + 2);
if (!url) {
- form_free_successful(success);
+ fetch_multipart_data_destroy(success);
free(data);
warn_user("NoMemory", 0);
return;
@@ -2522,7 +2523,7 @@
case method_POST_URLENC:
data = form_url_encode(form, success);
if (!data) {
- form_free_successful(success);
+ fetch_multipart_data_destroy(success);
warn_user("NoMemory", 0);
return;
}
@@ -2542,7 +2543,7 @@
assert(0);
}
- form_free_successful(success);
+ fetch_multipart_data_destroy(success);
free(data);
free(url);
}
Modified: branches/jmb/new-cache/desktop/browser.h
URL:
http://source.netsurf-browser.org/branches/jmb/new-cache/desktop/browser....
==============================================================================
--- branches/jmb/new-cache/desktop/browser.h (original)
+++ branches/jmb/new-cache/desktop/browser.h Wed Oct 14 19:15:10 2009
@@ -34,7 +34,6 @@
struct content;
struct form;
struct form_control;
-struct form_successful_control;
struct gui_window;
struct history;
struct selection;
Modified: branches/jmb/new-cache/render/form.c
URL:
http://source.netsurf-browser.org/branches/jmb/new-cache/render/form.c?re...
==============================================================================
--- branches/jmb/new-cache/render/form.c (original)
+++ branches/jmb/new-cache/render/form.c Wed Oct 14 19:15:10 2009
@@ -30,6 +30,7 @@
#include <stdbool.h>
#include <stdio.h>
#include <string.h>
+#include "content/fetch.h"
#include "css/css.h"
#include "css/utils.h"
#include "desktop/gui.h"
@@ -308,18 +309,18 @@
* \param form form to search for successful controls
* \param submit_button control used to submit the form, if any
* \param successful_controls updated to point to linked list of
- * form_successful_control, 0 if no controls
+ * fetch_multipart_data, 0 if no controls
* \return true on success, false on memory exhaustion
*
* See HTML 4.01 section 17.13.2.
*/
bool form_successful_controls(struct form *form,
struct form_control *submit_button,
- struct form_successful_control **successful_controls)
+ struct fetch_multipart_data **successful_controls)
{
struct form_control *control;
struct form_option *option;
- struct form_successful_control sentinel, *last_success, *success_new;
+ struct fetch_multipart_data sentinel, *last_success, *success_new;
char *value = NULL;
bool had_submit = false;
char *charset;
@@ -603,7 +604,7 @@
no_memory:
warn_user("NoMemory", 0);
- form_free_successful(sentinel.next);
+ fetch_multipart_data_destroy(sentinel.next);
return false;
#undef ENCODE_ITEM
@@ -659,12 +660,12 @@
* Encode controls using application/x-www-form-urlencoded.
*
* \param form form to which successful controls relate
- * \param control linked list of form_successful_control
+ * \param control linked list of fetch_multipart_data
* \return URL-encoded form, or 0 on memory exhaustion
*/
char *form_url_encode(struct form *form,
- struct form_successful_control *control)
+ struct fetch_multipart_data *control)
{
char *name, *value;
char *s = malloc(1), *s2;
@@ -711,78 +712,6 @@
if (len)
s[len - 1] = 0;
return s;
-}
-
-/**
- * Clone a linked list of form_successful control.
- *
- * \param list List to clone
- * \return Pointer to head of cloned list, or NULL on failure
- */
-struct form_successful_control *form_clone_successful(
- const struct form_successful_control *list)
-{
- struct form_successful_control *clone, *last = NULL;
- struct form_successful_control *result = NULL;
-
- for (; list != NULL; list = list->next) {
- clone = malloc(sizeof(struct form_successful_control));
- if (clone == NULL) {
- if (result != NULL)
- form_free_successful(result);
-
- return NULL;
- }
-
- clone->file = list->file;
-
- clone->name = strdup(list->name);
- if (clone->name == NULL) {
- free(clone);
- if (result != NULL)
- form_free_successful(result);
-
- return NULL;
- }
-
- clone->value = strdup(list->value);
- if (clone->value == NULL) {
- free(clone->name);
- free(clone);
- if (result != NULL)
- form_free_successful(result);
-
- return NULL;
- }
-
- clone->next = NULL;
-
- if (result == NULL)
- result = clone;
- else
- last->next = clone;
-
- last = clone;
- }
-
- return result;
-}
-
-/**
- * Free a linked list of form_successful_control.
- *
- * \param control Pointer to head of list to free
- */
-
-void form_free_successful(struct form_successful_control *control)
-{
- struct form_successful_control *next;
- for (; control; control = next) {
- next = control->next;
- free(control->name);
- free(control->value);
- free(control);
- }
}
/**
Modified: branches/jmb/new-cache/render/form.h
URL:
http://source.netsurf-browser.org/branches/jmb/new-cache/render/form.h?re...
==============================================================================
--- branches/jmb/new-cache/render/form.h (original)
+++ branches/jmb/new-cache/render/form.h Wed Oct 14 19:15:10 2009
@@ -125,14 +125,6 @@
struct form_option* next;
};
-/** Successful control, as defined by HTML 4.01 17.13. */
-struct form_successful_control {
- bool file; /**< It's a file */
- char *name; /**< Control name. */
- char *value; /**< Current value. */
- struct form_successful_control *next; /**< Next in linked list. */
-};
-
/**
* Called by the select menu when it wants an area to be redrawn. The
* coordinates are menu origin relative.
@@ -157,12 +149,9 @@
bool selected);
bool form_successful_controls(struct form *form,
struct form_control *submit_button,
- struct form_successful_control **successful_controls);
+ struct fetch_multipart_data **successful_controls);
char *form_url_encode(struct form *form,
- struct form_successful_control *control);
-struct form_successful_control *form_clone_successful(
- const struct form_successful_control *list);
-void form_free_successful(struct form_successful_control *control);
+ struct fetch_multipart_data *control);
bool form_open_select_menu(void *client_data,
struct form_control *control,
Modified: branches/jmb/new-cache/render/html.c
URL:
http://source.netsurf-browser.org/branches/jmb/new-cache/render/html.c?re...
==============================================================================
--- branches/jmb/new-cache/render/html.c (original)
+++ branches/jmb/new-cache/render/html.c Wed Oct 14 19:15:10 2009
@@ -1316,7 +1316,7 @@
bool html_replace_object(struct content *c, unsigned int i, char *url,
char *post_urlenc,
- struct form_successful_control *post_multipart)
+ struct fetch_multipart_data *post_multipart)
{
struct content *c_fetch;
struct content *page;
Modified: branches/jmb/new-cache/render/html.h
URL:
http://source.netsurf-browser.org/branches/jmb/new-cache/render/html.h?re...
==============================================================================
--- branches/jmb/new-cache/render/html.h (original)
+++ branches/jmb/new-cache/render/html.h Wed Oct 14 19:15:10 2009
@@ -31,11 +31,11 @@
#include "desktop/plot_style.h"
#include "render/parser_binding.h"
+struct fetch_multipart_data;
struct box;
struct rect;
struct browser_window;
struct content;
-struct form_successful_control;
struct imagemap;
struct object_params;
struct plotters;
@@ -183,7 +183,7 @@
bool background);
bool html_replace_object(struct content *c, unsigned int i, char *url,
char *post_urlenc,
- struct form_successful_control *post_multipart);
+ struct fetch_multipart_data *post_multipart);
void html_stop(struct content *c);
void html_open(struct content *c, struct browser_window *bw,
struct content *page, unsigned int index, struct box *box,