summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/CopyJob.h10
-rw-r--r--include/Exceptions.h23
-rw-r--r--include/HttpServ.h10
-rw-r--r--include/ReadJob.h8
-rw-r--r--include/Task.h12
5 files changed, 42 insertions, 21 deletions
diff --git a/include/CopyJob.h b/include/CopyJob.h
index 69eb088..3c88100 100644
--- a/include/CopyJob.h
+++ b/include/CopyJob.h
@@ -5,13 +5,19 @@
#include <Task.h>
#include <Handle.h>
+#define COPY_BUFSIZ 4096
+
class CopyJob : public Task {
public:
- CopyJob(Handle &, Handle &);
+ CopyJob(Handle *, Handle *, ssize_t = -1);
virtual ~CopyJob();
virtual int Do();
+ virtual String GetName();
private:
- Handle s, d;
+ Handle * s, * d;
+ ssize_t siz, cursiz;
+ char buffer[COPY_BUFSIZ];
+ int current;
};
#else
diff --git a/include/Exceptions.h b/include/Exceptions.h
index 87ba6d1..f04970c 100644
--- a/include/Exceptions.h
+++ b/include/Exceptions.h
@@ -37,6 +37,7 @@ class MemoryException;
char * xstrdup(const char *) throw (MemoryException);
void * xmalloc(ssize_t) throw (MemoryException);
void xfree(void *&);
+void * xrealloc(void *, size_t) throw (MemoryException);
// On prédéfinit la classe String, pour éviter
// les deadlocks de compilation...
@@ -48,7 +49,10 @@ class Base {
return xstrdup(s);
}
void * malloc(ssize_t s) const {
- return malloc(s);
+ return xmalloc(s);
+ }
+ void * realloc(void * p, size_t s) {
+ return xrealloc(p, s);
}
void * operator new(size_t s) {
return xmalloc(s);
@@ -56,6 +60,9 @@ class Base {
void * operator new(size_t s, void * p) {
return memset(p, 0, s);
}
+ void operator delete(void * p) {
+ xfree(p);
+ }
void free(void * p) const {
xfree(p);
}
@@ -86,19 +93,21 @@ enum op_t {
IO_READ
};
-class IOException : public GeneralException {
+class IOGeneral : public GeneralException {
public:
- IOException(String, op_t, ssize_t);
+ IOGeneral(String);
+ protected:
+ IOGeneral();
};
-class IOGeneral : public GeneralException {
+class IOException : public IOGeneral {
public:
- IOGeneral(String);
+ IOException(String, op_t, ssize_t);
};
-class IOInternal : public GeneralException {
+class IOAgain : public IOGeneral {
public:
- IOInternal(String, op_t);
+ IOAgain();
};
#else
diff --git a/include/HttpServ.h b/include/HttpServ.h
index dc89104..6bd2769 100644
--- a/include/HttpServ.h
+++ b/include/HttpServ.h
@@ -24,11 +24,11 @@ class HttpServ : public Base {
private:
String GetMime(const String &);
void ProcessRequest(Action *, Socket);
- bool ParseUri(String &, String &, Handle &);
- void ParseVars(Handle &, int);
- void ShowError(Handle &);
- void SendHeads(Handle &, const String &);
- void SendRedirect(Handle &);
+ bool ParseUri(String &, String &, Handle *);
+ void ParseVars(Handle *, int);
+ void ShowError(Handle *);
+ void SendHeads(Handle *, const String &);
+ void SendRedirect(Handle *);
String name;
Socket Listener;
Variables * Vars;
diff --git a/include/ReadJob.h b/include/ReadJob.h
index 19009a6..2d53125 100644
--- a/include/ReadJob.h
+++ b/include/ReadJob.h
@@ -4,14 +4,18 @@
#include <Task.h>
#include <Handle.h>
+#include <regex.h>
class ReadJob : public Task {
public:
- ReadJob(Handle &, Handle &);
+ ReadJob(Handle *, Handle *, String = "^$", int = REG_EXTENDED);
virtual ~ReadJob();
virtual int Do();
+ virtual String GetName();
private:
- Handle s, d;
+ Handle * s, * d;
+ int current;
+ regex_t * preg;
};
#else
diff --git a/include/Task.h b/include/Task.h
index 12e3bff..c67a59c 100644
--- a/include/Task.h
+++ b/include/Task.h
@@ -4,19 +4,21 @@
#include "Exceptions.h"
-#define TASK_ON_HOLD 0
-#define TASK_DONE 1
-#define TASK_WAITING_HANDLE 2
-#define TASK_WAITING_TIMEOUT 3
+#define TASK_ON_HOLD 1
+#define TASK_DONE 2
+#define TASK_WAITING_HANDLE 4
+#define TASK_WAITING_TIMEOUT 8
+#define TASK_WAITING_TASK 16
class Task : public Base {
public:
Task();
virtual ~Task();
- virtual int Do();
+ virtual String GetName();
int Run();
int GetState();
protected:
+ virtual int Do();
private:
int state;