diff options
author | Rob Kendrick <rjek@netsurf-browser.org> | 2008-07-26 15:18:21 +0000 |
---|---|---|
committer | Rob Kendrick <rjek@netsurf-browser.org> | 2008-07-26 15:18:21 +0000 |
commit | 94dea065b9f702733ca1610f17a1d8116075ff51 (patch) | |
tree | a4b5a1ddcedbe3557e3b6f4c2546f6d92ca5242d /utils/messages.c | |
parent | dcf1721dee2e05ef62977a260d0a1c59395623db (diff) | |
download | netsurf-94dea065b9f702733ca1610f17a1d8116075ff51.tar.gz netsurf-94dea065b9f702733ca1610f17a1d8116075ff51.tar.bz2 |
Add support for gzipped Messages files
svn path=/trunk/netsurf/; revision=4739
Diffstat (limited to 'utils/messages.c')
-rw-r--r-- | utils/messages.c | 13 |
1 files changed, 8 insertions, 5 deletions
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; } |