1 /*********************************************************************************
\r
3 * --------------------------------------------------------------------------------
\r
5 * This file is part of MiMic
\r
6 * Copyright (C)2011 Ryo Iizuka
\r
8 * MiMic is free software: you can redistribute it and/or modify
\r
9 * it under the terms of the GNU Lesser General Public License as published
\r
10 * by the Free Software Foundation, either version 3 of the License, or
\r
11 * (at your option) any later version.
\r
13 * This program is distributed in the hope that it will be useful,
\r
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
16 * GNU General Public License for more details.
\r
18 * You should have received a copy of the GNU Lesser General Public License
\r
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
\r
21 * For further information please contact.
\r
23 * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>
\r
25 *********************************************************************************/
\r
26 #ifndef NyLPC_TiHttpPtrStream_H_
\r
27 #define NyLPC_TiHttpPtrStream_H_
\r
29 /**********************************************************************
\r
31 * NyLPC_TiHttpPtrStream class
\r
33 **********************************************************************/
\r
34 #include "NyLPC_stdlib.h"
\r
38 #endif /* __cplusplus */
\r
41 * Httpストリームのインタフェイス。
\r
43 typedef struct NyLPC_TiHttpPtrStream NyLPC_TiHttpPtrStream_t;
\r
48 typedef NyLPC_TUInt8 NyLPC_TiHttpPtrStream_ET;
\r
49 #define NyLPC_TiHttpPtrStream_ET_NONE 0x00
\r
50 #define NyLPC_TiHttpPtrStream_ET_CHUNKED 0x01
\r
53 * HTTP通信タイムアウトのデフォルト値
\r
55 #define NyLPC_TiHttpPtrStream_DEFAULT_HTTP_TIMEOUT (5*1000)
\r
58 typedef NyLPC_TInt32 (*NyLPC_TiHttpPtrStream_pread)(void* i_inst,const void** o_buf_ptr,NyLPC_TUInt32 i_timeout);
\r
59 typedef NyLPC_TBool (*NyLPC_TiHttpPtrStream_write)(void* i_inst,const void* i_data,NyLPC_TInt32 i_length);
\r
60 typedef void (*NyLPC_TiHttpPtrStream_rseek)(void* i_inst,NyLPC_TUInt16 i_seek);
\r
61 typedef NyLPC_TBool (*NyLPC_TiHttpPtrStream_flush)(void* i_inst);
\r
62 typedef void (*NyLPC_TiHttpPtrStream_setReadEncoding)(void* i_inst,NyLPC_TiHttpPtrStream_ET i_et);
\r
63 typedef void (*NyLPC_TiHttpPtrStream_setWriteEncoding)(void* i_inst,NyLPC_TiHttpPtrStream_ET i_et);
\r
66 * _interface_httpptrstreamで宣言してください。
\r
68 struct NyLPC_TiHttpPtrStream_TInterface
\r
70 NyLPC_TiHttpPtrStream_pread pread;
\r
71 NyLPC_TiHttpPtrStream_write write;
\r
72 NyLPC_TiHttpPtrStream_rseek readSeek;
\r
73 NyLPC_TiHttpPtrStream_flush flush;
\r
74 NyLPC_TiHttpPtrStream_setReadEncoding setreadencoding;
\r
75 NyLPC_TiHttpPtrStream_setWriteEncoding setwriteencoding;
\r
77 struct NyLPC_TiHttpPtrStream
\r
82 const struct NyLPC_TiHttpPtrStream_TInterface* absfunc;
\r
86 * ストリームからデータを読み出して、そのポインタを返します。
\r
88 * ストリームから読み込んだデータサイズを返します。
\r
92 #define NyLPC_iHttpPtrStream_pread(i_inst,o_buf_ptr,i_timeout) (i_inst)->absfunc->pread((i_inst),(o_buf_ptr),i_timeout)
\r
96 * i_dataのデータ長を指定します。-1の場合、strlenを実行します。
\r
98 * 規定時間内にストリームへの書き込みが完了すると、TRUEを返します。
\r
100 #define NyLPC_iHttpPtrStream_write(i_inst,i_data,i_length) (i_inst)->absfunc->write((i_inst),i_data,i_length)
\r
101 #define NyLPC_iHttpPtrStream_rseek(i_inst,i_seek) (i_inst)->absfunc->readSeek((i_inst),(i_seek))
\r
103 * バッファに残っているデータを送信し、空にします。
\r
105 #define NyLPC_iHttpPtrStream_flush(i_inst) (i_inst)->absfunc->flush(i_inst)
\r
109 * この関数は削除するかもしれない。使用しないこと。
\r
110 * @bug 関数が非対称。cHttpBasicBodyParserがチャンク読み出し処理を肩代わりしている?
\r
112 #define NyLPC_iHttpPtrStream_setReadEncoding(i_inst,i_et) (i_inst)->absfunc->setreadencoding((i_inst),i_et)
\r
116 #define NyLPC_iHttpPtrStream_setWriteEncoding(i_inst,i_et) (i_inst)->absfunc->setwriteencoding((i_inst),i_et)
\r
120 #endif /* __cplusplus */
\r
122 #endif /* NyLPC_TiHttpPtrStream_H_ */
\r