3 #ifndef __HOS__stmbuf_h__
4 #define __HOS__stmbuf_h__
8 typedef struct c_streambuf
10 unsigned char *buf; /* バッファ領域の先頭アドレス */
11 int bufsz; /* バッファ領域のサイズ */
12 volatile int head; /* データの先頭 */
13 volatile int tail; /* データの末尾 */
22 void StreamBuf_Create(C_STREAMBUF *self, int bufsz, void *buf); /* バッファの生成 */
23 #define StreamBuf_Delete(self) do {} while(0) /* バッファの削除 */
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キャラクタの送信 */
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キャラクタの受信 */
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);
51 #endif /* __HOS__stmbuf_h__ */