From 0d382a262c0638d0f572fc37193ccc5ed3dc895f Mon Sep 17 00:00:00 2001 From: tpearson Date: Wed, 17 Feb 2010 00:32:19 +0000 Subject: Added old abandoned version of k9copy git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/k9copy@1091546 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- k9vamps/k9fifo.cpp | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 k9vamps/k9fifo.cpp (limited to 'k9vamps/k9fifo.cpp') diff --git a/k9vamps/k9fifo.cpp b/k9vamps/k9fifo.cpp new file mode 100644 index 0000000..7c32de7 --- /dev/null +++ b/k9vamps/k9fifo.cpp @@ -0,0 +1,54 @@ +// +// C++ Implementation: k9fifo +// +// Description: +// +// +// Author: Jean-Michel PETIT , (C) 2007 +// +// Copyright: See COPYING file that comes with this distribution +// +// +#include "k9fifo.h" +#include "ac.h" + +uint32_t k9fifo::count() { + return m_count; +} + +void k9fifo::enqueue (uchar *_buffer, uint32_t _size) { + mutex.lock(); + if (_size+queue > INPUT_SIZE) { + uint32_t s1,s2; + s1=INPUT_SIZE-queue; + tc_memcpy(array+queue,_buffer,s1); + s2=_size-s1; + tc_memcpy(array,_buffer+s1,s2); + } else + tc_memcpy(array+queue,_buffer,_size); + queue=(queue+_size) %INPUT_SIZE; + m_count+=_size; + mutex.unlock(); +} + +void k9fifo::dequeue(uchar *_buffer,uint32_t _size) { + mutex.lock(); + if ( _size+head >INPUT_SIZE) { + uint32_t s1,s2; + s1=INPUT_SIZE - head; + tc_memcpy(_buffer,array+head,s1); + s2=_size-s1; + tc_memcpy(_buffer+s1,array,s2); + } else + tc_memcpy(_buffer,array+head,_size); + head =(head+_size)%INPUT_SIZE; + m_count -=_size; + mutex.unlock(); +} + +void k9fifo::clear() { + mutex.lock(); + head=queue; + m_count=0; + mutex.unlock(); +} -- cgit v1.2.1