OSDN Git Service

6390e3f4680d164196cab61f8d29abaad7e4ec59
[hos/hos-v4a.git] / aplfw / library / container / stmbuf / stmbuf.h
1
2
3 #ifndef __HOS__stmbuf_h__
4 #define __HOS__stmbuf_h__
5
6
7 /* ストリームバッファクラス */
8 typedef struct c_streambuf
9 {
10         unsigned char *buf;             /* バッファ領域の先頭アドレス */
11         int           bufsz;    /* バッファ領域のサイズ */
12         volatile int  head;             /* データの先頭 */
13         volatile int  tail;             /* データの末尾 */
14 } C_STREAMBUF;
15
16
17 #ifdef __cplusplus
18 extern "C" {
19 #endif
20
21 /* 生成/削除 */
22 void    StreamBuf_Create(C_STREAMBUF *self, int bufsz, void *buf);                      /* バッファの生成 */
23 #define StreamBuf_Delete(self)  do {} while(0)                                                          /* バッファの削除 */
24
25 /* データ送信 */
26 int     StreamBuf_SendData(C_STREAMBUF *self, const void *data, int len);       /* データの送信 */
27 int     StreamBuf_GetBuf(C_STREAMBUF *self, void **p_buf);                                      /* 送信用バッファの取得(省コピー) */
28 void    StreamBuf_SendBuf(C_STREAMBUF *self, int len);                                          /* バッファ内のデータの送信(省コピー) */
29 int     StreamBuf_SendChar(C_STREAMBUF *self, int chr);                                         /* 1キャラクタの送信 */
30
31 /* データ受信 */
32 int     StreamBuf_RecvData(C_STREAMBUF *self, void *data, int len);                     /* データの受信 */
33 int     StreamBuf_RecvBuf(C_STREAMBUF *self, void **p_buf);                                     /* 受信したデータの入ったバッファの取得(省コピー) */
34 void    StreamBuf_RelBuf(C_STREAMBUF *self, int len);                                           /* 受信用バッファの解放(省コピー) */
35 int     StreamBuf_RecvChar(C_STREAMBUF *self);                                                          /* 1キャラクタの受信 */
36
37 /* 制御 */
38 void    StreamBuf_ClearBuf(C_STREAMBUF *self);                                                          /* バッファのクリア */
39 #define StreamBuf_RefMaxSize(self)              ((self)->bufsz - 1)                                     /* 最大格納可能サイズ参照 */
40 #define StreamBuf_RefBufAddr(self)              ((self)->buf)
41 #define StreamBuf_RefBufSize(self)              ((self)->bufsz)
42 int             StreamBuf_RefDataSize(C_STREAMBUF *self);
43 int             StreamBuf_RefFreeSize(C_STREAMBUF *self);
44
45 #ifdef __cplusplus
46 }
47 #endif
48
49
50
51 #endif  /* __HOS__stmbuf_h__ */
52