summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPixel <Pixel>2001-10-29 16:23:12 +0000
committerPixel <Pixel>2001-10-29 16:23:12 +0000
commita259ec553a1d685ebb976ec34eaaf700d24ee0c4 (patch)
treeca310bfa8858bc3d5a1602789ecbe41e9c2ca3dd
parent2e5bed84841f33ff28dd95b77b555720c875a286 (diff)
More tasking implementation
-rw-r--r--include/CopyJob.h20
-rw-r--r--include/Exceptions.h1
-rw-r--r--include/Handle.h6
-rw-r--r--include/Makefile.am3
-rw-r--r--include/ReadJob.h20
-rw-r--r--lib/CopyJob.cc15
-rw-r--r--lib/Handle.cc12
-rw-r--r--lib/Makefile.am2
-rw-r--r--lib/ReadJob.cc16
9 files changed, 89 insertions, 6 deletions
diff --git a/include/CopyJob.h b/include/CopyJob.h
index e69de29..69eb088 100644
--- a/include/CopyJob.h
+++ b/include/CopyJob.h
@@ -0,0 +1,20 @@
+#ifndef __COPYJOB_H__
+#define __COPYJOB_H__
+#ifdef __cplusplus
+
+#include <Task.h>
+#include <Handle.h>
+
+class CopyJob : public Task {
+ public:
+ CopyJob(Handle &, Handle &);
+ virtual ~CopyJob();
+ virtual int Do();
+ private:
+ Handle s, d;
+};
+
+#else
+#error This only works with a C++ compiler
+#endif
+#endif
diff --git a/include/Exceptions.h b/include/Exceptions.h
index 16737e0..87ba6d1 100644
--- a/include/Exceptions.h
+++ b/include/Exceptions.h
@@ -5,6 +5,7 @@
#include <stdio.h>
#include <unistd.h>
#include <stddef.h>
+#include <string.h>
/*
* Gère les exceptions du système. Le programme principal devrait tenter
diff --git a/include/Handle.h b/include/Handle.h
index 3cb16f1..1541bbe 100644
--- a/include/Handle.h
+++ b/include/Handle.h
@@ -33,9 +33,9 @@ class Handle : public Base {
bool IsClosed(void);
bool IsNonBlock(void);
void SetNonBlock(void);
- virtual bool CanRead() = 0;
- virtual bool CanWrite() = 0;
- virtual String GetName() = 0;
+ virtual bool CanRead();
+ virtual bool CanWrite();
+ virtual String GetName();
protected:
Handle(int h);
int GetHandle();
diff --git a/include/Makefile.am b/include/Makefile.am
index 4175224..245640d 100644
--- a/include/Makefile.am
+++ b/include/Makefile.am
@@ -1,5 +1,4 @@
include_HEADERS = \
Exceptions.h Handle.h String.h Output.h Socket.h HttpServ.h Variables.h Menu.h \
Action.h Message.h Form.h Confirm.h Table.h IRC.h Task.h Buffer.h General.h \
-Misc.h
-
+CopyJob.h ReadJob.h
diff --git a/include/ReadJob.h b/include/ReadJob.h
new file mode 100644
index 0000000..19009a6
--- /dev/null
+++ b/include/ReadJob.h
@@ -0,0 +1,20 @@
+#ifndef __READJOB_H__
+#define __READJOB_H__
+#ifdef __cplusplus
+
+#include <Task.h>
+#include <Handle.h>
+
+class ReadJob : public Task {
+ public:
+ ReadJob(Handle &, Handle &);
+ virtual ~ReadJob();
+ virtual int Do();
+ private:
+ Handle s, d;
+};
+
+#else
+#error This only works with a C++ compiler
+#endif
+#endif
diff --git a/lib/CopyJob.cc b/lib/CopyJob.cc
index e69de29..7dccbc5 100644
--- a/lib/CopyJob.cc
+++ b/lib/CopyJob.cc
@@ -0,0 +1,15 @@
+#include "CopyJob.h"
+
+CopyJob::CopyJob(Handle & as, Handle & ad) : s(as), d(ad) { }
+
+CopyJob::~CopyJob() { }
+
+int CopyJob::Do() {
+ int r;
+ char buffer[4096];
+
+ while (!s.IsClosed()) {
+ r = s.read(buffer, 4096);
+ d.write(buffer, r);
+ }
+}
diff --git a/lib/Handle.cc b/lib/Handle.cc
index c3efc55..0f1791e 100644
--- a/lib/Handle.cc
+++ b/lib/Handle.cc
@@ -138,3 +138,15 @@ void Handle::close() {
closed = 1;
}
+
+bool Handle::CanRead(void) {
+ return false;
+}
+
+bool Handle::CanWrite(void) {
+ return false;
+}
+
+String Handle::GetName(void) {
+ return _("Bare Handle - should not happend");
+}
diff --git a/lib/Makefile.am b/lib/Makefile.am
index 1135e12..01cef95 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -8,6 +8,6 @@ lib_LTLIBRARIES = libBaltisot.la
libBaltisot_la_SOURCES = Exceptions.cc Handle.cc Output.cc String.cc\
Socket.cc Input.cc HttpServ.cc Variables.cc Action.cc Menu.cc Message.cc\
Form.cc Confirm.cc Table.cc checkargs.c datecalc.c IRC.cc Task.cc Buffer.cc\
- Misc.cc
+ CopyJob.cc ReadJob.cc
libBaltisot_la_LDFLAGS = -release $(Baltisot_VERSION_INFO)
diff --git a/lib/ReadJob.cc b/lib/ReadJob.cc
new file mode 100644
index 0000000..9f4e084
--- /dev/null
+++ b/lib/ReadJob.cc
@@ -0,0 +1,16 @@
+#include "ReadJob.h"
+
+ReadJob::ReadJob(Handle & as, Handle & ad) : s(as), d(ad) { }
+
+ReadJob::~ReadJob() { }
+
+int ReadJob::Do() {
+ int r;
+ String buff;
+
+ while (!s.IsClosed()) {
+ buff << s;
+ buff >> d;
+ if (buff == "") return TASK_DONE;
+ }
+}