Add function to measure the length of the fifo buffer
authorWilfried Goesgens <dothebart@citadel.org>
Fri, 16 Sep 2011 18:41:28 +0000 (18:41 +0000)
committerWilfried Goesgens <dothebart@citadel.org>
Fri, 16 Sep 2011 18:41:28 +0000 (18:41 +0000)
libcitadel/lib/libcitadel.h
libcitadel/lib/stringbuf.c

index 021caf8d08fc2acd0cb17532e92d07c64560836b..ac102b1b25b41c1a1f65d9311bcba3b8c89e24d5 100644 (file)
@@ -241,6 +241,7 @@ int StrBuf_write_one_chunk_callback(int fd, short event, IOBuffer *FB);
 
 eReadState StrBufChunkSipLine(StrBuf *LineBuf, IOBuffer *FB);
 eReadState StrBufCheckBuffer(IOBuffer *FB);
+long IOBufferStrLength(IOBuffer *FB);
 
 int StrBufSipLine(StrBuf *LineBuf, const StrBuf *Buf, const char **Ptr);
 int StrBufReplaceToken(StrBuf *Buf, long where, long HowLong, const char *Repl, long ReplLen);
index 2b0d2fe8edface722f9862089b1a2ac4541c4b16..c8f8a6434d53436b8894b336f39d0e6b3b0e0337 100644 (file)
@@ -3774,6 +3774,14 @@ eReadState StrBufCheckBuffer(IOBuffer *FB)
        return eReadSuccess;
 }
 
+long IOBufferStrLength(IOBuffer *FB)
+{
+       if (FB->ReadWritePointer == NULL)
+               return StrLength(FB->Buf);
+       
+       return StrLength(FB->Buf) - (FB->ReadWritePointer - FB->Buf->buf);
+}
+
 /*******************************************************************************
  *           File I/O; Prefer buffered read since its faster!                  *
  *******************************************************************************/