From ba23e4b69341e5f3f2dbcd824663e75ebe2a581f Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Mon, 27 Nov 2006 15:35:18 +0000 Subject: Update project URL. svn path=/trunk/netsurf/; revision=3073 --- utils/config.h | 2 +- utils/container.c | 146 +++++++++++++++++++++++++++--------------------------- utils/container.h | 6 +-- utils/filename.c | 2 +- utils/filename.h | 2 +- utils/hashtable.c | 4 +- utils/hashtable.h | 2 +- utils/log.h | 2 +- utils/messages.c | 2 +- utils/messages.h | 2 +- utils/themes.c | 6 +-- utils/themes.h | 4 +- utils/tt2code | 2 +- utils/url.c | 2 +- utils/url.h | 2 +- utils/utf8.c | 2 +- utils/utf8.h | 2 +- utils/utils.c | 2 +- utils/utils.h | 2 +- 19 files changed, 97 insertions(+), 97 deletions(-) (limited to 'utils') diff --git a/utils/config.h b/utils/config.h index 459336e88..3f74b7fc1 100644 --- a/utils/config.h +++ b/utils/config.h @@ -1,5 +1,5 @@ /* - * This file is part of NetSurf, http://netsurf.sourceforge.net/ + * This file is part of NetSurf, http://netsurf-browser.org/ * Licensed under the GNU General Public License, * http://www.opensource.org/licenses/gpl-license * Copyright 2003,4 John M Bell diff --git a/utils/container.c b/utils/container.c index 5104b1875..c85e15ef1 100644 --- a/utils/container.c +++ b/utils/container.c @@ -1,5 +1,5 @@ /* - * This file is part of NetSurf, http://netsurf.sourceforge.net/ + * This file is part of NetSurf, http://netsurf-browser.org/ * Licensed under the GNU General Public License, * http://www.opensource.org/licenses/gpl-license * Copyright 2006 Rob Kendrick @@ -56,11 +56,11 @@ inline static size_t container_filelen(FILE *fd) { size_t o = ftell(fd); size_t a; - + fseek(fd, 0, SEEK_END); a = ftell(fd); fseek(fd, o, SEEK_SET); - + return a; } @@ -86,36 +86,36 @@ struct container_ctx *container_open(const char *filename) struct container_ctx *ctx = calloc(sizeof(struct container_ctx), 1); ctx->fh = fopen(filename, "rb"); - + if (ctx->fh == NULL) { free(ctx); return NULL; } - + /* we don't actually load any of the data (including directory) * until we need to, such that _get_name and _get_author are as quick * as possible. When we have, this gets set to true. */ ctx->processed = false; - + fread(&ctx->header.magic, 4, 1, ctx->fh); ctx->header.magic = ntohl(ctx->header.magic); - + fread(&ctx->header.parser, 4, 1, ctx->fh); ctx->header.parser = ntohl(ctx->header.parser); - + fread(ctx->header.name, 32, 1, ctx->fh); fread(ctx->header.author, 64, 1, ctx->fh); - + fread(&ctx->header.diroffset, 4, 1, ctx->fh); ctx->header.diroffset = ntohl(ctx->header.diroffset); - + if (ctx->header.magic != 0x4e53544d || ctx->header.parser != 3) { fclose(ctx->fh); free(ctx); return NULL; } - + return ctx; } @@ -128,14 +128,14 @@ static void container_process(struct container_ctx *ctx) ctx->data = mmap(NULL, ctx->header.diroffset, PROT_READ, MAP_PRIVATE, fileno(ctx->fh), 0); #else - ctx->data = malloc(ctx->header.diroffset); + ctx->data = malloc(ctx->header.diroffset); fseek(ctx->fh, 0, SEEK_SET); fread(ctx->data, ctx->header.diroffset, 1, ctx->fh); #endif fseek(ctx->fh, ctx->header.diroffset, SEEK_SET); /* now work through the directory structure taking it apart into * our structure */ -#define BEREAD(x) do { fread(&(x), 4, 1, ctx->fh);(x) = ntohl((x)); } while (0) +#define BEREAD(x) do { fread(&(x), 4, 1, ctx->fh);(x) = ntohl((x)); } while (0) do { fread(filename, 16, 1, ctx->fh); BEREAD(start); @@ -154,13 +154,13 @@ static const struct container_dirent *container_lookup( const unsigned char *entryname) { int i; - + for (i = 1; i <= ctx->entries; i++) { struct container_dirent *e = ctx->directory + i - 1; if (strcmp((char *)e->filename, (char *)entryname) == 0) return e; } - + return NULL; } @@ -169,10 +169,10 @@ const unsigned char *container_get(struct container_ctx *ctx, u_int32_t *size) { const struct container_dirent *e; - + if (ctx->processed == false) container_process(ctx); - + e = container_lookup(ctx, entryname); if (e == NULL) @@ -190,17 +190,17 @@ const unsigned char *container_iterate(struct container_ctx *ctx, int *state) if (ctx->processed == false) container_process(ctx); - + e = ctx->directory + *state; - + r = e->filename; - + if (r == NULL || r[0] == '\0') r = NULL; - + *state += 1; - - return r; + + return r; } const unsigned char *container_get_name(struct container_ctx *ctx) @@ -240,32 +240,32 @@ struct container_ctx *container_create(const char *filename, struct container_ctx *ctx = calloc(sizeof(struct container_ctx), 1); ctx->fh = fopen(filename, "wb"); - + if (ctx->fh == NULL) { free(ctx); return NULL; } - + ctx->creating = true; ctx->entries = 0; ctx->directory = NULL; ctx->header.parser = htonl(3); strncpy((char *)ctx->header.name, (char *)name, 32); strncpy((char *)ctx->header.author, (char *)author, 64); - + fwrite("NSTM", 4, 1, ctx->fh); fwrite(&ctx->header.parser, 4, 1, ctx->fh); fwrite(ctx->header.name, 32, 1, ctx->fh); fwrite(ctx->header.author, 64, 1, ctx->fh); - + ctx->header.diroffset = 108; - + /* skip over the directory offset for now, and fill it in later. * we don't know where it'll be yet! */ - + fseek(ctx->fh, 108, SEEK_SET); - + return ctx; } @@ -276,7 +276,7 @@ void container_add(struct container_ctx *ctx, const unsigned char *entryname, container_add_to_dir(ctx, entryname, ftell(ctx->fh), datalen); fwrite(data, datalen, 1, ctx->fh); } - + void container_close(struct container_ctx *ctx) { if (ctx->creating == true) { @@ -285,16 +285,16 @@ void container_close(struct container_ctx *ctx) /* discover where the directory's going to go. */ flen = container_filelen(ctx->fh); flen = (flen + 3) & (~3); /* round up to nearest 4 bytes */ - + /* write this location to the header */ fseek(ctx->fh, 104, SEEK_SET); nflen = htonl(flen); fwrite(&nflen, 4, 1, ctx->fh); - + /* seek to where the directory will be, and write it */ fseek(ctx->fh, flen, SEEK_SET); container_write_dir(ctx); - + } else if (ctx->processed) { #ifdef WITH_MMAP munmap(ctx->data, ctx->header.diroffset); @@ -315,26 +315,26 @@ int main(int argc, char *argv[]) u_int32_t size; int state = 0; char *n; - + container_add(ctx, "CHEESE", "This is a test of some cheese.\0", 31); container_add(ctx, "FOO", "This is a test of some cheese.\0", 31); - + container_close(ctx); - + ctx = container_open("test.theme"); - + printf("Theme name: %s\n", container_get_name(ctx)); printf("Theme author: %s\n", container_get_author(ctx)); - + printf("Test string: %s\n", container_get(ctx, "CHEESE", &size)); printf("Length of text: %d\n", size); - + while ( (n = container_iterate(ctx, &state)) ) { printf("%s\n", n); } - + container_close(ctx); - + exit(0); } #endif @@ -370,30 +370,30 @@ static void extract_theme(const char *themefile, const char *dirname) char path[PATH_MAX]; int state = 0; u_int32_t flen; - - + + if (stat(dirname, &statbuf) != -1) { fprintf(stderr, "error: directory '%s' already exists.\n", dirname); exit(1); } - + mkdir(dirname, 00777); - + cctx = container_open(themefile); if (cctx == NULL) { fprintf(stderr, "error: unable to open theme file '%s'\n", themefile); exit(1); } - + if (verbose == true) { printf("theme name: %s\n", container_get_name(cctx)); printf("theme author: %s\n", container_get_author(cctx)); } - + while ( (e = container_iterate(cctx, &state)) ) { - if (verbose == true) + if (verbose == true) printf("extracting %s\n", e); snprintf(path, PATH_MAX, "%s/%s", dirname, e); fh = fopen(path, "wb"); @@ -405,9 +405,9 @@ static void extract_theme(const char *themefile, const char *dirname) fclose(fh); } } - + container_close(cctx); - + } static void create_theme(const char *themefile, const char *dirname, @@ -423,16 +423,16 @@ static void create_theme(const char *themefile, const char *dirname, char path[PATH_MAX]; size_t flen; int t; - + if (dir == NULL) { perror("error: unable to open directory"); exit(1); } - + cctx = container_create(themefile, name, author); - + errno = 0; /* to distinguish between end of dir and err */ - + while ((e = readdir(dir)) != NULL) { if (strcmp(e->d_name, ".") != 0 && strcmp(e->d_name, "..") != 0) { @@ -443,9 +443,9 @@ static void create_theme(const char *themefile, const char *dirname, fprintf(stderr, "warning: name truncated to 15 characters.\n"); } - + snprintf(path, PATH_MAX, "%s/%s", dirname, e->d_name); - + stat(path, &statbuf); if (S_ISDIR(statbuf.st_mode)) { fprintf(stderr, @@ -453,7 +453,7 @@ static void create_theme(const char *themefile, const char *dirname, e->d_name); continue; } - + fh = fopen(path, "rb"); if (fh == NULL) { fprintf(stderr, @@ -470,14 +470,14 @@ static void create_theme(const char *themefile, const char *dirname, } errno = 0; } - + if (errno != 0) { perror("error: couldn't enumerate directory"); closedir(dir); container_close(cctx); exit(1); } - + closedir(dir); container_close(cctx); } @@ -491,16 +491,16 @@ int main(int argc, char *argv[]) { "name", 1, 0, 'n' }, { "author", 1, 0, 'a' }, { "verbose", 0, 0, 'v' }, - + { NULL, 0, 0, 0 } }; - + static char *s_opts = "hcxn:a:v"; int optch, optidx; bool creating = false, extracting = false; unsigned char name[32] = { '\0' }, author[64] = { '\0' }; char *themefile, *dirname; - + while ((optch = getopt_long(argc, argv, s_opts, l_opts, &optidx)) != -1) switch (optch) { case 'h': @@ -531,40 +531,40 @@ int main(int argc, char *argv[]) exit(1); break; } - + if (creating == extracting) { show_usage(argv[0]); exit(1); } - + if ((argc - optind) < 2) { show_usage(argv[0]); exit(1); } - - if (creating == true && + + if (creating == true && (strlen((char *)name) == 0 || strlen((char *)author) == 0)) { fprintf(stderr, "No theme name and/or author specified.\n"); show_usage(argv[0]); exit(1); } - + themefile = strdup(argv[optind]); dirname = strdup(argv[optind + 1]); - + if (verbose == true) printf("%s '%s' %s directory '%s'\n", creating ? "creating" : "extracting", themefile, creating ? "from" : "to", dirname); - + if (creating) { if (verbose == true) printf("name = %s, author = %s\n", name, author); - create_theme(themefile, dirname, name, author); + create_theme(themefile, dirname, name, author); } else { extract_theme(themefile, dirname); } - - return 0; + + return 0; } #endif diff --git a/utils/container.h b/utils/container.h index c96a79921..5a82ace2b 100644 --- a/utils/container.h +++ b/utils/container.h @@ -1,5 +1,5 @@ /* - * This file is part of NetSurf, http://netsurf.sourceforge.net/ + * This file is part of NetSurf, http://netsurf-browser.org/ * Licensed under the GNU General Public License, * http://www.opensource.org/licenses/gpl-license * Copyright 2006 Rob Kendrick @@ -7,7 +7,7 @@ /** \file * Container format handling for themes etc. */ - + #ifndef __CONTAINER_H__ #define __CONTAINER_H__ @@ -32,7 +32,7 @@ struct container_ctx *container_create(const char *filename, void container_add(struct container_ctx *ctx, const unsigned char *entryname, const unsigned char *data, const u_int32_t datalen); - + /* common interface */ void container_close(struct container_ctx *ctx); diff --git a/utils/filename.c b/utils/filename.c index 518a0a207..194d11c74 100644 --- a/utils/filename.c +++ b/utils/filename.c @@ -1,5 +1,5 @@ /* - * This file is part of NetSurf, http://netsurf.sourceforge.net/ + * This file is part of NetSurf, http://netsurf-browser.org/ * Licensed under the GNU General Public License, * http://www.opensource.org/licenses/gpl-license * Copyright 2006 Richard Wilson diff --git a/utils/filename.h b/utils/filename.h index f38a29cb8..7c8c6e39d 100644 --- a/utils/filename.h +++ b/utils/filename.h @@ -1,5 +1,5 @@ /* - * This file is part of NetSurf, http://netsurf.sourceforge.net/ + * This file is part of NetSurf, http://netsurf-browser.org/ * Licensed under the GNU General Public License, * http://www.opensource.org/licenses/gpl-license * Copyright 2006 Richard Wilson diff --git a/utils/hashtable.c b/utils/hashtable.c index ff5dad1ca..6c82be0b4 100644 --- a/utils/hashtable.c +++ b/utils/hashtable.c @@ -1,5 +1,5 @@ /* - * This file is part of NetSurf, http://netsurf.sourceforge.net/ + * This file is part of NetSurf, http://netsurf-browser.org/ * Licensed under the GNU General Public License, * http://www.opensource.org/licenses/gpl-license * Copyright 2006 Rob Kendrick @@ -123,7 +123,7 @@ bool hash_add(struct hash_table *ht, const char *key, const char *value) h = hash_string_fnv(key, &(e->key_length)); c = h % ht->nchains; - + v = strlen(value) ; e->pairing = malloc(v + e->key_length + 2); if (e->pairing == NULL) { diff --git a/utils/hashtable.h b/utils/hashtable.h index e48c76646..f4a36a538 100644 --- a/utils/hashtable.h +++ b/utils/hashtable.h @@ -1,5 +1,5 @@ /* - * This file is part of NetSurf, http://netsurf.sourceforge.net/ + * This file is part of NetSurf, http://netsurf-browser.org/ * Licensed under the GNU General Public License, * http://www.opensource.org/licenses/gpl-license * Copyright 2006 Rob Kendrick diff --git a/utils/log.h b/utils/log.h index 65417b930..6ad17bb0d 100644 --- a/utils/log.h +++ b/utils/log.h @@ -1,5 +1,5 @@ /* - * This file is part of NetSurf, http://netsurf.sourceforge.net/ + * This file is part of NetSurf, http://netsurf-browser.org/ * Licensed under the GNU General Public License, * http://www.opensource.org/licenses/gpl-license * Copyright 2003 James Bursa diff --git a/utils/messages.c b/utils/messages.c index e3a8d5c90..a10eec025 100644 --- a/utils/messages.c +++ b/utils/messages.c @@ -1,5 +1,5 @@ /* - * This file is part of NetSurf, http://netsurf.sourceforge.net/ + * This file is part of NetSurf, http://netsurf-browser.org/ * Licensed under the GNU General Public License, * http://www.opensource.org/licenses/gpl-license * Copyright 2004 James Bursa diff --git a/utils/messages.h b/utils/messages.h index 6f9dfb763..db1f713c8 100644 --- a/utils/messages.h +++ b/utils/messages.h @@ -1,5 +1,5 @@ /* - * This file is part of NetSurf, http://netsurf.sourceforge.net/ + * This file is part of NetSurf, http://netsurf-browser.org/ * Licensed under the GNU General Public License, * http://www.opensource.org/licenses/gpl-license * Copyright 2004 James Bursa diff --git a/utils/themes.c b/utils/themes.c index 4f5322134..0387a1d1d 100644 --- a/utils/themes.c +++ b/utils/themes.c @@ -1,5 +1,5 @@ /* - * This file is part of NetSurf, http://netsurf.sourceforge.net/ + * This file is part of NetSurf, http://netsurf-browser.org/ * Licensed under the GNU General Public License, * http://www.opensource.org/licenses/gpl-license * Copyright 2006 Rob Kendrick @@ -9,7 +9,7 @@ struct theme_descriptor; -/** +/** * Initialise the themes interface. This must be called once only before any * other themes_ functions are called. It will enumerate all the themes * found in the directory path names passed. Further themes can be added at @@ -63,7 +63,7 @@ struct theme_descriptor *themes_open(const unsigned char *themename) * from it. * * \param theme Theme that the caller is finished with. - */ + */ void themes_close(struct theme_descriptor *theme) { diff --git a/utils/themes.h b/utils/themes.h index 8d3336f7c..bbebec381 100644 --- a/utils/themes.h +++ b/utils/themes.h @@ -1,10 +1,10 @@ /* - * This file is part of NetSurf, http://netsurf.sourceforge.net/ + * This file is part of NetSurf, http://netsurf-browser.org/ * Licensed under the GNU General Public License, * http://www.opensource.org/licenses/gpl-license * Copyright 2006 Rob Kendrick */ - + #ifndef __THEMES_H__ #define __THEMES_H__ diff --git a/utils/tt2code b/utils/tt2code index e747bc5fc..8012f31e6 100755 --- a/utils/tt2code +++ b/utils/tt2code @@ -2,7 +2,7 @@ print < diff --git a/utils/url.c b/utils/url.c index 0d3605d2e..1c8005a5d 100644 --- a/utils/url.c +++ b/utils/url.c @@ -1,5 +1,5 @@ /* - * This file is part of NetSurf, http://netsurf.sourceforge.net/ + * This file is part of NetSurf, http://netsurf-browser.org/ * Licensed under the GNU General Public License, * http://www.opensource.org/licenses/gpl-license * Copyright 2006 Richard Wilson diff --git a/utils/url.h b/utils/url.h index 5877b9e9a..e9ad7fcb4 100644 --- a/utils/url.h +++ b/utils/url.h @@ -1,5 +1,5 @@ /* - * This file is part of NetSurf, http://netsurf.sourceforge.net/ + * This file is part of NetSurf, http://netsurf-browser.org/ * Licensed under the GNU General Public License, * http://www.opensource.org/licenses/gpl-license * Copyright 2005 James Bursa diff --git a/utils/utf8.c b/utils/utf8.c index ea9f8c85f..b811a6595 100644 --- a/utils/utf8.c +++ b/utils/utf8.c @@ -1,5 +1,5 @@ /* - * This file is part of NetSurf, http://netsurf.sourceforge.net/ + * This file is part of NetSurf, http://netsurf-browser.org/ * Licensed under the GNU General Public License, * http://www.opensource.org/licenses/gpl-license * Copyright 2005 John M Bell diff --git a/utils/utf8.h b/utils/utf8.h index a1a1c4e9a..fafce6d0c 100644 --- a/utils/utf8.h +++ b/utils/utf8.h @@ -1,5 +1,5 @@ /* - * This file is part of NetSurf, http://netsurf.sourceforge.net/ + * This file is part of NetSurf, http://netsurf-browser.org/ * Licensed under the GNU General Public License, * http://www.opensource.org/licenses/gpl-license * Copyright 2005 John M Bell diff --git a/utils/utils.c b/utils/utils.c index fca35ab21..63b8e9b29 100644 --- a/utils/utils.c +++ b/utils/utils.c @@ -1,5 +1,5 @@ /* - * This file is part of NetSurf, http://netsurf.sourceforge.net/ + * This file is part of NetSurf, http://netsurf-browser.org/ * Licensed under the GNU General Public License, * http://www.opensource.org/licenses/gpl-license * Copyright 2004 James Bursa diff --git a/utils/utils.h b/utils/utils.h index ba541cced..3e5ed6318 100644 --- a/utils/utils.h +++ b/utils/utils.h @@ -1,5 +1,5 @@ /* - * This file is part of NetSurf, http://netsurf.sourceforge.net/ + * This file is part of NetSurf, http://netsurf-browser.org/ * Licensed under the GNU General Public License, * http://www.opensource.org/licenses/gpl-license * Copyright 2004 James Bursa -- cgit v1.2.3