OSDN Git Service

(none)
[hos/hos-v4a.git] / aplfw / library / container / streambuf / streambuf_senddata.c
1 /** 
2  *  Hyper Operating System  Application Framework
3  *
4  * @file  streambuf.h
5  * @brief %jp{ストリームデータ用バッファクラス}
6  *
7  * Copyright (C) 2002-2007 by Project HOS
8  * http://sourceforge.jp/projects/hos/
9  */
10
11
12 #include <string.h>
13 #include "streambuf_local.h"
14
15
16 /** データの送信 */
17 unsigned int StreamBuf_SendData(C_STREAMBUF *self, const void *pData, unsigned int uiSize)
18 {
19         void                    *pBuf;                          /* バッファアドレス */
20         unsigned int    uiBufSize;                      /* バッファサイズ */
21         unsigned int    uiSendSize = 0;         /* 送信サイズ */
22
23         do
24         {
25                 /* 送信バッファ取得 */
26                 if ( (uiBufSize = StreamBuf_GetBuf(self, &pBuf)) <= 0 )
27                 {
28                         break;
29                 }
30                 
31                 /* サイズ計算 */
32                 if ( uiBufSize > uiSize )
33                 {
34                         uiBufSize = uiSize;
35                 }
36                 
37                 /* データコピー */
38                 memcpy(pBuf, pData, uiBufSize);
39                 
40                 /* 送信 */
41                 StreamBuf_SendBuf(self, uiBufSize);
42                 
43                 /* ポインタ更新 */
44                 pData       = (void *)((char *)pData + uiBufSize);
45                 uiSize     -= uiBufSize;
46                 uiSendSize += uiBufSize;
47         } while ( uiSize > 0 );
48         
49         
50         return uiSendSize;              /* 送信サイズを返す */
51 }
52
53
54 /* end of file */