Dillo v3.1.1-46-g8a360e32
Loading...
Searching...
No Matches
decode.c File Reference
#include <zlib.h>
#include <iconv.h>
#include <errno.h>
#include <stdlib.h>
#include "decode.h"
#include "utf8.hh"
#include "msg.h"
Include dependency graph for decode.c:

Go to the source code of this file.

Functions

Dstra_Decode_transfer_process (DecodeTransfer *dc, const char *instr, int inlen)
 Decode 'Transfer-Encoding: chunked' data.
 
bool_t a_Decode_transfer_finished (DecodeTransfer *dc)
 
void a_Decode_transfer_free (DecodeTransfer *dc)
 
static void Decode_compression_free (Decode *dc)
 
static DstrDecode_gzip (Decode *dc, const char *instr, int inlen)
 Decode gzipped data.
 
static DstrDecode_raw_deflate (Decode *dc, const char *instr, int inlen)
 Decode (raw) deflated data.
 
static DstrDecode_deflate (Decode *dc, const char *instr, int inlen)
 Decode deflated data, initially presuming that the required zlib wrapper is there.
 
static DstrDecode_charset (Decode *dc, const char *instr, int inlen)
 Translate to desired character set (UTF-8)
 
static void Decode_charset_free (Decode *dc)
 
DecodeTransfera_Decode_transfer_init (const char *format)
 Initialize transfer decoder.
 
static DecodeDecode_content_init_common (void)
 
Decodea_Decode_content_init (const char *format)
 Initialize content decoder.
 
Decodea_Decode_charset_init (const char *format)
 Initialize decoder to translate from any character set known to iconv() to UTF-8.
 
Dstra_Decode_process (Decode *dc, const char *instr, int inlen)
 Decode data.
 
void a_Decode_free (Decode *dc)
 

Variables

static const int bufsize = 8*1024
 

Function Documentation

◆ a_Decode_charset_init()

Decode * a_Decode_charset_init ( const char *  format)

Initialize decoder to translate from any character set known to iconv() to UTF-8.

GNU iconv(1) will provide a list of known character sets if invoked with the "--list" flag.

Definition at line 365 of file decode.c.

References Decode::buffer, bufsize, Decode::decode, Decode_charset(), Decode_charset_free(), dNew, dStr_new(), dStrAsciiCasecmp(), Decode::free, Decode::leftover, MSG_WARN, and Decode::state.

Referenced by a_Cache_set_content_type().

◆ a_Decode_content_init()

Decode * a_Decode_content_init ( const char *  format)

Initialize content decoder.

Currently handles 'gzip' and 'deflate'.

Definition at line 327 of file decode.c.

References _MSG, Decode::decode, Decode_content_init_common(), Decode_deflate(), Decode_gzip(), dStrAsciiCasecmp(), MSG, and Decode::state.

Referenced by Cache_parse_header().

◆ a_Decode_free()

void a_Decode_free ( Decode dc)

Definition at line 400 of file decode.c.

References dFree(), and Decode::free.

Referenced by a_Cache_set_content_type(), Cache_entry_free(), and Cache_finish_msg().

◆ a_Decode_process()

Dstr * a_Decode_process ( Decode dc,
const char *  instr,
int  inlen 
)

Decode data.

Definition at line 392 of file decode.c.

References Decode::decode.

Referenced by a_Cache_process_dbuf(), and Cache_ref_data().

◆ a_Decode_transfer_finished()

bool_t a_Decode_transfer_finished ( DecodeTransfer dc)

Definition at line 85 of file decode.c.

References DecodeTransfer::finished.

Referenced by a_Cache_process_dbuf().

◆ a_Decode_transfer_free()

void a_Decode_transfer_free ( DecodeTransfer dc)

Definition at line 90 of file decode.c.

References dFree(), dStr_free(), DecodeTransfer::leftover, and DecodeTransfer::state.

Referenced by Cache_entry_free(), and Cache_finish_msg().

◆ a_Decode_transfer_init()

DecodeTransfer * a_Decode_transfer_init ( const char *  format)

Initialize transfer decoder.

Currently handles "chunked".

Definition at line 291 of file decode.c.

References _MSG, dNew, dStr_new(), dStrAsciiCasecmp(), FALSE, DecodeTransfer::finished, DecodeTransfer::leftover, and DecodeTransfer::state.

Referenced by Cache_parse_header().

◆ a_Decode_transfer_process()

Dstr * a_Decode_transfer_process ( DecodeTransfer dc,
const char *  instr,
int  inlen 
)

Decode 'Transfer-Encoding: chunked' data.

Definition at line 26 of file decode.c.

References dStr_append_l(), dStr_erase(), dStr_sized_new(), DecodeTransfer::finished, DecodeTransfer::leftover, Dstr::len, MIN, DecodeTransfer::state, Dstr::str, and TRUE.

Referenced by a_Cache_process_dbuf().

◆ Decode_charset()

static Dstr * Decode_charset ( Decode dc,
const char *  instr,
int  inlen 
)
static

Translate to desired character set (UTF-8)

Definition at line 238 of file decode.c.

References Decode::buffer, bufsize, dStr_append_l(), dStr_erase(), dStr_new(), Decode::leftover, Dstr::len, Decode::state, Dstr::str, and utf8_replacement_char.

Referenced by a_Decode_charset_init().

◆ Decode_charset_free()

static void Decode_charset_free ( Decode dc)
static

Definition at line 279 of file decode.c.

References Decode::buffer, dFree(), dStr_free(), Decode::leftover, and Decode::state.

Referenced by a_Decode_charset_init().

◆ Decode_compression_free()

static void Decode_compression_free ( Decode dc)
static

Definition at line 97 of file decode.c.

References Decode::buffer, dFree(), and Decode::state.

Referenced by Decode_content_init_common().

◆ Decode_content_init_common()

static Decode * Decode_content_init_common ( void  )
static

◆ Decode_deflate()

static Dstr * Decode_deflate ( Decode dc,
const char *  instr,
int  inlen 
)
static

Decode deflated data, initially presuming that the required zlib wrapper is there.

On data error, switch to Decode_raw_deflate().

Definition at line 187 of file decode.c.

References Decode::buffer, bufsize, Decode::decode, Decode_raw_deflate(), dFree(), dNew, dStr_append_l(), dStr_free(), dStr_new(), MSG_WARN, and Decode::state.

Referenced by a_Decode_content_init().

◆ Decode_gzip()

static Dstr * Decode_gzip ( Decode dc,
const char *  instr,
int  inlen 
)
static

Decode gzipped data.

Definition at line 114 of file decode.c.

References Decode::buffer, bufsize, dStr_append_l(), dStr_new(), MSG_ERR, and Decode::state.

Referenced by a_Decode_content_init().

◆ Decode_raw_deflate()

static Dstr * Decode_raw_deflate ( Decode dc,
const char *  instr,
int  inlen 
)
static

Decode (raw) deflated data.

Definition at line 150 of file decode.c.

References Decode::buffer, bufsize, dStr_append_l(), dStr_new(), MSG_ERR, and Decode::state.

Referenced by Decode_deflate().

Variable Documentation

◆ bufsize