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

[encoding] enum stream_encoding -> stream_encoding_T

This commit is contained in:
Witold Filipczyk 2022-01-28 16:17:25 +01:00
parent 09e7b73a41
commit cea2521b91
6 changed files with 19 additions and 17 deletions

View File

@ -219,7 +219,7 @@ static void
render_encoded_document(struct cache_entry *cached, struct document *document)
{
struct uri *uri = cached->uri;
enum stream_encoding encoding = ENCODING_NONE;
stream_encoding_T encoding = ENCODING_NONE;
struct fragment *fragment = get_cache_fragment(cached);
struct string buffer = INIT_STRING("", 0);

View File

@ -106,7 +106,7 @@ static const struct decoding_backend *const decoding_backends[] = {
/* Associates encoded stream with a fd. */
struct stream_encoded *
open_encoded(int fd, enum stream_encoding encoding)
open_encoded(int fd, stream_encoding_T encoding)
{
struct stream_encoded *stream;
@ -134,7 +134,7 @@ read_encoded(struct stream_encoded *stream, char *data, int len)
* for parts of files. @data contains the original data, @len bytes
* long. The resulting decoded data chunk is *@new_len bytes long. */
char *
decode_encoded_buffer(struct stream_encoded *stream, enum stream_encoding encoding, char *data, int len,
decode_encoded_buffer(struct stream_encoded *stream, stream_encoding_T encoding, char *data, int len,
int *new_len)
{
return decoding_backends[encoding]->decode_buffer(stream, data, len, new_len);
@ -151,12 +151,12 @@ close_encoded(struct stream_encoded *stream)
/* Return a list of extensions associated with that encoding. */
const char *const *listext_encoded(enum stream_encoding encoding)
const char *const *listext_encoded(stream_encoding_T encoding)
{
return decoding_backends[encoding]->extensions;
}
enum stream_encoding
stream_encoding_T
guess_encoding(char *filename)
{
int fname_len = strlen(filename);
@ -180,7 +180,7 @@ guess_encoding(char *filename)
}
const char *
get_encoding_name(enum stream_encoding encoding)
get_encoding_name(stream_encoding_T encoding)
{
return decoding_backends[encoding]->name;
}
@ -190,7 +190,7 @@ get_encoding_name(enum stream_encoding encoding)
/* Tries to open @prefixname with each of the supported encoding extensions
* appended. */
static inline enum stream_encoding
static inline stream_encoding_T
try_encoding_extensions(struct string *filename, int *fd)
{
int length = filename->length;
@ -299,7 +299,7 @@ read_encoded_file(struct string *filename, struct string *page)
{
struct stream_encoded *stream;
struct stat stt;
enum stream_encoding encoding = ENCODING_NONE;
stream_encoding_T encoding = ENCODING_NONE;
int fd = open(filename->source, O_RDONLY | O_NOCTTY);
struct connection_state state = connection_state_for_errno(errno);

View File

@ -20,8 +20,10 @@ enum stream_encoding {
ENCODINGS_KNOWN,
};
typedef unsigned char stream_encoding_T;
struct stream_encoded {
enum stream_encoding encoding;
stream_encoding_T encoding;
void *data;
};
@ -34,14 +36,14 @@ struct decoding_backend {
void (*close)(struct stream_encoded *stream);
};
struct stream_encoded *open_encoded(int, enum stream_encoding);
struct stream_encoded *open_encoded(int, stream_encoding_T);
int read_encoded(struct stream_encoded *, char *, int);
char *decode_encoded_buffer(struct stream_encoded *stream, enum stream_encoding encoding, char *data, int len, int *new_len);
char *decode_encoded_buffer(struct stream_encoded *stream, stream_encoding_T encoding, char *data, int len, int *new_len);
void close_encoded(struct stream_encoded *);
const char *const *listext_encoded(enum stream_encoding);
enum stream_encoding guess_encoding(char *filename);
const char *get_encoding_name(enum stream_encoding encoding);
const char *const *listext_encoded(stream_encoding_T);
stream_encoding_T guess_encoding(char *filename);
const char *get_encoding_name(stream_encoding_T encoding);
/* Read from open @stream into the @page string */
struct connection_state

View File

@ -131,7 +131,7 @@ check_extension_type(char *extension)
static inline char *
check_encoding_type(char *extension)
{
enum stream_encoding encoding = guess_encoding(extension);
stream_encoding_T encoding = guess_encoding(extension);
const char *const *extension_list;
char *last_extension = strrchr(extension, '.');

View File

@ -45,7 +45,7 @@ struct connection {
off_t received; /* The number of received bytes. */
off_t est_length; /* Estimated number of bytes to transfer. */
enum stream_encoding content_encoding;
stream_encoding_T content_encoding;
struct stream_encoded *stream;
/* Called if non NULL when shutting down a connection. */

View File

@ -1874,7 +1874,7 @@ again:
if (d) {
#if defined(CONFIG_GZIP) || defined(CONFIG_BZIP2) || defined(CONFIG_LZMA) || defined(CONFIG_BROTLI) || defined(CONFIG_ZSTD)
char *extension = get_extension_from_uri(uri);
enum stream_encoding file_encoding;
stream_encoding_T file_encoding;
file_encoding = extension ? guess_encoding(extension) : ENCODING_NONE;
mem_free_if(extension);