X-Git-Url: https://jfr.im/git/irc/quakenet/newserv.git/blobdiff_plain/fe0f6b25f00fd951765c7730ae22c8a53d69adec..8c684fca9c7dbb4a2601628c744be9236ee68641:/lua/lua.h diff --git a/lua/lua.h b/lua/lua.h index 5f646642..43f1fbbb 100644 --- a/lua/lua.h +++ b/lua/lua.h @@ -5,7 +5,9 @@ #ifndef _LUA_H #define _LUA_H +#ifndef __USE_BSD #define __USE_BSD +#endif #include #include @@ -17,25 +19,39 @@ #include #include "../lib/sstring.h" +#include "../core/nsmalloc.h" + +#include "lualocal.h" +#include "luasocket.h" + +#define luamalloc(x) nsmalloc(POOL_LUA, x) +#define luarealloc(x, y) nsrealloc(POOL_LUA, x, y) +#define luafree(x) nsfree(POOL_LUA, x) /*** defines ************************************/ -#define LUA_BOTVERSION "1.38" -#define LUA_CHANFIXBOT "Z" +#define LUA_BOTVERSION "1.90" +#define LUA_CHANFIXBOT "D" #define LUA_OPERCHAN "#twilightzone" + +#ifndef LUA_PUKECHAN #define LUA_PUKECHAN "#qnet.keepout" +#endif -#undef LUA_DEBUGSOCKET #define LUA_PROFILE -#ifdef LUA_JITLIBNAME - -#define LUA_USEJIT +#define LUA_DEBUGSOCKET_ADDRESS "127.0.0.1" +#define LUA_DEBUGSOCKET_PORT 7733 +#ifdef LUA_USEJIT +#include +#define LUA_AUXVERSION " + " LUAJIT_VERSION +#else +#define LUA_AUXVERSION "" #endif -#define LUA_DEBUGSOCKET_ADDRESS "127.0.0.1" -#define LUA_DEBUGSOCKET_PORT 7733 +#define LUA_SMALLVERSION "v" LUA_BOTVERSION " (" LUA_VERSION LUA_AUXVERSION ")" +#define LUA_FULLVERSION "Lua engine " LUA_SMALLVERSION /*** end defines ************************************/ @@ -46,13 +62,15 @@ typedef struct lua_list { struct timeval ru_utime, ru_stime; struct lua_list *next; struct lua_list *prev; + lua_localnick *nicks; + lua_socket *sockets; } lua_list; #define LUA_STARTLOOP(l) { lua_list *ll; for(ll=lua_head;ll;ll=ll->next) { l = ll->l #define LUA_ENDLOOP() } } -#define LUA_PATHLEN 1024 +#define LUA_PATHLEN 150 extern lua_list *lua_head; extern sstring *cpath; @@ -61,6 +79,8 @@ lua_State *lua_loadscript(char *file); void lua_unloadscript(lua_list *l); lua_list *lua_scriptloaded(char *name); lua_list *lua_listfromstate(lua_State *l); +int lua_listexists(lua_list *l); +int lua_lineok(const char *data); #define lua_toint(l, n) (int)lua_tonumber(l, n) #define lua_isint(l, n) lua_isnumber(l, n) @@ -69,6 +89,9 @@ lua_list *lua_listfromstate(lua_State *l); #define lua_tolong(l, n) (long)lua_tonumber(l, n) #define lua_islong(l, n) lua_isnumber(l, n) #define lua_pushlong(l, n) lua_pushnumber(l, n) +#define lua_pushnumeric(l, n) lua_pushlong(l, n) +#define lua_tonumeric(l, n) lua_tolong(l, n) +#define lua_isnumeric(l, n) lua_islong(l, n) extern struct rusage r_usages; extern struct rusage r_usagee; @@ -86,45 +109,15 @@ extern struct rusage r_usagee; #define ACCOUNTING_STOP(l) getrusage(RUSAGE_SELF, &r_usagee); SET_TIMEDIFF(l, r_usages, r_usagee); } -#else - -#define ACCOUNTING_START(l) ; -#define ACCOUNTING_STOP(l) ; - #endif #ifdef LUA_DEBUGSOCKET -void lua_debugoutput(char *p, ...); +void lua_debugoutput(char *p, ...) __attribute__ ((format (printf, 1, 2))); #define DEBUGOUT(p, ...) lua_debugoutput(p , ##__VA_ARGS__) -#define lua_debugpcall(l, message, ...) { lua_list *l2 = lua_listfromstate(l); DEBUGOUT("%s: %s\n", l2->name->content, message); ACCOUNTING_START(l2); lua_pcall(l , ##__VA_ARGS__); ACCOUNTING_STOP(l2); } - -#else - -#define DEBUGOUT(p, ...) - -#ifdef LUA_PROFILE -#define lua_debugpcall(l, message, ...) { lua_list *l2 = lua_listfromstate(l); ACCOUNTING_START(l2); lua_pcall(l , ##__VA_ARGS__); ACCOUNTING_STOP(l2); } -#else -#define lua_debugpcall(l, message, ...) lua_pcall(l , ##__VA_ARGS__); ACCOUNTING_STOP(l2); -#endif - -#endif - -#ifndef INLINE - -#ifdef __GNUC__ -#define INLINE __attribute((always_inline)) inline -#endif - -#ifdef _MSC_VER -#define INLINE __forceinline -#endif -#ifndef INLINE -#define INLINE inline #endif -#endif /* INLINE */ +int lua_debugpcall(lua_State *l, char *message, int a, int b, int c); #endif