summaryrefslogtreecommitdiff
path: root/content
diff options
context:
space:
mode:
authorVincent Sanders <vince@kyllikki.org>2014-10-26 12:42:53 +0000
committerVincent Sanders <vince@kyllikki.org>2014-10-26 12:42:53 +0000
commit14e282948996f75e87a14ab90f4b3ed54d9d6ad7 (patch)
tree7f78ad2cc5c9965f6a329c81c025d1c240eb4f87 /content
parenta913af5cf54400b441f3b1fbfc5d508cf85fea43 (diff)
downloadnetsurf-14e282948996f75e87a14ab90f4b3ed54d9d6ad7.tar.gz
netsurf-14e282948996f75e87a14ab90f4b3ed54d9d6ad7.tar.bz2
remove the die API from the core.
The die() API for abnormal termination does not belong within the core of netsurf and instead errors are propogated back to the callers. This is the final part of this change and the API is now only used within some parts of the frontends
Diffstat (limited to 'content')
-rw-r--r--content/urldb.c27
-rw-r--r--content/urldb.h2
2 files changed, 16 insertions, 13 deletions
diff --git a/content/urldb.c b/content/urldb.c
index c74dae36d..650c7bc51 100644
--- a/content/urldb.c
+++ b/content/urldb.c
@@ -343,7 +343,7 @@ static struct bloom_filter *url_bloom;
*
* \param filename Name of file containing data
*/
-void urldb_load(const char *filename)
+nserror urldb_load(const char *filename)
{
#define MAXIMUM_URL_LENGTH 4096
char s[MAXIMUM_URL_LENGTH];
@@ -365,24 +365,24 @@ void urldb_load(const char *filename)
fp = fopen(filename, "r");
if (!fp) {
LOG(("Failed to open file '%s' for reading", filename));
- return;
+ return NSERROR_NOT_FOUND;
}
if (!fgets(s, MAXIMUM_URL_LENGTH, fp)) {
fclose(fp);
- return;
+ return NSERROR_NEED_DATA;
}
version = atoi(s);
if (version < MIN_URL_FILE_VERSION) {
LOG(("Unsupported URL file version."));
fclose(fp);
- return;
+ return NSERROR_INVALID;
}
if (version > URL_FILE_VERSION) {
LOG(("Unknown URL file version."));
fclose(fp);
- return;
+ return NSERROR_INVALID;
}
while (fgets(host, sizeof host, fp)) {
@@ -417,7 +417,8 @@ void urldb_load(const char *filename)
h = urldb_add_host(host);
if (!h) {
LOG(("Failed adding host: '%s'", host));
- die("Memory exhausted whilst loading URL file");
+ fclose(fp);
+ return NSERROR_NOMEM;
}
/* load the non-corrupt data */
@@ -467,8 +468,8 @@ void urldb_load(const char *filename)
*/
if (nsurl_create(url, &nsurl) != NSERROR_OK) {
LOG(("Failed inserting '%s'", url));
- die("Memory exhausted whilst loading "
- "URL file");
+ fclose(fp);
+ return NSERROR_NOMEM;
}
if (url_bloom != NULL) {
@@ -480,8 +481,8 @@ void urldb_load(const char *filename)
if (nsurl_get(nsurl, NSURL_PATH | NSURL_QUERY,
&path_query, &len) != NSERROR_OK) {
LOG(("Failed inserting '%s'", url));
- die("Memory exhausted whilst loading "
- "URL file");
+ fclose(fp);
+ return NSERROR_NOMEM;
}
scheme_lwc = nsurl_get_component(nsurl, NSURL_SCHEME);
@@ -491,8 +492,8 @@ void urldb_load(const char *filename)
fragment_lwc, nsurl);
if (!p) {
LOG(("Failed inserting '%s'", url));
- die("Memory exhausted whilst loading "
- "URL file");
+ fclose(fp);
+ return NSERROR_NOMEM;
}
nsurl_unref(nsurl);
lwc_string_unref(scheme_lwc);
@@ -533,6 +534,8 @@ void urldb_load(const char *filename)
fclose(fp);
LOG(("Successfully loaded URL file"));
#undef MAXIMUM_URL_LENGTH
+
+ return NSERROR_OK;
}
/**
diff --git a/content/urldb.h b/content/urldb.h
index d60043089..c0fece24e 100644
--- a/content/urldb.h
+++ b/content/urldb.h
@@ -68,7 +68,7 @@ struct bitmap;
void urldb_destroy(void);
/* Persistence support */
-void urldb_load(const char *filename);
+nserror urldb_load(const char *filename);
void urldb_save(const char *filename);
void urldb_set_url_persistence(nsurl *url, bool persist);