summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/Handle.cc30
-rw-r--r--lib/Input.cc2
2 files changed, 29 insertions, 3 deletions
diff --git a/lib/Handle.cc b/lib/Handle.cc
index d6fa0fb..c6f7a1a 100644
--- a/lib/Handle.cc
+++ b/lib/Handle.cc
@@ -74,6 +74,8 @@ ssize_t Handle::write(const void *cbuf, size_t count) throw (GeneralException) {
bool done, full = false;
const char * buf = (const char *)cbuf;
+ if (!count)
+ return 0;
do {
done = true;
@@ -120,6 +122,9 @@ ssize_t Handle::write(const void *cbuf, size_t count) throw (GeneralException) {
ssize_t Handle::read(void *buf, size_t count) throw (GeneralException) {
ssize_t r;
+ if (!count)
+ return 0;
+
#ifdef FULLDEBUG
printm(M_INFO, String(_("read: reading ")) + count + _(" bytes from handle ") + GetHandle() + "\n");
#endif
@@ -451,7 +456,7 @@ void Handle::writeU32(Uint32 v) {
#endif
}
-void copy(Handle * s, Handle * d, ssize_t size) {
+void copyone(Handle * s, Handle * d, ssize_t size) {
long i;
unsigned char c;
long r;
@@ -465,6 +470,29 @@ void copy(Handle * s, Handle * d, ssize_t size) {
}
}
+#define BSIZE 2048
+
+void copy(Handle * s, Handle * d, ssize_t size) {
+ long i;
+ static unsigned char b[BSIZE];
+ long r;
+
+ while (size) {
+ if ((size > BSIZE) || (size < 0)) {
+ r = s->read(b, BSIZE);
+ if (r)
+ d->write(b, r);
+ } else {
+ r = s->read(b, size);
+ if (r)
+ d->write(b, r);
+ }
+ if (!r)
+ break;
+ size -= r;
+ }
+}
+
void Handle::Flush() {
if (h < 0)
return;
diff --git a/lib/Input.cc b/lib/Input.cc
index d846acd..c77120c 100644
--- a/lib/Input.cc
+++ b/lib/Input.cc
@@ -5,8 +5,6 @@
#include <sys/stat.h>
#include <fcntl.h>
-#define DEBUG
-
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif