2 * http_contentdecoder.h
4 * Copyright (c) 2012 project bchan
6 * This software is provided 'as-is', without any express or implied
7 * warranty. In no event will the authors be held liable for any damages
8 * arising from the use of this software.
10 * Permission is granted to anyone to use this software for any purpose,
11 * including commercial applications, and to alter it and redistribute it
12 * freely, subject to the following restrictions:
14 * 1. The origin of this software must not be misrepresented; you must not
15 * claim that you wrote the original software. If you use this software
16 * in a product, an acknowledgment in the product documentation would be
17 * appreciated but is not required.
19 * 2. Altered source versions must be plainly marked as such, and must not be
20 * misrepresented as being the original software.
22 * 3. This notice may not be removed or altered from any source
28 /* Functionality name: http */
29 /* Detail name: contentdecoder */
32 #include <util/zlib.h>
34 #include "http_typedef.h"
36 /* rfc2616 3.5 Content Codings */
38 #ifndef __HTTP_CONTENTDECODER_H__
39 #define __HTTP_CONTENTDECODER_H__
41 /* Functionality name: http */
42 /* Detail name: contentdecoder */
43 /* Data structure identifier: result */
44 struct http_contentdecoder_result_ {
46 HTTP_CONTENTDECODER_RESULTTYPE_DATA,
47 HTTP_CONTENTDECODER_RESULTTYPE_NEED_INPUT,
48 HTTP_CONTENTDECODER_RESULTTYPE_END,
53 typedef struct http_contentdecoder_result_ http_contentdecoder_result;
55 /* Functionality name: http */
56 /* Detail name: contentdecoderidentity */
57 struct http_contentdecoderidentity_t_ {
58 http_contentdecoder_result result[2];
60 HTTP_CONTENTDECODERIDENTITY_STATE_DATA,
61 HTTP_CONTENTDECODERIDENTITY_STATE_END,
66 typedef struct http_contentdecoderidentity_t_ http_contentdecoderidentity_t;
68 /* Functionality name: gzip */
69 /* Detail name: headerskip */
70 struct gzip_headerskip_t_ {
72 GZIP_HEADERSKIP_STATE_MAGIC_NUMBER_FIRST,
73 GZIP_HEADERSKIP_STATE_MAGIC_NUMBER_SECOND,
74 GZIP_HEADERSKIP_STATE_METHOD,
75 GZIP_HEADERSKIP_STATE_FLAGS,
76 GZIP_HEADERSKIP_STATE_SKIP_UNUSED_FIELD,
77 GZIP_HEADERSKIP_STATE_EXTRA_FIELD_LEN_FIRST,
78 GZIP_HEADERSKIP_STATE_EXTRA_FIELD_LEN_SECOND,
79 GZIP_HEADERSKIP_STATE_SKIP_EXTRA_FIELD,
80 GZIP_HEADERSKIP_STATE_SKIP_FILE_NAME,
81 GZIP_HEADERSKIP_STATE_SKIP_FILE_COMMENT,
82 GZIP_HEADERSKIP_STATE_SKIP_HEADER_CRC_FIRST,
83 GZIP_HEADERSKIP_STATE_SKIP_HEADER_CRC_SECOND,
89 typedef struct gzip_headerskip_t_ gzip_headerskip_t;
91 /* Functionality name: http */
92 /* Detail name: contentdecodergzip */
93 #define HTTP_CONTENTDECODERGZIP_BUFLEN 512
94 struct http_contentdecodergzip_t_ {
95 http_contentdecoder_result result[1];
97 HTTP_CONTENTDECODERGZIP_STATE_SKIP_HEADER,
98 HTTP_CONTENTDECODERGZIP_STATE_DECODE,
99 HTTP_CONTENTDECODERGZIP_STATE_END_OF_DATA, /* tmp */
101 gzip_headerskip_t gzipheader;
103 UB buffer[HTTP_CONTENTDECODERGZIP_BUFLEN];
105 typedef struct http_contentdecodergzip_t_ http_contentdecodergzip_t;
107 /* Functionality name: http */
108 /* Detail name: contentdecoder */
109 struct http_contentdecoder_t_ {
110 HTTP_CONTENTCODING_VALUE type;
112 http_contentdecoderidentity_t identity;
113 http_contentdecodergzip_t gzip;
116 typedef struct http_contentdecoder_t_ http_contentdecoder_t;
118 IMPORT W http_contentdecoder_initialize(http_contentdecoder_t *decoder, HTTP_CONTENTCODING_VALUE type);
119 IMPORT VOID http_contentdecoder_finalize(http_contentdecoder_t *decoder);
120 IMPORT W http_contentdecoder_inputentitybody(http_contentdecoder_t *decoder, UB *data, W data_len);
121 IMPORT W http_contentdecoder_inputendofdata(http_contentdecoder_t *decoder);
122 IMPORT W http_contentdecoder_outputdata(http_contentdecoder_t *decoder, http_contentdecoder_result **result, W *result_len);