Buffering Services
[CONNECT]

Collaboration diagram for Buffering Services:


Defines

#define BUF_DEF_CHUNK_SIZE   1024

Typedefs

typedef BUF_tagBUF

Functions

size_t BUF_SetChunkSize (BUF *pBuf, size_t chunk_size)
size_t BUF_Size (BUF buf)
int BUF_Prepend (BUF *pBuf, const void *data, size_t size)
int BUF_Append (BUF *pBuf, const void *data, size_t size)
int BUF_Write (BUF *pBuf, const void *data, size_t size)
int BUF_PushBack (BUF *pBuf, const void *data, size_t size)
size_t BUF_Peek (BUF buf, void *data, size_t size)
size_t BUF_PeekAt (BUF buf, size_t pos, void *data, size_t size)
size_t BUF_PeekAtCB (BUF buf, size_t pos, void(*callback)(void *, void *, size_t), void *data, size_t size)
size_t BUF_Read (BUF buf, void *data, size_t size)
void BUF_Erase (BUF buf)
void BUF_Destroy (BUF buf)


Define Documentation

#define BUF_DEF_CHUNK_SIZE   1024
 

Set minimal size of a buffer memory chunk. Return the actually set chunk size on success; zero on error NOTE: if "*pBuf" == NULL then create it if "chunk_size" is passed 0 then set it to BUF_DEF_CHUNK_SIZE

Definition at line 81 of file ncbi_buffer.h.

Referenced by BUF_SetChunkSize().


Typedef Documentation

typedef struct BUF_tag* BUF
 

Definition at line 72 of file ncbi_buffer.h.


Function Documentation

int BUF_Append BUF pBuf,
const void *  data,
size_t  size
 

Append a block of data (of the specified size) past the end of the buffer (to be read last). Note that unlike BUF_Write(), in this call the data is not copied to the buffer but instead is just linked in from the original location. Return non-zero (true) if succeeded, zero (false) if failed.

Definition at line 126 of file ncbi_buffer.c.

References SBufChunkTag::alloc_size, BUF_SetChunkSize(), SBufChunkTag::data, SBufChunkTag::next, s_AllocChunk(), and SBufChunkTag::size.

void BUF_Destroy BUF  buf  ) 
 

Destroy all internal data. NOTE: do nothing if "buf" == NULL

Definition at line 405 of file ncbi_buffer.c.

References buf, BUF_Erase(), and free().

Referenced by CONN_Close(), s_Destroy(), SERV_Print(), SOCK_CloseEx(), SOCK_CreateOnTopEx(), URL_ConnectEx(), CConn_MemoryStream::~CConn_MemoryStream(), and IServer_MessageHandler::~IServer_MessageHandler().

void BUF_Erase BUF  buf  ) 
 

Make the buffer empty.

Definition at line 390 of file ncbi_buffer.c.

References buf, free(), and SBufChunkTag::next.

Referenced by BUF_Destroy(), s_Disconnect(), s_DropConnection(), s_FlushAndDisconnect(), s_PreRead(), and s_VT_Close().

size_t BUF_Peek BUF  buf,
void *  data,
size_t  size
 

Equivalent to "BUF_PeekAt(buf, 0, data, size)", see description below.

Definition at line 256 of file ncbi_buffer.c.

References buf, and BUF_PeekAt().

Referenced by DSOCK_SendMsg(), s_CONN_Read(), and s_Read().

size_t BUF_PeekAt BUF  buf,
size_t  pos,
void *  data,
size_t  size
 

Copy up to "size" bytes stored in "buf" (starting at position "pos") to "data". Return the # of copied bytes (can be less than "size"). Return zero and do nothing if "buf" is NULL or "pos" >= BUF_Size(buf). Do nothing and return min(BUF_Size(buf)-pos, size) if "data" is NULL.

Definition at line 262 of file ncbi_buffer.c.

References buf, SBufChunkTag::n_skip, SBufChunkTag::next, and SBufChunkTag::size.

Referenced by BUF_Peek(), BUF_Read(), and s_WritePending().

size_t BUF_PeekAtCB BUF  buf,
size_t  pos,
void(*)(void *, void *, size_t)  callback,
void *  data,
size_t  size
 

Call "callback" on up to "size" bytes stored in "buf" (starting at position "pos"), each chunk separately. Pass data as opaque parameter to callback. Return the # of processed bytes (can be less than "size"). Return zero and do nothing if "buf" is NULL or "pos" >= BUF_Size(buf). Do nothing and return min(BUF_Size(buf)-pos, size) if "callback" is NULL.

Definition at line 306 of file ncbi_buffer.c.

References buf, SBufChunkTag::n_skip, SBufChunkTag::next, and SBufChunkTag::size.

Referenced by s_ReadBufToString().

int BUF_Prepend BUF pBuf,
const void *  data,
size_t  size
 

Prepend a block of data (of the specified size) to the beginning of the buffer (to be read first). Note that unlike BUF_Pushback(), in this call the data is not copied into the buffer but instead is just linked in from the original location. Return non-zero (true) if succeeded, zero (false) if failed.

Definition at line 155 of file ncbi_buffer.c.

References SBufChunkTag::alloc_size, BUF_SetChunkSize(), SBufChunkTag::data, SBufChunkTag::next, s_AllocChunk(), and SBufChunkTag::size.

int BUF_PushBack BUF pBuf,
const void *  data,
size_t  size
 

Write the data to the very beginning of "*pBuf" (to be read first). On error (failed memory allocation), return zero value. NOTE: if "*pBuf" == NULL then create it.

Definition at line 224 of file ncbi_buffer.c.

References SBufChunkTag::alloc_size, BUF_SetChunkSize(), SBufChunkTag::data, SBufChunkTag::n_skip, SBufChunkTag::next, s_AllocChunk(), and SBufChunkTag::size.

Referenced by CONN_PushBack(), s_BUF_IO(), and s_PushBack().

size_t BUF_Read BUF  buf,
void *  data,
size_t  size
 

Copy up to "size" bytes stored in "buf" to "data" and remove copied data from the "buf". Return the # of copied-and/or-removed bytes(can be less than "size") NOTE: if "buf" == NULL then do nothing and return 0 if "data" == NULL then do not copy data anywhere(still, remove it)

Definition at line 352 of file ncbi_buffer.c.

References buf, BUF_PeekAt(), free(), SBufChunkTag::n_skip, SBufChunkTag::next, and SBufChunkTag::size.

Referenced by CONN_ReInit(), CNetScheduleHandler::ProcessMsgBatchHeader(), CNetScheduleHandler::ProcessMsgBatchSubmit(), s_BUF_IO(), s_CONN_Read(), s_FTPExecute(), s_Read(), s_ReadBufToString(), s_ReadStrFromBUF(), s_VT_Read(), s_WipeRBuf(), s_WipeWBuf(), and URL_ConnectEx().

size_t BUF_SetChunkSize BUF pBuf,
size_t  chunk_size
 

Definition at line 69 of file ncbi_buffer.c.

References BUF_DEF_CHUNK_SIZE, and malloc().

Referenced by BUF_Append(), BUF_Prepend(), BUF_PushBack(), BUF_Write(), DSOCK_CreateEx(), s_Accept(), s_Create(), and SOCK_CreateOnTopEx().

size_t BUF_Size BUF  buf  ) 
 

Return the number of bytes stored in "buf". NOTE: return 0 if "buf" == NULL

Definition at line 85 of file ncbi_buffer.c.

References buf, SBufChunkTag::n_skip, SBufChunkTag::next, size, and SBufChunkTag::size.

Referenced by CONN_ReadLine(), CONN_ReInit(), CONN_Wait(), DSOCK_SendMsg(), CNetScheduleHandler::ProcessMsgBatchSubmit(), s_Connect(), s_FlushAndDisconnect(), s_FTPExecute(), s_ReadBufToString(), s_ReadHeader(), s_ReadLine(), s_ReadStrFromBUF(), s_VT_Flush(), s_VT_Wait(), s_WipeRBuf(), s_WipeWBuf(), s_WritePending(), SOCK_Poll(), SOCK_Wait(), and URL_ConnectEx().

int BUF_Write BUF pBuf,
const void *  data,
size_t  size
 

Add new data to the end of "*pBuf" (to be read last). On error (failed memory allocation), return zero value. NOTE: if "*pBuf" == NULL then create it.

Definition at line 180 of file ncbi_buffer.c.

References SBufChunkTag::alloc_size, BUF_SetChunkSize(), SBufChunkTag::data, SBufChunkTag::next, s_AllocChunk(), and SBufChunkTag::size.

Referenced by DSOCK_RecvMsg(), s_CONN_Read(), s_Create(), s_Disconnect(), s_Read(), s_StripToPattern(), s_VT_Write(), s_Write(), SERV_Print(), SOCK_CreateOnTopEx(), and URL_ConnectEx().


Generated on Wed Dec 9 08:13:42 2009 for NCBI C++ ToolKit by  doxygen 1.4.6
Modified on Wed Dec 09 08:20:18 2009 by modify_doxy.py rev. 173732