summaryrefslogtreecommitdiffstats
path: root/k9vamps/k9fifo.cpp
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-02-17 00:32:19 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-02-17 00:32:19 +0000
commit0d382a262c0638d0f572fc37193ccc5ed3dc895f (patch)
tree8578dcddfce4191f3f7a142a37769df7add48475 /k9vamps/k9fifo.cpp
downloadk9copy-0d382a262c0638d0f572fc37193ccc5ed3dc895f.tar.gz
k9copy-0d382a262c0638d0f572fc37193ccc5ed3dc895f.zip
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
Diffstat (limited to 'k9vamps/k9fifo.cpp')
-rw-r--r--k9vamps/k9fifo.cpp54
1 files changed, 54 insertions, 0 deletions
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 <k9copy@free.fr>, (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();
+}