Drop support for URL file versions below 1.06

svn path=/trunk/netsurf/; revision=3945
This commit is contained in:
John Mark Bell 2008-03-13 18:25:41 +00:00
parent 2dadb5fac8
commit 9597b5359c

View File

@ -304,7 +304,7 @@ static struct search_node *search_trees[NUM_SEARCH_TREES] = {
#define MIN_COOKIE_FILE_VERSION 100 #define MIN_COOKIE_FILE_VERSION 100
#define COOKIE_FILE_VERSION 101 #define COOKIE_FILE_VERSION 101
static int loaded_cookie_file_version; static int loaded_cookie_file_version;
#define MIN_URL_FILE_VERSION 105 #define MIN_URL_FILE_VERSION 106
#define URL_FILE_VERSION 106 #define URL_FILE_VERSION 106
/** /**
@ -356,23 +356,12 @@ void urldb_load(const char *filename)
if (!fgets(s, MAXIMUM_URL_LENGTH, fp)) if (!fgets(s, MAXIMUM_URL_LENGTH, fp))
break; break;
urls = atoi(s); urls = atoi(s);
for (i = 0; i < ((version == 105 ? 6 : 8) * urls); /* Eight fields/url */
i++) for (i = 0; i < (8 * urls); i++) {
if (!fgets(s, MAXIMUM_URL_LENGTH, fp)) if (!fgets(s, MAXIMUM_URL_LENGTH, fp))
break; break;
continue;
}
if (version == 105) {
/* file:/ -> localhost */
if (strcasecmp(host, "file:/") == 0)
snprintf(host, sizeof host, "localhost");
else {
/* strip any port number */
char *colon = strrchr(host, ':');
if (colon)
*colon = '\0';
} }
continue;
} }
/* read number of URLs */ /* read number of URLs */
@ -395,77 +384,45 @@ void urldb_load(const char *filename)
/* load the non-corrupt data */ /* load the non-corrupt data */
for (i = 0; i < urls; i++) { for (i = 0; i < urls; i++) {
struct path_data *p = NULL; struct path_data *p = NULL;
char scheme[64], ports[10];
char url[64 + 3 + 256 + 6 + 4096 + 1];
unsigned int port;
bool is_file = false;
if (version == 105) { if (!fgets(scheme, sizeof scheme, fp))
if (!fgets(s, MAXIMUM_URL_LENGTH, fp)) break;
break; length = strlen(scheme) - 1;
length = strlen(s) - 1; scheme[length] = '\0';
s[length] = '\0';
if (strncasecmp(s, "file:", 5) == 0) { if (!fgets(ports, sizeof ports, fp))
/* local file, so fudge insertion */ break;
char url[7 + 4096]; length = strlen(ports) - 1;
ports[length] = '\0';
port = atoi(ports);
snprintf(url, sizeof url, if (!fgets(s, MAXIMUM_URL_LENGTH, fp))
"file://%s", s + 5); break;
length = strlen(s) - 1;
s[length] = '\0';
p = urldb_add_path("file", 0, h, if (!strcasecmp(host, "localhost") &&
s + 5, NULL, NULL, url); !strcasecmp(scheme, "file"))
if (!p) { is_file = true;
LOG(("Failed inserting '%s'",
url));
die("Memory exhausted "
"whilst loading "
"URL file");
}
} else {
if (!urldb_add_url(s)) {
LOG(("Failed inserting '%s'",
s));
}
p = urldb_find_url(s);
}
} else {
char scheme[64], ports[10];
char url[64 + 3 + 256 + 6 + 4096 + 1];
unsigned int port;
bool is_file = false;
if (!fgets(scheme, sizeof scheme, fp)) snprintf(url, sizeof url, "%s://%s%s%s%s",
break; scheme,
length = strlen(scheme) - 1; /* file URLs have no host */
scheme[length] = '\0'; (is_file ? "" : host),
(port ? ":" : ""),
(port ? ports : ""),
s);
if (!fgets(ports, sizeof ports, fp)) p = urldb_add_path(scheme, port, h, s, NULL, NULL,
break; url);
length = strlen(ports) - 1; if (!p) {
ports[length] = '\0'; LOG(("Failed inserting '%s'", url));
port = atoi(ports); die("Memory exhausted whilst loading "
"URL file");
if (!fgets(s, MAXIMUM_URL_LENGTH, fp))
break;
length = strlen(s) - 1;
s[length] = '\0';
if (!strcasecmp(host, "localhost") &&
!strcasecmp(scheme, "file"))
is_file = true;
snprintf(url, sizeof url, "%s://%s%s%s%s",
scheme,
/* file URLs have no host */
(is_file ? "" : host),
(port ? ":" : ""),
(port ? ports : ""),
s);
p = urldb_add_path(scheme, port, h, s, NULL, NULL,
url);
if (!p) {
LOG(("Failed inserting '%s'", url));
die("Memory exhausted whilst loading "
"URL file");
}
} }
if (!fgets(s, MAXIMUM_URL_LENGTH, fp)) if (!fgets(s, MAXIMUM_URL_LENGTH, fp))