diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/Action.h | 2 | ||||
-rw-r--r-- | include/Buffer.h | 29 | ||||
-rw-r--r-- | include/Confirm.h | 2 | ||||
-rw-r--r-- | include/CopyJob.h | 0 | ||||
-rw-r--r-- | include/Exceptions.h | 38 | ||||
-rw-r--r-- | include/Form.h | 3 | ||||
-rw-r--r-- | include/General.h | 7 | ||||
-rw-r--r-- | include/Handle.h | 5 | ||||
-rw-r--r-- | include/HttpServ.h | 4 | ||||
-rw-r--r-- | include/IRC.h | 2 | ||||
-rw-r--r-- | include/Makefile.am | 3 | ||||
-rw-r--r-- | include/Menu.h | 2 | ||||
-rw-r--r-- | include/Message.h | 2 | ||||
-rw-r--r-- | include/Socket.h | 4 | ||||
-rw-r--r-- | include/Table.h | 2 | ||||
-rw-r--r-- | include/Task.h | 20 | ||||
-rw-r--r-- | include/Variables.h | 2 |
17 files changed, 103 insertions, 24 deletions
diff --git a/include/Action.h b/include/Action.h index e9edf27..5fcf660 100644 --- a/include/Action.h +++ b/include/Action.h @@ -2,9 +2,9 @@ #define __ACTION_H__ #ifdef __cplusplus -#include "Exceptions.h" #include "Handle.h" #include "Variables.h" +#include "Exceptions.h" /* * La classe Action defini les actions HTTP possibles. diff --git a/include/Buffer.h b/include/Buffer.h new file mode 100644 index 0000000..c6bfcf4 --- /dev/null +++ b/include/Buffer.h @@ -0,0 +1,29 @@ +#ifndef __BUFFER_H__ +#define __BUFFER_H__ +#ifdef __cplusplus + +#include <Exceptions.h> +#include <Handle.h> + +#ifndef realloc_threshold +#define realloc_threshold 256 +#endif + +class Buffer: public Handle { + public: + Buffer(); + ~Buffer(); + virtual ssize_t write(const void *buf, size_t count); + virtual ssize_t read(void *buf, size_t count); + virtual bool CanRead(); + virtual bool CanWrite(); + virtual String GetName(); + private: + char * buffer; + int realsiz, bufsiz, ptr; +}; + +#else +#error This only works with a C++ compiler +#endif +#endif diff --git a/include/Confirm.h b/include/Confirm.h index b56e0d2..704bb88 100644 --- a/include/Confirm.h +++ b/include/Confirm.h @@ -2,9 +2,9 @@ #define __CONFIRM_H__ #ifdef __cplusplus -#include "Exceptions.h" #include "Action.h" #include "String.h" +#include "Exceptions.h" /* * Cette classe sert à afficher une boîte de dialogue de confirmation. diff --git a/include/CopyJob.h b/include/CopyJob.h new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/include/CopyJob.h diff --git a/include/Exceptions.h b/include/Exceptions.h index 6e8e1db..16737e0 100644 --- a/include/Exceptions.h +++ b/include/Exceptions.h @@ -25,7 +25,17 @@ // Impossible de surcharger free(void *). Les compilateurs // refuseront de passer un char * par exemple. +#ifdef OVER_FREE #define free(p) xfree((void*)p) +#else +#include <stdlib.h> +#endif + +class MemoryException; + +char * xstrdup(const char *) throw (MemoryException); +void * xmalloc(ssize_t) throw (MemoryException); +void xfree(void *&); // On prédéfinit la classe String, pour éviter // les deadlocks de compilation... @@ -33,13 +43,27 @@ class String; class Base { public: - char * strdup(const char *) const; - void * malloc(ssize_t) const; - void * operator new(size_t); - void * operator new(size_t, void *); + char * strdup(const char * s) const { + return xstrdup(s); + } + void * malloc(ssize_t s) const { + return malloc(s); + } + void * operator new(size_t s) { + return xmalloc(s); + } + void * operator new(size_t s, void * p) { + return memset(p, 0, s); + } + void free(void * p) const { + xfree(p); + } + void free(char * p) const { + xfree((void *) p); + } }; -class GeneralException : public Base{ +class GeneralException : public Base { public: GeneralException(String); GeneralException(const GeneralException &); @@ -76,10 +100,6 @@ class IOInternal : public GeneralException { IOInternal(String, op_t); }; -char * xstrdup(const char *) throw (MemoryException); -void * xmalloc(ssize_t) throw (MemoryException); -void xfree(void *&); - #else #error This only works with a C++ compiler #endif diff --git a/include/Form.h b/include/Form.h index 8a35898..e0bf75d 100644 --- a/include/Form.h +++ b/include/Form.h @@ -2,9 +2,10 @@ #define __FORM_H__ #ifdef __cplusplus -#include "Exceptions.h" #include "Action.h" #include "String.h" +#include "Exceptions.h" + /* * Cette classe sert à afficher un formulaire de saisie. * Constructeur: diff --git a/include/General.h b/include/General.h new file mode 100644 index 0000000..6f423ed --- /dev/null +++ b/include/General.h @@ -0,0 +1,7 @@ +#ifndef __GENERAL_H__ +#define __GENERAL_H__ + +#define MAX(__a,__b) ((__a)<(__b)?(__b):(__a)) +#define MIN(__a,__b) ((__a)>(__b)?(__b):(__a)) + +#endif diff --git a/include/Handle.h b/include/Handle.h index 0044fa6..3cb16f1 100644 --- a/include/Handle.h +++ b/include/Handle.h @@ -28,8 +28,8 @@ class Handle : public Base { public: Handle(const Handle &); virtual ~Handle(); - ssize_t read(void *buf, size_t count) throw (IOException); - ssize_t write(const void *buf, size_t count) throw (IOException); + virtual ssize_t read(void *buf, size_t count) throw (IOException); + virtual ssize_t write(const void *buf, size_t count) throw (IOException); bool IsClosed(void); bool IsNonBlock(void); void SetNonBlock(void); @@ -39,6 +39,7 @@ class Handle : public Base { protected: Handle(int h); int GetHandle(); + void close(); private: int h; bool closed, nonblock; diff --git a/include/HttpServ.h b/include/HttpServ.h index 71dc4eb..d4ef60c 100644 --- a/include/HttpServ.h +++ b/include/HttpServ.h @@ -4,9 +4,9 @@ #include "Socket.h" #include "String.h" -#include "Exceptions.h" #include "Variables.h" #include "Action.h" +#include "Exceptions.h" /* * La classe HttpServ. Le constructueur (int, const String &) indique le port @@ -23,7 +23,7 @@ class HttpServ : public Base { void MainLoop(Action *); private: String GetMime(const String &); - void ProcessRequest(Action *); + void ProcessRequest(Action *, Socket); bool ParseUri(String &, String &, Socket &); void ParseVars(Socket &, int); void ShowError(Socket &); diff --git a/include/IRC.h b/include/IRC.h index 5f5a3f5..7c7e32c 100644 --- a/include/IRC.h +++ b/include/IRC.h @@ -2,8 +2,8 @@ #define __IRC_H__ #ifdef __cplusplus -#include "Exceptions.h" #include "Socket.h" +#include "Exceptions.h" #define RPL_WELCOME 1 #define RPL_YOURHOST 2 diff --git a/include/Makefile.am b/include/Makefile.am index 6109711..4175224 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -1,4 +1,5 @@ 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 +Action.h Message.h Form.h Confirm.h Table.h IRC.h Task.h Buffer.h General.h \ +Misc.h diff --git a/include/Menu.h b/include/Menu.h index 67bc54e..7ea7662 100644 --- a/include/Menu.h +++ b/include/Menu.h @@ -2,9 +2,9 @@ #define __MENU_H__ #ifdef __cplusplus -#include "Exceptions.h" #include "Action.h" #include "String.h" +#include "Exceptions.h" /* * Cette classe permet d'afficher un menu. diff --git a/include/Message.h b/include/Message.h index 1cdb297..888d0be 100644 --- a/include/Message.h +++ b/include/Message.h @@ -2,9 +2,9 @@ #define __MESSAGE_H__ #ifdef __cplusplus -#include "Exceptions.h" #include "Action.h" #include "String.h" +#include "Exceptions.h" /* * Cette classe sert a afficher un message. diff --git a/include/Socket.h b/include/Socket.h index 355d3b2..80c7180 100644 --- a/include/Socket.h +++ b/include/Socket.h @@ -2,11 +2,11 @@ #define __SOCKET_H__ #ifdef __cplusplus -#include "String.h" #include "Handle.h" -#include "Exceptions.h" +#include "String.h" #include "Output.h" #include "Input.h" +#include "Exceptions.h" /* * Cree un socket. diff --git a/include/Table.h b/include/Table.h index bfcd652..c80fc8a 100644 --- a/include/Table.h +++ b/include/Table.h @@ -2,9 +2,9 @@ #define __TABLE_H__ #ifdef __cplusplus -#include "Exceptions.h" #include "Action.h" #include "String.h" +#include "Exceptions.h" /* * Affiche une table. diff --git a/include/Task.h b/include/Task.h index fe70d7b..12e3bff 100644 --- a/include/Task.h +++ b/include/Task.h @@ -2,6 +2,26 @@ #define __TASK_H__ #ifdef __cplusplus +#include "Exceptions.h" + +#define TASK_ON_HOLD 0 +#define TASK_DONE 1 +#define TASK_WAITING_HANDLE 2 +#define TASK_WAITING_TIMEOUT 3 + +class Task : public Base { + public: + Task(); + virtual ~Task(); + virtual int Do(); + int Run(); + int GetState(); + protected: + + private: + int state; +}; + #else #error This only works with a C++ compiler #endif diff --git a/include/Variables.h b/include/Variables.h index ffaf98e..bbd2916 100644 --- a/include/Variables.h +++ b/include/Variables.h @@ -3,9 +3,9 @@ #ifdef __cplusplus #include <vector> -#include "Exceptions.h" #include "String.h" #include "Handle.h" +#include "Exceptions.h" /* * Cette classe nous sert a gérer les variables transportées par les formulaires. |