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_TCPTRSTREAM_H_
\r
27 #define NYLPC_TCPTRSTREAM_H_
\r
29 /**********************************************************************
\r
31 * NyLPC_TcPtrStream class
\r
33 **********************************************************************/
\r
34 #include "NyLPC_stdlib.h"
\r
38 #endif /* __cplusplus */
\r
41 * ブロッキングストリームのベース型です。
\r
43 typedef struct NyLPC_TcPtrStream NyLPC_TcPtrStream_t;
\r
46 typedef NyLPC_TInt32 (*NyLPC_TcPtrStream_pread)(NyLPC_TcPtrStream_t* i_inst,const void** o_buf_ptr,NyLPC_TUInt32 i_wait_msec);
\r
47 typedef NyLPC_TBool (*NyLPC_TcPtrStream_write)(NyLPC_TcPtrStream_t* i_inst,const void* i_data,NyLPC_TInt16 i_length,NyLPC_TUInt32 i_wait_msec);
\r
48 typedef void (*NyLPC_TcPtrStream_rseek)(NyLPC_TcPtrStream_t* i_inst,NyLPC_TUInt16 i_seek);
\r
49 typedef void (*NyLPC_TcPtrStream_close)(NyLPC_TcPtrStream_t* i_inst);
\r
51 struct NyLPC_TcPtrStream_TInterface
\r
53 NyLPC_TcPtrStream_pread pread;
\r
54 NyLPC_TcPtrStream_write write;
\r
55 NyLPC_TcPtrStream_rseek readSeek;
\r
56 NyLPC_TcPtrStream_close close;
\r
60 struct NyLPC_TcPtrStream
\r
62 const struct NyLPC_TcPtrStream_TInterface* _interface;
\r
66 * ストリームからデータを読み出して、そのポインタを返します。
\r
68 * ストリームから読み込んだデータサイズを返します。
\r
72 #define NyLPC_cPtrStream_read(i_inst,o_buf_ptr,i_wait_msec) (i_inst)->_interface->read((i_inst),o_buf_ptr,i_wait_msec)
\r
76 * i_dataのデータ長を指定します。-1の場合、strlenを実行します。
\r
78 * 規定時間内にストリームへの書き込みが完了すると、TRUEを返します。
\r
80 #define NyLPC_cPtrStream_write(i_inst,i_data,i_length,i_wait_msec) (i_inst)->_interface->write((i_inst),i_data,i_length,i_wait_msec)
\r
85 NyLPC_TBool NyLPC_cPtrStream_writeln(NyLPC_TcPtrStream_t* i_inst,const void* i_data,NyLPC_TInt16 i_length,NyLPC_TUInt32 i_wait_msec);
\r
91 NyLPC_TBool NyLPC_cPtrStream_writeInt(NyLPC_TcPtrStream_t* i_inst,NyLPC_TInt32 i_val,NyLPC_TUInt32 i_wait_msec,NyLPC_TUInt32 i_base);
\r
96 * 書き込みメモリの先頭ポインタを返します。この値は次回のpwriteに入力してください。
\r
98 #define NyLPC_cPtrStream_wreserv(i_inst,i_hint,o_len)
\r
101 #define NyLPC_cPtrStream_rseek(i_inst,i_seek) (i_inst)->_interface->preadSeek((i_inst),i_seek)
\r
104 readの場合は占有している共有メモリの解放、ブロックしているタスクの解放をします。
\r
105 writeの場合はバッファに残っているデータの書き込みを保証します。
\r
107 #define NyLPC_cPtrStream_close(i_inst) i_inst->_interface->close(i_inst)
\r
111 #endif /* __cplusplus */
\r
113 #endif /* NYLPC_TCPTRSTREAM_H_ */
\r