diff --git a/src/encoding/bzip2.c b/src/encoding/bzip2.c index 88c83bb4a..e3ddfe76d 100644 --- a/src/encoding/bzip2.c +++ b/src/encoding/bzip2.c @@ -179,9 +179,9 @@ bzip2_close(struct stream_encoded *stream) } } -static unsigned char *bzip2_extensions[] = { ".bz2", ".tbz", NULL }; +static const unsigned char *const bzip2_extensions[] = { ".bz2", ".tbz", NULL }; -struct decoding_backend bzip2_decoding_backend = { +const struct decoding_backend bzip2_decoding_backend = { "bzip2", bzip2_extensions, bzip2_open, diff --git a/src/encoding/bzip2.h b/src/encoding/bzip2.h index 2718b249c..1367500e7 100644 --- a/src/encoding/bzip2.h +++ b/src/encoding/bzip2.h @@ -4,7 +4,7 @@ #include "encoding/encoding.h" #ifdef CONFIG_BZIP2 -extern struct decoding_backend bzip2_decoding_backend; +extern const struct decoding_backend bzip2_decoding_backend; #else #define bzip2_decoding_backend dummy_decoding_backend #endif diff --git a/src/encoding/encoding.c b/src/encoding/encoding.c index 68158e25a..42dc62b16 100644 --- a/src/encoding/encoding.c +++ b/src/encoding/encoding.c @@ -69,9 +69,9 @@ dummy_close(struct stream_encoded *stream) mem_free(stream->data); } -static unsigned char *dummy_extensions[] = { NULL }; +static const unsigned char *const dummy_extensions[] = { NULL }; -static struct decoding_backend dummy_decoding_backend = { +static const struct decoding_backend dummy_decoding_backend = { "none", dummy_extensions, dummy_open, @@ -87,7 +87,7 @@ static struct decoding_backend dummy_decoding_backend = { #include "encoding/gzip.h" #include "encoding/lzma.h" -static struct decoding_backend *decoding_backends[] = { +static const struct decoding_backend *const decoding_backends[] = { &dummy_decoding_backend, &gzip_decoding_backend, &bzip2_decoding_backend, @@ -147,7 +147,7 @@ close_encoded(struct stream_encoded *stream) /* Return a list of extensions associated with that encoding. */ -unsigned char **listext_encoded(enum stream_encoding encoding) +const unsigned char *const *listext_encoded(enum stream_encoding encoding) { return decoding_backends[encoding]->extensions; } @@ -160,7 +160,7 @@ guess_encoding(unsigned char *filename) int enc; for (enc = 1; enc < ENCODINGS_KNOWN; enc++) { - unsigned char **ext = decoding_backends[enc]->extensions; + const unsigned char *const *ext = decoding_backends[enc]->extensions; while (ext && *ext) { int len = strlen(*ext); @@ -175,7 +175,7 @@ guess_encoding(unsigned char *filename) return ENCODING_NONE; } -unsigned char * +const unsigned char * get_encoding_name(enum stream_encoding encoding) { return decoding_backends[encoding]->name; @@ -194,7 +194,7 @@ try_encoding_extensions(struct string *filename, int *fd) /* No file of that name was found, try some others names. */ for (encoding = 1; encoding < ENCODINGS_KNOWN; encoding++) { - unsigned char **ext = listext_encoded(encoding); + const unsigned char *const *ext = listext_encoded(encoding); for (; ext && *ext; ext++) { add_to_string(filename, *ext); diff --git a/src/encoding/encoding.h b/src/encoding/encoding.h index 2c0bfbae0..8b32c3b38 100644 --- a/src/encoding/encoding.h +++ b/src/encoding/encoding.h @@ -20,8 +20,8 @@ struct stream_encoded { }; struct decoding_backend { - unsigned char *name; - unsigned char **extensions; + const unsigned char *name; + const unsigned char *const *extensions; int (*open)(struct stream_encoded *stream, int fd); int (*read)(struct stream_encoded *stream, unsigned char *data, int len); unsigned char *(*decode_buffer)(unsigned char *data, int len, int *new_len); @@ -33,9 +33,9 @@ int read_encoded(struct stream_encoded *, unsigned char *, int); unsigned char *decode_encoded_buffer(enum stream_encoding encoding, unsigned char *data, int len, int *new_len); void close_encoded(struct stream_encoded *); -unsigned char **listext_encoded(enum stream_encoding); +const unsigned char *const *listext_encoded(enum stream_encoding); enum stream_encoding guess_encoding(unsigned char *filename); -unsigned char *get_encoding_name(enum stream_encoding encoding); +const unsigned char *get_encoding_name(enum stream_encoding encoding); /* Read from open @stream into the @page string */ enum connection_state diff --git a/src/encoding/gzip.c b/src/encoding/gzip.c index db469242b..a46800078 100644 --- a/src/encoding/gzip.c +++ b/src/encoding/gzip.c @@ -229,9 +229,9 @@ gzip_close(struct stream_encoded *stream) gzclose((gzFile *) stream->data); } -static unsigned char *gzip_extensions[] = { ".gz", ".tgz", NULL }; +static const unsigned char *const gzip_extensions[] = { ".gz", ".tgz", NULL }; -struct decoding_backend gzip_decoding_backend = { +const struct decoding_backend gzip_decoding_backend = { "gzip", gzip_extensions, gzip_open, diff --git a/src/encoding/gzip.h b/src/encoding/gzip.h index 7965a4d82..c13038e33 100644 --- a/src/encoding/gzip.h +++ b/src/encoding/gzip.h @@ -4,7 +4,7 @@ #include "encoding/encoding.h" #ifdef CONFIG_GZIP -extern struct decoding_backend gzip_decoding_backend; +extern const struct decoding_backend gzip_decoding_backend; #else #define gzip_decoding_backend dummy_decoding_backend #endif diff --git a/src/encoding/lzma.c b/src/encoding/lzma.c index ad50a9e00..f4d134591 100644 --- a/src/encoding/lzma.c +++ b/src/encoding/lzma.c @@ -182,9 +182,9 @@ lzma_close(struct stream_encoded *stream) lzma_cleanup(data); } -static unsigned char *lzma_extensions[] = { ".lzma", NULL }; +static const unsigned char *const lzma_extensions[] = { ".lzma", NULL }; -struct decoding_backend lzma_decoding_backend = { +const struct decoding_backend lzma_decoding_backend = { "lzma", lzma_extensions, lzma_open, diff --git a/src/encoding/lzma.h b/src/encoding/lzma.h index 474d3dd38..9268aee1c 100644 --- a/src/encoding/lzma.h +++ b/src/encoding/lzma.h @@ -4,7 +4,7 @@ #include "encoding/encoding.h" #ifdef CONFIG_LZMA -extern struct decoding_backend lzma_decoding_backend; +extern const struct decoding_backend lzma_decoding_backend; #else #define lzma_decoding_backend dummy_decoding_backend #endif diff --git a/src/mime/mime.c b/src/mime/mime.c index 5c39b43f7..f50dc9fc1 100644 --- a/src/mime/mime.c +++ b/src/mime/mime.c @@ -130,7 +130,7 @@ static inline unsigned char * check_encoding_type(unsigned char *extension) { enum stream_encoding encoding = guess_encoding(extension); - unsigned char **extension_list; + const unsigned char *const *extension_list; unsigned char *last_extension = strrchr(extension, '.'); if (encoding == ENCODING_NONE || !last_extension)