]>
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. */
14 #include <sys/times.h>
16 #include <sys/resource.h>
19 #include "../lib/sstring.h"
22 #include "luasocket.h"
24 /*** defines ************************************/
26 #define LUA_BOTVERSION "1.84"
27 #define LUA_CHANFIXBOT "Z"
28 #define LUA_OPERCHAN "#twilightzone"
31 #define LUA_PUKECHAN "#qnet.keepout"
36 #define LUA_DEBUGSOCKET_ADDRESS "127.0.0.1"
37 #define LUA_DEBUGSOCKET_PORT 7733
41 #define LUA_AUXVERSION " + " LUAJIT_VERSION
43 #define LUA_AUXVERSION ""
46 #define LUA_FULLVERSION "Lua engine v" LUA_BOTVERSION " (" LUA_VERSION LUA_AUXVERSION ")"
48 /*** end defines ************************************/
50 typedef struct lua_list
{
54 struct timeval ru_utime
, ru_stime
;
55 struct lua_list
*next
;
56 struct lua_list
*prev
;
61 #define LUA_STARTLOOP(l) { lua_list *ll; for(ll=lua_head;ll;ll=ll->next) { l = ll->l
63 #define LUA_ENDLOOP() } }
65 #define LUA_PATHLEN 1024
67 extern lua_list
*lua_head
;
68 extern sstring
*cpath
;
70 lua_State
*lua_loadscript(char *file
);
71 void lua_unloadscript(lua_list
*l
);
72 lua_list
*lua_scriptloaded(char *name
);
73 lua_list
*lua_listfromstate(lua_State
*l
);
74 int lua_listexists(lua_list
*l
);
75 int lua_lineok(const char *data
);
77 #define lua_toint(l, n) (int)lua_tonumber(l, n)
78 #define lua_isint(l, n) lua_isnumber(l, n)
79 #define lua_pushint(l, n) lua_pushnumber(l, n)
81 #define lua_tolong(l, n) (long)lua_tonumber(l, n)
82 #define lua_islong(l, n) lua_isnumber(l, n)
83 #define lua_pushlong(l, n) lua_pushnumber(l, n)
85 extern struct rusage r_usages
;
86 extern struct rusage r_usagee
;
88 #define USEC_DIFFERENTIAL 1000000
92 #define ACCOUNTING_START(l) { l->calls++; getrusage(RUSAGE_SELF, &r_usages);
94 #define twrap(A2, B2, C2, D2) A2(&(B2), &(C2), &(D2))
96 #define _SET_2TIMEDIFF(L4, S2, E2, I2) twrap(timersub, E2.I2, S2.I2, E2.I2); twrap(timeradd, L4->I2, E2.I2, L4->I2);
97 #define SET_TIMEDIFF(L3, S2, E2) _SET_2TIMEDIFF(L3, S2, E2, ru_utime); _SET_2TIMEDIFF(L3, S2, E2, ru_stime);
99 #define ACCOUNTING_STOP(l) getrusage(RUSAGE_SELF, &r_usagee); SET_TIMEDIFF(l, r_usages, r_usagee); }
103 #ifdef LUA_DEBUGSOCKET
105 void lua_debugoutput(char *p
, ...);
106 #define DEBUGOUT(p, ...) lua_debugoutput(p , ##__VA_ARGS__)
113 #define INLINE __attribute((always_inline)) inline
117 #define INLINE __forceinline
121 #define INLINE inline
126 INLINE
int lua_debugpcall(lua_State
*l
, char *message
, int a
, int b
, int c
);