Merge scheme switcher branch in.

svn path=/trunk/netsurf/; revision=3330
This commit is contained in:
Daniel Silverstone 2007-06-10 17:46:44 +00:00
parent ccc270eea1
commit 1dd7e97eb3
9 changed files with 1814 additions and 1373 deletions

File diff suppressed because it is too large Load Diff

View File

@ -14,7 +14,6 @@
#include <stdbool.h>
#include <sys/select.h>
#include <curl/curl.h>
#include "utils/config.h"
typedef enum {
@ -64,15 +63,17 @@ struct ssl_cert_info {
#endif
extern bool fetch_active;
extern CURLM *fetch_curl_multi;
typedef void (*fetch_callback)(fetch_msg msg, void *p, const void *data,
unsigned long size);
void fetch_init(void);
struct fetch * fetch_start(const char *url, const char *referer,
void (*callback)(fetch_msg msg, void *p, const void *data,
unsigned long size),
void *p, bool only_2xx, const char *post_urlenc,
struct form_successful_control *post_multipart,
bool verifiable, const char *parent_url, char *headers[]);
fetch_callback callback,
void *p, bool only_2xx, const char *post_urlenc,
struct form_successful_control *post_multipart,
bool verifiable, const char *parent_url, char *headers[]);
void fetch_abort(struct fetch *f);
void fetch_poll(void);
void fetch_quit(void);
@ -80,10 +81,35 @@ const char *fetch_filetype(const char *unix_path);
char *fetch_mimetype(const char *ro_path);
bool fetch_can_fetch(const char *url);
void fetch_change_callback(struct fetch *fetch,
void (*callback)(fetch_msg msg, void *p, const void *data,
unsigned long size),
void *p);
fetch_callback callback,
void *p);
long fetch_http_code(struct fetch *fetch);
const char *fetch_get_referer(struct fetch *fetch);
/* 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 *, bool,
const char *, const char **);
typedef bool (*fetcher_start_fetch)(void *);
typedef void (*fetcher_abort_fetch)(void *);
typedef void (*fetcher_free_fetch)(void *);
typedef void (*fetcher_poll_fetcher)(const char *);
typedef void (*fetcher_finalise)(const char *);
bool fetch_add_fetcher(const char *scheme,
fetcher_initialise initialiser,
fetcher_setup_fetch setup_fetch,
fetcher_start_fetch start_fetch,
fetcher_abort_fetch abort_fetch,
fetcher_free_fetch free_fetch,
fetcher_poll_fetcher poll_fetcher,
fetcher_finalise finaliser);
void fetch_send_callback(fetch_msg msg, struct fetch *fetch, void *data, unsigned long size);
void fetch_can_be_freed(struct fetch *fetch);
void fetch_set_http_code(struct fetch *fetch, long http_code);
const char *fetch_get_referer_to_send(struct fetch *fetch);
#endif

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,22 @@
/*
* This file is part of NetSurf, http://netsurf-browser.org/
* Licensed under the GNU General Public License,
* http://www.opensource.org/licenses/gpl-license
* Copyright 2007 Daniel Silverstone <dsilvers@digital-scurf.org>
*/
/** \file
* Fetching of data from a URL (Registration).
*/
#ifndef NETSURF_CONTENT_FETCHERS_FETCH_CURL_H
#define NETSURF_CONTENT_FETCHERS_FETCH_CURL_H
#include <curl/curl.h>
void register_curl_fetchers(void);
/** Global cURL multi handle. */
extern CURLM *fetch_curl_multi;
#endif

View File

@ -22,6 +22,7 @@
#include <glade/glade.h>
#include "content/content.h"
#include "content/fetch.h"
#include "content/fetchers/fetch_curl.h"
#include "content/urldb.h"
#include "desktop/401login.h"
#include "desktop/browser.h"

View File

@ -20,12 +20,13 @@
SYSTEM_CC ?= gcc
OBJECTS_COMMON = content.o fetch.o fetchcache.o urldb.o # content/
OBJECTS_COMMON += fetch_curl.o # content/fetchers/
OBJECTS_COMMON += css.o css_enum.o parser.o ruleset.o scanner.o # css/
OBJECTS_COMMON += box.o box_construct.o box_normalise.o directory.o \
form.o html.o html_redraw.o imagemap.o layout.o list.o \
table.o textplain.o # render/
OBJECTS_COMMON += filename.o hashtable.o messages.o talloc.o \
url.o utf8.o utils.o # utils/
url.o utf8.o utils.o useragent.o # utils/
OBJECTS_COMMON += knockout.o options.o tree.o version.o # desktop/
OBJECTS_IMAGE = bmp.o bmpread.o gif.o gifread.o ico.o jpeg.o \
@ -110,7 +111,7 @@ else
include posix.mk
endif
VPATH = content:css:desktop:image:render:riscos:riscos/configure:riscos/gui:utils:debug:gtk
VPATH = content:content/fetchers:css:desktop:image:render:riscos:riscos/configure:riscos/gui:utils:debug:gtk
WARNFLAGS = -W -Wall -Wundef -Wpointer-arith -Wcast-qual \
-Wcast-align -Wwrite-strings -Wstrict-prototypes \
@ -131,7 +132,7 @@ CFLAGS_GTK = -std=c99 -Dgtk -Dnsgtk \
-D_BSD_SOURCE \
-DGTK_DISABLE_DEPRECATED \
-D_POSIX_C_SOURCE \
$(WARNFLAGS) -I. -g -O2 -Wformat=2 \
$(WARNFLAGS) -I. -g -O0 -Wformat=2 \
`pkg-config --cflags libglade-2.0 gtk+-2.0` `xml2-config --cflags`
# Stop GCC under Cygwin throwing a fit
@ -209,7 +210,7 @@ $(OBJDIR_NCOS)/%.o : %.s
# available), remove */*.[ch] from the line below.
# Under RISC OS, you may require *Set UnixFS$sfix "", if perl gives
# "No such file or directory" errors.
depend: css/css_enum.c css/parser.c css/scanner.c utils/translit.c */*.[ch]
depend: css/css_enum.c css/parser.c css/scanner.c utils/translit.c */*.[ch] */*/*.[ch]
@echo "--> modified files $?"
@echo "--> updating dependencies"
@-mkdir -p $(OBJDIR_RISCOS) $(OBJDIR_RISCOS_SMALL) $(OBJDIR_NCOS) $(OBJDIR_DEBUG) $(OBJDIR_GTK)

98
utils/ring.h Normal file
View File

@ -0,0 +1,98 @@
/*
* This file is part of NetSurf, http://netsurf-browser.org/
* Licensed under the GNU General Public License,
* http://www.opensource.org/licenses/gpl-license
* Copyright 2006, 2007 Daniel Silverstone <dsilvers@digital-scurf.org>
*/
/** \file
* Ring list structure.
*
* Rings are structures which have an r_next pointer and an r_prev
* pointer which are always initialised and always point at the next
* or previous element respectively.
*
* The degenerate case of a single element in the ring simply points
* at itself in both directions. A zero element ring is NULL.
*
* Some of the ring functions are specific to the fetcher but may be
* of use to others and are thus included here.
*/
#ifndef _NETSURF_UTILS_RING_H_
#define _NETSURF_UTILS_RING_H_
/** Insert the given item into the specified ring.
* Assumes that the element is zeroed as appropriate.
*/
#define RING_INSERT(ring,element) \
/*LOG(("RING_INSERT(%s, %p(%s))", #ring, element, element->host));*/ \
if (ring) { \
element->r_next = ring; \
element->r_prev = ring->r_prev; \
ring->r_prev = element; \
element->r_prev->r_next = element; \
} else \
ring = element->r_prev = element->r_next = element
/** Remove the given element from the specified ring.
* Will zero the element as needed
*/
#define RING_REMOVE(ring, element) \
/*LOG(("RING_REMOVE(%s, %p(%s)", #ring, element, element->host));*/ \
if (element->r_next != element ) { \
/* Not the only thing in the ring */ \
element->r_next->r_prev = element->r_prev; \
element->r_prev->r_next = element->r_next; \
if (ring == element) ring = element->r_next; \
} else { \
/* Only thing in the ring */ \
ring = 0; \
} \
element->r_next = element->r_prev = 0
/** Find the element (by hostname) in the given ring, leave it in the
* provided element variable
*/
#define RING_FINDBYHOST(ring, element, hostname) \
/*LOG(("RING_FINDBYHOST(%s, %s)", #ring, hostname));*/ \
if (ring) { \
bool found = false; \
element = ring; \
do { \
if (strcasecmp(element->host, hostname) == 0) { \
found = true; \
break; \
} \
element = element->r_next; \
} while (element != ring); \
if (!found) element = 0; \
} else element = 0
/** Measure the size of a ring and put it in the supplied variable */
#define RING_GETSIZE(ringtype, ring, sizevar) \
/*LOG(("RING_GETSIZE(%s)", #ring));*/ \
if (ring) { \
ringtype *p = ring; \
sizevar = 0; \
do { \
sizevar++; \
p = p->r_next; \
} while (p != ring); \
} else sizevar = 0
/** Count the number of elements in the ring which match the provided hostname */
#define RING_COUNTBYHOST(ringtype, ring, sizevar, hostname) \
/*LOG(("RING_COUNTBYHOST(%s, %s)", #ring, hostname));*/ \
if (ring) { \
ringtype *p = ring; \
sizevar = 0; \
do { \
if (strcasecmp(p->host, hostname) == 0) \
sizevar++; \
p = p->r_next; \
} while (p != ring); \
} else sizevar = 0
#endif

60
utils/useragent.c Normal file
View File

@ -0,0 +1,60 @@
/*
* This file is part of NetSurf, http://netsurf-browser.org/
* Licensed under the GNU General Public License,
* http://www.opensource.org/licenses/gpl-license
* Copyright 2007 Daniel Silverstone <dsilvers@digital-scurf.org>
* Copyright 2007 Rob Kendrick <rjek@netsurf-browser.org>
*/
#include <sys/utsname.h>
#include <stdio.h>
#include "useragent.h"
#include "desktop/netsurf.h"
#include "utils/log.h"
static const char *core_user_agent_string = NULL;
#define NETSURF_UA_FORMAT_STRING "NetSurf/%d.%d (%s; %s)"
/**
* Prepare core_user_agent_string with a string suitable for use as a
* user agent in HTTP requests.
*/
static void
build_user_agent(void)
{
struct utsname un;
const char *sysname = "Unknown";
const char *machine = "Unknown";
int len;
if (uname(&un) == 0) {
sysname = un.sysname;
machine = un.machine;
}
len = snprintf(NULL, 0, NETSURF_UA_FORMAT_STRING,
netsurf_version_major,
netsurf_version_minor,
un.sysname,
un.machine);
core_user_agent_string = malloc(len + 1);
snprintf(core_user_agent_string, len + 1,
NETSURF_UA_FORMAT_STRING,
netsurf_version_major,
netsurf_version_minor,
un.sysname,
un.machine);
LOG(("Built user agent \"%s\"", core_user_agent_string));
}
/* This is a function so that later we can override it trivially */
const char *
user_agent_string(void)
{
if (core_user_agent_string == NULL)
build_user_agent();
return core_user_agent_string;
}

19
utils/useragent.h Normal file
View File

@ -0,0 +1,19 @@
/*
* This file is part of NetSurf, http://netsurf-browser.org/
* Licensed under the GNU General Public License,
* http://www.opensource.org/licenses/gpl-license
* Copyright 2007 Daniel Silverstone <dsilvers@digital-scurf.org>
* Copyright 2007 Rob Kendrick <rjek@netsurf-browser.org>
*/
#ifndef _NETSURF_UTILS_USERAGENT_H_
#define _NETSURF_UTILS_USERAGENT_H_
/** Retrieve the core user agent for this release.
*
* The string returned can be relied upon to exist for the duration of
* the execution of the program. There is no need to copy it.
*/
const char * user_agent_string(void);
#endif