diff options
-rw-r--r-- | include/Exceptions.h | 11 | ||||
-rw-r--r-- | include/Handle.h | 4 | ||||
-rw-r--r-- | include/Input.h | 2 | ||||
-rw-r--r-- | include/Makefile.am | 2 | ||||
-rw-r--r-- | include/Output.h | 2 | ||||
-rw-r--r-- | include/Task.h | 7 | ||||
-rw-r--r-- | include/TaskMan.h | 22 | ||||
-rw-r--r-- | lib/CopyJob.cc | 2 | ||||
-rw-r--r-- | lib/Exceptions.cc | 8 | ||||
-rw-r--r-- | lib/Handle.cc | 11 | ||||
-rw-r--r-- | lib/Input.cc | 2 | ||||
-rw-r--r-- | lib/Makefile.am | 2 | ||||
-rw-r--r-- | lib/Output.cc | 2 | ||||
-rw-r--r-- | lib/Task.cc | 5 | ||||
-rw-r--r-- | lib/TaskMan.cc | 3 | ||||
-rw-r--r-- | po/ChangeLog | 5 |
16 files changed, 61 insertions, 29 deletions
diff --git a/include/Exceptions.h b/include/Exceptions.h index 8c37342..56460a6 100644 --- a/include/Exceptions.h +++ b/include/Exceptions.h @@ -34,10 +34,10 @@ class MemoryException; -char * xstrdup(const char *) throw (MemoryException); -void * xmalloc(ssize_t) throw (MemoryException); +char * xstrdup(const char *) throw (GeneralException); +void * xmalloc(ssize_t) throw (GeneralException); void xfree(void *&); -void * xrealloc(void *, size_t) throw (MemoryException); +void * xrealloc(void *, size_t) throw (GeneralException); // On prédéfinit la classe String, pour éviter // les deadlocks de compilation... @@ -110,6 +110,11 @@ class IOAgain : public IOGeneral { IOAgain(); }; +class TaskSwitch : public GeneralException { + public: + TaskSwitch(); +}; + #else #error This only works with a C++ compiler #endif diff --git a/include/Handle.h b/include/Handle.h index 2554892..6d44a48 100644 --- a/include/Handle.h +++ b/include/Handle.h @@ -28,8 +28,8 @@ class Handle : public Base { public: Handle(const Handle &); virtual ~Handle(); - virtual ssize_t read(void *buf, size_t count) throw (IOGeneral); - virtual ssize_t write(const void *buf, size_t count) throw (IOGeneral); + virtual ssize_t read(void *buf, size_t count) throw (GeneralException); + virtual ssize_t write(const void *buf, size_t count) throw (GeneralException); bool IsClosed(void); bool IsNonBlock(void); void SetNonBlock(void); diff --git a/include/Input.h b/include/Input.h index 81a48d8..1beb1b5 100644 --- a/include/Input.h +++ b/include/Input.h @@ -11,7 +11,7 @@ class Input : public Handle { public: - Input(String = "") throw (IOGeneral); + Input(String = "") throw (GeneralException); virtual ~Input() {} virtual bool CanWrite(); virtual bool CanRead(); diff --git a/include/Makefile.am b/include/Makefile.am index 156307a..9546421 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -1,4 +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 \ -CopyJob.h ReadJob.h Regex.h +CopyJob.h ReadJob.h Regex.h TaskMan.h diff --git a/include/Output.h b/include/Output.h index 6c944ab..98af0ac 100644 --- a/include/Output.h +++ b/include/Output.h @@ -11,7 +11,7 @@ class Output : public Handle { public: - Output(String = "", int trunc = 1) throw (IOGeneral); + Output(String = "", int trunc = 1) throw (GeneralException); virtual ~Output() {} virtual bool CanWrite(); virtual bool CanRead(); diff --git a/include/Task.h b/include/Task.h index c67a59c..f2fe722 100644 --- a/include/Task.h +++ b/include/Task.h @@ -4,11 +4,8 @@ #include "Exceptions.h" -#define TASK_ON_HOLD 1 -#define TASK_DONE 2 -#define TASK_WAITING_HANDLE 4 -#define TASK_WAITING_TIMEOUT 8 -#define TASK_WAITING_TASK 16 +#define TASK_ON_HOLD 0 +#define TASK_DONE 1 class Task : public Base { public: diff --git a/include/TaskMan.h b/include/TaskMan.h new file mode 100644 index 0000000..fe0d565 --- /dev/null +++ b/include/TaskMan.h @@ -0,0 +1,22 @@ +#ifndef __TASKMAN_H__ +#define __TASKMAN_H__ +#ifdef __cplusplus + +#include <Task,h> +#include <vector.h> + +catch TaskMan : public Base { + public: + TaskMan(); + ~TaskMan(); + int AddTask(const Task &); + void MainLoop(void); + private: + vector<Task> TaskList; + static int Inited; +}; + +#else +#error This only works with a C++ compiler +#endif +#endif diff --git a/lib/CopyJob.cc b/lib/CopyJob.cc index 04dff0b..6a35689 100644 --- a/lib/CopyJob.cc +++ b/lib/CopyJob.cc @@ -8,8 +8,6 @@ CopyJob::~CopyJob() { } int CopyJob::Do() { int r, tr; - cerr << "CopyJob running...\n"; - while (!s->IsClosed() || (siz != cursiz)) { if (!current) { tr = siz >= 0 ? siz - cursiz : COPY_BUFSIZ; diff --git a/lib/Exceptions.cc b/lib/Exceptions.cc index a4fca0f..9d2ba8e 100644 --- a/lib/Exceptions.cc +++ b/lib/Exceptions.cc @@ -38,7 +38,9 @@ IOGeneral::IOGeneral() { } IOAgain::IOAgain() : IOGeneral(_("No more bytes for reading or writing.")) { } -char * xstrdup(const char * s) throw (MemoryException) { +TaskSwitch::TaskSwitch() : GeneralException(_("Switching task in a non-tasked environnement")) { } + +char * xstrdup(const char * s) throw (GeneralException) { char * r; if (!(r = ::strdup(s))) { @@ -48,7 +50,7 @@ char * xstrdup(const char * s) throw (MemoryException) { return r; } -void * xmalloc(ssize_t s) throw (MemoryException) { +void * xmalloc(ssize_t s) throw (GeneralException) { void * r; if (!(r = ::malloc(s))) { @@ -60,7 +62,7 @@ void * xmalloc(ssize_t s) throw (MemoryException) { return r; } -void * xrealloc(void * ptr, size_t s) throw (MemoryException) { +void * xrealloc(void * ptr, size_t s) throw (GeneralException) { void * r; if (!(r = ::realloc(ptr, s))) { diff --git a/lib/Handle.cc b/lib/Handle.cc index c1fbc8c..e5a23a3 100644 --- a/lib/Handle.cc +++ b/lib/Handle.cc @@ -20,7 +20,7 @@ int Handle::GetHandle() { return h; } -ssize_t Handle::write(const void *buf, size_t count) throw (IOGeneral) { +ssize_t Handle::write(const void *buf, size_t count) throw (GeneralException) { ssize_t r, tr = 0; bool done, full = false; @@ -40,7 +40,7 @@ ssize_t Handle::write(const void *buf, size_t count) throw (IOGeneral) { done = false; full = true; if (nonblock) { - throw IOAgain(); + throw TaskSwitch(); } else { sleep(1); } @@ -58,19 +58,16 @@ ssize_t Handle::write(const void *buf, size_t count) throw (IOGeneral) { return r + tr; } -ssize_t Handle::read(void *buf, size_t count) throw (IOGeneral) { +ssize_t Handle::read(void *buf, size_t count) throw (GeneralException) { ssize_t r; errno = 0; if ((r = ::read(h, buf, count)) < 0) { - cerr << "read: throwing exception...\n"; if ((!errno) || (errno = EAGAIN)) { // Avant de déclarer une erreur, on vérifie si ce n'est pas un // problème lié au fait qu'il n'y a plus d'octets. - cerr << "Throwing a 'again' exception.\n"; - throw IOAgain(); + throw TaskSwitch(); } else { - cerr << "Throwing an unknow exception.\n"; throw IOException(GetName(), IO_READ, count); } } diff --git a/lib/Input.cc b/lib/Input.cc index f4e2602..9ce7ca0 100644 --- a/lib/Input.cc +++ b/lib/Input.cc @@ -10,7 +10,7 @@ #include "Exceptions.h" #include "config.h" -Input::Input(String no) throw (IOGeneral) : +Input::Input(String no) throw (GeneralException) : Handle(no.strlen() ? open(no.to_charp(), O_RDONLY) : 0), n(no) { if (GetHandle() < 0) { diff --git a/lib/Makefile.am b/lib/Makefile.am index f5b1cfb..9778018 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\ - CopyJob.cc ReadJob.cc Regex.cc + CopyJob.cc ReadJob.cc Regex.cc TaskMan.cc libBaltisot_la_LDFLAGS = -release $(Baltisot_VERSION_INFO) diff --git a/lib/Output.cc b/lib/Output.cc index 75bb437..ab51c9f 100644 --- a/lib/Output.cc +++ b/lib/Output.cc @@ -10,7 +10,7 @@ #include "Exceptions.h" #include "config.h" -Output::Output(String no, int trunc = 1) throw (IOGeneral) : +Output::Output(String no, int trunc = 1) throw (GeneralException) : Handle(no.strlen() ? open(no.to_charp(), O_WRONLY | O_CREAT | (trunc ? O_TRUNC : O_APPEND)) : 1), n(no) { if (GetHandle() < 0) { diff --git a/lib/Task.cc b/lib/Task.cc index 27d2a24..faaeaf3 100644 --- a/lib/Task.cc +++ b/lib/Task.cc @@ -12,7 +12,10 @@ int Task::Do() { int Task::Run() { cerr << "Running task '" << GetName() << "'...\n"; try { - while ((state = Do()) != TASK_DONE); + state = Do(); + } + catch (TaskSwitch) { + throw; } catch (GeneralException e) { cerr << "Task " << GetName() << " caused an unexpected exception: '" << e.GetMsg() << "', closing it.\n"; diff --git a/lib/TaskMan.cc b/lib/TaskMan.cc new file mode 100644 index 0000000..58c7eae --- /dev/null +++ b/lib/TaskMan.cc @@ -0,0 +1,3 @@ +#include <TaskMan.h> + +Task::Task() ( )
\ No newline at end of file diff --git a/po/ChangeLog b/po/ChangeLog index 002e315..99f40f7 100644 --- a/po/ChangeLog +++ b/po/ChangeLog @@ -1,3 +1,8 @@ +2001-11-09 gettextize <bug-gnu-utils@gnu.org> + + * Makefile.in.in: Upgrade to gettext-0.10.40. + * stamp-cat-id: Remove file. + 2001-11-08 gettextize <bug-gnu-utils@gnu.org> * Makefile.in.in: Upgrade to gettext-0.10.40. |