OSDN Git Service

7ae1220b9be8fff4ffa367503d833a460715eb00
[mimic/MiMicSDK.git] / lib / src / NyLPC_cPtrStream.c
1 /*********************************************************************************\r
2  * PROJECT: MiMic\r
3  * --------------------------------------------------------------------------------\r
4  *\r
5  * This file is part of MiMic\r
6  * Copyright (C)2011 Ryo Iizuka\r
7  *\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
12  *\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
17  *\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
20  *\r
21  * For further information please contact.\r
22  *      http://nyatla.jp/\r
23  *      <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>\r
24  *\r
25  *********************************************************************************/\r
26 \r
27 #include "NyLPC_cPtrStream_protected.h"\r
28 #include <stdlib.h>\r
29 \r
30 \r
31 const struct NyLPC_TcPtrStream_TInterface NyLPC_TcPtrStream_Interface={\r
32         NyLPC_cPtrStream_pread_func,\r
33         NyLPC_cPtrStream_write_func,\r
34         NyLPC_cPtrStream_pseek_func,\r
35         NyLPC_cPtrStream_close_func\r
36 };\r
37 \r
38 /*private*/\r
39 NyLPC_TInt32 NyLPC_cPtrStream_pread_func(NyLPC_TcPtrStream_t* i_inst,const void** o_buf_ptr,NyLPC_TUInt32 i_wait_msec)\r
40 {\r
41         (void)i_inst;\r
42         (void)o_buf_ptr;\r
43         (void)i_wait_msec;\r
44         return -1;\r
45 }\r
46 \r
47 NyLPC_TBool NyLPC_cPtrStream_write_func(NyLPC_TcPtrStream_t* i_inst,const void* i_data,NyLPC_TInt16 i_length,NyLPC_TUInt32 i_wait_msec)\r
48 {\r
49         (void)i_inst;\r
50         (void)i_data;\r
51         (void)i_length;\r
52         (void)i_wait_msec;\r
53         return NyLPC_TBool_FALSE;\r
54 }\r
55 \r
56 \r
57 void NyLPC_cPtrStream_pseek_func(NyLPC_TcPtrStream_t* i_inst,NyLPC_TUInt16 i_seek)\r
58 {\r
59         (void)i_inst;\r
60         (void)i_seek;\r
61 }\r
62 \r
63 void NyLPC_cPtrStream_close_func(NyLPC_TcPtrStream_t* i_inst)\r
64 {\r
65         (void)i_inst;\r
66 }\r
67 \r
68 \r
69 /**\r
70  * See Header file.\r
71  */\r
72 NyLPC_TBool NyLPC_cPtrStream_writeln(NyLPC_TcPtrStream_t* i_inst,const void* i_data,NyLPC_TInt16 i_length,NyLPC_TUInt32 i_wait_msec)\r
73 {\r
74         if(NyLPC_cPtrStream_write(i_inst,i_data,i_length,i_wait_msec)){\r
75                 if(NyLPC_cPtrStream_write(i_inst,"\r\n",2,i_wait_msec)){\r
76                         return NyLPC_TBool_TRUE;\r
77                 }\r
78         }\r
79         return NyLPC_TBool_FALSE;\r
80 }\r
81 /**\r
82  * See Header file.\r
83  */\r
84 NyLPC_TBool NyLPC_cPtrStream_writeInt(NyLPC_TcPtrStream_t* i_inst,NyLPC_TInt32 i_val,NyLPC_TUInt32 i_wait_msec,NyLPC_TUInt32 i_base)\r
85 {\r
86         NyLPC_TChar v[12];\r
87         itoa(i_val,v,i_base);\r
88         if(NyLPC_cPtrStream_write(i_inst,v,strlen(v),i_wait_msec)){\r
89                 return NyLPC_TBool_TRUE;\r
90         }\r
91         return NyLPC_TBool_FALSE;\r
92 }\r