diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Buffer.cc | 5 | ||||
-rw-r--r-- | lib/Exceptions.cc | 7 | ||||
-rw-r--r-- | lib/Handle.cc | 4 | ||||
-rw-r--r-- | lib/InPipe.cc | 5 | ||||
-rw-r--r-- | lib/Input.cc | 3 | ||||
-rw-r--r-- | lib/OutPipe.cc | 5 | ||||
-rw-r--r-- | lib/Output.cc | 3 |
7 files changed, 30 insertions, 2 deletions
diff --git a/lib/Buffer.cc b/lib/Buffer.cc index e8335d9..83369bd 100644 --- a/lib/Buffer.cc +++ b/lib/Buffer.cc @@ -9,6 +9,11 @@ Buffer::~Buffer() { free(buffer); } +Buffer::Buffer(const Buffer & b) : Handle(-1), buffer(0), zero(b.zero), realsiz(b.realsiz), bufsiz(b.bufsiz), ptr(b.ptr) { + buffer = (char *) malloc(bufsiz); + memcpy(buffer, b.buffer, bufsiz); +} + ssize_t Buffer::write(const void *buf, size_t count) { if (!count) { return 0; diff --git a/lib/Exceptions.cc b/lib/Exceptions.cc index 1283f6a..7c9d318 100644 --- a/lib/Exceptions.cc +++ b/lib/Exceptions.cc @@ -118,6 +118,13 @@ void xfree(void *& p) { } } +void xfree(char *& p) { + if (p) { + ::free(p - sizeof(size_t)); + p = 0; + } +} + int xpipe(int * p, int flag) throw (GeneralException) { if (pipe(p)) { throw GeneralException(String(_("Error creating pipe: ")) + strerror(errno)); diff --git a/lib/Handle.cc b/lib/Handle.cc index 6c3bbbd..fe7c10b 100644 --- a/lib/Handle.cc +++ b/lib/Handle.cc @@ -6,7 +6,7 @@ #include "Handle.h" #include "config.h" -Handle::Handle(const Handle & nh) : h(nh.h >= 0 ? dup(nh.h) : nh.h), closed(false), nonblock(false), zfile(0), z(0) { +Handle::Handle(const Handle & nh) : h(nh.h >= 0 ? dup(nh.h) : nh.h), closed(nh.closed), nonblock(nh.closed), zfile(0), z(0) { // cerr << "Duplication of handle " << nh.h << " to " << h << endl; if ((h >= 0) && (nh.z)) { SetZ(nh.z); @@ -18,7 +18,7 @@ Handle::~Handle() { close(); } -Handle::Handle(int nh) : h(nh), closed(false), zfile(0), z(0) { +Handle::Handle(int nh) : h(nh), closed(false), nonblock(false), zfile(0), z(0) { // cerr << "Initialising handle " << h << endl; } diff --git a/lib/InPipe.cc b/lib/InPipe.cc index 978d24b..c61005f 100644 --- a/lib/InPipe.cc +++ b/lib/InPipe.cc @@ -4,6 +4,11 @@ InPipe::InPipe() : Handle(pipe(p, 0)), hooked(0) { } +InPipe::InPipe(const InPipe & i) : Handle(i), hooked(i.hooked) { + p[0] = GetHandle(); + p[1] = dup(i.p[1]); +} + InPipe::~InPipe() { if (hooked) { ::close(1); diff --git a/lib/Input.cc b/lib/Input.cc index 318821d..5652c57 100644 --- a/lib/Input.cc +++ b/lib/Input.cc @@ -26,6 +26,9 @@ Input::Input(String no) throw (GeneralException) : date_modif = s.st_mtime; } +Input::Input(const Input & i) : Handle(i), n(i.n), size(i.size), date_modif(i.date_modif) { +} + bool Input::CanWrite() { return 0; } diff --git a/lib/OutPipe.cc b/lib/OutPipe.cc index 4b2e710..be93e15 100644 --- a/lib/OutPipe.cc +++ b/lib/OutPipe.cc @@ -11,6 +11,11 @@ OutPipe::~OutPipe() { } } +OutPipe::OutPipe(const OutPipe & o) : Handle(o), hooked(o.hooked) { + p[0] = dup(i.p[0]); + p[1] = GetHandle(); +} + void OutPipe::Hook() { if (!hooked) { hooked = 1; diff --git a/lib/Output.cc b/lib/Output.cc index 27f28d2..deecfb0 100644 --- a/lib/Output.cc +++ b/lib/Output.cc @@ -17,6 +17,9 @@ Output::Output(String no, int trunc = 1) throw (GeneralException) : } } +Output::Output(const Output & o) : Handle(o), n(o.n) { +} + bool Output::CanWrite() { return 1; } |