From f827d071ff3f8c45aca1cc5e4b9b7b71729313e3 Mon Sep 17 00:00:00 2001 From: pixel Date: Tue, 19 Jun 2007 13:39:14 +0000 Subject: Removing inline declaration, to avoid half-definition of the class. --- lib/LuaHttp.cc | 198 +++++++++++++++++++++++++++++---------------------------- 1 file changed, 101 insertions(+), 97 deletions(-) diff --git a/lib/LuaHttp.cc b/lib/LuaHttp.cc index 736739e..422c0b3 100644 --- a/lib/LuaHttp.cc +++ b/lib/LuaHttp.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* $Id: LuaHttp.cc,v 1.16 2007-06-17 15:21:50 pixel Exp $ */ +/* $Id: LuaHttp.cc,v 1.17 2007-06-19 13:39:14 pixel Exp $ */ #include "md5.h" #include "Domain.h" @@ -26,7 +26,16 @@ #include "LuaTask.h" #include "Base64.h" -class LuaDomain; +class LuaDomain : public Domain { + public: + LuaDomain(Lua * _L, String r); + virtual ~LuaDomain(); + virtual void Do(const HttpRequest & req, HttpResponse * res) throw (GeneralException); + private: + Lua * L; + static int max_id; + int id; +}; class LuaLuaDomain : public LuaObject { public: @@ -268,113 +277,108 @@ int sLua_HttpResponse::HttpResponse_proceed_statics(Lua * L, int n, int caller) return r; } -class LuaDomain : public Domain { - public: - LuaDomain(Lua * _L, String r) : Domain(r), L(_L->Father()) { - id = max_id++; +LuaDomain::LuaDomain(Lua * _L, String r) : Domain(r), L(_L->Father()) { + id = max_id++; - L->push(DOMAIN_REGISTRY); - L->gettable(LUA_REGISTRYINDEX); - L->push((lua_Number) id); - L->copy(2); - L->settable(); - L->pop(); - } - virtual ~LuaDomain() { - L->push(DOMAIN_REGISTRY); - L->gettable(LUA_REGISTRYINDEX); - L->push((lua_Number) id); - L->push(); - L->settable(); - L->pop(); - } - virtual void Do(const HttpRequest & req, HttpResponse * res) throw (GeneralException) { - int i; + L->push(DOMAIN_REGISTRY); + L->gettable(LUA_REGISTRYINDEX); + L->push((lua_Number) id); + L->copy(2); + L->settable(); + L->pop(); +} + +LuaDomain::~LuaDomain() { + L->push(DOMAIN_REGISTRY); + L->gettable(LUA_REGISTRYINDEX); + L->push((lua_Number) id); + L->push(); + L->settable(); + L->pop(); +} + +void LuaDomain::Do(const HttpRequest & req, HttpResponse * res) throw (GeneralException) { + int i; - Lua * oldL = L; - Lua * L = oldL->thread(false); - oldL->pop(); + Lua * oldL = L; + Lua * L = oldL->thread(false); + oldL->pop(); - L->push(DOMAIN_REGISTRY); - L->gettable(LUA_REGISTRYINDEX); - L->push((lua_Number) id); - L->gettable(); - L->remove(); + L->push(DOMAIN_REGISTRY); + L->gettable(LUA_REGISTRYINDEX); + L->push((lua_Number) id); + L->gettable(); + L->remove(); + + L->newtable(); + + L->push("vars"); + L->newtable(); + for (i = 0; i < req.vars->GetNb(); i++) { + char * v = (*(req.vars))[i].strdup(), * p; - L->newtable(); - - L->push("vars"); - L->newtable(); - for (i = 0; i < req.vars->GetNb(); i++) { - char * v = (*(req.vars))[i].strdup(), * p; - - p = strchr(v, '='); - *p = 0; - p++; - - L->push(v); - L->push(p); - L->settable(); - - free(v); - } - L->settable(); + p = strchr(v, '='); + *p = 0; + p++; - L->push("headers"); - L->newtable(); - for (i = 0; i < req.headers->GetNb(); i++) { - char * v = (*(req.headers))[i].strdup(), * p; - - p = strchr(v, '='); - *p = 0; - p++; - - L->push(v); - L->push(p); - L->settable(); - - free(v); - } + L->push(v); + L->push(p); L->settable(); - L->push("uri"); - L->push(req.uri); - L->settable(); + free(v); + } + L->settable(); + + L->push("headers"); + L->newtable(); + for (i = 0; i < req.headers->GetNb(); i++) { + char * v = (*(req.headers))[i].strdup(), * p; - L->push("login"); - L->push(req.login); - L->settable(); + p = strchr(v, '='); + *p = 0; + p++; - L->push("password"); - L->push(req.password); + L->push(v); + L->push(p); L->settable(); - - L->push("lip"); - L->push((lua_Number) req.lip); - L->settable(); - - L->push("dip"); - L->push((lua_Number) req.dip); - L->settable(); - L->push("lport"); - L->push((lua_Number) req.lport); - L->settable(); - - L->push("dport"); - L->push((lua_Number) req.dport); - L->settable(); - - LuaHttpResponse r(res); - r.push(L); - - res->builder = new LuaTask(L, 2); + free(v); } - private: - Lua * L; - static int max_id; - int id; -}; + L->settable(); + + L->push("uri"); + L->push(req.uri); + L->settable(); + + L->push("login"); + L->push(req.login); + L->settable(); + + L->push("password"); + L->push(req.password); + L->settable(); + + L->push("lip"); + L->push((lua_Number) req.lip); + L->settable(); + + L->push("dip"); + L->push((lua_Number) req.dip); + L->settable(); + + L->push("lport"); + L->push((lua_Number) req.lport); + L->settable(); + + L->push("dport"); + L->push((lua_Number) req.dport); + L->settable(); + + LuaHttpResponse r(res); + r.push(L); + + res->builder = new LuaTask(L, 2); +} int LuaDomain::max_id = 1; -- cgit v1.2.3