1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-12-04 14:46:47 -05:00

More const in encoding backends.

This commit is contained in:
Kalle Olavi Niemitalo 2007-02-24 21:42:56 +02:00 committed by Kalle Olavi Niemitalo
parent 20ba46ddde
commit a75302caf2
9 changed files with 21 additions and 21 deletions

View File

@ -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,

View File

@ -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

View File

@ -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);

View File

@ -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

View File

@ -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,

View File

@ -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

View File

@ -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,

View File

@ -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

View File

@ -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)