diff options
author | pixel <pixel> | 2004-11-27 21:46:02 +0000 |
---|---|---|
committer | pixel <pixel> | 2004-11-27 21:46:02 +0000 |
commit | ae2779e504ca5ae11a87e047b4536a5f428cce4d (patch) | |
tree | 19604ce1873e9cc98be9b840b894cb7eae341532 /include | |
parent | 583964f9f8e954eb57b31663065c5b9e833d045e (diff) |
Large dos2unix commit...
Diffstat (limited to 'include')
34 files changed, 2479 insertions, 2479 deletions
diff --git a/include/Action.h b/include/Action.h index 542a6b6..2a4c75a 100644 --- a/include/Action.h +++ b/include/Action.h @@ -1,32 +1,32 @@ -#ifndef __ACTION_H__
-#define __ACTION_H__
-
-#include <Task.h>
-#include <Handle.h>
-#include <Variables.h>
-#include <Exceptions.h>
-
-class Action : public Base {
- public:
- Action(const String & = "");
- virtual ~Action();
- Action * Look4URL(const String &);
- virtual Task * Do(Variables *, Variables *, Handle *) = 0;
- virtual void SendHead(Handle *);
- virtual void SendFoot(Handle *);
- virtual void ShowButton(Handle *, const String & = " Ok ", const String & = "start");
- virtual String GetTitle(void) = 0;
- String GetURL(void);
- void CleanUp(void);
-
- protected:
- void Accessed(void);
-
- private:
- static Action * start;
- Action * next, * prev;
- String URL;
- bool hastoclean, accessed;
-};
-
-#endif
+#ifndef __ACTION_H__ +#define __ACTION_H__ + +#include <Task.h> +#include <Handle.h> +#include <Variables.h> +#include <Exceptions.h> + +class Action : public Base { + public: + Action(const String & = ""); + virtual ~Action(); + Action * Look4URL(const String &); + virtual Task * Do(Variables *, Variables *, Handle *) = 0; + virtual void SendHead(Handle *); + virtual void SendFoot(Handle *); + virtual void ShowButton(Handle *, const String & = " Ok ", const String & = "start"); + virtual String GetTitle(void) = 0; + String GetURL(void); + void CleanUp(void); + + protected: + void Accessed(void); + + private: + static Action * start; + Action * next, * prev; + String URL; + bool hastoclean, accessed; +}; + +#endif diff --git a/include/BLua.h b/include/BLua.h index 52918ee..e2fc852 100644 --- a/include/BLua.h +++ b/include/BLua.h @@ -1,376 +1,376 @@ -/*
- * Baltisot
- * Copyright (C) 1999-2003 Nicolas "Pixel" Noble
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-/* $Id: BLua.h,v 1.18 2004-11-27 21:01:20 pixel Exp $ */
-
-#ifndef __BLUA_H__
-#define __BLUA_H__
-
-struct lua_State;
-
-extern "C" {
- void do_lua_lock(lua_State *);
- void do_lua_unlock(lua_State *);
-}
-
-#define lua_lock(L) do_lua_lock(L)
-#define lua_unlock(L) do_lua_unlock(L)
-
-#include <lua.h>
-#include <map>
-#include <Exceptions.h>
-#include <Handle.h>
-
-class Lua : public Base {
- public:
- Lua();
- Lua(const Lua &) throw (GeneralException);
- virtual ~Lua();
- void open_base();
- void open_table();
- void open_io();
- void open_string();
- void open_math();
- void open_debug();
- void open_dir();
- void declarefunc(const String &, lua_CFunction, int = LUA_GLOBALSINDEX);
- void call(const String &, int = LUA_GLOBALSINDEX, int = 0, int = 0);
- void call(int = 0, int = 0);
- void push();
- void push(lua_Number);
- void push(const String &);
- void push(bool);
- void push(char *, int size = -1);
- void push(void *);
- void push(lua_CFunction, int = 0);
- void pop(int = 1);
- void newtable();
- void * newuser(size_t);
- void settable(int = -3, bool raw = false);
- void gettable(int = -2, bool raw = false);
- void setvar();
- int gettop();
- void error(const String &);
- int type(int = -1);
- bool isnil(int = -1);
- bool isboolean(int = -1);
- bool isnumber(int = -1);
- bool isstring(int = -1);
- bool istable(int = -1);
- bool isfunction(int = -1);
- bool iscfunction(int = -1);
- bool isuserdata(int = -1);
- bool islightuserdata(int = -1);
- bool toboolean(int = -1);
- lua_Number tonumber(int = -1);
- String tostring(int = -1);
- lua_CFunction tocfunction(int = -1);
- void * touserdata(int = -1);
- Lua * tothread(int = -1);
- void load(Handle *, bool docall = true) throw (GeneralException);
- void dump(Handle *, bool strip = true);
- Lua * thread();
- int yield(int nargs = 0);
- int resume(int nresults = 0);
- static Lua * find(lua_State *) throw (GeneralException);
- void showerror();
- int getmetatable(int = -1);
- int setmetatable(int = -2);
- int sethook(lua_Hook func, int mask, int count);
-
- void do_break();
-
- virtual void lock() {}
- virtual void unlock() {}
- private:
- Lua(lua_State *);
- lua_State * L;
- static std::map<lua_State *, Lua *> lualist;
-};
-
-class LuaObject : public Base {
- public:
- LuaObject() : wantdestruct(false), pushed(false) {}
- virtual void push(Lua *) throw (GeneralException);
- static void * getme(Lua *, int = 1);
- void pushdestruct(Lua *) throw (GeneralException);
- protected:
- virtual void pushmembers(Lua *) = 0;
- void pushme(Lua *, void *, bool = true);
- static void pushit(Lua *, const String &, lua_CFunction);
- static void pushmeta(Lua *, const String &, lua_CFunction);
- bool wantdestruct, pushed;
-};
-
-class LuaException : public GeneralException {
- public:
- LuaException(String);
- protected:
- LuaException();
-};
-
-enum Lua_types_t {
- LUA_OBJECT = 0x01,
- LUA_TABLE = 0x02,
- LUA_BOOLEAN = 0x04,
- LUA_NUMBER = 0x08,
- LUA_STRING = 0x10,
- LUA_FUNCTION = 0x20,
- LUA_NIL = 0x40,
- LUA_ANY = 0x7f,
-};
-
-#define MAX_TYPE 7
-
-#define MAXARGS 32
-
-struct lua_functypes_t {
- int number;
- char * name;
- int minargs, maxargs;
- int argtypes[MAXARGS];
-};
-
-#define DECLARE_METHOD(classname, enumvar) static int method_##enumvar(lua_State * L) { \
- return LuaHelpers<classname>::method_multiplex( \
- enumvar, \
- L, \
- sLua_##classname::classname##_proceed, \
- 0, \
- classname##_methods, \
- true); \
- }
-
-#define DECLARE_FUNCTION(classname, enumvar) static int function_##enumvar(lua_State * L) { \
- return LuaHelpers<classname>::method_multiplex( \
- enumvar, \
- L, \
- 0, \
- sLua_##classname::classname##_proceed_statics, \
- classname##_functions, \
- false); \
- }
-
-#define PUSH_METHOD(classname, enumvar) pushit( \
- L, \
- classname##_methods[enumvar].name, \
- sLua_##classname::method_##enumvar)
-
-#define PUSH_METAMETHOD(classname, enumvar) pushmeta( \
- L, \
- String("__") + classname##_methods[enumvar].name, \
- sLua_##classname::method_##enumvar)
-
-#define PUSH_FUNCTION(classname, enumvar) L->declarefunc( \
- classname##_functions[enumvar].name, \
- sLua_##classname::function_##enumvar)
-
-
-#define CHECK_METHODS(classname) { \
- int i = 0; \
- while (classname##_methods[i].number != -1) { \
- if (i != classname##_methods[i].number) { \
- throw GeneralException("Datas of " #classname "_methods inconsistants!"); \
- } \
- i++; \
- } \
-}
-
-#define CHECK_FUNCTIONS(classname) { \
- int i = 0; \
- while (classname##_functions[i].number != -1) { \
- if (i != classname##_functions[i].number) { \
- throw GeneralException("Datas of " #classname "_functions inconsistants!"); \
- } \
- i++; \
- } \
-}
-
-#include <typeinfo>
-
-template <class T>
-class LuaHelpers : public Base {
- public:
- static int method_multiplex(int caller, lua_State * _L, int (*proceed)(Lua * L, int n, T * obj, int caller), int (*proceed_static)(Lua * L, int n, int caller), lua_functypes_t * tab, bool method) {
- Lua * L = Lua::find(_L);
- int add = method ? 1 : 0;
- int n = L->gettop() - add;
- T * obj = 0;
- int i, j, mask;
- bool invalid = false, arg_valid;
-
- if (method)
- obj = (T *) LuaObject::getme(L);
-
- if ((n < tab[caller].minargs) || (n > tab[caller].maxargs)) {
- invalid = true;
- } else {
- for (i = 0; i < tab[caller].maxargs && !invalid; i++) {
- if (n >= (i + 1)) {
- arg_valid = false;
- for (j = 0; j < MAX_TYPE && !arg_valid; j++) {
- mask = 1 << j;
- if (tab[caller].argtypes[i] & mask) {
- switch(mask) {
- case LUA_OBJECT:
- if (L->istable(i + 1 + add)) {
- L->push("__obj");
- L->gettable(i + 1 + add);
- arg_valid = L->isuserdata();
- L->pop();
- } else {
- arg_valid = L->isnil(i + 1 + add);
- }
- break;
- case LUA_TABLE:
- arg_valid = L->istable(i + 1 + add);
- break;
- case LUA_BOOLEAN:
- arg_valid = L->isboolean(i + 1 + add);
- break;
- case LUA_NUMBER:
- arg_valid = L->isnumber(i + 1 + add);
- break;
- case LUA_STRING:
- arg_valid = L->isstring(i + 1 + add);
- break;
- case LUA_FUNCTION:
- arg_valid = L->isfunction(i + 1 + add);
- break;
- case LUA_NIL:
- arg_valid = L->isnil(i + 1 + add);
- break;
- }
- }
- }
- invalid = !arg_valid;
- }
- }
- }
-
- if (invalid) {
- if (method) {
- L->error(String("Invalid arguments to method `") + typeid(T).name() + "::" + tab[caller].name + "'");
- } else {
- L->error(String("Invalid arguments to function `") + typeid(T).name() + "::" + tab[caller].name + "'");
- }
- }
-
- if (method) {
- return proceed(L, n, obj, caller);
- } else {
- return proceed_static(L, n, caller);
- }
- }
-};
-
-
- /*******************************\
-|** Let's have a sample of use **|
- \*******************************/
-
-#ifdef THIS_IS_A_SAMPLE_WHICH_DOES_NOT_COMPILE
-Luacdfile::Luacdfile(cdfile * h) : LuaHandle(h) { }
-
-enum cdfile_methods_t {
- CDFILE_XXX = 0,
- CDFILE_YYY
-};
-
-enum cdfile_functions_t {
- CDFILE_NEWCDFILE = 0,
-};
-
-struct lua_functypes_t cdutils_methods[] = {
- { CDFILE_XXX, "xxx", 1, 1, {LUA_OBJECT} },
- { CDFILE_YYY, "yyy", 0, 2, {LUA_NUMBER, LUA_NUMBER} },
- { -1, 0, 0, 0, 0 }
-};
-
-struct lua_functypes_t cdfile_functions[] = {
- { CDFILE_NEWCDFILE, "cdfile", 1, 4, {LUA_OBJECT, LUA_ANY, LUA_NUMBER, LUA_NUMBER} },
- { -1, 0, 0, 0, 0 }
-};
-
-class sLua_cdfile : public Base {
- public:
- static int newcdfile(lua_State * L);
- DECLARE_METHOD(cdfile, CDFILE_XXX);
- DECLARE_METHOD(cdfile, CDFILE_YYY);
- DECLARE_FUNCTION(cdfile, CDFILE_NEWCDFILE);
- private:
- static int cdfile_proceed(Lua * L, int n, cdfile * obj, int caller);
- static int cdfile_proceed_statics(Lua * L, int n, int caller);
-};
-
-void Luacdfile::pushmembers(Lua * L) {
- {
- LuaHandle::pushmembers(L);
- or
- pushme(L, SomeObject);
- }
- PUSH_METHOD(cdfile, CDFILE_XXX);
- PUSH_METHOD(cdfile, CDFILE_YYY);
-}
-
-void Luacdfile::pushstatics(Lua * L) {
- CHECK_METHODS(cdfile);
- CHECK_FUNCTIONS(cdfile);
-
- PUSH_FUNCTION(cdfile, CDFILE_NEWCDFILE);
-}
-
-int sLua_cdfile::cdfile_proceed(Lua * L, int n, cdfile * cdfile, int caller) {
- int r = 0;
- SomeObj * obj;
- int arg1 = DEFAULT1, arg2 = DEFAULT2;
-
- switch(caller) {
- case CDFILE_XXX:
- obj = (SomeObj *) LuaObject::getme(L, 2);
- cdfile->xxx(obj);
- break;
- case CDFILE_YYY:
- if (n >= 1)
- arg1 = L->tonumber(2);
- if (n >= 2)
- arg2 = L->tonumber(3);
- L->push((lua_Number) cdfile->yyy(arg1, arg2));
- r = 1;
- break;
- }
-
- return r;
-}
-
-int sLua_cdfile::cdfile_proceed_statics(Lua * L, int n, int caller) {
- int r = 0;
-
- switch(caller) {
- case CDFILE_NEWCDFILE:
- /****TODO****/
- break;
- }
-
- return r;
-}
-
-#endif
-
-#endif
+/* + * Baltisot + * Copyright (C) 1999-2003 Nicolas "Pixel" Noble + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* $Id: BLua.h,v 1.19 2004-11-27 21:46:02 pixel Exp $ */ + +#ifndef __BLUA_H__ +#define __BLUA_H__ + +struct lua_State; + +extern "C" { + void do_lua_lock(lua_State *); + void do_lua_unlock(lua_State *); +} + +#define lua_lock(L) do_lua_lock(L) +#define lua_unlock(L) do_lua_unlock(L) + +#include <lua.h> +#include <map> +#include <Exceptions.h> +#include <Handle.h> + +class Lua : public Base { + public: + Lua(); + Lua(const Lua &) throw (GeneralException); + virtual ~Lua(); + void open_base(); + void open_table(); + void open_io(); + void open_string(); + void open_math(); + void open_debug(); + void open_dir(); + void declarefunc(const String &, lua_CFunction, int = LUA_GLOBALSINDEX); + void call(const String &, int = LUA_GLOBALSINDEX, int = 0, int = 0); + void call(int = 0, int = 0); + void push(); + void push(lua_Number); + void push(const String &); + void push(bool); + void push(char *, int size = -1); + void push(void *); + void push(lua_CFunction, int = 0); + void pop(int = 1); + void newtable(); + void * newuser(size_t); + void settable(int = -3, bool raw = false); + void gettable(int = -2, bool raw = false); + void setvar(); + int gettop(); + void error(const String &); + int type(int = -1); + bool isnil(int = -1); + bool isboolean(int = -1); + bool isnumber(int = -1); + bool isstring(int = -1); + bool istable(int = -1); + bool isfunction(int = -1); + bool iscfunction(int = -1); + bool isuserdata(int = -1); + bool islightuserdata(int = -1); + bool toboolean(int = -1); + lua_Number tonumber(int = -1); + String tostring(int = -1); + lua_CFunction tocfunction(int = -1); + void * touserdata(int = -1); + Lua * tothread(int = -1); + void load(Handle *, bool docall = true) throw (GeneralException); + void dump(Handle *, bool strip = true); + Lua * thread(); + int yield(int nargs = 0); + int resume(int nresults = 0); + static Lua * find(lua_State *) throw (GeneralException); + void showerror(); + int getmetatable(int = -1); + int setmetatable(int = -2); + int sethook(lua_Hook func, int mask, int count); + + void do_break(); + + virtual void lock() {} + virtual void unlock() {} + private: + Lua(lua_State *); + lua_State * L; + static std::map<lua_State *, Lua *> lualist; +}; + +class LuaObject : public Base { + public: + LuaObject() : wantdestruct(false), pushed(false) {} + virtual void push(Lua *) throw (GeneralException); + static void * getme(Lua *, int = 1); + void pushdestruct(Lua *) throw (GeneralException); + protected: + virtual void pushmembers(Lua *) = 0; + void pushme(Lua *, void *, bool = true); + static void pushit(Lua *, const String &, lua_CFunction); + static void pushmeta(Lua *, const String &, lua_CFunction); + bool wantdestruct, pushed; +}; + +class LuaException : public GeneralException { + public: + LuaException(String); + protected: + LuaException(); +}; + +enum Lua_types_t { + LUA_OBJECT = 0x01, + LUA_TABLE = 0x02, + LUA_BOOLEAN = 0x04, + LUA_NUMBER = 0x08, + LUA_STRING = 0x10, + LUA_FUNCTION = 0x20, + LUA_NIL = 0x40, + LUA_ANY = 0x7f, +}; + +#define MAX_TYPE 7 + +#define MAXARGS 32 + +struct lua_functypes_t { + int number; + char * name; + int minargs, maxargs; + int argtypes[MAXARGS]; +}; + +#define DECLARE_METHOD(classname, enumvar) static int method_##enumvar(lua_State * L) { \ + return LuaHelpers<classname>::method_multiplex( \ + enumvar, \ + L, \ + sLua_##classname::classname##_proceed, \ + 0, \ + classname##_methods, \ + true); \ + } + +#define DECLARE_FUNCTION(classname, enumvar) static int function_##enumvar(lua_State * L) { \ + return LuaHelpers<classname>::method_multiplex( \ + enumvar, \ + L, \ + 0, \ + sLua_##classname::classname##_proceed_statics, \ + classname##_functions, \ + false); \ + } + +#define PUSH_METHOD(classname, enumvar) pushit( \ + L, \ + classname##_methods[enumvar].name, \ + sLua_##classname::method_##enumvar) + +#define PUSH_METAMETHOD(classname, enumvar) pushmeta( \ + L, \ + String("__") + classname##_methods[enumvar].name, \ + sLua_##classname::method_##enumvar) + +#define PUSH_FUNCTION(classname, enumvar) L->declarefunc( \ + classname##_functions[enumvar].name, \ + sLua_##classname::function_##enumvar) + + +#define CHECK_METHODS(classname) { \ + int i = 0; \ + while (classname##_methods[i].number != -1) { \ + if (i != classname##_methods[i].number) { \ + throw GeneralException("Datas of " #classname "_methods inconsistants!"); \ + } \ + i++; \ + } \ +} + +#define CHECK_FUNCTIONS(classname) { \ + int i = 0; \ + while (classname##_functions[i].number != -1) { \ + if (i != classname##_functions[i].number) { \ + throw GeneralException("Datas of " #classname "_functions inconsistants!"); \ + } \ + i++; \ + } \ +} + +#include <typeinfo> + +template <class T> +class LuaHelpers : public Base { + public: + static int method_multiplex(int caller, lua_State * _L, int (*proceed)(Lua * L, int n, T * obj, int caller), int (*proceed_static)(Lua * L, int n, int caller), lua_functypes_t * tab, bool method) { + Lua * L = Lua::find(_L); + int add = method ? 1 : 0; + int n = L->gettop() - add; + T * obj = 0; + int i, j, mask; + bool invalid = false, arg_valid; + + if (method) + obj = (T *) LuaObject::getme(L); + + if ((n < tab[caller].minargs) || (n > tab[caller].maxargs)) { + invalid = true; + } else { + for (i = 0; i < tab[caller].maxargs && !invalid; i++) { + if (n >= (i + 1)) { + arg_valid = false; + for (j = 0; j < MAX_TYPE && !arg_valid; j++) { + mask = 1 << j; + if (tab[caller].argtypes[i] & mask) { + switch(mask) { + case LUA_OBJECT: + if (L->istable(i + 1 + add)) { + L->push("__obj"); + L->gettable(i + 1 + add); + arg_valid = L->isuserdata(); + L->pop(); + } else { + arg_valid = L->isnil(i + 1 + add); + } + break; + case LUA_TABLE: + arg_valid = L->istable(i + 1 + add); + break; + case LUA_BOOLEAN: + arg_valid = L->isboolean(i + 1 + add); + break; + case LUA_NUMBER: + arg_valid = L->isnumber(i + 1 + add); + break; + case LUA_STRING: + arg_valid = L->isstring(i + 1 + add); + break; + case LUA_FUNCTION: + arg_valid = L->isfunction(i + 1 + add); + break; + case LUA_NIL: + arg_valid = L->isnil(i + 1 + add); + break; + } + } + } + invalid = !arg_valid; + } + } + } + + if (invalid) { + if (method) { + L->error(String("Invalid arguments to method `") + typeid(T).name() + "::" + tab[caller].name + "'"); + } else { + L->error(String("Invalid arguments to function `") + typeid(T).name() + "::" + tab[caller].name + "'"); + } + } + + if (method) { + return proceed(L, n, obj, caller); + } else { + return proceed_static(L, n, caller); + } + } +}; + + + /*******************************\ +|** Let's have a sample of use **| + \*******************************/ + +#ifdef THIS_IS_A_SAMPLE_WHICH_DOES_NOT_COMPILE +Luacdfile::Luacdfile(cdfile * h) : LuaHandle(h) { } + +enum cdfile_methods_t { + CDFILE_XXX = 0, + CDFILE_YYY +}; + +enum cdfile_functions_t { + CDFILE_NEWCDFILE = 0, +}; + +struct lua_functypes_t cdutils_methods[] = { + { CDFILE_XXX, "xxx", 1, 1, {LUA_OBJECT} }, + { CDFILE_YYY, "yyy", 0, 2, {LUA_NUMBER, LUA_NUMBER} }, + { -1, 0, 0, 0, 0 } +}; + +struct lua_functypes_t cdfile_functions[] = { + { CDFILE_NEWCDFILE, "cdfile", 1, 4, {LUA_OBJECT, LUA_ANY, LUA_NUMBER, LUA_NUMBER} }, + { -1, 0, 0, 0, 0 } +}; + +class sLua_cdfile : public Base { + public: + static int newcdfile(lua_State * L); + DECLARE_METHOD(cdfile, CDFILE_XXX); + DECLARE_METHOD(cdfile, CDFILE_YYY); + DECLARE_FUNCTION(cdfile, CDFILE_NEWCDFILE); + private: + static int cdfile_proceed(Lua * L, int n, cdfile * obj, int caller); + static int cdfile_proceed_statics(Lua * L, int n, int caller); +}; + +void Luacdfile::pushmembers(Lua * L) { + { + LuaHandle::pushmembers(L); + or + pushme(L, SomeObject); + } + PUSH_METHOD(cdfile, CDFILE_XXX); + PUSH_METHOD(cdfile, CDFILE_YYY); +} + +void Luacdfile::pushstatics(Lua * L) { + CHECK_METHODS(cdfile); + CHECK_FUNCTIONS(cdfile); + + PUSH_FUNCTION(cdfile, CDFILE_NEWCDFILE); +} + +int sLua_cdfile::cdfile_proceed(Lua * L, int n, cdfile * cdfile, int caller) { + int r = 0; + SomeObj * obj; + int arg1 = DEFAULT1, arg2 = DEFAULT2; + + switch(caller) { + case CDFILE_XXX: + obj = (SomeObj *) LuaObject::getme(L, 2); + cdfile->xxx(obj); + break; + case CDFILE_YYY: + if (n >= 1) + arg1 = L->tonumber(2); + if (n >= 2) + arg2 = L->tonumber(3); + L->push((lua_Number) cdfile->yyy(arg1, arg2)); + r = 1; + break; + } + + return r; +} + +int sLua_cdfile::cdfile_proceed_statics(Lua * L, int n, int caller) { + int r = 0; + + switch(caller) { + case CDFILE_NEWCDFILE: + /****TODO****/ + break; + } + + return r; +} + +#endif + +#endif diff --git a/include/BString.h b/include/BString.h index 13dd33b..2809822 100644 --- a/include/BString.h +++ b/include/BString.h @@ -1,101 +1,101 @@ -/*
- * Baltisot
- * Copyright (C) 1999-2003 Nicolas "Pixel" Noble
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-/* $Id: BString.h,v 1.11 2004-11-27 21:43:48 pixel Exp $ */
-
-#ifndef __STRING_H__
-#define __STRING_H__
-
-#include <string.h>
-#include <stdarg.h>
-#include <iostream>
-#include <string>
-#include <Exceptions.h>
-#include <generic.h>
-
-struct ugly_string {
- const char * p;
-};
-
-class String : public Base {
- public:
- String(const String &);
- String(const char * = "");
- String(char);
- String(int);
- String(unsigned int);
- String(int64);
- String(Uint64);
- String(double);
- ~String();
- const char * set(const char *, va_list);
- const char * set(const char *, ...);
- const char * set(const ugly_string &, ...);
- int scanf(const char *, ...) const;
- int scanf(const ugly_string &, ...) const;
- const char * to_charp(size_t = 0, ssize_t = -1) const;
- String extract(size_t = 0, ssize_t = -1) const;
- char * strdup(size_t = 0, ssize_t = -1) const;
- int to_int() const;
- double to_double() const;
- String to_sqldate() const;
- String to_sqltime() const;
- String from_sqldate() const;
- String from_sqltime() const;
- double datedif(const String &) const;
- bool is_date() const;
- bool is_number() const;
- bool is_float() const;
- bool is_time() const;
- size_t strlen() const;
- ssize_t strchr(char, size_t = 0) const;
- ssize_t strrchr(char) const;
- ssize_t strstr(const String &) const;
- int strchrcnt(char) const;
- String ltrim() const;
- String rtrim() const;
- String trim() const;
- String & operator=(const String &);
- String operator+(const String &) const;
- String & operator+=(const String &);
- bool operator!=(const String &) const;
- bool operator==(const String &) const;
- bool operator<=(const String &) const;
- bool operator>=(const String &) const;
- bool operator<(const String &) const;
- bool operator>(const String &) const;
- char operator[](size_t i) const;
- char & operator[](size_t i);
- operator ugly_string() const;
- String & toupper();
- String & tolower();
-
- private:
- String(int hs, char *);
- static char t[];
- char * str;
- size_t siz;
-};
-
-std::ostream & operator<<(std::ostream &, const String &);
-std::istream & operator>>(std::istream &, String &);
-
-String operator+(const char *, const String &);
-
-#endif
+/* + * Baltisot + * Copyright (C) 1999-2003 Nicolas "Pixel" Noble + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* $Id: BString.h,v 1.12 2004-11-27 21:46:02 pixel Exp $ */ + +#ifndef __STRING_H__ +#define __STRING_H__ + +#include <string.h> +#include <stdarg.h> +#include <iostream> +#include <string> +#include <Exceptions.h> +#include <generic.h> + +struct ugly_string { + const char * p; +}; + +class String : public Base { + public: + String(const String &); + String(const char * = ""); + String(char); + String(int); + String(unsigned int); + String(int64); + String(Uint64); + String(double); + ~String(); + const char * set(const char *, va_list); + const char * set(const char *, ...); + const char * set(const ugly_string &, ...); + int scanf(const char *, ...) const; + int scanf(const ugly_string &, ...) const; + const char * to_charp(size_t = 0, ssize_t = -1) const; + String extract(size_t = 0, ssize_t = -1) const; + char * strdup(size_t = 0, ssize_t = -1) const; + int to_int() const; + double to_double() const; + String to_sqldate() const; + String to_sqltime() const; + String from_sqldate() const; + String from_sqltime() const; + double datedif(const String &) const; + bool is_date() const; + bool is_number() const; + bool is_float() const; + bool is_time() const; + size_t strlen() const; + ssize_t strchr(char, size_t = 0) const; + ssize_t strrchr(char) const; + ssize_t strstr(const String &) const; + int strchrcnt(char) const; + String ltrim() const; + String rtrim() const; + String trim() const; + String & operator=(const String &); + String operator+(const String &) const; + String & operator+=(const String &); + bool operator!=(const String &) const; + bool operator==(const String &) const; + bool operator<=(const String &) const; + bool operator>=(const String &) const; + bool operator<(const String &) const; + bool operator>(const String &) const; + char operator[](size_t i) const; + char & operator[](size_t i); + operator ugly_string() const; + String & toupper(); + String & tolower(); + + private: + String(int hs, char *); + static char t[]; + char * str; + size_t siz; +}; + +std::ostream & operator<<(std::ostream &, const String &); +std::istream & operator>>(std::istream &, String &); + +String operator+(const char *, const String &); + +#endif diff --git a/include/Buffer.h b/include/Buffer.h index 41e8da3..dceac94 100644 --- a/include/Buffer.h +++ b/include/Buffer.h @@ -1,61 +1,61 @@ -/*
- * Baltisot
- * Copyright (C) 1999-2003 Nicolas "Pixel" Noble
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-/* $Id: Buffer.h,v 1.18 2004-11-27 21:43:48 pixel Exp $ */
-
-#ifndef __BUFFER_H__
-#define __BUFFER_H__
-
-#include <zlib.h>
-#include <Exceptions.h>
-#include <Handle.h>
-
-#ifndef realloc_threshold
-#define realloc_threshold 256
-#endif
-
-class Buffer : public Handle {
- public:
- Buffer(bool seekable = false);
- Buffer(const Buffer &);
- virtual ~Buffer();
- virtual ssize_t write(const void *buf, size_t count) throw(GeneralException);
- virtual ssize_t read(void *buf, size_t count) throw (GeneralException);
- virtual bool CanRead() const;
- virtual bool CanWrite() const;
- virtual String GetName() const;
- virtual Buffer operator=(const Buffer &);
- virtual bool CanWatch() const;
- virtual ssize_t GetSize() const;
- virtual bool CanSeek() const;
- virtual off_t seek(off_t, int = SEEK_SET) throw (GeneralException);
- virtual off_t tell() const;
- Byte operator[](size_t) const;
- Byte & operator[](size_t);
- off_t wseek(off_t, int = SEEK_SET) throw (GeneralException);
- off_t wtell() const;
- void reset();
-
- private:
- Byte * buffer, zero;
- size_t realsiz, bufsiz, ptr, wptr;
- bool seekable;
-};
-
-#endif
+/* + * Baltisot + * Copyright (C) 1999-2003 Nicolas "Pixel" Noble + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* $Id: Buffer.h,v 1.19 2004-11-27 21:46:02 pixel Exp $ */ + +#ifndef __BUFFER_H__ +#define __BUFFER_H__ + +#include <zlib.h> +#include <Exceptions.h> +#include <Handle.h> + +#ifndef realloc_threshold +#define realloc_threshold 256 +#endif + +class Buffer : public Handle { + public: + Buffer(bool seekable = false); + Buffer(const Buffer &); + virtual ~Buffer(); + virtual ssize_t write(const void *buf, size_t count) throw(GeneralException); + virtual ssize_t read(void *buf, size_t count) throw (GeneralException); + virtual bool CanRead() const; + virtual bool CanWrite() const; + virtual String GetName() const; + virtual Buffer operator=(const Buffer &); + virtual bool CanWatch() const; + virtual ssize_t GetSize() const; + virtual bool CanSeek() const; + virtual off_t seek(off_t, int = SEEK_SET) throw (GeneralException); + virtual off_t tell() const; + Byte operator[](size_t) const; + Byte & operator[](size_t); + off_t wseek(off_t, int = SEEK_SET) throw (GeneralException); + off_t wtell() const; + void reset(); + + private: + Byte * buffer, zero; + size_t realsiz, bufsiz, ptr, wptr; + bool seekable; +}; + +#endif diff --git a/include/Color.h b/include/Color.h index d4807ed..5b2ec06 100644 --- a/include/Color.h +++ b/include/Color.h @@ -1,320 +1,320 @@ -#ifndef __COLOR_H__
-#define __COLOR_H__
-
-struct Color {
- Color() : R(255), G(255), B(255), A(255) { }
- Color(unsigned char aR, unsigned char aG, unsigned char aB, unsigned char aA = 255) :
- R(aR), G(aG), B(aB), A(aA) { }
- Color(const Color & c) : R(c.R), G(c.G), B(c.B), A(c.A) { }
- bool operator==(const Color & c) const {
- return (R == c.R) && (G == c.G) && (B == c.B) && (A == c.A);
- }
- unsigned char R, G, B, A;
-};
-
-/*
-
-From http://www.spacetoday.org/BoilerRoom/Colors.html :
-
-F0F8FF aliceblue
-FAEBD7 antiquewhite
-00FFFF aqua
-7FFFD4 aquamarine
-F0FFFF azure
-F5F5DC beige
-FFE4C4 bisque
-000000 black
-FFEBCD blanchedalmond
-0000FF blue
-8A2BE2 blueviolet
-A52A2A brown
-DEB887 burlywood
-5F9EA0 cadetblue
-7FFF00 chartreuse
-D2691E chocolate
-FF7F50 coral
-6495ED cornflowerblue
-FFF8DC cornsilk
-DC143C crimson
-00FFFF cyan
-00008B darkblue
-008B8B darkcyan
-B8860B darkgoldenrod
-A9A9A9 darkgray
-006400 darkgreen
-BDB76B darkkhaki
-8B008B darkmagenta
-556B2F darkolivegreen
-FF8C00 darkorange
-9932CC darkorchid
-8B0000 darkred
-E9967A darksalmon
-8FBC8F darkseagreen
-483D8B darkslateblue
-2F4F4F darkslategray
-00CED1 darkturquoise
-9400D3 darkviolet
-FF1493 deeppink
-00BFFF deepskyblue
-696969 dimgray
-1E90FF dodgerblue
-B22222 firebrick
-FFFAF0 floralwhite
-228B22 forestgreen
-FF00FF fuchsia
-DCDCDC gainsboro
-F8F8FF ghostwhite
-FFD700 gold
-DAA520 goldenrod
-808080 gray
-008000 green
-ADFF2F greenyellow
-F0FFF0 honeydew
-FF69B4 hotpink
-CD5C5C indianred
-4B0082 indigo
-FFFFF0 ivory
-F0E68C khaki
-E6E6FA lavender
-FFF0F5 lavenderblush
-7CFC00 lawngreen
-FFFACD lemonchiffon
-ADD8E6 lightblue
-F08080 lightcoral
-E0FFFF lightcyan
-FAFAD2 lightgoldenrodyellow
-90EE90 lightgreen
-D3D3D3 lightgrey
-FFB6C1 lightpink
-FFA07A lightsalmon
-20B2AA lightseagreen
-87CEFA lightskyblue
-778899 lightslategray
-B0C4DE lightsteelblue
-FFFFE0 lightyellow
-00FF00 lime
-32CD32 limegreen
-FAF0E6 linen
-FF00FF magenta
-800000 maroon
-66CDAA mediumaquamarine
-0000CD mediumblue
-BA55D3 mediumorchid
-9370DB mediumpurple
-3CB371 mediumseagreen
-7B68EE mediumslateblue
-00FA9A mediumspringgreen
-48D1CC mediumturquoise
-C71585 mediumvioletred
-191970 midnightblue
-F5FFFA mintcream
-FFE4E1 mistyrose
-FFE4B5 moccasin
-FFDEAD navajowhite
-000080 navy
-FDF5E6 oldlace
-808000 olive
-6B8E23 olivedrab
-FFA500 orange
-FF4500 orangered
-DA70D6 orchid
-EEE8AA palegoldenrod
-98FB98 palegreen
-AFEEEE paleturquoise
-DB7093 palevioletred
-FFEFD5 papayawhip
-FFDAB9 peachpuff
-CD853F peru
-FFC0CB pink
-DDA0DD plum
-B0E0E6 powderblue
-800080 purple
-FF0000 red
-BC8F8F rosybrown
-4169E1 royalblue
-8B4513 saddlebrown
-FA8072 salmon
-F4A460 sandybrown
-2E8B57 seagreen
-FFF5EE seashell
-A0522D sienna
-C0C0C0 silver
-87CEEB skyblue
-6A5ACD slateblue
-708090 slategray
-FFFAFA snow
-00FF7F springgreen
-4682B4 steelblue
-D2B48C tan
-008080 teal
-D8BFD8 thistle
-FF6347 tomato
-40E0D0 turquoise
-EE82EE violet
-F5DEB3 wheat
-FFFFFF white
-F5F5F5 whitesmoke
-FFFF00 yellow
-9ACD32 yellowgreen
-
-*/
-
-#define ALICEBLUE (Color(0xf0, 0xf8, 0xff))
-#define ANTIQUEWHITE (Color(0xfa, 0xeb, 0xd7))
-#define AQUA (Color(0x00, 0xff, 0xff))
-#define AQUAMARINE (Color(0x7f, 0xff, 0xd4))
-#define AZURE (Color(0xf0, 0xff, 0xff))
-#define BEIGE (Color(0xf5, 0xf5, 0xdc))
-#define BISQUE (Color(0xff, 0xe4, 0xc4))
-#define BLACK (Color(0x00, 0x00, 0x00))
-#define BLANCHEDALMOND (Color(0xff, 0xeb, 0xcd))
-#define BLUE (Color(0x00, 0x00, 0xff))
-#define BLUEVIOLET (Color(0x8a, 0x2b, 0xe2))
-#define BROWN (Color(0xa5, 0x2a, 0x2a))
-#define BURLYWOOD (Color(0xde, 0xb8, 0x87))
-#define CADETBLUE (Color(0x5f, 0x9e, 0xa0))
-#define CHARTREUSE (Color(0x7f, 0xff, 0x00))
-#define CHOCOLATE (Color(0xd2, 0x69, 0x1e))
-#define CORAL (Color(0xff, 0x7f, 0x50))
-#define CORNFLOWERBLUE (Color(0x64, 0x95, 0xed))
-#define CORNSILK (Color(0xff, 0xf8, 0xdc))
-#define CRIMSON (Color(0xdc, 0x14, 0x3c))
-#define CYAN (Color(0x00, 0xff, 0xff))
-#define DARKBLUE (Color(0x00, 0x00, 0x8b))
-#define DARKCYAN (Color(0x00, 0x8b, 0x8b))
-#define DARKGOLDENROD (Color(0xb8, 0x86, 0x0b))
-#define DARKGRAY (Color(0xa9, 0xa9, 0xa9))
-#define DARKGREEN (Color(0x00, 0x64, 0x00))
-#define DARKKHAKI (Color(0xbd, 0xb7, 0x6b))
-#define DARKMAGENTA (Color(0x8b, 0x00, 0x8b))
-#define DARKOLIVEGREEN (Color(0x55, 0x6b, 0x2f))
-#define DARKORANGE (Color(0xff, 0x8c, 0x00))
-#define DARKORCHID (Color(0x99, 0x32, 0xcc))
-#define DARKRED (Color(0x8b, 0x00, 0x00))
-#define DARKSALMON (Color(0xe9, 0x96, 0x7a))
-#define DARKSEAGREEN (Color(0x8f, 0xbc, 0x8f))
-#define DARKSLATEBLUE (Color(0x48, 0x3d, 0x8b))
-#define DARKSLATEGRAY (Color(0x2f, 0x4f, 0x4f))
-#define DARKTURQUOISE (Color(0x00, 0xce, 0xd1))
-#define DARKVIOLET (Color(0x94, 0x00, 0xd3))
-#define DEEPPINK (Color(0xff, 0x14, 0x93))
-#define DEEPSKYBLUE (Color(0x00, 0xbf, 0xff))
-#define DIMGRAY (Color(0x69, 0x69, 0x69))
-#define DODGERBLUE (Color(0x1e, 0x90, 0xff))
-#define FIREBRICK (Color(0xb2, 0x22, 0x22))
-#define FLORALWHITE (Color(0xff, 0xfa, 0xf0))
-#define FORESTGREEN (Color(0x22, 0x8b, 0x22))
-#define FUCHSIA (Color(0xff, 0x00, 0xff))
-#define GAINSBORO (Color(0xdc, 0xdc, 0xdc))
-#define GHOSTWHITE (Color(0xf8, 0xf8, 0xff))
-#define GOLD (Color(0xff, 0xd7, 0x00))
-#define GOLDENROD (Color(0xda, 0xa5, 0x20))
-#define GRAY (Color(0x80, 0x80, 0x80))
-#define GREEN (Color(0x00, 0x80, 0x00))
-#define GREENYELLOW (Color(0xad, 0xff, 0x2f))
-#define HONEYDEW (Color(0xf0, 0xff, 0xf0))
-#define HOTPINK (Color(0xff, 0x69, 0xb4))
-#define INDIANRED (Color(0xcd, 0x5c, 0x5c))
-#define INDIGO (Color(0x4b, 0x00, 0x82))
-#define IVORY (Color(0xff, 0xff, 0xf0))
-#define KHAKI (Color(0xf0, 0xe6, 0x8c))
-#define LAVENDER (Color(0xe6, 0xe6, 0xfa))
-#define LAVENDERBLUSH (Color(0xff, 0xf0, 0xf5))
-#define LAWNGREEN (Color(0x7c, 0xfc, 0x00))
-#define LEMONCHIFFON (Color(0xff, 0xfa, 0xcd))
-#define LIGHTBLUE (Color(0xad, 0xd8, 0xe6))
-#define LIGHTCORAL (Color(0xf0, 0x80, 0x80))
-#define LIGHTCYAN (Color(0xe0, 0xff, 0xff))
-#define LIGHTGOLDENRODYELLOW (Color(0xfa, 0xfa, 0xd2))
-#define LIGHTGREEN (Color(0x90, 0xee, 0x90))
-#define LIGHTGREY (Color(0xd3, 0xd3, 0xd3))
-#define LIGHTPINK (Color(0xff, 0xb6, 0xc1))
-#define LIGHTSALMON (Color(0xff, 0xa0, 0x7a))
-#define LIGHTSEAGREEN (Color(0x20, 0xb2, 0xaa))
-#define LIGHTSKYBLUE (Color(0x87, 0xce, 0xfa))
-#define LIGHTSLATEGRAY (Color(0x77, 0x88, 0x99))
-#define LIGHTSTEELBLUE (Color(0xb0, 0xc4, 0xde))
-#define LIGHTYELLOW (Color(0xff, 0xff, 0xe0))
-#define LIME (Color(0x00, 0xff, 0x00))
-#define LIMEGREEN (Color(0x32, 0xcd, 0x32))
-#define LINEN (Color(0xfa, 0xf0, 0xe6))
-#define MAGENTA (Color(0xff, 0x00, 0xff))
-#define MAROON (Color(0x80, 0x00, 0x00))
-#define MEDIUMAQUAMARINE (Color(0x66, 0xcd, 0xaa))
-#define MEDIUMBLUE (Color(0x00, 0x00, 0xcd))
-#define MEDIUMORCHID (Color(0xba, 0x55, 0xd3))
-#define MEDIUMPURPLE (Color(0x93, 0x70, 0xdb))
-#define MEDIUMSEAGREEN (Color(0x3c, 0xb3, 0x71))
-#define MEDIUMSLATEBLUE (Color(0x7b, 0x68, 0xee))
-#define MEDIUMSPRINGGREEN (Color(0x00, 0xfa, 0x9a))
-#define MEDIUMTURQUOISE (Color(0x48, 0xd1, 0xcc))
-#define MEDIUMVIOLETRED (Color(0xc7, 0x15, 0x85))
-#define MIDNIGHTBLUE (Color(0x19, 0x19, 0x70))
-#define MINTCREAM (Color(0xf5, 0xff, 0xfa))
-#define MISTYROSE (Color(0xff, 0xe4, 0xe1))
-#define MOCCASIN (Color(0xff, 0xe4, 0xb5))
-#define NAVAJOWHITE (Color(0xff, 0xde, 0xad))
-#define NAVY (Color(0x00, 0x00, 0x80))
-#define OLDLACE (Color(0xfd, 0xf5, 0xe6))
-#define OLIVE (Color(0x80, 0x80, 0x00))
-#define OLIVEDRAB (Color(0x6b, 0x8e, 0x23))
-#define ORANGE (Color(0xff, 0xa5, 0x00))
-#define ORANGERED (Color(0xff, 0x45, 0x00))
-#define ORCHID (Color(0xda, 0x70, 0xd6))
-#define PALEGOLDENROD (Color(0xee, 0xe8, 0xaa))
-#define PALEGREEN (Color(0x98, 0xfb, 0x98))
-#define PALETURQUOISE (Color(0xaf, 0xee, 0xee))
-#define PALEVIOLETRED (Color(0xdb, 0x70, 0x93))
-#define PAPAYAWHIP (Color(0xff, 0xef, 0xd5))
-#define PEACHPUFF (Color(0xff, 0xda, 0xb9))
-#define PERU (Color(0xcd, 0x85, 0x3f))
-#define PINK (Color(0xff, 0xc0, 0xcb))
-#define PLUM (Color(0xdd, 0xa0, 0xdd))
-#define POWDERBLUE (Color(0xb0, 0xe0, 0xe6))
-#define PURPLE (Color(0x80, 0x00, 0x80))
-#define RED (Color(0xff, 0x00, 0x00))
-#define ROSYBROWN (Color(0xbc, 0x8f, 0x8f))
-#define ROYALBLUE (Color(0x41, 0x69, 0xe1))
-#define SADDLEBROWN (Color(0x8b, 0x45, 0x13))
-#define SALMON (Color(0xfa, 0x80, 0x72))
-#define SANDYBROWN (Color(0xf4, 0xa4, 0x60))
-#define SEAGREEN (Color(0x2e, 0x8b, 0x57))
-#define SEASHELL (Color(0xff, 0xf5, 0xee))
-#define SIENNA (Color(0xa0, 0x52, 0x2d))
-#define SILVER (Color(0xc0, 0xc0, 0xc0))
-#define SKYBLUE (Color(0x87, 0xce, 0xeb))
-#define SLATEBLUE (Color(0x6a, 0x5a, 0xcd))
-#define SLATEGRAY (Color(0x70, 0x80, 0x90))
-#define SNOW (Color(0xff, 0xfa, 0xfa))
-#define SPRINGGREEN (Color(0x00, 0xff, 0x7f))
-#define STEELBLUE (Color(0x46, 0x82, 0xb4))
-#define TAN (Color(0xd2, 0xb4, 0x8c))
-#define TEAL (Color(0x00, 0x80, 0x80))
-#define THISTLE (Color(0xd8, 0xbf, 0xd8))
-#define TOMATO (Color(0xff, 0x63, 0x47))
-#define TURQUOISE (Color(0x40, 0xe0, 0xd0))
-#define VIOLET (Color(0xee, 0x82, 0xee))
-#define WHEAT (Color(0xf5, 0xde, 0xb3))
-#define WHITE (Color(0xff, 0xff, 0xff))
-#define WHITESMOKE (Color(0xf5, 0xf5, 0xf5))
-#define YELLOW (Color(0xff, 0xff, 0x00))
-#define YELLOWGREEN (Color(0x9a, 0xcd, 0x32))
-
-#define DOS_BLACK (Color(0x00, 0x00, 0x00)) // Black
-#define DOS_BLUE (Color(0x00, 0x00, 0xaa)) // Blue
-#define DOS_GREEN (Color(0x00, 0xaa, 0x00)) // Green
-#define DOS_CYAN (Color(0x00, 0xaa, 0xaa)) // Cyan
-#define DOS_RED (Color(0xaa, 0x00, 0x00)) // Red
-#define DOS_MAGENTA (Color(0xaa, 0x00, 0xaa)) // Magenta
-#define DOS_BRAWN (Color(0xaa, 0x55, 0x00)) // Brawn
-#define DOS_WHITE (Color(0xaa, 0xaa, 0xaa)) // White
-#define DOS_GRAY (Color(0x55, 0x55, 0x55)) // Gray
-#define DOS_HIGH_BLUE (Color(0x55, 0x55, 0xff)) // High Blue
-#define DOS_HIGH_GREEN (Color(0x55, 0xff, 0x55)) // High Green
-#define DOS_HIGH_CYAN (Color(0x55, 0xff, 0xff)) // High Cyan
-#define DOS_HIGH_RED (Color(0xff, 0x55, 0x55)) // High Red
-#define DOS_HIGH_MAGENTA (Color(0xff, 0x55, 0xff)) // High Magenta
-#define DOS_YELLOW (Color(0xff, 0xff, 0x55)) // Yellow
-#define DOS_HIGH_WHITE (Color(0xff, 0xff, 0xff)) // High White
-
-#endif
+#ifndef __COLOR_H__ +#define __COLOR_H__ + +struct Color { + Color() : R(255), G(255), B(255), A(255) { } + Color(unsigned char aR, unsigned char aG, unsigned char aB, unsigned char aA = 255) : + R(aR), G(aG), B(aB), A(aA) { } + Color(const Color & c) : R(c.R), G(c.G), B(c.B), A(c.A) { } + bool operator==(const Color & c) const { + return (R == c.R) && (G == c.G) && (B == c.B) && (A == c.A); + } + unsigned char R, G, B, A; +}; + +/* + +From http://www.spacetoday.org/BoilerRoom/Colors.html : + +F0F8FF aliceblue +FAEBD7 antiquewhite +00FFFF aqua +7FFFD4 aquamarine +F0FFFF azure +F5F5DC beige +FFE4C4 bisque +000000 black +FFEBCD blanchedalmond +0000FF blue +8A2BE2 blueviolet +A52A2A brown +DEB887 burlywood +5F9EA0 cadetblue +7FFF00 chartreuse +D2691E chocolate +FF7F50 coral +6495ED cornflowerblue +FFF8DC cornsilk +DC143C crimson +00FFFF cyan +00008B darkblue +008B8B darkcyan +B8860B darkgoldenrod +A9A9A9 darkgray +006400 darkgreen +BDB76B darkkhaki +8B008B darkmagenta +556B2F darkolivegreen +FF8C00 darkorange +9932CC darkorchid +8B0000 darkred +E9967A darksalmon +8FBC8F darkseagreen +483D8B darkslateblue +2F4F4F darkslategray +00CED1 darkturquoise +9400D3 darkviolet +FF1493 deeppink +00BFFF deepskyblue +696969 dimgray +1E90FF dodgerblue +B22222 firebrick +FFFAF0 floralwhite +228B22 forestgreen +FF00FF fuchsia +DCDCDC gainsboro +F8F8FF ghostwhite +FFD700 gold +DAA520 goldenrod +808080 gray +008000 green +ADFF2F greenyellow +F0FFF0 honeydew +FF69B4 hotpink +CD5C5C indianred +4B0082 indigo +FFFFF0 ivory +F0E68C khaki +E6E6FA lavender +FFF0F5 lavenderblush +7CFC00 lawngreen +FFFACD lemonchiffon +ADD8E6 lightblue +F08080 lightcoral +E0FFFF lightcyan +FAFAD2 lightgoldenrodyellow +90EE90 lightgreen +D3D3D3 lightgrey +FFB6C1 lightpink +FFA07A lightsalmon +20B2AA lightseagreen +87CEFA lightskyblue +778899 lightslategray +B0C4DE lightsteelblue +FFFFE0 lightyellow +00FF00 lime +32CD32 limegreen +FAF0E6 linen +FF00FF magenta +800000 maroon +66CDAA mediumaquamarine +0000CD mediumblue +BA55D3 mediumorchid +9370DB mediumpurple +3CB371 mediumseagreen +7B68EE mediumslateblue +00FA9A mediumspringgreen +48D1CC mediumturquoise +C71585 mediumvioletred +191970 midnightblue +F5FFFA mintcream +FFE4E1 mistyrose +FFE4B5 moccasin +FFDEAD navajowhite +000080 navy +FDF5E6 oldlace +808000 olive +6B8E23 olivedrab +FFA500 orange +FF4500 orangered +DA70D6 orchid +EEE8AA palegoldenrod +98FB98 palegreen +AFEEEE paleturquoise +DB7093 palevioletred +FFEFD5 papayawhip +FFDAB9 peachpuff +CD853F peru +FFC0CB pink +DDA0DD plum +B0E0E6 powderblue +800080 purple +FF0000 red +BC8F8F rosybrown +4169E1 royalblue +8B4513 saddlebrown +FA8072 salmon +F4A460 sandybrown +2E8B57 seagreen +FFF5EE seashell +A0522D sienna +C0C0C0 silver +87CEEB skyblue +6A5ACD slateblue +708090 slategray +FFFAFA snow +00FF7F springgreen +4682B4 steelblue +D2B48C tan +008080 teal +D8BFD8 thistle +FF6347 tomato +40E0D0 turquoise +EE82EE violet +F5DEB3 wheat +FFFFFF white +F5F5F5 whitesmoke +FFFF00 yellow +9ACD32 yellowgreen + +*/ + +#define ALICEBLUE (Color(0xf0, 0xf8, 0xff)) +#define ANTIQUEWHITE (Color(0xfa, 0xeb, 0xd7)) +#define AQUA (Color(0x00, 0xff, 0xff)) +#define AQUAMARINE (Color(0x7f, 0xff, 0xd4)) +#define AZURE (Color(0xf0, 0xff, 0xff)) +#define BEIGE (Color(0xf5, 0xf5, 0xdc)) +#define BISQUE (Color(0xff, 0xe4, 0xc4)) +#define BLACK (Color(0x00, 0x00, 0x00)) +#define BLANCHEDALMOND (Color(0xff, 0xeb, 0xcd)) +#define BLUE (Color(0x00, 0x00, 0xff)) +#define BLUEVIOLET (Color(0x8a, 0x2b, 0xe2)) +#define BROWN (Color(0xa5, 0x2a, 0x2a)) +#define BURLYWOOD (Color(0xde, 0xb8, 0x87)) +#define CADETBLUE (Color(0x5f, 0x9e, 0xa0)) +#define CHARTREUSE (Color(0x7f, 0xff, 0x00)) +#define CHOCOLATE (Color(0xd2, 0x69, 0x1e)) +#define CORAL (Color(0xff, 0x7f, 0x50)) +#define CORNFLOWERBLUE (Color(0x64, 0x95, 0xed)) +#define CORNSILK (Color(0xff, 0xf8, 0xdc)) +#define CRIMSON (Color(0xdc, 0x14, 0x3c)) +#define CYAN (Color(0x00, 0xff, 0xff)) +#define DARKBLUE (Color(0x00, 0x00, 0x8b)) +#define DARKCYAN (Color(0x00, 0x8b, 0x8b)) +#define DARKGOLDENROD (Color(0xb8, 0x86, 0x0b)) +#define DARKGRAY (Color(0xa9, 0xa9, 0xa9)) +#define DARKGREEN (Color(0x00, 0x64, 0x00)) +#define DARKKHAKI (Color(0xbd, 0xb7, 0x6b)) +#define DARKMAGENTA (Color(0x8b, 0x00, 0x8b)) +#define DARKOLIVEGREEN (Color(0x55, 0x6b, 0x2f)) +#define DARKORANGE (Color(0xff, 0x8c, 0x00)) +#define DARKORCHID (Color(0x99, 0x32, 0xcc)) +#define DARKRED (Color(0x8b, 0x00, 0x00)) +#define DARKSALMON (Color(0xe9, 0x96, 0x7a)) +#define DARKSEAGREEN (Color(0x8f, 0xbc, 0x8f)) +#define DARKSLATEBLUE (Color(0x48, 0x3d, 0x8b)) +#define DARKSLATEGRAY (Color(0x2f, 0x4f, 0x4f)) +#define DARKTURQUOISE (Color(0x00, 0xce, 0xd1)) +#define DARKVIOLET (Color(0x94, 0x00, 0xd3)) +#define DEEPPINK (Color(0xff, 0x14, 0x93)) +#define DEEPSKYBLUE (Color(0x00, 0xbf, 0xff)) +#define DIMGRAY (Color(0x69, 0x69, 0x69)) +#define DODGERBLUE (Color(0x1e, 0x90, 0xff)) +#define FIREBRICK (Color(0xb2, 0x22, 0x22)) +#define FLORALWHITE (Color(0xff, 0xfa, 0xf0)) +#define FORESTGREEN (Color(0x22, 0x8b, 0x22)) +#define FUCHSIA (Color(0xff, 0x00, 0xff)) +#define GAINSBORO (Color(0xdc, 0xdc, 0xdc)) +#define GHOSTWHITE (Color(0xf8, 0xf8, 0xff)) +#define GOLD (Color(0xff, 0xd7, 0x00)) +#define GOLDENROD (Color(0xda, 0xa5, 0x20)) +#define GRAY (Color(0x80, 0x80, 0x80)) +#define GREEN (Color(0x00, 0x80, 0x00)) +#define GREENYELLOW (Color(0xad, 0xff, 0x2f)) +#define HONEYDEW (Color(0xf0, 0xff, 0xf0)) +#define HOTPINK (Color(0xff, 0x69, 0xb4)) +#define INDIANRED (Color(0xcd, 0x5c, 0x5c)) +#define INDIGO (Color(0x4b, 0x00, 0x82)) +#define IVORY (Color(0xff, 0xff, 0xf0)) +#define KHAKI (Color(0xf0, 0xe6, 0x8c)) +#define LAVENDER (Color(0xe6, 0xe6, 0xfa)) +#define LAVENDERBLUSH (Color(0xff, 0xf0, 0xf5)) +#define LAWNGREEN (Color(0x7c, 0xfc, 0x00)) +#define LEMONCHIFFON (Color(0xff, 0xfa, 0xcd)) +#define LIGHTBLUE (Color(0xad, 0xd8, 0xe6)) +#define LIGHTCORAL (Color(0xf0, 0x80, 0x80)) +#define LIGHTCYAN (Color(0xe0, 0xff, 0xff)) +#define LIGHTGOLDENRODYELLOW (Color(0xfa, 0xfa, 0xd2)) +#define LIGHTGREEN (Color(0x90, 0xee, 0x90)) +#define LIGHTGREY (Color(0xd3, 0xd3, 0xd3)) +#define LIGHTPINK (Color(0xff, 0xb6, 0xc1)) +#define LIGHTSALMON (Color(0xff, 0xa0, 0x7a)) +#define LIGHTSEAGREEN (Color(0x20, 0xb2, 0xaa)) +#define LIGHTSKYBLUE (Color(0x87, 0xce, 0xfa)) +#define LIGHTSLATEGRAY (Color(0x77, 0x88, 0x99)) +#define LIGHTSTEELBLUE (Color(0xb0, 0xc4, 0xde)) +#define LIGHTYELLOW (Color(0xff, 0xff, 0xe0)) +#define LIME (Color(0x00, 0xff, 0x00)) +#define LIMEGREEN (Color(0x32, 0xcd, 0x32)) +#define LINEN (Color(0xfa, 0xf0, 0xe6)) +#define MAGENTA (Color(0xff, 0x00, 0xff)) +#define MAROON (Color(0x80, 0x00, 0x00)) +#define MEDIUMAQUAMARINE (Color(0x66, 0xcd, 0xaa)) +#define MEDIUMBLUE (Color(0x00, 0x00, 0xcd)) +#define MEDIUMORCHID (Color(0xba, 0x55, 0xd3)) +#define MEDIUMPURPLE (Color(0x93, 0x70, 0xdb)) +#define MEDIUMSEAGREEN (Color(0x3c, 0xb3, 0x71)) +#define MEDIUMSLATEBLUE (Color(0x7b, 0x68, 0xee)) +#define MEDIUMSPRINGGREEN (Color(0x00, 0xfa, 0x9a)) +#define MEDIUMTURQUOISE (Color(0x48, 0xd1, 0xcc)) +#define MEDIUMVIOLETRED (Color(0xc7, 0x15, 0x85)) +#define MIDNIGHTBLUE (Color(0x19, 0x19, 0x70)) +#define MINTCREAM (Color(0xf5, 0xff, 0xfa)) +#define MISTYROSE (Color(0xff, 0xe4, 0xe1)) +#define MOCCASIN (Color(0xff, 0xe4, 0xb5)) +#define NAVAJOWHITE (Color(0xff, 0xde, 0xad)) +#define NAVY (Color(0x00, 0x00, 0x80)) +#define OLDLACE (Color(0xfd, 0xf5, 0xe6)) +#define OLIVE (Color(0x80, 0x80, 0x00)) +#define OLIVEDRAB (Color(0x6b, 0x8e, 0x23)) +#define ORANGE (Color(0xff, 0xa5, 0x00)) +#define ORANGERED (Color(0xff, 0x45, 0x00)) +#define ORCHID (Color(0xda, 0x70, 0xd6)) +#define PALEGOLDENROD (Color(0xee, 0xe8, 0xaa)) +#define PALEGREEN (Color(0x98, 0xfb, 0x98)) +#define PALETURQUOISE (Color(0xaf, 0xee, 0xee)) +#define PALEVIOLETRED (Color(0xdb, 0x70, 0x93)) +#define PAPAYAWHIP (Color(0xff, 0xef, 0xd5)) +#define PEACHPUFF (Color(0xff, 0xda, 0xb9)) +#define PERU (Color(0xcd, 0x85, 0x3f)) +#define PINK (Color(0xff, 0xc0, 0xcb)) +#define PLUM (Color(0xdd, 0xa0, 0xdd)) +#define POWDERBLUE (Color(0xb0, 0xe0, 0xe6)) +#define PURPLE (Color(0x80, 0x00, 0x80)) +#define RED (Color(0xff, 0x00, 0x00)) +#define ROSYBROWN (Color(0xbc, 0x8f, 0x8f)) +#define ROYALBLUE (Color(0x41, 0x69, 0xe1)) +#define SADDLEBROWN (Color(0x8b, 0x45, 0x13)) +#define SALMON (Color(0xfa, 0x80, 0x72)) +#define SANDYBROWN (Color(0xf4, 0xa4, 0x60)) +#define SEAGREEN (Color(0x2e, 0x8b, 0x57)) +#define SEASHELL (Color(0xff, 0xf5, 0xee)) +#define SIENNA (Color(0xa0, 0x52, 0x2d)) +#define SILVER (Color(0xc0, 0xc0, 0xc0)) +#define SKYBLUE (Color(0x87, 0xce, 0xeb)) +#define SLATEBLUE (Color(0x6a, 0x5a, 0xcd)) +#define SLATEGRAY (Color(0x70, 0x80, 0x90)) +#define SNOW (Color(0xff, 0xfa, 0xfa)) +#define SPRINGGREEN (Color(0x00, 0xff, 0x7f)) +#define STEELBLUE (Color(0x46, 0x82, 0xb4)) +#define TAN (Color(0xd2, 0xb4, 0x8c)) +#define TEAL (Color(0x00, 0x80, 0x80)) +#define THISTLE (Color(0xd8, 0xbf, 0xd8)) +#define TOMATO (Color(0xff, 0x63, 0x47)) +#define TURQUOISE (Color(0x40, 0xe0, 0xd0)) +#define VIOLET (Color(0xee, 0x82, 0xee)) +#define WHEAT (Color(0xf5, 0xde, 0xb3)) +#define WHITE (Color(0xff, 0xff, 0xff)) +#define WHITESMOKE (Color(0xf5, 0xf5, 0xf5)) +#define YELLOW (Color(0xff, 0xff, 0x00)) +#define YELLOWGREEN (Color(0x9a, 0xcd, 0x32)) + +#define DOS_BLACK (Color(0x00, 0x00, 0x00)) // Black +#define DOS_BLUE (Color(0x00, 0x00, 0xaa)) // Blue +#define DOS_GREEN (Color(0x00, 0xaa, 0x00)) // Green +#define DOS_CYAN (Color(0x00, 0xaa, 0xaa)) // Cyan +#define DOS_RED (Color(0xaa, 0x00, 0x00)) // Red +#define DOS_MAGENTA (Color(0xaa, 0x00, 0xaa)) // Magenta +#define DOS_BRAWN (Color(0xaa, 0x55, 0x00)) // Brawn +#define DOS_WHITE (Color(0xaa, 0xaa, 0xaa)) // White +#define DOS_GRAY (Color(0x55, 0x55, 0x55)) // Gray +#define DOS_HIGH_BLUE (Color(0x55, 0x55, 0xff)) // High Blue +#define DOS_HIGH_GREEN (Color(0x55, 0xff, 0x55)) // High Green +#define DOS_HIGH_CYAN (Color(0x55, 0xff, 0xff)) // High Cyan +#define DOS_HIGH_RED (Color(0xff, 0x55, 0x55)) // High Red +#define DOS_HIGH_MAGENTA (Color(0xff, 0x55, 0xff)) // High Magenta +#define DOS_YELLOW (Color(0xff, 0xff, 0x55)) // Yellow +#define DOS_HIGH_WHITE (Color(0xff, 0xff, 0xff)) // High White + +#endif diff --git a/include/ConfigFile.h b/include/ConfigFile.h index 02e9bbe..11434bd 100644 --- a/include/ConfigFile.h +++ b/include/ConfigFile.h @@ -1,19 +1,19 @@ -#ifndef __CONFIGFILE_H__
-#define __CONFIGFILE_H__
-
-#include <Exceptions.h>
-#include <Handle.h>
-#include <map>
-
-typedef std::map<String, String> ConfigSectionContents;
-typedef std::map<String, ConfigSectionContents> ConfigSection;
-
-class ConfigFile : public Base {
- public:
- ConfigFile(Handle *) throw (GeneralException);
- ConfigSectionContents & operator[](String);
- private:
- ConfigSection c;
-};
-
-#endif
+#ifndef __CONFIGFILE_H__ +#define __CONFIGFILE_H__ + +#include <Exceptions.h> +#include <Handle.h> +#include <map> + +typedef std::map<String, String> ConfigSectionContents; +typedef std::map<String, ConfigSectionContents> ConfigSection; + +class ConfigFile : public Base { + public: + ConfigFile(Handle *) throw (GeneralException); + ConfigSectionContents & operator[](String); + private: + ConfigSection c; +}; + +#endif diff --git a/include/Confirm.h b/include/Confirm.h index 0fd9723..ef1dabc 100644 --- a/include/Confirm.h +++ b/include/Confirm.h @@ -1,20 +1,20 @@ -#ifndef __CONFIRM_H__
-#define __CONFIRM_H__
-
-#include <Action.h>
-#include <BString.h>
-#include <Exceptions.h>
-
-class Confirm : public Action {
- public:
- Confirm(const String & titre, const String & msg, const String & url, Action * yes, Action * no = 0);
- virtual ~Confirm() { }
- virtual String GetTitle();
- virtual Task * Do(Variables *, Variables *, Handle *);
-
- private:
- String tit, msg;
- Action * NYes, * NNo;
-};
-
-#endif
+#ifndef __CONFIRM_H__ +#define __CONFIRM_H__ + +#include <Action.h> +#include <BString.h> +#include <Exceptions.h> + +class Confirm : public Action { + public: + Confirm(const String & titre, const String & msg, const String & url, Action * yes, Action * no = 0); + virtual ~Confirm() { } + virtual String GetTitle(); + virtual Task * Do(Variables *, Variables *, Handle *); + + private: + String tit, msg; + Action * NYes, * NNo; +}; + +#endif diff --git a/include/CopyJob.h b/include/CopyJob.h index bcc9afe..7284b24 100644 --- a/include/CopyJob.h +++ b/include/CopyJob.h @@ -1,26 +1,26 @@ -#ifndef __COPYJOB_H__
-#define __COPYJOB_H__
-
-#include <sys/time.h>
-#include <Task.h>
-#include <Handle.h>
-
-#define COPY_BUFSIZ 4096
-
-class CopyJob : public Task {
- public:
- CopyJob(Handle *, Handle *, ssize_t = -1, bool = false, bool = false, int = -1);
- virtual ~CopyJob();
- virtual int Do() throw (GeneralException);
- virtual String GetName();
-
- private:
- Handle * s, * d;
- bool ds, dd;
- ssize_t siz, cursiz;
- char buffer[COPY_BUFSIZ + 1];
- int r, w, tw, shape;
- struct timeval start;
-};
-
-#endif
+#ifndef __COPYJOB_H__ +#define __COPYJOB_H__ + +#include <sys/time.h> +#include <Task.h> +#include <Handle.h> + +#define COPY_BUFSIZ 4096 + +class CopyJob : public Task { + public: + CopyJob(Handle *, Handle *, ssize_t = -1, bool = false, bool = false, int = -1); + virtual ~CopyJob(); + virtual int Do() throw (GeneralException); + virtual String GetName(); + + private: + Handle * s, * d; + bool ds, dd; + ssize_t siz, cursiz; + char buffer[COPY_BUFSIZ + 1]; + int r, w, tw, shape; + struct timeval start; +}; + +#endif diff --git a/include/Exceptions.h b/include/Exceptions.h index 310dfb1..cf293c8 100644 --- a/include/Exceptions.h +++ b/include/Exceptions.h @@ -1,160 +1,160 @@ -/*
- * Baltisot
- * Copyright (C) 1999-2003 Nicolas "Pixel" Noble
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-/* $Id: Exceptions.h,v 1.37 2004-11-27 21:43:48 pixel Exp $ */
-
-#ifndef __EXCEPTIONS_H__
-#define __EXCEPTIONS_H__
-
-#include <stdio.h>
-#include <stddef.h>
-#include <string.h>
-#include <stdlib.h>
-#include <stdarg.h>
-#include <vector>
-#include <generic.h>
-
-#if !defined pid_t && !defined _SYS_TYPES_H
-typedef int pid_t;
-#endif
-
-#ifdef _MSC_VER
-#pragma warning (disable:4290)
-#endif
-
-class String;
-struct ugly_string;
-
-class Base {
- public:
- virtual ~Base() {};
- static char * strdup(const char * s);
- static void * malloc(ssize_t s);
- static void * realloc(void * p, size_t s);
- static void * calloc(size_t n, size_t s);
- void * operator new(size_t s);
- void * operator new(size_t s, void * p);
- void operator delete(void * p);
- template <class T>
- static void free(T *& p) {
- unsigned char * t = (unsigned char *) p;
- xfree(t);
- p = 0;
- }
- static int pipe(int * p, int flag = 0);
- static pid_t fork();
- static void exit(int);
- static void printm(int level, const ugly_string &, ...);
- static void printm(int level, const char *, ...);
- static void exception(const String &);
- static void pushcontext(const String &);
- static void popcontext(void);
- static void flushcontext(void);
- private:
- static std::vector<String> context;
-};
-
-class GeneralException : public Base {
- public:
- GeneralException(String);
- GeneralException(const GeneralException &);
- ~GeneralException();
- const char * GetMsg() const;
-
- protected:
- GeneralException();
- char * msg;
- static char t[BUFSIZ];
-};
-
-char * xstrdup(const char *);
-void * xmalloc(size_t) throw (GeneralException);
-void xfree(unsigned char *&);
-void * xrealloc(void *, size_t);
-int xpipe(int *, int = 0) throw (GeneralException);
-pid_t xfork() throw (GeneralException);
-void xexit(int) throw (GeneralException);
-void xexception(const String &) throw (GeneralException);
-
-class MemoryException : public GeneralException {
- public:
- MemoryException(ssize_t);
-};
-
-class TaskNotFound : public GeneralException {
- public:
- TaskNotFound();
-};
-
-enum op_t {
- IO_WRITE = 1,
- IO_READ
-};
-
-class IOGeneral : public GeneralException {
- public:
- IOGeneral(String);
- protected:
- IOGeneral();
-};
-
-class IOException : public IOGeneral {
- public:
- IOException(String, op_t, ssize_t);
-};
-
-class IOAgain : public IOGeneral {
- public:
- IOAgain();
-};
-
-class TaskSwitch : public GeneralException {
- public:
- TaskSwitch();
-};
-
-class Exit : public GeneralException {
- public:
- Exit(int);
- int GetCode();
- private:
- int code;
-};
-
-class printer_t : public Base {
- public:
- virtual bool printm(int, const char *, va_list) = 0;
-};
-
-extern printer_t * printer;
-
-class locker_t : public Base {
- public:
- virtual void lock() = 0;
- virtual void unlock() = 0;
-};
-
-extern locker_t * locker;
-
-#define LOCK if (locker) locker->lock()
-#define UNLOCK if (locker) locker->unlock();
-
-#include <BString.h>
-
-#endif
+/* + * Baltisot + * Copyright (C) 1999-2003 Nicolas "Pixel" Noble + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* $Id: Exceptions.h,v 1.38 2004-11-27 21:46:02 pixel Exp $ */ + +#ifndef __EXCEPTIONS_H__ +#define __EXCEPTIONS_H__ + +#include <stdio.h> +#include <stddef.h> +#include <string.h> +#include <stdlib.h> +#include <stdarg.h> +#include <vector> +#include <generic.h> + +#if !defined pid_t && !defined _SYS_TYPES_H +typedef int pid_t; +#endif + +#ifdef _MSC_VER +#pragma warning (disable:4290) +#endif + +class String; +struct ugly_string; + +class Base { + public: + virtual ~Base() {}; + static char * strdup(const char * s); + static void * malloc(ssize_t s); + static void * realloc(void * p, size_t s); + static void * calloc(size_t n, size_t s); + void * operator new(size_t s); + void * operator new(size_t s, void * p); + void operator delete(void * p); + template <class T> + static void free(T *& p) { + unsigned char * t = (unsigned char *) p; + xfree(t); + p = 0; + } + static int pipe(int * p, int flag = 0); + static pid_t fork(); + static void exit(int); + static void printm(int level, const ugly_string &, ...); + static void printm(int level, const char *, ...); + static void exception(const String &); + static void pushcontext(const String &); + static void popcontext(void); + static void flushcontext(void); + private: + static std::vector<String> context; +}; + +class GeneralException : public Base { + public: + GeneralException(String); + GeneralException(const GeneralException &); + ~GeneralException(); + const char * GetMsg() const; + + protected: + GeneralException(); + char * msg; + static char t[BUFSIZ]; +}; + +char * xstrdup(const char *); +void * xmalloc(size_t) throw (GeneralException); +void xfree(unsigned char *&); +void * xrealloc(void *, size_t); +int xpipe(int *, int = 0) throw (GeneralException); +pid_t xfork() throw (GeneralException); +void xexit(int) throw (GeneralException); +void xexception(const String &) throw (GeneralException); + +class MemoryException : public GeneralException { + public: + MemoryException(ssize_t); +}; + +class TaskNotFound : public GeneralException { + public: + TaskNotFound(); +}; + +enum op_t { + IO_WRITE = 1, + IO_READ +}; + +class IOGeneral : public GeneralException { + public: + IOGeneral(String); + protected: + IOGeneral(); +}; + +class IOException : public IOGeneral { + public: + IOException(String, op_t, ssize_t); +}; + +class IOAgain : public IOGeneral { + public: + IOAgain(); +}; + +class TaskSwitch : public GeneralException { + public: + TaskSwitch(); +}; + +class Exit : public GeneralException { + public: + Exit(int); + int GetCode(); + private: + int code; +}; + +class printer_t : public Base { + public: + virtual bool printm(int, const char *, va_list) = 0; +}; + +extern printer_t * printer; + +class locker_t : public Base { + public: + virtual void lock() = 0; + virtual void unlock() = 0; +}; + +extern locker_t * locker; + +#define LOCK if (locker) locker->lock() +#define UNLOCK if (locker) locker->unlock(); + +#include <BString.h> + +#endif diff --git a/include/Form.h b/include/Form.h index 5dccb35..f0fa93f 100644 --- a/include/Form.h +++ b/include/Form.h @@ -1,23 +1,23 @@ -#ifndef __FORM_H__
-#define __FORM_H__
-
-#include <Action.h>
-#include <BString.h>
-#include <Exceptions.h>
-
-class Form : public Action {
- public:
- Form(const String & titre, const String & url, const String & inv,
- String * names, String * invs, String * defaults, String ** lists, String ** descs,
- int nb, Action * ok = 0);
- virtual ~Form() { }
- virtual String GetTitle();
- virtual Task * Do(Variables *, Variables *, Handle *);
-
- private:
- String tit, iv, * nms, * ivs, * defs, ** lsts, ** dscs;
- int n;
- Action * Next;
-};
-
-#endif
+#ifndef __FORM_H__ +#define __FORM_H__ + +#include <Action.h> +#include <BString.h> +#include <Exceptions.h> + +class Form : public Action { + public: + Form(const String & titre, const String & url, const String & inv, + String * names, String * invs, String * defaults, String ** lists, String ** descs, + int nb, Action * ok = 0); + virtual ~Form() { } + virtual String GetTitle(); + virtual Task * Do(Variables *, Variables *, Handle *); + + private: + String tit, iv, * nms, * ivs, * defs, ** lsts, ** dscs; + int n; + Action * Next; +}; + +#endif diff --git a/include/GMPString.h b/include/GMPString.h index d1c7424..77364bf 100644 --- a/include/GMPString.h +++ b/include/GMPString.h @@ -1,18 +1,18 @@ -#ifndef __GMPSTRING_H__
-#define __GMPSTRING_H__
-#include <gmpxx.h>
-#include "BString.h"
-
-class GMPString : public Base {
- public:
- GMPString(const GMPString &);
- GMPString(const mpz_class &);
- GMPString(const mpq_class &);
- GMPString(const mpf_class &);
- ~GMPString();
- operator String() const;
- private:
- char * str;
-};
-
-#endif
+#ifndef __GMPSTRING_H__ +#define __GMPSTRING_H__ +#include <gmpxx.h> +#include "BString.h" + +class GMPString : public Base { + public: + GMPString(const GMPString &); + GMPString(const mpz_class &); + GMPString(const mpq_class &); + GMPString(const mpf_class &); + ~GMPString(); + operator String() const; + private: + char * str; +}; + +#endif diff --git a/include/Handle.h b/include/Handle.h index ee0f3f7..9b6f88d 100644 --- a/include/Handle.h +++ b/include/Handle.h @@ -1,92 +1,92 @@ -/*
- * Baltisot
- * Copyright (C) 1999-2003 Nicolas "Pixel" Noble
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-/* $Id: Handle.h,v 1.33 2004-11-27 21:43:48 pixel Exp $ */
-
-#ifndef __HANDLE_H__
-#define __HANDLE_H__
-
-#include <sys/types.h>
-#include <time.h>
-
-#include <zlib.h>
-#include <iostream>
-#include <BString.h>
-#include <Exceptions.h>
-
-class Handle : public Base {
- public:
- Handle(const Handle &);
- virtual ~Handle();
- virtual ssize_t read(void * buf, size_t count) throw (GeneralException);
- virtual ssize_t write(const void * buf, size_t count) throw (GeneralException);
- Uint8 readU8();
- Uint16 readU16();
- Uint32 readU32();
- void writeU8(Uint8);
- void writeU16(Uint16);
- void writeU32(Uint32);
- void copyto(Handle *, ssize_t = -1);
- void copyfrom(Handle *, ssize_t = -1);
- bool IsClosed(void) const;
- bool IsNonBlock(void) const;
- void SetNonBlock(void);
- virtual bool CanRead() const;
- virtual bool CanWrite() const;
- virtual bool CanSeek() const;
- virtual off_t seek(off_t, int = SEEK_SET) throw (GeneralException);
- virtual off_t tell() const;
- virtual String GetName() const;
- virtual ssize_t GetSize() const;
- virtual time_t GetModif() const;
- void close() throw (GeneralException);
- int GetHandle();
- void * GetHFile();
- virtual bool CanWatch() const;
- virtual int Dup() const throw (GeneralException);
- virtual void SetZ(int = 9) throw (GeneralException);
- virtual void Flush();
-
- void * mmap(off_t = 0, size_t = -1) throw (GeneralException);
- void munmap() throw (GeneralException);
- protected:
- Handle(int h);
- int GetHandle() const;
- off_t itell;
- void * hFile;
- private:
- ssize_t uwrite(const void *, size_t) throw (GeneralException);
- ssize_t uread(void *, size_t);
- int h;
- bool closed, nonblock;
- gzFile zfile;
- z_stream zstrm;
- int z, c;
- void * hMapObject;
- bool mapped;
- size_t maplength;
- void * mappedarea;
-};
-
-Handle & operator<<(Handle &, const String &);
-Handle & operator>>(Handle &, String &);
-
-void copy(Handle *, Handle *, ssize_t = -1);
-
-#endif
+/* + * Baltisot + * Copyright (C) 1999-2003 Nicolas "Pixel" Noble + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* $Id: Handle.h,v 1.34 2004-11-27 21:46:02 pixel Exp $ */ + +#ifndef __HANDLE_H__ +#define __HANDLE_H__ + +#include <sys/types.h> +#include <time.h> + +#include <zlib.h> +#include <iostream> +#include <BString.h> +#include <Exceptions.h> + +class Handle : public Base { + public: + Handle(const Handle &); + virtual ~Handle(); + virtual ssize_t read(void * buf, size_t count) throw (GeneralException); + virtual ssize_t write(const void * buf, size_t count) throw (GeneralException); + Uint8 readU8(); + Uint16 readU16(); + Uint32 readU32(); + void writeU8(Uint8); + void writeU16(Uint16); + void writeU32(Uint32); + void copyto(Handle *, ssize_t = -1); + void copyfrom(Handle *, ssize_t = -1); + bool IsClosed(void) const; + bool IsNonBlock(void) const; + void SetNonBlock(void); + virtual bool CanRead() const; + virtual bool CanWrite() const; + virtual bool CanSeek() const; + virtual off_t seek(off_t, int = SEEK_SET) throw (GeneralException); + virtual off_t tell() const; + virtual String GetName() const; + virtual ssize_t GetSize() const; + virtual time_t GetModif() const; + void close() throw (GeneralException); + int GetHandle(); + void * GetHFile(); + virtual bool CanWatch() const; + virtual int Dup() const throw (GeneralException); + virtual void SetZ(int = 9) throw (GeneralException); + virtual void Flush(); + + void * mmap(off_t = 0, size_t = -1) throw (GeneralException); + void munmap() throw (GeneralException); + protected: + Handle(int h); + int GetHandle() const; + off_t itell; + void * hFile; + private: + ssize_t uwrite(const void *, size_t) throw (GeneralException); + ssize_t uread(void *, size_t); + int h; + bool closed, nonblock; + gzFile zfile; + z_stream zstrm; + int z, c; + void * hMapObject; + bool mapped; + size_t maplength; + void * mappedarea; +}; + +Handle & operator<<(Handle &, const String &); +Handle & operator>>(Handle &, String &); + +void copy(Handle *, Handle *, ssize_t = -1); + +#endif diff --git a/include/HttpServ.h b/include/HttpServ.h index e704814..fc58246 100644 --- a/include/HttpServ.h +++ b/include/HttpServ.h @@ -1,30 +1,30 @@ -#ifndef __HTTPSERV_H__
-#define __HTTPSERV_H__
-
-#include <Socket.h>
-#include <BString.h>
-#include <Variables.h>
-#include <Action.h>
-#include <Task.h>
-#include <Exceptions.h>
-
-class HttpServ : public Task {
- public:
- HttpServ(Action *, int = 1500, const String & = String("GruiK Server v0.1")) throw (GeneralException);
- virtual ~HttpServ();
- void SetMenu(Action *);
- virtual String GetName();
-
- protected:
- virtual int Do() throw (GeneralException);
-
- private:
- Socket Listener;
- Action * p;
- String name;
- int localport;
-};
-
-extern String endhl, endnl;
-
-#endif
+#ifndef __HTTPSERV_H__ +#define __HTTPSERV_H__ + +#include <Socket.h> +#include <BString.h> +#include <Variables.h> +#include <Action.h> +#include <Task.h> +#include <Exceptions.h> + +class HttpServ : public Task { + public: + HttpServ(Action *, int = 1500, const String & = String("GruiK Server v0.1")) throw (GeneralException); + virtual ~HttpServ(); + void SetMenu(Action *); + virtual String GetName(); + + protected: + virtual int Do() throw (GeneralException); + + private: + Socket Listener; + Action * p; + String name; + int localport; +}; + +extern String endhl, endnl; + +#endif diff --git a/include/IRC.h b/include/IRC.h index 65a827c..6823b21 100644 --- a/include/IRC.h +++ b/include/IRC.h @@ -1,201 +1,201 @@ -#ifndef __IRC_H__
-#define __IRC_H__
-
-#include <Socket.h>
-#include <Exceptions.h>
-#include <BString.h>
-
-#define RPL_WELCOME 1
-#define RPL_YOURHOST 2
-#define RPL_CREATED 3
-#define RPL_MYINFO 4
-#define RPL_BOUNCE 5
-#define RPL_TRACELINK 200
-#define RPL_TRACECONNECTING 201
-#define RPL_TRACEHANDSHAKE 202
-#define RPL_TRACEUNKNOWN 203
-#define RPL_TRACEOPERATOR 204
-#define RPL_TRACEUSER 205
-#define RPL_TRACESERVER 206
-#define RPL_TRACESERVICE 207
-#define RPL_TRACENEWTYPE 208
-#define RPL_TRACECLASS 209
-#define RPL_TRACERECONNECT 210
-#define RPL_STATSLINKINFO 211
-#define RPL_STATSCOMMANDS 212
-#define RPL_STATSCLINE 213
-#define RPL_STATSILINE 215
-#define RPL_STATSQLINE 217
-#define RPL_ENDOFSTATS 219
-#define RPL_UMODEIS 221
-#define RPL_SERVICEINFO 231
-#define RPL_SERVICE 233
-#define RPL_SERVLIST 234
-#define RPL_SERVLISTEND 235
-#define RPL_STATSVLINE 240
-#define RPL_STATSUPTIME 242
-#define RPL_STATSOLINE 243
-#define RPL_STATSHLINE 244
-#define RPL_STATSPING 246
-#define RPL_STATSDLINE 250
-#define RPL_LUSERCLIENT 251
-#define RPL_LUSEROP 252
-#define RPL_LUSERUNKNOWN 253
-#define RPL_LUSERCHANNELS 254
-#define RPL_LUSERME 255
-#define RPL_ADMINME 256
-#define RPL_ADMINLOC1 257
-#define RPL_ADMINLOC2 258
-#define RPL_ADMINEMAIL 259
-#define RPL_TRACELOG 261
-#define RPL_TRACEEND 262
-#define RPL_TRYAGAIN 263
-#define RPL_NONE 300
-#define RPL_AWAY 301
-#define RPL_USERHOST 302
-#define RPL_ISON 303
-#define RPL_UNAWAY 305
-#define RPL_NOWAWAY 306
-#define RPL_WHOISUSER 311
-#define RPL_WHOISSERVER 312
-#define RPL_WHOISOPERATOR 313
-#define RPL_WHOWASUSER 314
-#define RPL_ENDOFWHO 315
-#define RPL_WHOISIDLE 317
-#define RPL_ENDOFWHOIS 318
-#define RPL_WHOISCHANNELS 319
-#define RPL_LISTSTART 321
-#define RPL_LIST 322
-#define RPL_LISTEND 323
-#define RPL_CHANNELMODEIS 324
-#define RPL_UNIQOPIS 325
-#define RPL_NOTOPIC 331
-#define RPL_TOPIC 332
-#define RPL_INVITING 341
-#define RPL_SUMMONING 342
-#define RPL_INVITELIST 346
-#define RPL_ENDOFINVITELIST 347
-#define RPL_EXCEPTLIST 348
-#define RPL_ENDOFEXCEPTLIST 349
-#define RPL_VERSION 351
-#define RPL_WHOREPLY 352
-#define RPL_NAMREPLY 353
-#define RPL_KILLDONE 361
-#define RPL_CLOSEEND 363
-#define RPL_LINKS 364
-#define RPL_ENDOFLINKS 365
-#define RPL_ENDOFNAMES 366
-#define RPL_BANLIST 367
-#define RPL_ENDOFBANLIST 368
-#define RPL_ENDOFWHOWAS 369
-#define RPL_INFO 371
-#define RPL_MOTD 372
-#define RPL_ENDOFINFO 374
-#define RPL_MOTDSTART 375
-#define RPL_ENDOFMOTD 376
-#define RPL_YOUREOPER 381
-#define RPL_REHASHING 382
-#define RPL_YOURESERVICE 383
-#define RPL_MYPORTIS 384
-#define RPL_TIME 391
-#define RPL_USERSSTART 392
-#define RPL_USERS 393
-#define RPL_ENDOFUSERS 394
-#define RPL_NOUSERS 395
-#define ERR_NOSUCHNICK 401
-#define ERR_NOSUCHSERVER 402
-#define ERR_NOSUCHCHANNEL 403
-#define ERR_CANNOTSENDTOCHAN 404
-#define ERR_TOOMANYCHANNELS 405
-#define ERR_WASNOSUCHNICK 406
-#define ERR_TOOMANYTARGETS 407
-#define ERR_NOSUCHSERVICE 408
-#define ERR_NOORIGIN 409
-#define ERR_NORECIPIENT 411
-#define ERR_NOTEXTTOSEND 412
-#define ERR_NOTOPLEVEL 413
-#define ERR_WILDTOPLEVEL 414
-#define ERR_BADMASK 415
-#define ERR_UNKNOWNCOMMAND 421
-#define ERR_NOMOTD 422
-#define ERR_NOADMININFO 423
-#define ERR_FILEERROR 424
-#define ERR_NONICKNAMEGIVEN 431
-#define ERR_ERRONEUSNICKNAME 432
-#define ERR_NICKNAMEINUSE 433
-#define ERR_NICKCOLLISION 436
-#define ERR_UNAVAILRESOURCE 437
-#define ERR_USERNOTINCHANNEL 441
-#define ERR_NOTONCHANNEL 442
-#define ERR_USERONCHANNEL 443
-#define ERR_NOLOGIN 444
-#define ERR_SUMMONDISABLED 445
-#define ERR_USERSDISABLED 446
-#define ERR_NOTREGISTERED 451
-#define ERR_NEEDMOREPARAMS 461
-#define ERR_ALREADYREGISTRED 462
-#define ERR_NOPERMFORHOST 463
-#define ERR_PASSWDMISMATCH 464
-#define ERR_YOUREBANNEDCREEP 465
-#define ERR_YOUWILLBEBANNED 466
-#define ERR_KEYSET 467
-#define ERR_CHANNELISFULL 471
-#define ERR_UNKNOWNMODE 472
-#define ERR_INVITEONLYCHAN 473
-#define ERR_BANNEDFROMCHAN 474
-#define ERR_BADCHANNELKEY 475
-#define ERR_BADCHANMASK 476
-#define ERR_NOCHANMODES 477
-#define ERR_BANLISTFULL 478
-#define ERR_NOPRIVILEGES 481
-#define ERR_CHANOPRIVSNEEDED 482
-#define ERR_CANTKILLSERVER 483
-#define ERR_RESTRICTED 484
-#define ERR_UNIQOPPRIVSNEEDED 485
-#define ERR_NOOPERHOST 491
-#define ERR_NOSERVICEHOST 492
-#define ERR_UMODEUNKNOWNFLAG 501
-#define ERR_USERSDONTMATCH 502
-
-typedef struct {
- char * msg;
- int code;
-} ircmsg_t;
-
-#define MSG_COUNT 151
-
-extern ircmsg_t ircmsgs[];
-
-class Channel : public Base {
- public:
- Channel(const String &, const String & = "");
- ~Channel();
-
- protected:
- Channel * GetNext();
- Channel * GetPrev();
- String GetName();
- String GetKey();
-
- private:
- String Name, Key;
- static Channel * start;
- Channel * next, * prev;
-};
-
-class IRC : public Base {
- public:
- IRC(const String & = "Nick", const String & = "irc.openprojects.net", const String & = "guest_user", const String & = "Irc Name", int Port = 6667);
- virtual ~IRC();
- bool Connect();
- void MainLoop();
-
- private:
- int Parse(const String &);
- String nick, server, user, name;
- int port;
- Socket sock;
- int loginsequence;
-};
-
-#endif
+#ifndef __IRC_H__ +#define __IRC_H__ + +#include <Socket.h> +#include <Exceptions.h> +#include <BString.h> + +#define RPL_WELCOME 1 +#define RPL_YOURHOST 2 +#define RPL_CREATED 3 +#define RPL_MYINFO 4 +#define RPL_BOUNCE 5 +#define RPL_TRACELINK 200 +#define RPL_TRACECONNECTING 201 +#define RPL_TRACEHANDSHAKE 202 +#define RPL_TRACEUNKNOWN 203 +#define RPL_TRACEOPERATOR 204 +#define RPL_TRACEUSER 205 +#define RPL_TRACESERVER 206 +#define RPL_TRACESERVICE 207 +#define RPL_TRACENEWTYPE 208 +#define RPL_TRACECLASS 209 +#define RPL_TRACERECONNECT 210 +#define RPL_STATSLINKINFO 211 +#define RPL_STATSCOMMANDS 212 +#define RPL_STATSCLINE 213 +#define RPL_STATSILINE 215 +#define RPL_STATSQLINE 217 +#define RPL_ENDOFSTATS 219 +#define RPL_UMODEIS 221 +#define RPL_SERVICEINFO 231 +#define RPL_SERVICE 233 +#define RPL_SERVLIST 234 +#define RPL_SERVLISTEND 235 +#define RPL_STATSVLINE 240 +#define RPL_STATSUPTIME 242 +#define RPL_STATSOLINE 243 +#define RPL_STATSHLINE 244 +#define RPL_STATSPING 246 +#define RPL_STATSDLINE 250 +#define RPL_LUSERCLIENT 251 +#define RPL_LUSEROP 252 +#define RPL_LUSERUNKNOWN 253 +#define RPL_LUSERCHANNELS 254 +#define RPL_LUSERME 255 +#define RPL_ADMINME 256 +#define RPL_ADMINLOC1 257 +#define RPL_ADMINLOC2 258 +#define RPL_ADMINEMAIL 259 +#define RPL_TRACELOG 261 +#define RPL_TRACEEND 262 +#define RPL_TRYAGAIN 263 +#define RPL_NONE 300 +#define RPL_AWAY 301 +#define RPL_USERHOST 302 +#define RPL_ISON 303 +#define RPL_UNAWAY 305 +#define RPL_NOWAWAY 306 +#define RPL_WHOISUSER 311 +#define RPL_WHOISSERVER 312 +#define RPL_WHOISOPERATOR 313 +#define RPL_WHOWASUSER 314 +#define RPL_ENDOFWHO 315 +#define RPL_WHOISIDLE 317 +#define RPL_ENDOFWHOIS 318 +#define RPL_WHOISCHANNELS 319 +#define RPL_LISTSTART 321 +#define RPL_LIST 322 +#define RPL_LISTEND 323 +#define RPL_CHANNELMODEIS 324 +#define RPL_UNIQOPIS 325 +#define RPL_NOTOPIC 331 +#define RPL_TOPIC 332 +#define RPL_INVITING 341 +#define RPL_SUMMONING 342 +#define RPL_INVITELIST 346 +#define RPL_ENDOFINVITELIST 347 +#define RPL_EXCEPTLIST 348 +#define RPL_ENDOFEXCEPTLIST 349 +#define RPL_VERSION 351 +#define RPL_WHOREPLY 352 +#define RPL_NAMREPLY 353 +#define RPL_KILLDONE 361 +#define RPL_CLOSEEND 363 +#define RPL_LINKS 364 +#define RPL_ENDOFLINKS 365 +#define RPL_ENDOFNAMES 366 +#define RPL_BANLIST 367 +#define RPL_ENDOFBANLIST 368 +#define RPL_ENDOFWHOWAS 369 +#define RPL_INFO 371 +#define RPL_MOTD 372 +#define RPL_ENDOFINFO 374 +#define RPL_MOTDSTART 375 +#define RPL_ENDOFMOTD 376 +#define RPL_YOUREOPER 381 +#define RPL_REHASHING 382 +#define RPL_YOURESERVICE 383 +#define RPL_MYPORTIS 384 +#define RPL_TIME 391 +#define RPL_USERSSTART 392 +#define RPL_USERS 393 +#define RPL_ENDOFUSERS 394 +#define RPL_NOUSERS 395 +#define ERR_NOSUCHNICK 401 +#define ERR_NOSUCHSERVER 402 +#define ERR_NOSUCHCHANNEL 403 +#define ERR_CANNOTSENDTOCHAN 404 +#define ERR_TOOMANYCHANNELS 405 +#define ERR_WASNOSUCHNICK 406 +#define ERR_TOOMANYTARGETS 407 +#define ERR_NOSUCHSERVICE 408 +#define ERR_NOORIGIN 409 +#define ERR_NORECIPIENT 411 +#define ERR_NOTEXTTOSEND 412 +#define ERR_NOTOPLEVEL 413 +#define ERR_WILDTOPLEVEL 414 +#define ERR_BADMASK 415 +#define ERR_UNKNOWNCOMMAND 421 +#define ERR_NOMOTD 422 +#define ERR_NOADMININFO 423 +#define ERR_FILEERROR 424 +#define ERR_NONICKNAMEGIVEN 431 +#define ERR_ERRONEUSNICKNAME 432 +#define ERR_NICKNAMEINUSE 433 +#define ERR_NICKCOLLISION 436 +#define ERR_UNAVAILRESOURCE 437 +#define ERR_USERNOTINCHANNEL 441 +#define ERR_NOTONCHANNEL 442 +#define ERR_USERONCHANNEL 443 +#define ERR_NOLOGIN 444 +#define ERR_SUMMONDISABLED 445 +#define ERR_USERSDISABLED 446 +#define ERR_NOTREGISTERED 451 +#define ERR_NEEDMOREPARAMS 461 +#define ERR_ALREADYREGISTRED 462 +#define ERR_NOPERMFORHOST 463 +#define ERR_PASSWDMISMATCH 464 +#define ERR_YOUREBANNEDCREEP 465 +#define ERR_YOUWILLBEBANNED 466 +#define ERR_KEYSET 467 +#define ERR_CHANNELISFULL 471 +#define ERR_UNKNOWNMODE 472 +#define ERR_INVITEONLYCHAN 473 +#define ERR_BANNEDFROMCHAN 474 +#define ERR_BADCHANNELKEY 475 +#define ERR_BADCHANMASK 476 +#define ERR_NOCHANMODES 477 +#define ERR_BANLISTFULL 478 +#define ERR_NOPRIVILEGES 481 +#define ERR_CHANOPRIVSNEEDED 482 +#define ERR_CANTKILLSERVER 483 +#define ERR_RESTRICTED 484 +#define ERR_UNIQOPPRIVSNEEDED 485 +#define ERR_NOOPERHOST 491 +#define ERR_NOSERVICEHOST 492 +#define ERR_UMODEUNKNOWNFLAG 501 +#define ERR_USERSDONTMATCH 502 + +typedef struct { + char * msg; + int code; +} ircmsg_t; + +#define MSG_COUNT 151 + +extern ircmsg_t ircmsgs[]; + +class Channel : public Base { + public: + Channel(const String &, const String & = ""); + ~Channel(); + + protected: + Channel * GetNext(); + Channel * GetPrev(); + String GetName(); + String GetKey(); + + private: + String Name, Key; + static Channel * start; + Channel * next, * prev; +}; + +class IRC : public Base { + public: + IRC(const String & = "Nick", const String & = "irc.openprojects.net", const String & = "guest_user", const String & = "Irc Name", int Port = 6667); + virtual ~IRC(); + bool Connect(); + void MainLoop(); + + private: + int Parse(const String &); + String nick, server, user, name; + int port; + Socket sock; + int loginsequence; +}; + +#endif diff --git a/include/Image.h b/include/Image.h index 4a7d0ef..633ab55 100644 --- a/include/Image.h +++ b/include/Image.h @@ -1,53 +1,53 @@ -#ifndef __IMAGE_H__
-#define __IMAGE_H__
-
-#include <Buffer.h>
-#include <generic.h>
-#include <Color.h>
-
-enum {
- FORMAT_TGA_BASIC
-};
-
-class Image : public Buffer {
- public:
- Image(unsigned int, unsigned int);
- virtual ~Image();
- Color GetPixel(unsigned int, unsigned int) const;
- void SetPixel(unsigned int, unsigned int, Color);
- bool Prepare(unsigned int = FORMAT_TGA_BASIC);
- void Fill(Color = Color(0, 0, 0));
- virtual String GetName() const;
- virtual bool CanWrite() const;
-
- private:
- typedef unsigned char Byte;
- typedef unsigned short int Word;
- typedef unsigned long int DWord;
- struct TGAHeader {
- Byte IDLength;
- Byte ColorMapType;
- Byte ImageType;
- Word CM_FirstEntry;
- Word CM_Length;
- Byte CM_EntrySize;
- Word IS_XOrigin;
- Word IS_YOrigin;
- Word IS_Width;
- Word IS_Height;
- Byte IS_Depth;
- Byte IS_Descriptor;
- } PACKED;
-
- struct TGAFooter {
- DWord ExtOffset;
- DWord DevOffset;
- char Sig[18];
- } PACKED;
-
- unsigned int x, y;
- bool r;
- Color * img;
-};
-
-#endif
+#ifndef __IMAGE_H__ +#define __IMAGE_H__ + +#include <Buffer.h> +#include <generic.h> +#include <Color.h> + +enum { + FORMAT_TGA_BASIC +}; + +class Image : public Buffer { + public: + Image(unsigned int, unsigned int); + virtual ~Image(); + Color GetPixel(unsigned int, unsigned int) const; + void SetPixel(unsigned int, unsigned int, Color); + bool Prepare(unsigned int = FORMAT_TGA_BASIC); + void Fill(Color = Color(0, 0, 0)); + virtual String GetName() const; + virtual bool CanWrite() const; + + private: + typedef unsigned char Byte; + typedef unsigned short int Word; + typedef unsigned long int DWord; + struct TGAHeader { + Byte IDLength; + Byte ColorMapType; + Byte ImageType; + Word CM_FirstEntry; + Word CM_Length; + Byte CM_EntrySize; + Word IS_XOrigin; + Word IS_YOrigin; + Word IS_Width; + Word IS_Height; + Byte IS_Depth; + Byte IS_Descriptor; + } PACKED; + + struct TGAFooter { + DWord ExtOffset; + DWord DevOffset; + char Sig[18]; + } PACKED; + + unsigned int x, y; + bool r; + Color * img; +}; + +#endif diff --git a/include/InPipe.h b/include/InPipe.h index b08b35c..2828da3 100644 --- a/include/InPipe.h +++ b/include/InPipe.h @@ -1,19 +1,19 @@ -#ifndef __INPIPE_H__
-#define __INPIPE_H__
-
-#include <Handle.h>
-
-class InPipe : public Handle {
- public:
- InPipe();
- InPipe(const InPipe &);
- virtual ~InPipe();
- void Hook();
- virtual bool CanWrite();
- virtual bool CanRead();
- virtual String GetName();
- private:
- int p[2], hooked;
-};
-
-#endif
+#ifndef __INPIPE_H__ +#define __INPIPE_H__ + +#include <Handle.h> + +class InPipe : public Handle { + public: + InPipe(); + InPipe(const InPipe &); + virtual ~InPipe(); + void Hook(); + virtual bool CanWrite(); + virtual bool CanRead(); + virtual String GetName(); + private: + int p[2], hooked; +}; + +#endif diff --git a/include/Input.h b/include/Input.h index 20eaf4c..5a76e71 100644 --- a/include/Input.h +++ b/include/Input.h @@ -1,116 +1,116 @@ -/*
- * Baltisot
- * Copyright (C) 1999-2003 Nicolas "Pixel" Noble
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-/* $Id: Input.h,v 1.20 2004-11-27 21:43:48 pixel Exp $ */
-
-#ifndef __INPUT_H__
-#define __INPUT_H__
-
-#include <sys/types.h>
-#include <time.h>
-#include <BString.h>
-#include <Handle.h>
-
-enum ArchiveType {
- ARCHIVE_BUILTIN = 0,
- ARCHIVE_EXECUTABLE
-};
-
-class Input : public Handle {
- public:
- Input(const String & = "") throw (GeneralException);
- Input(const Input &);
- virtual ~Input() {}
- virtual bool CanWrite() const;
- virtual bool CanRead() const;
- virtual bool CanSeek() const;
- virtual off_t seek(off_t, int = SEEK_SET) throw (GeneralException);
- virtual String GetName() const;
- virtual ssize_t GetSize() const;
- virtual time_t GetModif() const;
- virtual void SetZ(int = 9) throw (GeneralException);
-
- struct openresults_t {
- String name;
- int type;
- size_t size;
- size_t ptr;
- };
-
- protected:
- String n;
- off_t size;
- time_t date_modif;
- openresults_t results;
- bool fromarchive;
-
- private:
- int wrapopen(const String &, openresults_t *);
-};
-
-class Stdin_t : public Input {
- public:
- Stdin_t();
- virtual ~Stdin_t() {}
- virtual bool CanSeek() const;
- virtual String GetName() const;
-};
-
-extern Stdin_t Stdin;
-
-class Archive : public Base {
- public:
- Archive(const String &, int = ARCHIVE_BUILTIN);
- Archive(Handle *, int = ARCHIVE_BUILTIN);
- virtual ~Archive();
- protected:
- static Archive * inarchive(const String &);
- Handle * GetHandle();
- int open(const String &, Input::openresults_t *);
- private:
- void create() throw (GeneralException);
- bool inarchivein(const String &);
- int openin(const String &, Input::openresults_t *) throw (GeneralException);
- class FileTree : public Base {
- public:
- FileTree(const String & = "", size_t = 0, int = 0, FileTree * = 0);
- virtual ~FileTree();
- int compute_ptrs(size_t = 0);
- FileTree * Father();
- FileTree * Child();
- FileTree * Next();
- FileTree * Prev();
- String name;
- int type;
- size_t size;
- size_t ptr;
- private:
- void touched();
- FileTree * next, * prev, * father, * child;
- } filetree;
- String name;
- Handle * archive;
- int type;
- Archive * next, * prev;
- static Archive * header;
-
- friend class Input;
-};
-
-#endif
+/* + * Baltisot + * Copyright (C) 1999-2003 Nicolas "Pixel" Noble + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* $Id: Input.h,v 1.21 2004-11-27 21:46:02 pixel Exp $ */ + +#ifndef __INPUT_H__ +#define __INPUT_H__ + +#include <sys/types.h> +#include <time.h> +#include <BString.h> +#include <Handle.h> + +enum ArchiveType { + ARCHIVE_BUILTIN = 0, + ARCHIVE_EXECUTABLE +}; + +class Input : public Handle { + public: + Input(const String & = "") throw (GeneralException); + Input(const Input &); + virtual ~Input() {} + virtual bool CanWrite() const; + virtual bool CanRead() const; + virtual bool CanSeek() const; + virtual off_t seek(off_t, int = SEEK_SET) throw (GeneralException); + virtual String GetName() const; + virtual ssize_t GetSize() const; + virtual time_t GetModif() const; + virtual void SetZ(int = 9) throw (GeneralException); + + struct openresults_t { + String name; + int type; + size_t size; + size_t ptr; + }; + + protected: + String n; + off_t size; + time_t date_modif; + openresults_t results; + bool fromarchive; + + private: + int wrapopen(const String &, openresults_t *); +}; + +class Stdin_t : public Input { + public: + Stdin_t(); + virtual ~Stdin_t() {} + virtual bool CanSeek() const; + virtual String GetName() const; +}; + +extern Stdin_t Stdin; + +class Archive : public Base { + public: + Archive(const String &, int = ARCHIVE_BUILTIN); + Archive(Handle *, int = ARCHIVE_BUILTIN); + virtual ~Archive(); + protected: + static Archive * inarchive(const String &); + Handle * GetHandle(); + int open(const String &, Input::openresults_t *); + private: + void create() throw (GeneralException); + bool inarchivein(const String &); + int openin(const String &, Input::openresults_t *) throw (GeneralException); + class FileTree : public Base { + public: + FileTree(const String & = "", size_t = 0, int = 0, FileTree * = 0); + virtual ~FileTree(); + int compute_ptrs(size_t = 0); + FileTree * Father(); + FileTree * Child(); + FileTree * Next(); + FileTree * Prev(); + String name; + int type; + size_t size; + size_t ptr; + private: + void touched(); + FileTree * next, * prev, * father, * child; + } filetree; + String name; + Handle * archive; + int type; + Archive * next, * prev; + static Archive * header; + + friend class Input; +}; + +#endif diff --git a/include/LuaHandle.h b/include/LuaHandle.h index 2ef61df..ed31593 100644 --- a/include/LuaHandle.h +++ b/include/LuaHandle.h @@ -1,81 +1,81 @@ -/*
- * Baltisot
- * Copyright (C) 1999-2003 Nicolas "Pixel" Noble
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-/* $Id: LuaHandle.h,v 1.7 2004-11-27 21:43:48 pixel Exp $ */
-
-#ifndef __LUAHANDLE_H__
-#define __LUAHANDLE_H__
-
-#include <Exceptions.h>
-#include <Input.h>
-#include <Output.h>
-#include <Buffer.h>
-#include <BLua.h>
-
-class LuaHandle : public LuaObject {
- public:
- LuaHandle(Handle *);
- protected:
- virtual void pushmembers(Lua *);
- Handle * h;
-};
-
-class LuaInput : public LuaHandle {
- public:
- static void pushconstruct(Lua *);
- LuaInput(Input *);
- protected:
- virtual void pushmembers(Lua *);
-};
-
-class LuaOutput : public LuaHandle {
- public:
- static void pushconstruct(Lua *);
- LuaOutput(Output *);
- protected:
- virtual void pushmembers(Lua *);
-};
-
-class LuaBuffer : public LuaHandle {
- public:
- static void pushconstruct(Lua *);
- LuaBuffer(Buffer *);
- protected:
- virtual void pushmembers(Lua *);
-};
-
-class HandleLua : public Handle {
- public:
- HandleLua();
- virtual ~HandleLua();
- virtual ssize_t read(void * buf, size_t count) throw (GeneralException);
- virtual ssize_t write(const void * buf, size_t count) throw (GeneralException);
- virtual bool CanRead() const;
- virtual bool CanWrite() const;
- virtual bool CanSeek() const;
- virtual off_t seek(off_t, int = SEEK_SET) throw (GeneralException);
- virtual off_t tell() const;
- virtual String GetName() const;
- virtual ssize_t GetSize() const;
- virtual time_t GetModif() const;
- virtual bool CanWatch() const;
- virtual void Flush();
-};
-
-#endif
+/* + * Baltisot + * Copyright (C) 1999-2003 Nicolas "Pixel" Noble + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* $Id: LuaHandle.h,v 1.8 2004-11-27 21:46:03 pixel Exp $ */ + +#ifndef __LUAHANDLE_H__ +#define __LUAHANDLE_H__ + +#include <Exceptions.h> +#include <Input.h> +#include <Output.h> +#include <Buffer.h> +#include <BLua.h> + +class LuaHandle : public LuaObject { + public: + LuaHandle(Handle *); + protected: + virtual void pushmembers(Lua *); + Handle * h; +}; + +class LuaInput : public LuaHandle { + public: + static void pushconstruct(Lua *); + LuaInput(Input *); + protected: + virtual void pushmembers(Lua *); +}; + +class LuaOutput : public LuaHandle { + public: + static void pushconstruct(Lua *); + LuaOutput(Output *); + protected: + virtual void pushmembers(Lua *); +}; + +class LuaBuffer : public LuaHandle { + public: + static void pushconstruct(Lua *); + LuaBuffer(Buffer *); + protected: + virtual void pushmembers(Lua *); +}; + +class HandleLua : public Handle { + public: + HandleLua(); + virtual ~HandleLua(); + virtual ssize_t read(void * buf, size_t count) throw (GeneralException); + virtual ssize_t write(const void * buf, size_t count) throw (GeneralException); + virtual bool CanRead() const; + virtual bool CanWrite() const; + virtual bool CanSeek() const; + virtual off_t seek(off_t, int = SEEK_SET) throw (GeneralException); + virtual off_t tell() const; + virtual String GetName() const; + virtual ssize_t GetSize() const; + virtual time_t GetModif() const; + virtual bool CanWatch() const; + virtual void Flush(); +}; + +#endif diff --git a/include/Main.h b/include/Main.h index f0db8ca..7d8da5e 100644 --- a/include/Main.h +++ b/include/Main.h @@ -1,60 +1,60 @@ -/*
- * Baltisot
- * Copyright (C) 1999-2003 Nicolas "Pixel" Noble
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-/* $Id: Main.h,v 1.15 2004-11-27 21:43:48 pixel Exp $ */
-
-#ifndef __MAIN_H__
-#define __MAIN_H__
-
-#include <Exceptions.h>
-#include <gettext.h>
-
-extern char ** environ;
-
-class Main : public Base {
- public:
- Main();
- virtual ~Main();
- virtual int startup() throw (GeneralException) = 0;
- static int truemain(Main *, int, char **, char **);
- protected:
- int argc;
- char ** argv;
- char ** enve;
- bool setted;
- private:
- void set_args(int, char **, char **);
-
-};
-
-#define CODE_BEGINS \
-class Appli; \
-Appli * Application; \
-class Appli : public Main {
-#define CODE_ENDS }; \
-int main(int argc, char ** argv) { \
- int r; \
- setlocale(LC_ALL, ""); \
- Application = new Appli(); \
- r = Main::truemain(Application, argc, argv, environ); \
- delete Application; \
- return r; \
- }
-
-#endif
+/* + * Baltisot + * Copyright (C) 1999-2003 Nicolas "Pixel" Noble + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* $Id: Main.h,v 1.16 2004-11-27 21:46:03 pixel Exp $ */ + +#ifndef __MAIN_H__ +#define __MAIN_H__ + +#include <Exceptions.h> +#include <gettext.h> + +extern char ** environ; + +class Main : public Base { + public: + Main(); + virtual ~Main(); + virtual int startup() throw (GeneralException) = 0; + static int truemain(Main *, int, char **, char **); + protected: + int argc; + char ** argv; + char ** enve; + bool setted; + private: + void set_args(int, char **, char **); + +}; + +#define CODE_BEGINS \ +class Appli; \ +Appli * Application; \ +class Appli : public Main { +#define CODE_ENDS }; \ +int main(int argc, char ** argv) { \ + int r; \ + setlocale(LC_ALL, ""); \ + Application = new Appli(); \ + r = Main::truemain(Application, argc, argv, environ); \ + delete Application; \ + return r; \ + } + +#endif diff --git a/include/Menu.h b/include/Menu.h index 1caec66..91e1459 100644 --- a/include/Menu.h +++ b/include/Menu.h @@ -1,22 +1,22 @@ -#ifndef __MENU_H__
-#define __MENU_H__
-
-#include <Action.h>
-#include <BString.h>
-#include <Exceptions.h>
-
-class Menu : public Action {
- public:
- Menu(const String & titre, const String & url, String * labels, Action ** listac, int nb);
- virtual ~Menu() {}
- virtual String GetTitle();
- virtual Task * Do(Variables *, Variables *, Handle *);
-
- private:
- String tit;
- String * lt;
- Action ** la;
- int nba;
-};
-
-#endif
+#ifndef __MENU_H__ +#define __MENU_H__ + +#include <Action.h> +#include <BString.h> +#include <Exceptions.h> + +class Menu : public Action { + public: + Menu(const String & titre, const String & url, String * labels, Action ** listac, int nb); + virtual ~Menu() {} + virtual String GetTitle(); + virtual Task * Do(Variables *, Variables *, Handle *); + + private: + String tit; + String * lt; + Action ** la; + int nba; +}; + +#endif diff --git a/include/Message.h b/include/Message.h index fd6c6e9..01c59da 100644 --- a/include/Message.h +++ b/include/Message.h @@ -1,20 +1,20 @@ -#ifndef __MESSAGE_H__
-#define __MESSAGE_H__
-
-#include <Action.h>
-#include <BString.h>
-#include <Exceptions.h>
-
-class Message : public Action {
- public:
- Message(const String & titre, const String & msg, const String & url, Action * ok = 0);
- virtual ~Message() { }
- virtual String GetTitle();
- virtual Task * Do(Variables *, Variables *, Handle *);
-
- private:
- String tit, msg;
- Action * Next;
-};
-
-#endif
+#ifndef __MESSAGE_H__ +#define __MESSAGE_H__ + +#include <Action.h> +#include <BString.h> +#include <Exceptions.h> + +class Message : public Action { + public: + Message(const String & titre, const String & msg, const String & url, Action * ok = 0); + virtual ~Message() { } + virtual String GetTitle(); + virtual Task * Do(Variables *, Variables *, Handle *); + + private: + String tit, msg; + Action * Next; +}; + +#endif diff --git a/include/OutPipe.h b/include/OutPipe.h index 9d016da..467a89b 100644 --- a/include/OutPipe.h +++ b/include/OutPipe.h @@ -1,19 +1,19 @@ -#ifndef __OUTPIPE_H__
-#define __OUTPIPE_H__
-
-#include <Handle.h>
-
-class OutPipe : public Handle {
- public:
- OutPipe();
- OutPipe(const OutPipe &);
- virtual ~OutPipe();
- void Hook();
- virtual bool CanWrite();
- virtual bool CanRead();
- virtual String GetName();
- private:
- int p[2], hooked;
-};
-
-#endif
+#ifndef __OUTPIPE_H__ +#define __OUTPIPE_H__ + +#include <Handle.h> + +class OutPipe : public Handle { + public: + OutPipe(); + OutPipe(const OutPipe &); + virtual ~OutPipe(); + void Hook(); + virtual bool CanWrite(); + virtual bool CanRead(); + virtual String GetName(); + private: + int p[2], hooked; +}; + +#endif diff --git a/include/Output.h b/include/Output.h index 17d12d8..3144b32 100644 --- a/include/Output.h +++ b/include/Output.h @@ -1,71 +1,71 @@ -/*
- * Baltisot
- * Copyright (C) 1999-2003 Nicolas "Pixel" Noble
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-/* $Id: Output.h,v 1.13 2004-11-27 21:43:48 pixel Exp $ */
-
-#ifndef __OUTPUT_H__
-#define __OUTPUT_H__
-
-#include <sys/types.h>
-#include <time.h>
-#include <BString.h>
-#include <Handle.h>
-
-class Output : public Handle {
- public:
- Output(String = "", int create = 1, int trunc = 1) throw (GeneralException);
- Output(const Output &);
- virtual ~Output() {}
- virtual bool CanWrite() const;
- virtual bool CanRead() const;
- virtual bool CanSeek() const;
- virtual off_t seek(off_t, int = SEEK_SET) throw (GeneralException);
- virtual String GetName() const;
-
- protected:
- String n;
- off_t size;
- time_t date_modif;
-
- private:
- int wrapopen(const String &, int, int);
-};
-
-class Stdout_t : public Output {
- public:
- Stdout_t();
- virtual ~Stdout_t() {}
- virtual bool CanSeek() const;
- virtual String GetName() const;
-};
-
-class Stderr_t : public Handle {
- public:
- Stderr_t();
- virtual ~Stderr_t() {}
- virtual bool CanWrite() const;
- virtual bool CanRead() const;
- virtual bool CanSeek() const;
- virtual String GetName() const;
-};
-
-extern Stdout_t Stdout;
-extern Stderr_t Stderr;
-
-#endif
+/* + * Baltisot + * Copyright (C) 1999-2003 Nicolas "Pixel" Noble + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* $Id: Output.h,v 1.14 2004-11-27 21:46:03 pixel Exp $ */ + +#ifndef __OUTPUT_H__ +#define __OUTPUT_H__ + +#include <sys/types.h> +#include <time.h> +#include <BString.h> +#include <Handle.h> + +class Output : public Handle { + public: + Output(String = "", int create = 1, int trunc = 1) throw (GeneralException); + Output(const Output &); + virtual ~Output() {} + virtual bool CanWrite() const; + virtual bool CanRead() const; + virtual bool CanSeek() const; + virtual off_t seek(off_t, int = SEEK_SET) throw (GeneralException); + virtual String GetName() const; + + protected: + String n; + off_t size; + time_t date_modif; + + private: + int wrapopen(const String &, int, int); +}; + +class Stdout_t : public Output { + public: + Stdout_t(); + virtual ~Stdout_t() {} + virtual bool CanSeek() const; + virtual String GetName() const; +}; + +class Stderr_t : public Handle { + public: + Stderr_t(); + virtual ~Stderr_t() {} + virtual bool CanWrite() const; + virtual bool CanRead() const; + virtual bool CanSeek() const; + virtual String GetName() const; +}; + +extern Stdout_t Stdout; +extern Stderr_t Stderr; + +#endif diff --git a/include/ReadJob.h b/include/ReadJob.h index 95a373e..d861aff 100644 --- a/include/ReadJob.h +++ b/include/ReadJob.h @@ -1,20 +1,20 @@ -#ifndef __READJOB_H__
-#define __READJOB_H__
-
-#include <Task.h>
-#include <Handle.h>
-#include <Regex.h>
-
-class ReadJob : public Task {
- public:
- ReadJob(Handle *, Handle *, const Regex & = empty);
- virtual ~ReadJob();
- virtual int Do() throw (GeneralException);
- virtual String GetName();
-
- private:
- Handle * s, * d;
- const Regex * regex;
-};
-
-#endif
+#ifndef __READJOB_H__ +#define __READJOB_H__ + +#include <Task.h> +#include <Handle.h> +#include <Regex.h> + +class ReadJob : public Task { + public: + ReadJob(Handle *, Handle *, const Regex & = empty); + virtual ~ReadJob(); + virtual int Do() throw (GeneralException); + virtual String GetName(); + + private: + Handle * s, * d; + const Regex * regex; +}; + +#endif diff --git a/include/Regex.h b/include/Regex.h index daac59f..b076342 100644 --- a/include/Regex.h +++ b/include/Regex.h @@ -1,22 +1,22 @@ -#ifndef __REGEX_H__
-#define __REGEX_H__
-
-#include <Exceptions.h>
-#include <BString.h>
-#include <regex.h>
-
-class Regex : public Base {
- public:
- Regex(const String &, int = REG_EXTENDED, int = 0) throw (GeneralException);
- Regex(const Regex &);
- ~Regex();
- bool Match(const String &) const;
- private:
- regex_t preg;
- int cflags, eflags;
- char * pattern;
-};
-
-extern Regex empty, any;
-
-#endif
+#ifndef __REGEX_H__ +#define __REGEX_H__ + +#include <Exceptions.h> +#include <BString.h> +#include <regex.h> + +class Regex : public Base { + public: + Regex(const String &, int = REG_EXTENDED, int = 0) throw (GeneralException); + Regex(const Regex &); + ~Regex(); + bool Match(const String &) const; + private: + regex_t preg; + int cflags, eflags; + char * pattern; +}; + +extern Regex empty, any; + +#endif diff --git a/include/SQL.h b/include/SQL.h index 637ff90..4385a6d 100644 --- a/include/SQL.h +++ b/include/SQL.h @@ -1,25 +1,25 @@ -#ifndef __SQL_H__
-#define __SQL_H__
-
-#include <map>
-#include <mysql.h>
-#include <Exceptions.h>
-
-typedef std::map<String, String> AssocArray;
-
-class SQLConnection : public Base {
- public:
- SQLConnection(String host, String user, String passwd, String db, int port = 3306, String socket = "", unsigned long clags = 0) throw (GeneralException);
- ~SQLConnection();
- void query(String) throw (GeneralException);
- int numrows();
- int numfields();
- AssocArray fetchrow();
- private:
- MYSQL con;
- MYSQL_RES * res;
- int nr, nf;
- MYSQL_FIELD * fields;
-};
-
-#endif
+#ifndef __SQL_H__ +#define __SQL_H__ + +#include <map> +#include <mysql.h> +#include <Exceptions.h> + +typedef std::map<String, String> AssocArray; + +class SQLConnection : public Base { + public: + SQLConnection(String host, String user, String passwd, String db, int port = 3306, String socket = "", unsigned long clags = 0) throw (GeneralException); + ~SQLConnection(); + void query(String) throw (GeneralException); + int numrows(); + int numfields(); + AssocArray fetchrow(); + private: + MYSQL con; + MYSQL_RES * res; + int nr, nf; + MYSQL_FIELD * fields; +}; + +#endif diff --git a/include/Socket.h b/include/Socket.h index 482a09f..245ed9e 100644 --- a/include/Socket.h +++ b/include/Socket.h @@ -1,33 +1,33 @@ -#ifndef __SOCKET_H__
-#define __SOCKET_H__
-
-#include <Handle.h>
-#include <BString.h>
-#include <Output.h>
-#include <Input.h>
-#include <Exceptions.h>
-
-class Socket : public Handle {
- public:
- Socket() throw (GeneralException);
- Socket(const Socket &);
- virtual ~Socket() {}
- bool SetLocal(const String &, int = 0);
- bool Connect(const String &, int);
- bool Listen();
- Socket Accept() throw (GeneralException);
- bool IsConnected();
- bool IsListening();
- virtual bool CanRead();
- virtual bool CanWrite();
- virtual String GetName();
- int GetPort();
- void CloseWrite();
- void CloseRead();
-
- private:
- Socket(int s);
- bool connected, listening, writeclosed, readclosed;
-};
-
-#endif
+#ifndef __SOCKET_H__ +#define __SOCKET_H__ + +#include <Handle.h> +#include <BString.h> +#include <Output.h> +#include <Input.h> +#include <Exceptions.h> + +class Socket : public Handle { + public: + Socket() throw (GeneralException); + Socket(const Socket &); + virtual ~Socket() {} + bool SetLocal(const String &, int = 0); + bool Connect(const String &, int); + bool Listen(); + Socket Accept() throw (GeneralException); + bool IsConnected(); + bool IsListening(); + virtual bool CanRead(); + virtual bool CanWrite(); + virtual String GetName(); + int GetPort(); + void CloseWrite(); + void CloseRead(); + + private: + Socket(int s); + bool connected, listening, writeclosed, readclosed; +}; + +#endif diff --git a/include/Table.h b/include/Table.h index 00de842..c972fa3 100644 --- a/include/Table.h +++ b/include/Table.h @@ -1,21 +1,21 @@ -#ifndef __TABLE_H__
-#define __TABLE_H__
-
-#include <Action.h>
-#include <BString.h>
-#include <Exceptions.h>
-
-class Table : public Action {
- public:
- Table(const String & titre, const String & url, String * heads, String * cells, int nbcol, int nblgn, Action * ok = 0);
- virtual ~Table() { }
- virtual String GetTitle();
- virtual Task * Do(Variables *, Variables *, Handle *);
-
- private:
- String tit, * hds, * cls;
- int nc, nl;
- Action * Next;
-};
-
-#endif
+#ifndef __TABLE_H__ +#define __TABLE_H__ + +#include <Action.h> +#include <BString.h> +#include <Exceptions.h> + +class Table : public Action { + public: + Table(const String & titre, const String & url, String * heads, String * cells, int nbcol, int nblgn, Action * ok = 0); + virtual ~Table() { } + virtual String GetTitle(); + virtual Task * Do(Variables *, Variables *, Handle *); + + private: + String tit, * hds, * cls; + int nc, nl; + Action * Next; +}; + +#endif diff --git a/include/Task.h b/include/Task.h index 384207a..9c966a3 100644 --- a/include/Task.h +++ b/include/Task.h @@ -1,55 +1,55 @@ -#ifndef __TASK_H__
-#define __TASK_H__
-
-#include <unistd.h>
-#include <sys/time.h>
-#include <vector>
-#include <Exceptions.h>
-#include <Handle.h>
-
-#define TASK_ON_HOLD 0
-#define TASK_DONE 1
-#define TASK_BURST 2
-
-#define W4_STICKY 1
-#define W4_READING 2
-#define W4_WRITING 4
-
-class Task : public Base {
- public:
- Task();
- virtual ~Task();
- virtual String GetName();
- int Run();
- int DryRun();
- int GetState();
- void Suspend(int = -1) throw (GeneralException);
- void WaitFor(Task *);
- void WaitFor(Handle *, int = 0);
- void WaitFor(pid_t);
- void WaitFor(timeval, int = 0);
- Task * WaitedBy();
- void SetBurst();
- void Stop();
- void Restart();
- bool IsStopped();
- void RemoveFromWatches();
-
- protected:
- virtual int Do() throw (GeneralException);
- int current;
-
- private:
- class wbta_t {
- public:
- wbta_t(Task * ata) : ta(ata) { }
- Task * ta;
- };
-
- int state;
- bool stopped;
- bool suspended;
- Task * wbta;
-};
-
-#endif
+#ifndef __TASK_H__ +#define __TASK_H__ + +#include <unistd.h> +#include <sys/time.h> +#include <vector> +#include <Exceptions.h> +#include <Handle.h> + +#define TASK_ON_HOLD 0 +#define TASK_DONE 1 +#define TASK_BURST 2 + +#define W4_STICKY 1 +#define W4_READING 2 +#define W4_WRITING 4 + +class Task : public Base { + public: + Task(); + virtual ~Task(); + virtual String GetName(); + int Run(); + int DryRun(); + int GetState(); + void Suspend(int = -1) throw (GeneralException); + void WaitFor(Task *); + void WaitFor(Handle *, int = 0); + void WaitFor(pid_t); + void WaitFor(timeval, int = 0); + Task * WaitedBy(); + void SetBurst(); + void Stop(); + void Restart(); + bool IsStopped(); + void RemoveFromWatches(); + + protected: + virtual int Do() throw (GeneralException); + int current; + + private: + class wbta_t { + public: + wbta_t(Task * ata) : ta(ata) { } + Task * ta; + }; + + int state; + bool stopped; + bool suspended; + Task * wbta; +}; + +#endif diff --git a/include/TaskMan.h b/include/TaskMan.h index dec46a3..128339f 100644 --- a/include/TaskMan.h +++ b/include/TaskMan.h @@ -1,74 +1,74 @@ -#ifndef __TASKMAN_H__
-#define __TASKMAN_H__
-
-#include <signal.h>
-#include <Task.h>
-#include <vector>
-
-#define E_BURST 0
-#define E_HANDLE 1
-#define E_PROCESS 2
-#define E_TIMEOUT 3
-#define E_TASK 4
-
-class TaskMan : public Base {
- public:
- static void AddTask(Task *);
- static std::vector<Task *>::iterator FindTask(Task *) throw (GeneralException);
- static void RemoveFromWatches(Task *);
- static void Init() throw (GeneralException);
- static void MainLoop() throw (GeneralException);
- static void WaitFor(Handle *, Task *, int = 0);
- static void WaitFor(pid_t, Task *, int = 0);
- static void WaitFor(timeval, Task *, int = 0);
- static int GotChild(pid_t, int);
- static void Stop();
- static int Event();
- static Task * Etask();
- static Handle * Ehandle();
- static int Eprocess();
- static int Estatus();
-
- class w4ha_t {
- public:
- w4ha_t(Handle * aha, int aflags, Task * aT) : ha(aha), flags(aflags), dirthy(true), T(aT) { }
- Handle * ha;
- int flags;
- bool dirthy;
- Task * T;
- };
-
- class w4pr_t {
- public:
- w4pr_t(pid_t apr, Task * aT) : pr(apr), flag(0), status(0), T(aT) { }
- pid_t pr;
- int flag, status;
- Task * T;
- };
-
- class w4to_t {
- public:
- w4to_t(timeval ato, int aflags, Task * aT) : to(ato), flags(aflags), T(aT) { }
- timeval to;
- int flags;
- Task * T;
- };
- typedef std::vector<Task *> TaskList_t;
-
- private:
- static TaskList_t TaskList;
- static TaskList_t Zombies;
- static int number;
- static bool inited;
- static std::vector<w4ha_t> w4ha;
- static std::vector<w4pr_t> w4pr;
- static std::vector<w4to_t> w4to;
- static bool stopped;
- static int event;
- static Task * etask;
- static Handle * ehandle;
- static int eprocess, estatus;
- static sigset_t sigchildset;
-};
-
-#endif
+#ifndef __TASKMAN_H__ +#define __TASKMAN_H__ + +#include <signal.h> +#include <Task.h> +#include <vector> + +#define E_BURST 0 +#define E_HANDLE 1 +#define E_PROCESS 2 +#define E_TIMEOUT 3 +#define E_TASK 4 + +class TaskMan : public Base { + public: + static void AddTask(Task *); + static std::vector<Task *>::iterator FindTask(Task *) throw (GeneralException); + static void RemoveFromWatches(Task *); + static void Init() throw (GeneralException); + static void MainLoop() throw (GeneralException); + static void WaitFor(Handle *, Task *, int = 0); + static void WaitFor(pid_t, Task *, int = 0); + static void WaitFor(timeval, Task *, int = 0); + static int GotChild(pid_t, int); + static void Stop(); + static int Event(); + static Task * Etask(); + static Handle * Ehandle(); + static int Eprocess(); + static int Estatus(); + + class w4ha_t { + public: + w4ha_t(Handle * aha, int aflags, Task * aT) : ha(aha), flags(aflags), dirthy(true), T(aT) { } + Handle * ha; + int flags; + bool dirthy; + Task * T; + }; + + class w4pr_t { + public: + w4pr_t(pid_t apr, Task * aT) : pr(apr), flag(0), status(0), T(aT) { } + pid_t pr; + int flag, status; + Task * T; + }; + + class w4to_t { + public: + w4to_t(timeval ato, int aflags, Task * aT) : to(ato), flags(aflags), T(aT) { } + timeval to; + int flags; + Task * T; + }; + typedef std::vector<Task *> TaskList_t; + + private: + static TaskList_t TaskList; + static TaskList_t Zombies; + static int number; + static bool inited; + static std::vector<w4ha_t> w4ha; + static std::vector<w4pr_t> w4pr; + static std::vector<w4to_t> w4to; + static bool stopped; + static int event; + static Task * etask; + static Handle * ehandle; + static int eprocess, estatus; + static sigset_t sigchildset; +}; + +#endif diff --git a/include/Variables.h b/include/Variables.h index 9fab80c..ac4ef58 100644 --- a/include/Variables.h +++ b/include/Variables.h @@ -1,28 +1,28 @@ -#ifndef __VARIABLES_H__
-#define __VARIABLES_H__
-
-#include <vector>
-#include <BString.h>
-#include <Handle.h>
-#include <Exceptions.h>
-
-class Variables : public Base {
- public:
- Variables(int = 0);
- Variables(const Variables &);
- ~Variables();
- void SetTo(int i, const String &);
- String operator[](const String &);
- String operator[](int i);
- void Dump(Handle *, const String & = "");
- int GetNb();
- void Add(const String &);
- void Del(int);
- void Del(const String &);
-
- private:
- std::vector<String> Vars;
- int nbvars;
-};
-
-#endif
+#ifndef __VARIABLES_H__ +#define __VARIABLES_H__ + +#include <vector> +#include <BString.h> +#include <Handle.h> +#include <Exceptions.h> + +class Variables : public Base { + public: + Variables(int = 0); + Variables(const Variables &); + ~Variables(); + void SetTo(int i, const String &); + String operator[](const String &); + String operator[](int i); + void Dump(Handle *, const String & = ""); + int GetNb(); + void Add(const String &); + void Del(int); + void Del(const String &); + + private: + std::vector<String> Vars; + int nbvars; +}; + +#endif diff --git a/include/generic.h b/include/generic.h index bdfb51c..fe9b529 100644 --- a/include/generic.h +++ b/include/generic.h @@ -1,194 +1,194 @@ -/*
- * Baltisot
- * Copyright (C) 1999-2003 Nicolas "Pixel" Noble
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-/* $Id: generic.h,v 1.30 2004-11-27 21:43:48 pixel Exp $ */
-
-#ifndef __GENERIC_H__
-#define __GENERIC_H__
-
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <string.h>
-
-#define M_BARE -1
-#define M_ERROR 0
-#define M_STATUS 1
-#define M_WARNING 2
-#define M_INFO 3
-
-#ifdef _WIN32
-#include <windows.h>
-#endif
-
-#ifndef bcopy
-#define bcopy(x,y,z) memcpy((y),(x),(z))
-#endif
-
-#if ! defined SDL_VERSIONNUM && ! defined Uint32
-typedef unsigned long int Uint32;
-#endif
-
-#ifndef int32
-typedef signed long int int32;
-#endif
-
-#ifndef Uint16
-typedef unsigned short int Uint16;
-#endif
-
-#ifndef int16
-typedef signed short int int16;
-#endif
-
-#ifndef Uint8
-typedef unsigned char Uint8;
-#endif
-
-#ifndef int8
-typedef signed char int8;
-#endif
-
-#ifndef Byte
-typedef Uint8 Byte;
-#endif
-
-#ifndef Word
-typedef Uint16 Word;
-#endif
-
-#ifndef DWord
-typedef Uint32 DWord;
-#endif
-
-#if !defined __ssize_t_defined && !defined _SSIZE_T && !defined ssize_t && !defined _BSD_SSIZE_T_DEFINED_
-typedef int32 ssize_t;
-#endif
-
-#if defined __linux__ || defined sun || defined __solaris__ || defined __CYGWIN32__ || defined __MINGW32__ || defined FORCE64 || defined __APPLE__
-typedef long long int64;
-typedef unsigned long long Uint64;
-#else
-#if defined _WIN32
-typedef _int64 int64;
-typedef unsigned _int64 Uint64;
-#else
-#error Unsupported platform (need 64 bits ints definition)
-#endif
-#endif
-
-#ifndef PACKED
-#if defined __linux__ || defined sun || defined __solaris__ || defined __CYGWIN32__ || defined __MINGW32__ || defined __APPLE__
-#define PACKED __attribute__((packed))
-#else // PACKED
-#define PACKED
-#endif
-#endif // !PACKED
-
-#ifndef PPACKED
-#if defined __linux__ || defined sun || defined __solaris__ || defined __CYGWIN32__ || defined __MINGW32__ || defined __APPLE__
-#define PPACKED
-#else // PPACKED
-#define PPACKED __declspec(align(1))
-#endif
-#endif // !PPACKED
-
-extern char verbosity;
-char ** split(char * s, char t);
-
-#ifdef _WIN32
-#define tolittle(x) x
-static Uint32 tobig(Uint32 x) {
- return (x >> 24) | ((x >> 8) & 0x0000ff00) | ((x << 8) & 0x00ff0000) | (x << 24);
-}
-#else
-#define tolittle(x) x
-static Uint32 tobig(Uint32 x) {
- return (x >> 24) | ((x >> 8) & 0x0000ff00) | ((x << 8) & 0x00ff0000) | (x << 24);
-}
-#endif
-
-#if defined __cplusplus
-
-#ifndef MAX
-template<class T>
-inline T MAX(T a, T b) {
- return a < b ? b : a;
-}
-#endif
-
-#ifndef MIN
-template<class T>
-inline T MIN(T a, T b) {
- return a > b ? b : a;
-}
-#endif
-
-#ifndef SWAP
-template<class T>
-inline void SWAP(T & a, T & b) {
- T t = a;
- a = b;
- b = t;
-}
-#endif
-
-#ifndef ABS
-template<class T>
-inline T ABS(T x) {
- T ox = -x;
- return x > 0 ? x : ox;
-}
-#endif
-
-#if defined __linux__ || defined sun || defined __solaris__ || defined __CYGWIN32__ || defined __MINGW32__ || defined __APPLE__
-#define FUNCNAME String(__PRETTY_FUNCTION__)
-#else
-#define FUNCNAME String(__FUNCSIG__)
-#endif
-
-#else // cplusplus
-
-#ifndef MAX
-#define MAX(__a,__b) ((__a)<(__b)?(__b):(__a))
-#endif
-
-#ifndef MIN
-#define MIN(__a,__b) ((__a)>(__b)?(__b):(__a))
-#endif
-
-#endif // !cplusplus
-
-#define BITCOUNT(x) (((BX_(x)+(BX_(x)>>4)) & 0x0F0F0F0F) % 255)
-#define BX_(x) ((x) - (((x)>>1)&0x77777777) \
- - (((x)>>2)&0x33333333) \
- - (((x)>>3)&0x11111111))
-#define ISPOT(x) (((x)&(x-1))==0?1:0)
-
-#if defined __linux__ || defined sun || defined __solaris__ || defined __CYGWIN32__ || defined __APPLE__
-#define MKDIR(name) mkdir(name, 0777)
-#else
-#if defined __WIN32__ || defined _WIN32
-#include <direct.h>
-#define MKDIR mkdir
-#else
-#error Unknow compiler/platform
-#endif
-#endif
-
-#endif
+/* + * Baltisot + * Copyright (C) 1999-2003 Nicolas "Pixel" Noble + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* $Id: generic.h,v 1.31 2004-11-27 21:46:03 pixel Exp $ */ + +#ifndef __GENERIC_H__ +#define __GENERIC_H__ + +#include <sys/types.h> +#include <sys/stat.h> +#include <string.h> + +#define M_BARE -1 +#define M_ERROR 0 +#define M_STATUS 1 +#define M_WARNING 2 +#define M_INFO 3 + +#ifdef _WIN32 +#include <windows.h> +#endif + +#ifndef bcopy +#define bcopy(x,y,z) memcpy((y),(x),(z)) +#endif + +#if ! defined SDL_VERSIONNUM && ! defined Uint32 +typedef unsigned long int Uint32; +#endif + +#ifndef int32 +typedef signed long int int32; +#endif + +#ifndef Uint16 +typedef unsigned short int Uint16; +#endif + +#ifndef int16 +typedef signed short int int16; +#endif + +#ifndef Uint8 +typedef unsigned char Uint8; +#endif + +#ifndef int8 +typedef signed char int8; +#endif + +#ifndef Byte +typedef Uint8 Byte; +#endif + +#ifndef Word +typedef Uint16 Word; +#endif + +#ifndef DWord +typedef Uint32 DWord; +#endif + +#if !defined __ssize_t_defined && !defined _SSIZE_T && !defined ssize_t && !defined _BSD_SSIZE_T_DEFINED_ +typedef int32 ssize_t; +#endif + +#if defined __linux__ || defined sun || defined __solaris__ || defined __CYGWIN32__ || defined __MINGW32__ || defined FORCE64 || defined __APPLE__ +typedef long long int64; +typedef unsigned long long Uint64; +#else +#if defined _WIN32 +typedef _int64 int64; +typedef unsigned _int64 Uint64; +#else +#error Unsupported platform (need 64 bits ints definition) +#endif +#endif + +#ifndef PACKED +#if defined __linux__ || defined sun || defined __solaris__ || defined __CYGWIN32__ || defined __MINGW32__ || defined __APPLE__ +#define PACKED __attribute__((packed)) +#else // PACKED +#define PACKED +#endif +#endif // !PACKED + +#ifndef PPACKED +#if defined __linux__ || defined sun || defined __solaris__ || defined __CYGWIN32__ || defined __MINGW32__ || defined __APPLE__ +#define PPACKED +#else // PPACKED +#define PPACKED __declspec(align(1)) +#endif +#endif // !PPACKED + +extern char verbosity; +char ** split(char * s, char t); + +#ifdef _WIN32 +#define tolittle(x) x +static Uint32 tobig(Uint32 x) { + return (x >> 24) | ((x >> 8) & 0x0000ff00) | ((x << 8) & 0x00ff0000) | (x << 24); +} +#else +#define tolittle(x) x +static Uint32 tobig(Uint32 x) { + return (x >> 24) | ((x >> 8) & 0x0000ff00) | ((x << 8) & 0x00ff0000) | (x << 24); +} +#endif + +#if defined __cplusplus + +#ifndef MAX +template<class T> +inline T MAX(T a, T b) { + return a < b ? b : a; +} +#endif + +#ifndef MIN +template<class T> +inline T MIN(T a, T b) { + return a > b ? b : a; +} +#endif + +#ifndef SWAP +template<class T> +inline void SWAP(T & a, T & b) { + T t = a; + a = b; + b = t; +} +#endif + +#ifndef ABS +template<class T> +inline T ABS(T x) { + T ox = -x; + return x > 0 ? x : ox; +} +#endif + +#if defined __linux__ || defined sun || defined __solaris__ || defined __CYGWIN32__ || defined __MINGW32__ || defined __APPLE__ +#define FUNCNAME String(__PRETTY_FUNCTION__) +#else +#define FUNCNAME String(__FUNCSIG__) +#endif + +#else // cplusplus + +#ifndef MAX +#define MAX(__a,__b) ((__a)<(__b)?(__b):(__a)) +#endif + +#ifndef MIN +#define MIN(__a,__b) ((__a)>(__b)?(__b):(__a)) +#endif + +#endif // !cplusplus + +#define BITCOUNT(x) (((BX_(x)+(BX_(x)>>4)) & 0x0F0F0F0F) % 255) +#define BX_(x) ((x) - (((x)>>1)&0x77777777) \ + - (((x)>>2)&0x33333333) \ + - (((x)>>3)&0x11111111)) +#define ISPOT(x) (((x)&(x-1))==0?1:0) + +#if defined __linux__ || defined sun || defined __solaris__ || defined __CYGWIN32__ || defined __APPLE__ +#define MKDIR(name) mkdir(name, 0777) +#else +#if defined __WIN32__ || defined _WIN32 +#include <direct.h> +#define MKDIR mkdir +#else +#error Unknow compiler/platform +#endif +#endif + +#endif diff --git a/include/gettext.h b/include/gettext.h index 2a4856e..de7395c 100644 --- a/include/gettext.h +++ b/include/gettext.h @@ -1,64 +1,64 @@ -/* Convenience header for conditional use of GNU <libintl.h>.
- Copyright (C) 1995-1998, 2000-2002 Free Software Foundation, Inc.
-
- This program is free software; you can redistribute it and/or modify it
- under the terms of the GNU Library General Public License as published
- by the Free Software Foundation; either version 2, or (at your option)
- any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
- USA. */
-
-#ifndef _LIBGETTEXT_H
-#define _LIBGETTEXT_H 1
-
-/* NLS can be disabled through the configure --disable-nls option. */
-#if ENABLE_NLS && defined HAVE_LIBINTL_H
-
-/* Get declarations of GNU message catalog functions. */
-# include <libintl.h>
-
-#else
-
-/* Disabled NLS.
- The casts to 'const char *' serve the purpose of producing warnings
- for invalid uses of the value returned from these functions.
- On pre-ANSI systems without 'const', the config.h file is supposed to
- contain "#define const". */
-# define gettext(Msgid) ((const char *) (Msgid))
-# define dgettext(Domainname, Msgid) ((const char *) (Msgid))
-# define dcgettext(Domainname, Msgid, Category) ((const char *) (Msgid))
-# define ngettext(Msgid1, Msgid2, N) \
- ((N) == 1 ? (const char *) (Msgid1) : (const char *) (Msgid2))
-# define dngettext(Domainname, Msgid1, Msgid2, N) \
- ((N) == 1 ? (const char *) (Msgid1) : (const char *) (Msgid2))
-# define dcngettext(Domainname, Msgid1, Msgid2, N, Category) \
- ((N) == 1 ? (const char *) (Msgid1) : (const char *) (Msgid2))
-# define textdomain(Domainname) ((const char *) (Domainname))
-# define bindtextdomain(Domainname, Dirname) ((const char *) (Dirname))
-# define bind_textdomain_codeset(Domainname, Codeset) ((const char *) (Codeset))
-# define setlocale(category, locale)
-# define LC_ALL 0
-
-#endif
-
-/* A pseudo function call that serves as a marker for the automated
- extraction of messages, but does not call gettext(). The run-time
- translation is done at a different place in the code.
- The argument, String, should be a literal string. Concatenated strings
- and other string expressions won't work.
- The macro's expansion is not parenthesized, so that it is suitable as
- initializer for static 'char[]' or 'const char[]' variables. */
-#define gettext_noop(String) String
-
-#define _(Text) dgettext ("Baltisot", Text)
-#define N_(Text) Text
-
-#endif /* _LIBGETTEXT_H */
+/* Convenience header for conditional use of GNU <libintl.h>. + Copyright (C) 1995-1998, 2000-2002 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify it + under the terms of the GNU Library General Public License as published + by the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, + USA. */ + +#ifndef _LIBGETTEXT_H +#define _LIBGETTEXT_H 1 + +/* NLS can be disabled through the configure --disable-nls option. */ +#if ENABLE_NLS && defined HAVE_LIBINTL_H + +/* Get declarations of GNU message catalog functions. */ +# include <libintl.h> + +#else + +/* Disabled NLS. + The casts to 'const char *' serve the purpose of producing warnings + for invalid uses of the value returned from these functions. + On pre-ANSI systems without 'const', the config.h file is supposed to + contain "#define const". */ +# define gettext(Msgid) ((const char *) (Msgid)) +# define dgettext(Domainname, Msgid) ((const char *) (Msgid)) +# define dcgettext(Domainname, Msgid, Category) ((const char *) (Msgid)) +# define ngettext(Msgid1, Msgid2, N) \ + ((N) == 1 ? (const char *) (Msgid1) : (const char *) (Msgid2)) +# define dngettext(Domainname, Msgid1, Msgid2, N) \ + ((N) == 1 ? (const char *) (Msgid1) : (const char *) (Msgid2)) +# define dcngettext(Domainname, Msgid1, Msgid2, N, Category) \ + ((N) == 1 ? (const char *) (Msgid1) : (const char *) (Msgid2)) +# define textdomain(Domainname) ((const char *) (Domainname)) +# define bindtextdomain(Domainname, Dirname) ((const char *) (Dirname)) +# define bind_textdomain_codeset(Domainname, Codeset) ((const char *) (Codeset)) +# define setlocale(category, locale) +# define LC_ALL 0 + +#endif + +/* A pseudo function call that serves as a marker for the automated + extraction of messages, but does not call gettext(). The run-time + translation is done at a different place in the code. + The argument, String, should be a literal string. Concatenated strings + and other string expressions won't work. + The macro's expansion is not parenthesized, so that it is suitable as + initializer for static 'char[]' or 'const char[]' variables. */ +#define gettext_noop(String) String + +#define _(Text) dgettext ("Baltisot", Text) +#define N_(Text) Text + +#endif /* _LIBGETTEXT_H */ diff --git a/include/template.h b/include/template.h index 784dcd2..591bfcb 100644 --- a/include/template.h +++ b/include/template.h @@ -1,3 +1,3 @@ -#ifndef ___H__
-#define ___H__
-#endif
+#ifndef ___H__ +#define ___H__ +#endif |