]>
jfr.im git - irc/quakenet/newserv.git/blob - lua/lua.h
1 /* Copyright (C) Chris Porter 2005 */
2 /* ALL RIGHTS RESERVED. */
3 /* Don't put this into the SVN repo. */
16 #include <sys/times.h>
18 #include <sys/resource.h>
21 #include "../lib/sstring.h"
22 #include "../core/nsmalloc.h"
25 #include "luasocket.h"
26 #include "luascheduler.h"
28 #define luamalloc(x) nsmalloc(POOL_LUA, x)
29 #define luarealloc(x, y) nsrealloc(POOL_LUA, x, y)
30 #define luafree(x) nsfree(POOL_LUA, x)
32 /*** defines ************************************/
34 #define LUA_BOTVERSION "1.95"
35 #define LUA_CHANFIXBOT "N2"
36 #define LUA_OPERCHAN "#twilightzone"
39 #define LUA_PUKECHAN "#qnet.keepout"
44 #define LUA_DEBUGSOCKET_ADDRESS "127.0.0.1"
45 #define LUA_DEBUGSOCKET_PORT 7733
49 #define LUA_AUXVERSION " + " LUAJIT_VERSION
51 #define LUA_AUXVERSION ""
54 #define LUA_SMALLVERSION "v" LUA_BOTVERSION " (" LUA_VERSION LUA_AUXVERSION ")"
55 #define LUA_FULLVERSION "Lua engine " LUA_SMALLVERSION
57 /*** end defines ************************************/
59 typedef struct lua_list
{
63 struct timeval ru_utime
, ru_stime
;
64 struct lua_list
*next
;
65 struct lua_list
*prev
;
68 lua_scheduler
*schedulers
;
71 #define LUA_STARTLOOP(l) { lua_list *ll; for(ll=lua_head;ll;ll=ll->next) { l = ll->l
73 #define LUA_ENDLOOP() } }
75 #define LUA_PATHLEN 150
77 extern lua_list
*lua_head
;
78 extern sstring
*cpath
;
80 lua_State
*lua_loadscript(char *file
);
81 void lua_unloadscript(lua_list
*l
);
82 lua_list
*lua_scriptloaded(char *name
);
83 lua_list
*lua_listfromstate(lua_State
*l
);
84 int lua_listexists(lua_list
*l
);
85 int lua_lineok(const char *data
);
87 #define lua_toint(l, n) (int)lua_tonumber(l, n)
88 #define lua_isint(l, n) lua_isnumber(l, n)
89 #define lua_pushint(l, n) lua_pushnumber(l, n)
91 #define lua_tolong(l, n) (long)lua_tonumber(l, n)
92 #define lua_islong(l, n) lua_isnumber(l, n)
93 #define lua_pushlong(l, n) lua_pushnumber(l, n)
94 #define lua_pushnumeric(l, n) lua_pushlong(l, n)
95 #define lua_tonumeric(l, n) lua_tolong(l, n)
96 #define lua_isnumeric(l, n) lua_islong(l, n)
98 extern struct rusage r_usages
;
99 extern struct rusage r_usagee
;
101 #define USEC_DIFFERENTIAL 1000000
105 #define ACCOUNTING_START(l) { l->calls++; getrusage(RUSAGE_SELF, &r_usages);
107 #define twrap(A2, B2, C2, D2) A2(&(B2), &(C2), &(D2))
109 #define _SET_2TIMEDIFF(L4, S2, E2, I2) twrap(timersub, E2.I2, S2.I2, E2.I2); twrap(timeradd, L4->I2, E2.I2, L4->I2);
110 #define SET_TIMEDIFF(L3, S2, E2) _SET_2TIMEDIFF(L3, S2, E2, ru_utime); _SET_2TIMEDIFF(L3, S2, E2, ru_stime);
112 #define ACCOUNTING_STOP(l) getrusage(RUSAGE_SELF, &r_usagee); SET_TIMEDIFF(l, r_usages, r_usagee); }
116 #ifdef LUA_DEBUGSOCKET
118 void lua_debugoutput(char *p
, ...) __attribute__ ((format (printf
, 1, 2)));
119 #define DEBUGOUT(p, ...) lua_debugoutput(p , ##__VA_ARGS__)
123 int lua_debugpcall(lua_State
*l
, char *message
, int a
, int b
, int c
);