Warning fixes.

svn path=/trunk/netsurf/; revision=3332
This commit is contained in:
John Mark Bell 2007-06-10 18:08:22 +00:00
parent e6d754cc96
commit 87ca206e13
4 changed files with 49 additions and 39 deletions

View File

@ -255,7 +255,7 @@ struct fetch * fetch_start(const char *url, const char *referer,
fetch->referer = 0;
fetch->ops = 0;
fetch->fetch_is_active = false;
if (referer != NULL) {
fetch->referer = strdup(referer);
if (fetch->referer == NULL)
@ -276,33 +276,33 @@ struct fetch * fetch_start(const char *url, const char *referer,
}
fetcher = fetcher->next_fetcher;
}
if (fetch->ops == NULL)
goto failed;
/* Got a scheme fetcher, try and set up the fetch */
fetch->fetcher_handle =
fetch->fetcher_handle =
fetch->ops->setup_fetch(fetch, url, only_2xx, post_urlenc,
post_multipart, verifiable, parent_url,
(const char **)headers);
if (fetch->fetcher_handle == NULL)
goto failed;
/* Rah, got it, so ref the fetcher. */
fetch_ref_fetcher(fetch->ops);
/* these aren't needed past here */
if (ref1) {
free(ref1);
ref1 = 0;
}
if (ref2) {
free(ref2);
ref2 = 0;
}
/* Dump us in the queue and ask the queue to run. */
RING_INSERT(queue_ring, fetch);
fetch_dispatch_jobs();
@ -446,18 +446,18 @@ bool fetch_can_fetch(const char *url)
const char *semi;
size_t len;
scheme_fetcher *fetcher = fetchers;
if ((semi = strchr(url, ':')) == NULL)
return false;
len = semi - url;
while (fetcher != NULL) {
if (strlen(fetcher->scheme_name) == len &&
strncmp(fetcher->scheme_name, url, len) == 0)
return true;
fetcher = fetcher->next_fetcher;
}
return false;
}
@ -498,9 +498,10 @@ const char *fetch_get_referer(struct fetch *fetch)
}
void
fetch_send_callback(fetch_msg msg, struct fetch *fetch, void *data, unsigned long size)
fetch_send_callback(fetch_msg msg, struct fetch *fetch, const void *data,
unsigned long size)
{
LOG(("Fetcher sending callback. Fetch %p, fetcher %p data %p size %d",
LOG(("Fetcher sending callback. Fetch %p, fetcher %p data %p size %lu",
fetch, fetch->fetcher_handle, data, size));
fetch->callback(msg, fetch->p, data, size);
}
@ -525,7 +526,7 @@ fetch_can_be_freed(struct fetch *fetch)
void
fetch_set_http_code(struct fetch *fetch, long http_code)
{
LOG(("Setting HTTP code to %d", http_code));
LOG(("Setting HTTP code to %ld", http_code));
fetch->http_code = http_code;
}

View File

@ -90,7 +90,7 @@ const char *fetch_get_referer(struct fetch *fetch);
typedef bool (*fetcher_initialise)(const char *);
typedef void* (*fetcher_setup_fetch)(struct fetch *, const char *,
bool, const char *,
bool, const char *,
struct form_successful_control *, bool,
const char *, const char **);
typedef bool (*fetcher_start_fetch)(void *);
@ -108,7 +108,8 @@ bool fetch_add_fetcher(const char *scheme,
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_send_callback(fetch_msg msg, struct fetch *fetch,
const 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);

View File

@ -162,9 +162,9 @@ fetch_curl_setup(struct fetch *parent_fetch, const char *url,
fetch = malloc(sizeof (*fetch));
if (!fetch)
return 0;
fetch->fetch_handle = parent_fetch;
res = url_host(url, &host);
if (res != URL_FUNC_OK) {
/* we only fail memory exhaustion */
@ -175,7 +175,7 @@ fetch_curl_setup(struct fetch *parent_fetch, const char *url,
if (!host)
goto failed;
}
LOG(("fetch %p, url '%s'", fetch, url));
/* construct a new fetch structure */
@ -255,13 +255,13 @@ fetch_curl_setup(struct fetch *parent_fetch, const char *url,
/* And add any headers specified by the caller */
for (i = 0; headers[i]; i++) {
if (strncasecmp(headers[i], "If-Modified-Since:", 18) == 0) {
char *d = headers[i] + 18;
const char *d = headers[i] + 18;
for (; *d && (*d == ' ' || *d == '\t'); d++)
/* do nothing */;
fetch->last_modified = curl_getdate(d, NULL);
}
else if (strncasecmp(headers[i], "If-None-Match:", 14) == 0) {
char *d = headers[i] + 14;
const char *d = headers[i] + 14;
for (; *d && (*d == ' ' || *d == '\t' || *d == '"');
d++)
/* do nothing */;
@ -758,7 +758,7 @@ static void fetch_curl_done(CURL *curl_handle, CURLcode result)
#endif
else if (error)
fetch_send_callback(FETCH_ERROR, f->fetch_handle, fetch_error_buffer, 0);
fetch_curl_stop(f);
}
@ -1277,13 +1277,13 @@ fetch_curl_finalise(const char *scheme)
/* All the fetchers have been finalised. */
LOG(("All cURL fetchers finalised, closing down cURL"));
CURLMcode codem;
curl_easy_cleanup(fetch_blank_curl);
codem = curl_multi_cleanup(fetch_curl_multi);
if (codem != CURLM_OK)
LOG(("curl_multi_cleanup failed: ignoring"));
curl_global_cleanup();
}
}
@ -1299,7 +1299,7 @@ void register_curl_fetchers(void)
CURLcode code;
curl_version_info_data *data;
int i;
LOG(("curl_version %s", curl_version()));
code = curl_global_init(CURL_GLOBAL_ALL);
@ -1318,7 +1318,7 @@ void register_curl_fetchers(void)
if (!fetch_blank_curl)
die("Failed to initialise the fetch module "
"(curl_easy_init failed).");
#undef SETOPT
#define SETOPT(option, value) \
code = curl_easy_setopt(fetch_blank_curl, option, value); \
@ -1344,9 +1344,9 @@ void register_curl_fetchers(void)
if (option_ca_bundle)
SETOPT(CURLOPT_CAINFO, option_ca_bundle);
/* cURL initialised okay, register the fetchers */
data = curl_version_info(CURLVERSION_NOW);
for (i = 0; data->protocols[i]; i++)

View File

@ -8,10 +8,11 @@
#include <sys/utsname.h>
#include <stdio.h>
#include <stdlib.h>
#include "useragent.h"
#include "desktop/netsurf.h"
#include "utils/log.h"
#include "utils/useragent.h"
static const char *core_user_agent_string = NULL;
@ -27,25 +28,32 @@ build_user_agent(void)
struct utsname un;
const char *sysname = "Unknown";
const char *machine = "Unknown";
char *ua_string;
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,
sysname,
machine);
ua_string = malloc(len + 1);
if (!ua_string) {
/** \todo this needs handling better */
return;
}
snprintf(ua_string, len + 1,
NETSURF_UA_FORMAT_STRING,
netsurf_version_major,
netsurf_version_minor,
un.sysname,
un.machine);
sysname,
machine);
core_user_agent_string = ua_string;
LOG(("Built user agent \"%s\"", core_user_agent_string));
}