summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Kendrick <rjek@netsurf-browser.org>2008-07-26 15:18:21 +0000
committerRob Kendrick <rjek@netsurf-browser.org>2008-07-26 15:18:21 +0000
commit94dea065b9f702733ca1610f17a1d8116075ff51 (patch)
treea4b5a1ddcedbe3557e3b6f4c2546f6d92ca5242d
parentdcf1721dee2e05ef62977a260d0a1c59395623db (diff)
downloadnetsurf-94dea065b9f702733ca1610f17a1d8116075ff51.tar.gz
netsurf-94dea065b9f702733ca1610f17a1d8116075ff51.tar.bz2
Add support for gzipped Messages files
svn path=/trunk/netsurf/; revision=4739
-rw-r--r--utils/config.h1
-rw-r--r--utils/messages.c13
2 files changed, 8 insertions, 6 deletions
diff --git a/utils/config.h b/utils/config.h
index da875a72c..39a394f47 100644
--- a/utils/config.h
+++ b/utils/config.h
@@ -75,7 +75,6 @@ char *strndup(const char *s, size_t n);
#else
/* We're likely to have a working mmap() */
#define WITH_MMAP
- #define WITH_NSSPRITE
#if !defined(DEBUG_BUILD)
/* Use librsvg and Cairo for rendering SVG */
#define WITH_RSVG
diff --git a/utils/messages.c b/utils/messages.c
index e0f5a1097..5ac44ae3c 100644
--- a/utils/messages.c
+++ b/utils/messages.c
@@ -29,6 +29,7 @@
#include <stdio.h>
#include <stdbool.h>
#include <string.h>
+#include <zlib.h>
#include "utils/log.h"
#include "utils/messages.h"
#include "utils/utils.h"
@@ -51,7 +52,7 @@ static struct hash_table *messages_hash = NULL;
struct hash_table *messages_load_ctx(const char *path, struct hash_table *ctx)
{
char s[400];
- FILE *fp;
+ gzFile *fp;
assert(path != NULL);
@@ -62,16 +63,17 @@ struct hash_table *messages_load_ctx(const char *path, struct hash_table *ctx)
return NULL;
}
- fp = fopen(path, "r");
+ fp = gzopen(path, "r");
if (!fp) {
snprintf(s, sizeof s, "Unable to open messages file "
"\"%.100s\": %s", path, strerror(errno));
s[sizeof s - 1] = 0;
LOG(("%s", s));
+ hash_destroy(ctx);
return NULL;
}
- while (fgets(s, sizeof s, fp)) {
+ while (gzgets(fp, s, sizeof s)) {
char *colon, *value;
if (s[0] == 0 || s[0] == '#')
@@ -87,12 +89,13 @@ struct hash_table *messages_load_ctx(const char *path, struct hash_table *ctx)
if (hash_add(ctx, s, value) == false) {
LOG(("Unable to add %s:%s to hash table of %s",
s, value, path));
- fclose(fp);
+ gzclose(fp);
+ hash_destroy(ctx);
return NULL;
}
}
- fclose(fp);
+ gzclose(fp);
return ctx;
}