From: <arn...@us...> - 2007-12-02 22:02:05
|
Revision: 97 http://adchpp.svn.sourceforge.net/adchpp/?rev=97&view=rev Author: arnetheduck Date: 2007-12-02 14:01:57 -0800 (Sun, 02 Dec 2007) Log Message: ----------- Some adc 1.0 issues fixed, bring back lua on track, lua 5.1.2 Modified Paths: -------------- adchpp/trunk/adchpp/AdcCommand.h adchpp/trunk/adchpp/Client.h adchpp/trunk/adchpp/SettingsManager.cpp adchpp/trunk/adchpp/SettingsManager.h adchpp/trunk/adchpp/SocketManager.cpp adchpp/trunk/etc/adchpp.xml adchpp/trunk/lua/Makefile adchpp/trunk/lua/lbaselib.c adchpp/trunk/lua/lcode.c adchpp/trunk/lua/ldebug.c adchpp/trunk/lua/lfunc.c adchpp/trunk/lua/loadlib.c adchpp/trunk/lua/loslib.c adchpp/trunk/lua/lparser.c adchpp/trunk/lua/lstrlib.c adchpp/trunk/lua/lua.h adchpp/trunk/lua/luaconf.h adchpp/trunk/lua/lvm.c adchpp/trunk/lua/print.c adchpp/trunk/plugins/Script/examples/access.lua adchpp/trunk/readme.txt adchpp/trunk/swig/SConscript adchpp/trunk/swig/adchpp.i adchpp/trunk/swig/lua.i Removed Paths: ------------- adchpp/trunk/etc/Example.adchpp.xml Modified: adchpp/trunk/adchpp/AdcCommand.h =================================================================== --- adchpp/trunk/adchpp/AdcCommand.h 2007-11-25 21:44:36 UTC (rev 96) +++ adchpp/trunk/adchpp/AdcCommand.h 2007-12-02 22:01:57 UTC (rev 97) @@ -57,10 +57,12 @@ ERROR_BAD_STATE = 44, ERROR_FEATURE_MISSING = 45, ERROR_BAD_IP = 46, + ERROR_NO_HUB_HASH = 47, ERROR_TRANSFER_GENERIC = 50, ERROR_FILE_NOT_AVAILABLE = 51, ERROR_FILE_PART_NOT_AVAILABLE = 52, - ERROR_SLOTS_FULL = 53 + ERROR_SLOTS_FULL = 53, + ERROR_NO_CLIENT_HASH = 54 }; enum Severity { @@ -100,7 +102,7 @@ C(CMD, 'C','M','D'); #undef C - enum { HUB_SID = 0x41414141 }; + enum { HUB_SID = 0xffffffff }; uint32_t toCMD(uint8_t a, uint8_t b, uint8_t c) { return (((uint32_t)a) | (((uint32_t)b)<<8) | (((uint32_t)c)<<16)); } Modified: adchpp/trunk/adchpp/Client.h =================================================================== --- adchpp/trunk/adchpp/Client.h 2007-11-25 21:44:36 UTC (rev 96) +++ adchpp/trunk/adchpp/Client.h 2007-12-02 22:01:57 UTC (rev 97) @@ -50,9 +50,10 @@ FLAG_BOT = 0x01, FLAG_REGISTERED = 0x02, FLAG_OP = 0x04, - FLAG_OWNER = 0x08, - FLAG_HUB = 0x10, - MASK_CLIENT_TYPE = FLAG_BOT | FLAG_REGISTERED | FLAG_OP | FLAG_OWNER | FLAG_HUB, + FLAG_SU = 0x08, + FLAG_OWNER = 0x10, + FLAG_HUB = 0x20, + MASK_CLIENT_TYPE = FLAG_BOT | FLAG_REGISTERED | FLAG_OP | FLAG_SU | FLAG_OWNER | FLAG_HUB, FLAG_PASSWORD = 0x100, FLAG_HIDDEN = 0x101, /** Extended away, no need to send msg */ Modified: adchpp/trunk/adchpp/SettingsManager.cpp =================================================================== --- adchpp/trunk/adchpp/SettingsManager.cpp 2007-11-25 21:44:36 UTC (rev 96) +++ adchpp/trunk/adchpp/SettingsManager.cpp 2007-12-02 22:01:57 UTC (rev 97) @@ -47,7 +47,6 @@ SettingsManager::SettingsManager() throw() { memset(intSettings, 0, sizeof(intSettings)); - memset(int64Settings, 0, sizeof(int64Settings)); set(HUB_NAME, appName); // set(SERVER_IP, ""); Modified: adchpp/trunk/adchpp/SettingsManager.h =================================================================== --- adchpp/trunk/adchpp/SettingsManager.h 2007-11-25 21:44:36 UTC (rev 96) +++ adchpp/trunk/adchpp/SettingsManager.h 2007-12-02 22:01:57 UTC (rev 97) @@ -109,7 +109,6 @@ std::string strSettings[STR_LAST - STR_FIRST]; int intSettings[INT_LAST - INT_FIRST]; - int64_t int64Settings[/*INT64_LAST - INT64_FIRST*/1]; SignalLoad::Signal signalLoad_; }; Modified: adchpp/trunk/adchpp/SocketManager.cpp =================================================================== --- adchpp/trunk/adchpp/SocketManager.cpp 2007-11-25 21:44:36 UTC (rev 96) +++ adchpp/trunk/adchpp/SocketManager.cpp 2007-12-02 22:01:57 UTC (rev 97) @@ -581,12 +581,18 @@ bool get(vector<epoll_event>& events) { events.resize(1024); - int n = epoll_wait(poll_fd, &events[0], events.size(), WRITE_TIMEOUT); - if(n == -1) { - return false; + while(true) { + int n = epoll_wait(poll_fd, &events[0], events.size(), WRITE_TIMEOUT); + if(n == -1) { + if(errno != EINTR) { + return false; + } + // Keep looping + } else { + events.resize(n); + return true; + } } - events.resize(n); - return true; } void remove(const ManagedSocketPtr& ms) { Deleted: adchpp/trunk/etc/Example.adchpp.xml =================================================================== --- adchpp/trunk/etc/Example.adchpp.xml 2007-11-25 21:44:36 UTC (rev 96) +++ adchpp/trunk/etc/Example.adchpp.xml 2007-12-02 22:01:57 UTC (rev 97) @@ -1,15 +0,0 @@ -<?xml version="1.0" encoding="utf-8" standalone="yes"?> -<Language Name="Example Language" Author="arnetheduck" Version=2.0 Revision="1"> - <Strings> - <String Name="B">B</String> - <String Name="CidTaken">CID taken</String> - <String Name="DiskFull">Disk full?</String> - <String Name="Gb">GiB</String> - <String Name="HubFull">Hub is currently full</String> - <String Name="Kb">KiB</String> - <String Name="Mb">MiB</String> - <String Name="NickInvalid">Your nick contains invalid characters. Adios.</String> - <String Name="NickTaken">Your nick is already taken, please select another one</String> - <String Name="Tb">TiB</String> - </Strings> -</Language> Modified: adchpp/trunk/etc/adchpp.xml =================================================================== --- adchpp/trunk/etc/adchpp.xml 2007-11-25 21:44:36 UTC (rev 96) +++ adchpp/trunk/etc/adchpp.xml 2007-12-02 22:01:57 UTC (rev 97) @@ -1,9 +1,6 @@ <?xml version="1.0" encoding="utf-8" standalone="yes"?> <ADCHubPlusPlus> <Settings> -<!-- Language file --> - <!-- The strings in the language file is used when messages are sent out to the user by the hub --> - <LanguageFile type="string">Example.adchpp.xml</LanguageFile> <!-- Hub name and message of the day --> <!-- This is the name of the hub as it should be reported to the clients during @@ -27,17 +24,6 @@ on the same port, which facilates hub blocking. --> <ServerPort type="int">2780</ServerPort> -<!-- Maximum users --> - <!-- The maximum number of users that should be allowed into the hub at any time, - 0 = disable --> - <MaxUsers type="int">0</MaxUsers> - -<!-- Redirection settings --> - <!-- The server to redirect to (if enabled) when full --> - <RedirectServer>adc://wza.digitalbrains.com:1416</RedirectServer> - <!-- Enable/disable redirect when full --> - <RedirectFull>0</RedirectFull> - <!-- Flood protection --> <FloodAdd>1</FloodAdd> <FloodThreshold>25</FloodThreshold> Modified: adchpp/trunk/lua/Makefile =================================================================== --- adchpp/trunk/lua/Makefile 2007-11-25 21:44:36 UTC (rev 96) +++ adchpp/trunk/lua/Makefile 2007-12-02 22:01:57 UTC (rev 97) @@ -20,7 +20,7 @@ # == END OF USER SETTINGS. NO NEED TO CHANGE ANYTHING BELOW THIS LINE ========= -PLATS= aix ansi bsd generic linux macosx mingw posix solaris +PLATS= aix ansi bsd freebsd generic linux macosx mingw posix solaris LUA_A= liblua.a CORE_O= lapi.o lcode.o ldebug.o ldo.o ldump.o lfunc.o lgc.o llex.o lmem.o \ @@ -77,7 +77,8 @@ # convenience targets for popular platforms none: - @echo "Please choose a platform: $(PLATS)" + @echo "Please choose a platform:" + @echo " $(PLATS)" aix: $(MAKE) all CC="xlc" CFLAGS="-O2 -DLUA_USE_POSIX -DLUA_USE_DLOPEN" MYLIBS="-ldl" MYLDFLAGS="-brtl -bexpall" @@ -88,6 +89,9 @@ bsd: $(MAKE) all MYCFLAGS="-DLUA_USE_POSIX -DLUA_USE_DLOPEN" MYLIBS="-Wl,-E" +freebsd: + $(MAKE) all MYCFLAGS="-DLUA_USE_LINUX" MYLIBS="-Wl,-E -lreadline" + generic: $(MAKE) all MYCFLAGS= @@ -103,6 +107,7 @@ $(MAKE) "LUA_A=lua51.dll" "LUA_T=lua.exe" \ "AR=$(CC) -shared -o" "RANLIB=strip --strip-unneeded" \ "MYCFLAGS=-DLUA_BUILD_AS_DLL" "MYLIBS=" "MYLDFLAGS=-s" lua.exe + $(MAKE) "LUAC_T=luac.exe" luac.exe posix: $(MAKE) all MYCFLAGS=-DLUA_USE_POSIX Modified: adchpp/trunk/lua/lbaselib.c =================================================================== --- adchpp/trunk/lua/lbaselib.c 2007-11-25 21:44:36 UTC (rev 96) +++ adchpp/trunk/lua/lbaselib.c 2007-12-02 22:01:57 UTC (rev 97) @@ -1,5 +1,5 @@ /* -** $Id: lbaselib.c,v 1.191 2006/06/02 15:34:00 roberto Exp $ +** $Id: lbaselib.c,v 1.191a 2006/06/02 15:34:00 roberto Exp $ ** Basic library ** See Copyright Notice in lua.h */ @@ -114,11 +114,11 @@ } -static void getfunc (lua_State *L) { +static void getfunc (lua_State *L, int opt) { if (lua_isfunction(L, 1)) lua_pushvalue(L, 1); else { lua_Debug ar; - int level = luaL_optint(L, 1, 1); + int level = opt ? luaL_optint(L, 1, 1) : luaL_checkint(L, 1); luaL_argcheck(L, level >= 0, 1, "level must be non-negative"); if (lua_getstack(L, level, &ar) == 0) luaL_argerror(L, 1, "invalid level"); @@ -131,7 +131,7 @@ static int luaB_getfenv (lua_State *L) { - getfunc(L); + getfunc(L, 1); if (lua_iscfunction(L, -1)) /* is a C function? */ lua_pushvalue(L, LUA_GLOBALSINDEX); /* return the thread's global env. */ else @@ -142,7 +142,7 @@ static int luaB_setfenv (lua_State *L) { luaL_checktype(L, 2, LUA_TTABLE); - getfunc(L); + getfunc(L, 0); lua_pushvalue(L, 2); if (lua_isnumber(L, 1) && lua_tonumber(L, 1) == 0) { /* change environment of current thread */ Modified: adchpp/trunk/lua/lcode.c =================================================================== --- adchpp/trunk/lua/lcode.c 2007-11-25 21:44:36 UTC (rev 96) +++ adchpp/trunk/lua/lcode.c 2007-12-02 22:01:57 UTC (rev 97) @@ -1,5 +1,5 @@ /* -** $Id: lcode.c,v 2.25 2006/03/21 19:28:49 roberto Exp $ +** $Id: lcode.c,v 2.25a 2006/03/21 19:28:49 roberto Exp $ ** Code generator for Lua ** See Copyright Notice in lua.h */ @@ -35,15 +35,20 @@ void luaK_nil (FuncState *fs, int from, int n) { Instruction *previous; if (fs->pc > fs->lasttarget) { /* no jumps to current position? */ - if (fs->pc == 0) /* function start? */ - return; /* positions are already clean */ - if (GET_OPCODE(*(previous = &fs->f->code[fs->pc-1])) == OP_LOADNIL) { - int pfrom = GETARG_A(*previous); - int pto = GETARG_B(*previous); - if (pfrom <= from && from <= pto+1) { /* can connect both? */ - if (from+n-1 > pto) - SETARG_B(*previous, from+n-1); - return; + if (fs->pc == 0) { /* function start? */ + if (from >= fs->nactvar) + return; /* positions are already clean */ + } + else { + previous = &fs->f->code[fs->pc-1]; + if (GET_OPCODE(*previous) == OP_LOADNIL) { + int pfrom = GETARG_A(*previous); + int pto = GETARG_B(*previous); + if (pfrom <= from && from <= pto+1) { /* can connect both? */ + if (from+n-1 > pto) + SETARG_B(*previous, from+n-1); + return; + } } } } @@ -657,10 +662,16 @@ if (constfolding(op, e1, e2)) return; else { + int o2 = (op != OP_UNM && op != OP_LEN) ? luaK_exp2RK(fs, e2) : 0; int o1 = luaK_exp2RK(fs, e1); - int o2 = (op != OP_UNM && op != OP_LEN) ? luaK_exp2RK(fs, e2) : 0; - freeexp(fs, e2); - freeexp(fs, e1); + if (o1 > o2) { + freeexp(fs, e1); + freeexp(fs, e2); + } + else { + freeexp(fs, e2); + freeexp(fs, e1); + } e1->u.s.info = luaK_codeABC(fs, op, 0, o1, o2); e1->k = VRELOCABLE; } @@ -718,10 +729,15 @@ luaK_exp2nextreg(fs, v); /* operand must be on the `stack' */ break; } - default: { + case OPR_ADD: case OPR_SUB: case OPR_MUL: case OPR_DIV: + case OPR_MOD: case OPR_POW: { if (!isnumeral(v)) luaK_exp2RK(fs, v); break; } + default: { + luaK_exp2RK(fs, v); + break; + } } } Modified: adchpp/trunk/lua/ldebug.c =================================================================== --- adchpp/trunk/lua/ldebug.c 2007-11-25 21:44:36 UTC (rev 96) +++ adchpp/trunk/lua/ldebug.c 2007-12-02 22:01:57 UTC (rev 97) @@ -1,5 +1,5 @@ /* -** $Id: ldebug.c,v 2.29 2005/12/22 16:19:56 roberto Exp $ +** $Id: ldebug.c,v 2.29a 2005/12/22 16:19:56 roberto Exp $ ** Debug Interface ** See Copyright Notice in lua.h */ @@ -432,14 +432,16 @@ break; } case OP_CLOSURE: { - int nup; + int nup, j; check(b < pt->sizep); nup = pt->p[b]->nups; check(pc + nup < pt->sizecode); - for (; nup>0; nup--) { - OpCode op1 = GET_OPCODE(pt->code[pc+nup]); + for (j = 1; j <= nup; j++) { + OpCode op1 = GET_OPCODE(pt->code[pc + j]); check(op1 == OP_GETUPVAL || op1 == OP_MOVE); } + if (reg != NO_REG) /* tracing? */ + pc += nup; /* do not 'execute' these pseudo-instructions */ break; } case OP_VARARG: { Modified: adchpp/trunk/lua/lfunc.c =================================================================== --- adchpp/trunk/lua/lfunc.c 2007-11-25 21:44:36 UTC (rev 96) +++ adchpp/trunk/lua/lfunc.c 2007-12-02 22:01:57 UTC (rev 97) @@ -1,5 +1,5 @@ /* -** $Id: lfunc.c,v 2.12 2005/12/22 16:19:56 roberto Exp $ +** $Id: lfunc.c,v 2.12a 2005/12/22 16:19:56 roberto Exp $ ** Auxiliary functions to manipulate prototypes and closures ** See Copyright Notice in lua.h */ @@ -55,7 +55,7 @@ GCObject **pp = &L->openupval; UpVal *p; UpVal *uv; - while ((p = ngcotouv(*pp)) != NULL && p->v >= level) { + while (*pp != NULL && (p = ngcotouv(*pp))->v >= level) { lua_assert(p->v != &p->u.value); if (p->v == level) { /* found a corresponding upvalue? */ if (isdead(g, obj2gco(p))) /* is it dead? */ @@ -96,7 +96,7 @@ void luaF_close (lua_State *L, StkId level) { UpVal *uv; global_State *g = G(L); - while ((uv = ngcotouv(L->openupval)) != NULL && uv->v >= level) { + while (L->openupval != NULL && (uv = ngcotouv(L->openupval))->v >= level) { GCObject *o = obj2gco(uv); lua_assert(!isblack(o) && uv->v != &uv->u.value); L->openupval = uv->next; /* remove from `open' list */ Modified: adchpp/trunk/lua/loadlib.c =================================================================== --- adchpp/trunk/lua/loadlib.c 2007-11-25 21:44:36 UTC (rev 96) +++ adchpp/trunk/lua/loadlib.c 2007-12-02 22:01:57 UTC (rev 97) @@ -1,5 +1,5 @@ /* -** $Id: loadlib.c,v 1.52 2006/04/10 18:27:23 roberto Exp $ +** $Id: loadlib.c,v 1.54a 2006/07/03 20:16:49 roberto Exp $ ** Dynamic library loader for Lua ** See Copyright Notice in lua.h ** @@ -16,9 +16,9 @@ #define loadlib_c #define LUA_LIB +#include "lua.h" + #include "lauxlib.h" -#include "lobject.h" -#include "lua.h" #include "lualib.h" @@ -98,7 +98,7 @@ char buff[MAX_PATH + 1]; char *lb; DWORD nsize = sizeof(buff)/sizeof(char); - DWORD n = GetModuleFileName(NULL, buff, nsize); + DWORD n = GetModuleFileNameA(NULL, buff, nsize); if (n == 0 || n == nsize || (lb = strrchr(buff, '\\')) == NULL) luaL_error(L, "unable to get ModuleFileName"); else { @@ -112,7 +112,7 @@ static void pusherror (lua_State *L) { int error = GetLastError(); char buffer[128]; - if (FormatMessage(FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_FROM_SYSTEM, + if (FormatMessageA(FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_FROM_SYSTEM, NULL, error, 0, buffer, sizeof(buffer), NULL)) lua_pushstring(L, buffer); else @@ -125,7 +125,7 @@ static void *ll_load (lua_State *L, const char *path) { - HINSTANCE lib = LoadLibrary(path); + HINSTANCE lib = LoadLibraryA(path); if (lib == NULL) pusherror(L); return lib; } @@ -356,15 +356,16 @@ path = lua_tostring(L, -1); if (path == NULL) luaL_error(L, LUA_QL("package.%s") " must be a string", pname); - lua_pushstring(L, ""); /* error accumulator */ + lua_pushliteral(L, ""); /* error accumulator */ while ((path = pushnexttemplate(L, path)) != NULL) { const char *filename; filename = luaL_gsub(L, lua_tostring(L, -1), LUA_PATH_MARK, name); + lua_remove(L, -2); /* remove path template */ if (readable(filename)) /* does file exist and is readable? */ return filename; /* return that file name */ - lua_pop(L, 2); /* remove path template and file name */ - luaO_pushfstring(L, "\n\tno file " LUA_QS, filename); - lua_concat(L, 2); + lua_pushfstring(L, "\n\tno file " LUA_QS, filename); + lua_remove(L, -2); /* remove file name */ + lua_concat(L, 2); /* add entry to possible error message */ } return NULL; /* not found */ } @@ -423,8 +424,8 @@ funcname = mkfuncname(L, name); if ((stat = ll_loadfunc(L, filename, funcname)) != 0) { if (stat != ERRFUNC) loaderror(L, filename); /* real error */ - luaO_pushfstring(L, "\n\tno module " LUA_QS " in file " LUA_QS, - name, filename); + lua_pushfstring(L, "\n\tno module " LUA_QS " in file " LUA_QS, + name, filename); return 1; /* function not found */ } return 1; @@ -438,7 +439,7 @@ luaL_error(L, LUA_QL("package.preload") " must be a table"); lua_getfield(L, -1, name); if (lua_isnil(L, -1)) /* not found? */ - luaO_pushfstring(L, "\n\tno field package.preload['%s']", name); + lua_pushfstring(L, "\n\tno field package.preload['%s']", name); return 1; } @@ -462,7 +463,7 @@ lua_getfield(L, LUA_ENVIRONINDEX, "loaders"); if (!lua_istable(L, -1)) luaL_error(L, LUA_QL("package.loaders") " must be a table"); - lua_pushstring(L, ""); /* error message accumulator */ + lua_pushliteral(L, ""); /* error message accumulator */ for (i=1; ; i++) { lua_rawgeti(L, -2, i); /* get a loader */ if (lua_isnil(L, -1)) @@ -646,8 +647,8 @@ setpath(L, "path", LUA_PATH, LUA_PATH_DEFAULT); /* set field `path' */ setpath(L, "cpath", LUA_CPATH, LUA_CPATH_DEFAULT); /* set field `cpath' */ /* store config information */ - lua_pushstring(L, LUA_DIRSEP "\n" LUA_PATHSEP "\n" LUA_PATH_MARK "\n" - LUA_EXECDIR "\n" LUA_IGMARK); + lua_pushliteral(L, LUA_DIRSEP "\n" LUA_PATHSEP "\n" LUA_PATH_MARK "\n" + LUA_EXECDIR "\n" LUA_IGMARK); lua_setfield(L, -2, "config"); /* set field `loaded' */ luaL_findtable(L, LUA_REGISTRYINDEX, "_LOADED", 2); Modified: adchpp/trunk/lua/loslib.c =================================================================== --- adchpp/trunk/lua/loslib.c 2007-11-25 21:44:36 UTC (rev 96) +++ adchpp/trunk/lua/loslib.c 2007-12-02 22:01:57 UTC (rev 97) @@ -1,5 +1,5 @@ /* -** $Id: loslib.c,v 1.19 2006/04/26 18:19:49 roberto Exp $ +** $Id: loslib.c,v 1.20 2006/09/19 13:57:08 roberto Exp $ ** Standard Operating System library ** See Copyright Notice in lua.h */ @@ -146,11 +146,22 @@ setboolfield(L, "isdst", stm->tm_isdst); } else { - char b[256]; - if (strftime(b, sizeof(b), s, stm)) - lua_pushstring(L, b); - else - return luaL_error(L, LUA_QL("date") " format too long"); + char cc[3]; + luaL_Buffer b; + cc[0] = '%'; cc[2] = '\0'; + luaL_buffinit(L, &b); + for (; *s; s++) { + if (*s != '%' || *(s + 1) == '\0') /* no conversion specifier? */ + luaL_addchar(&b, *s); + else { + size_t reslen; + char buff[200]; /* should be big enough for any conversion result */ + cc[1] = *(++s); + reslen = strftime(buff, sizeof(buff), cc, stm); + luaL_addlstring(&b, buff, reslen); + } + } + luaL_pushresult(&b); } return 1; } Modified: adchpp/trunk/lua/lparser.c =================================================================== --- adchpp/trunk/lua/lparser.c 2007-11-25 21:44:36 UTC (rev 96) +++ adchpp/trunk/lua/lparser.c 2007-12-02 22:01:57 UTC (rev 97) @@ -1,5 +1,5 @@ /* -** $Id: lparser.c,v 2.42 2006/06/05 15:57:59 roberto Exp $ +** $Id: lparser.c,v 2.42a 2006/06/05 15:57:59 roberto Exp $ ** Lua Parser ** See Copyright Notice in lua.h */ @@ -489,7 +489,7 @@ static void listfield (LexState *ls, struct ConsControl *cc) { expr(ls, &cc->v); - luaY_checklimit(ls->fs, cc->na, MAXARG_Bx, "items in a constructor"); + luaY_checklimit(ls->fs, cc->na, MAX_INT, "items in a constructor"); cc->na++; cc->tostore++; } Modified: adchpp/trunk/lua/lstrlib.c =================================================================== --- adchpp/trunk/lua/lstrlib.c 2007-11-25 21:44:36 UTC (rev 96) +++ adchpp/trunk/lua/lstrlib.c 2007-12-02 22:01:57 UTC (rev 97) @@ -1,5 +1,5 @@ /* -** $Id: lstrlib.c,v 1.132 2006/04/26 20:41:19 roberto Exp $ +** $Id: lstrlib.c,v 1.132a 2006/04/26 20:41:19 roberto Exp $ ** Standard library for string operations and pattern-matching ** See Copyright Notice in lua.h */ @@ -723,7 +723,7 @@ static const char *scanformat (lua_State *L, const char *strfrmt, char *form) { const char *p = strfrmt; - while (strchr(FLAGS, *p)) p++; /* skip flags */ + while (*p != '\0' && strchr(FLAGS, *p) != NULL) p++; /* skip flags */ if ((size_t)(p - strfrmt) >= sizeof(FLAGS)) luaL_error(L, "invalid format (repeated flags)"); if (isdigit(uchar(*p))) p++; /* skip width */ Modified: adchpp/trunk/lua/lua.h =================================================================== --- adchpp/trunk/lua/lua.h 2007-11-25 21:44:36 UTC (rev 96) +++ adchpp/trunk/lua/lua.h 2007-12-02 22:01:57 UTC (rev 97) @@ -1,5 +1,5 @@ /* -** $Id: lua.h,v 1.218 2006/06/02 15:34:00 roberto Exp $ +** $Id: lua.h,v 1.218a 2006/06/02 15:34:00 roberto Exp $ ** Lua - An Extensible Extension Language ** Lua.org, PUC-Rio, Brazil (http://www.lua.org) ** See Copyright Notice at the end of this file @@ -17,9 +17,9 @@ #define LUA_VERSION "Lua 5.1" -#define LUA_RELEASE "Lua 5.1.1" +#define LUA_RELEASE "Lua 5.1.2" #define LUA_VERSION_NUM 501 -#define LUA_COPYRIGHT "Copyright (C) 1994-2006 Lua.org, PUC-Rio" +#define LUA_COPYRIGHT "Copyright (C) 1994-2007 Lua.org, PUC-Rio" #define LUA_AUTHORS "R. Ierusalimschy, L. H. de Figueiredo & W. Celes" @@ -359,7 +359,7 @@ /****************************************************************************** -* Copyright (C) 1994-2006 Lua.org, PUC-Rio. All rights reserved. +* Copyright (C) 1994-2007 Lua.org, PUC-Rio. All rights reserved. * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the Modified: adchpp/trunk/lua/luaconf.h =================================================================== --- adchpp/trunk/lua/luaconf.h 2007-11-25 21:44:36 UTC (rev 96) +++ adchpp/trunk/lua/luaconf.h 2007-12-02 22:01:57 UTC (rev 97) @@ -1,5 +1,5 @@ /* -** $Id: luaconf.h,v 1.82 2006/04/10 18:27:23 roberto Exp $ +** $Id: luaconf.h,v 1.82a 2006/04/10 18:27:23 roberto Exp $ ** Configuration file for Lua ** See Copyright Notice in lua.h */ @@ -216,7 +216,7 @@ ** =================================================================== */ -#if defined(lua_c) +#if defined(lua_c) || defined(luaall_c) /* @@ lua_stdin_is_tty detects whether the standard input is a 'tty' (that @@ -360,7 +360,7 @@ /* @@ LUA_COMPAT_OPENLIB controls compatibility with old 'luaL_openlib' @* behavior. -** CHANGE it to undefined as soon as you replace to 'luaL_registry' +** CHANGE it to undefined as soon as you replace to 'luaL_register' ** your uses of 'luaL_openlib' */ #define LUA_COMPAT_OPENLIB Modified: adchpp/trunk/lua/lvm.c =================================================================== --- adchpp/trunk/lua/lvm.c 2007-11-25 21:44:36 UTC (rev 96) +++ adchpp/trunk/lua/lvm.c 2007-12-02 22:01:57 UTC (rev 97) @@ -1,5 +1,5 @@ /* -** $Id: lvm.c,v 2.63 2006/06/05 15:58:59 roberto Exp $ +** $Id: lvm.c,v 2.63a 2006/06/05 15:58:59 roberto Exp $ ** Lua virtual machine ** See Copyright Notice in lua.h */ @@ -165,7 +165,7 @@ const TValue *tm = luaT_gettmbyobj(L, p1, event); /* try first operand */ if (ttisnil(tm)) tm = luaT_gettmbyobj(L, p2, event); /* try second operand */ - if (!ttisfunction(tm)) return 0; + if (ttisnil(tm)) return 0; callTMres(L, res, tm, p1, p2); return 1; } @@ -281,10 +281,12 @@ do { StkId top = L->base + last + 1; int n = 2; /* number of elements handled in this pass (at least 2) */ - if (!tostring(L, top-2) || !tostring(L, top-1)) { + if (!(ttisstring(top-2) || ttisnumber(top-2)) || !tostring(L, top-1)) { if (!call_binTM(L, top-2, top-1, top-2, TM_CONCAT)) luaG_concaterror(L, top-2, top-1); - } else if (tsvalue(top-1)->len > 0) { /* if len=0, do nothing */ + } else if (tsvalue(top-1)->len == 0) /* second op is empty? */ + (void)tostring(L, top - 2); /* result is first op (as string) */ + else { /* at least two string values; get as many as possible */ size_t tl = tsvalue(top-1)->len; char *buffer; Modified: adchpp/trunk/lua/print.c =================================================================== --- adchpp/trunk/lua/print.c 2007-11-25 21:44:36 UTC (rev 96) +++ adchpp/trunk/lua/print.c 2007-12-02 22:01:57 UTC (rev 97) @@ -1,5 +1,5 @@ /* -** $Id: print.c,v 1.55 2006/05/31 13:30:05 lhf Exp $ +** $Id: print.c,v 1.55a 2006/05/31 13:30:05 lhf Exp $ ** print bytecodes ** See Copyright Notice in lua.h */ @@ -23,8 +23,7 @@ static void PrintString(const TString* ts) { const char* s=getstr(ts); - int n=ts->tsv.len; - int i; + size_t i,n=ts->tsv.len; putchar('"'); for (i=0; i<n; i++) { @@ -32,6 +31,7 @@ switch (c) { case '"': printf("\\\""); break; + case '\\': printf("\\\\"); break; case '\a': printf("\\a"); break; case '\b': printf("\\b"); break; case '\f': printf("\\f"); break; Modified: adchpp/trunk/plugins/Script/examples/access.lua =================================================================== --- adchpp/trunk/plugins/Script/examples/access.lua 2007-11-25 21:44:36 UTC (rev 96) +++ adchpp/trunk/plugins/Script/examples/access.lua 2007-12-02 22:01:57 UTC (rev 97) @@ -5,14 +5,6 @@ adchpp = luadchpp --- Temporary fixes for SWIG 1.3.29 -adchpp.TYPE_BROADCAST = string.char(adchpp.TYPE_BROADCAST) -adchpp.TYPE_DIRECT = string.char(adchpp.TYPE_DIRECT) -adchpp.TYPE_ECHO = string.char(adchpp.TYPE_ECHO) -adchpp.TYPE_FEATURE = string.char(adchpp.TYPE_FEATURE) -adchpp.TYPE_INFO = string.char(adchpp.TYPE_INFO) -adchpp.TYPE_HUB = string.char(adchpp.TYPE_HUB) - -- Configuration local users_file = adchpp.Util_getCfgPath() .. "users.txt" @@ -59,21 +51,21 @@ local context_send = "[BFD]" local command_contexts = { - [adchpp.CMD_STA] = context_hub, - [adchpp.CMD_SUP] = context_hub, - [adchpp.CMD_SID] = context_hub, - [adchpp.CMD_INF] = context_bcast, - [adchpp.CMD_MSG] = context_send, - [adchpp.CMD_SCH] = context_send, - [adchpp.CMD_RES] = context_direct, - [adchpp.CMD_CTM] = context_direct, - [adchpp.CMD_RCM] = context_direct, - [adchpp.CMD_GPA] = context_hub, - [adchpp.CMD_PAS] = context_hub, - [adchpp.CMD_QUI] = context_hub, - [adchpp.CMD_GET] = context_hub, - [adchpp.CMD_GFI] = context_hub, - [adchpp.CMD_SND] = context_hub, + [adchpp.AdcCommand_CMD_STA] = context_hub, + [adchpp.AdcCommand_CMD_SUP] = context_hub, + [adchpp.AdcCommand_CMD_SID] = context_hub, + [adchpp.AdcCommand_CMD_INF] = context_bcast, + [adchpp.AdcCommand_CMD_MSG] = context_send, + [adchpp.AdcCommand_CMD_SCH] = context_send, + [adchpp.AdcCommand_CMD_RES] = context_direct, + [adchpp.AdcCommand_CMD_CTM] = context_direct, + [adchpp.AdcCommand_CMD_RCM] = context_direct, + [adchpp.AdcCommand_CMD_GPA] = context_hub, + [adchpp.AdcCommand_CMD_PAS] = context_hub, + [adchpp.AdcCommand_CMD_QUI] = context_hub, + [adchpp.AdcCommand_CMD_GET] = context_hub, + [adchpp.AdcCommand_CMD_GFI] = context_hub, + [adchpp.AdcCommand_CMD_SND] = context_hub, } local user_commands = { @@ -242,7 +234,7 @@ save_users() end -local command_processed = adchpp.DONT_DISPATCH + adchpp.DONT_SEND +local command_processed = adchpp.ClientManager_DONT_DISPATCH + adchpp.ClientManager_DONT_SEND local function onINF(c, cmd) Modified: adchpp/trunk/readme.txt =================================================================== --- adchpp/trunk/readme.txt 2007-11-25 21:44:36 UTC (rev 96) +++ adchpp/trunk/readme.txt 2007-12-02 22:01:57 UTC (rev 97) @@ -18,7 +18,7 @@ gcc 4.2+ (linux or mingw) boost (http://www.boost.org) scons (http://www.scons.org) -swig 1.3.31+ +swig 1.3.31 ** Important!! The hub will _NOT_ run on Win9x/ME. ** Modified: adchpp/trunk/swig/SConscript =================================================================== --- adchpp/trunk/swig/SConscript 2007-11-25 21:44:36 UTC (rev 96) +++ adchpp/trunk/swig/SConscript 2007-12-02 22:01:57 UTC (rev 97) @@ -104,7 +104,7 @@ # We assume the lua from the script plugin will be used... env.Append(CPPPATH=['#', '#/lua/']) - + if env['PLATFORM'] == 'win32': env.Append(CPPDEFINES=['LUA_BUILD_AS_DLL=1']) else: Modified: adchpp/trunk/swig/adchpp.i =================================================================== --- adchpp/trunk/swig/adchpp.i 2007-11-25 21:44:36 UTC (rev 96) +++ adchpp/trunk/swig/adchpp.i 2007-12-02 22:01:57 UTC (rev 97) @@ -278,21 +278,15 @@ SEV_FATAL = 2 }; -#ifdef SWIGLUA - static const short TYPE_BROADCAST = 'B'; - static const short TYPE_DIRECT = 'D'; - static const short TYPE_ECHO = 'E'; - static const short TYPE_FEATURE = 'F'; - static const short TYPE_INFO = 'I'; - static const short TYPE_HUB = 'H'; -#else static const char TYPE_BROADCAST = 'B'; + static const char TYPE_CLIENT = 'C'; static const char TYPE_DIRECT = 'D'; static const char TYPE_ECHO = 'E'; static const char TYPE_FEATURE = 'F'; static const char TYPE_INFO = 'I'; static const char TYPE_HUB = 'H'; -#endif + static const char TYPE_UDP = 'U'; + // Known commands... #define C(n, a, b, c) static const unsigned int CMD_##n = (((uint32_t)a) | (((uint32_t)b)<<8) | (((uint32_t)c)<<16)); // Base commands @@ -315,7 +309,7 @@ C(CMD, 'C','M','D'); #undef C - enum { HUB_SID = 0x41414141 }; + enum { HUB_SID = 0xffffffff }; AdcCommand(); explicit AdcCommand(Severity sev, Error err, const std::string& desc, char aType); @@ -389,9 +383,10 @@ FLAG_BOT = 0x01, FLAG_REGISTERED = 0x02, FLAG_OP = 0x04, - FLAG_OWNER = 0x08, - FLAG_HUB = 0x10, - MASK_CLIENT_TYPE = FLAG_BOT | FLAG_REGISTERED | FLAG_OP | FLAG_OWNER | FLAG_HUB, + FLAG_SU = 0x08, + FLAG_OWNER = 0x10, + FLAG_HUB = 0x20, + MASK_CLIENT_TYPE = FLAG_BOT | FLAG_REGISTERED | FLAG_OP | FLAG_SU | FLAG_OWNER | FLAG_HUB, FLAG_PASSWORD = 0x100, FLAG_HIDDEN = 0x101, /** Extended away, no need to send msg */ @@ -460,6 +455,62 @@ void logDateTime(const std::string& area, const std::string& msg) throw(); }; +%template(SignalC) Signal<void (Client&)>; +%template(SignalTraitsC) SignalTraits<void (Client&)>; +%template(SignalCA) Signal<void (Client&, AdcCommand&)>; +%template(SignalTraitsCA) SignalTraits<void (Client&, AdcCommand&)>; +%template(SignalCAI) Signal<void (Client&, AdcCommand&, int&)>; +%template(SignalTraitsCAI) SignalTraits<void (Client&, AdcCommand&, int&)>; +%template(SignalCI) Signal<void (Client&, int)>; +%template(SignalTraitsCI) SignalTraits<void (Client&, int)>; +%template(SignalCS) Signal<void (Client&, const std::string&)>; +%template(SignalTraitsCS) SignalTraits<void (Client&, const std::string&)>; +%template(SignalS) Signal<void (const SimpleXML&)>; +%template(SignalTraitsS) SignalTraits<void (const SimpleXML&)>; + +%template(ManagedC) boost::intrusive_ptr<ManagedConnection<Signal<void (Client&)> > >; +%template(ManagedCA) boost::intrusive_ptr<ManagedConnection<Signal<void (Client&, AdcCommand&)> > >; +%template(ManagedCAI) boost::intrusive_ptr<ManagedConnection<Signal<void (Client&, AdcCommand&, int&)> > >; +%template(ManagedCI) boost::intrusive_ptr<ManagedConnection<Signal<void (Client&, int)> > >; +%template(ManagedCS) boost::intrusive_ptr<ManagedConnection<Signal<void (Client&, const std::string&)> > >; +%template(ManagedS) boost::intrusive_ptr<ManagedConnection<Signal<const SimpleXML&> > >; + +%extend Signal<void (Client&)> { + SignalTraits<void (Client&)>::ManagedConnection connect(std::tr1::function<void (Client&)> f) { + return manage(self, f); + } +} + +%extend Signal<void (Client&, AdcCommand&)> { + SignalTraits<void (Client&, AdcCommand&)>::ManagedConnection connect(std::tr1::function<void (Client&, AdcCommand&)> f) { + return manage(self, f); + } +} + +%extend Signal<void (Client&, AdcCommand&, int&)> { + SignalTraits<void (Client&, AdcCommand&, int&)>::ManagedConnection connect(std::tr1::function<void (Client&, AdcCommand&, int&)> f) { + return manage(self, f); + } +} + +%extend Signal<void (Client&, int)> { + SignalTraits<void (Client&, int)>::ManagedConnection connect(std::tr1::function<void (Client&, int)> f) { + return manage(self, f); + } +} + +%extend Signal<void (Client&, const std::string&)> { + SignalTraits<void (Client&, const std::string&)>::ManagedConnection connect(std::tr1::function<void (Client&, const std::string&)> f) { + return manage(self, f); + } +} + +%extend Signal<void (const SimpleXML&)> { + SignalTraits<void (const SimpleXML&)>::ManagedConnection connect(std::tr1::function<void (const SimpleXML&)> f) { + return manage(self, f); + } +} + class SocketManager { public: %extend { @@ -541,7 +592,7 @@ void enterIdentify(Client& c, bool sendData) throw(); - vector<uint8_t> enterVerify(Client& c, bool sendData) throw(); + ByteVector enterVerify(Client& c, bool sendData) throw(); bool enterNormal(Client& c, bool sendData, bool sendOwnInf) throw(); bool verifySUP(Client& c, AdcCommand& cmd) throw(); @@ -659,40 +710,6 @@ SignalLoad::Signal& signalLoad(); }; -%template(SignalC) Signal<void (Client&)>; -%template(SignalCA) Signal<void (Client&, AdcCommand&)>; -%template(SignalCAI) Signal<void (Client&, AdcCommand&, int&)>; -%template(SignalS) Signal<void (const SimpleXML&)>; - -%template(ManagedC) boost::intrusive_ptr<ManagedConnection<Signal<void (Client&)> > >; -%template(ManagedCAI) boost::intrusive_ptr<ManagedConnection<Signal<void (Client&, AdcCommand&, int&)> > >; -%template(ManagedCS) boost::intrusive_ptr<ManagedConnection<Signal<void (Client&, const std::string&)> > >; -%template(ManagedCI) boost::intrusive_ptr<ManagedConnection<Signal<void (Client&, int)> > >; - -%extend Signal<void (Client&)> { - boost::intrusive_ptr<ManagedConnection<Signal<void (Client&)> > > connect(std::tr1::function<void (Client&)> f) { - return manage(self, f); - } -} - -%extend Signal<void (Client&, AdcCommand&)> { - boost::intrusive_ptr<ManagedConnection<Signal<void (Client&, AdcCommand&)> > > connect(std::tr1::function<void (Client&, AdcCommand&)> f) { - return manage(self, f); - } -} - -%extend Signal<void (Client&, AdcCommand&, int&)> { - boost::intrusive_ptr<ManagedConnection<Signal<void (Client&, AdcCommand&, int&)> > > connect(std::tr1::function<void (Client&, AdcCommand&, int&)> f) { - return manage(self, f); - } -} - -%extend Signal<void (Client&, std::string&)> { - boost::intrusive_ptr<ManagedConnection<Signal<void (Client&, std::string&)> > > connect(std::tr1::function<void (Client&, std::string&)> f) { - return manage(self, f)); - } -} - class TigerHash { public: /** Hash size in bytes */ Modified: adchpp/trunk/swig/lua.i =================================================================== --- adchpp/trunk/swig/lua.i 2007-11-25 21:44:36 UTC (rev 96) +++ adchpp/trunk/swig/lua.i 2007-12-02 22:01:57 UTC (rev 97) @@ -5,23 +5,23 @@ %wrapper %{ static int traceback (lua_State *L) { - lua_getfield(L, LUA_GLOBALSINDEX, "debug"); - if (!lua_istable(L, -1)) { - printf("No debug table\n"); - lua_pop(L, 1); - return 1; - } - lua_getfield(L, -1, "traceback"); - if (!lua_isfunction(L, -1)) { - printf("No traceback in debug\n"); - lua_pop(L, 2); - return 1; - } + lua_getfield(L, LUA_GLOBALSINDEX, "debug"); + if (!lua_istable(L, -1)) { + printf("No debug table\n"); + lua_pop(L, 1); + return 1; + } + lua_getfield(L, -1, "traceback"); + if (!lua_isfunction(L, -1)) { + printf("No traceback in debug\n"); + lua_pop(L, 2); + return 1; + } - lua_pushvalue(L, 1); /* pass error message */ - lua_pushinteger(L, 2); /* skip this function and traceback */ - lua_call(L, 2, 1); /* call debug.traceback */ - return 1; + lua_pushvalue(L, 1); /* pass error message */ + lua_pushinteger(L, 2); /* skip this function and traceback */ + lua_call(L, 2, 1); /* call debug.traceback */ + return 1; } class RegistryItem : private boost::noncopyable { @@ -92,6 +92,14 @@ lua_pop(L, 1); } + void operator()(const adchpp::SimpleXML& s) { + pushFunction(); + + SWIG_NewPointerObj(L, &s, SWIGTYPE_p_adchpp__SimpleXML, 0); + docall(1, 0); + } + + private: void pushFunction() { registryItem->push(); } @@ -147,6 +155,18 @@ $1 = LuaFunction(L); } +%typemap(in) std::tr1::function<void (adchpp::Client &, int) > { + $1 = LuaFunction(L); +} + +%typemap(in) std::tr1::function<void (adchpp::Client &, const std::string&) > { + $1 = LuaFunction(L); +} + +%typemap(in) std::tr1::function<void (const SimpleXML&) > { + $1 = LuaFunction(L); +} + %include "adchpp.i" %extend adchpp::AdcCommand { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |