]> jfr.im git - irc/quakenet/newserv.git/blob - lua/lua.h
Add: irc_topic, irc_getnickbynick, irc_getuserchanmodes. Add call+memory support...
[irc/quakenet/newserv.git] / lua / lua.h
1 /* Copyright (C) Chris Porter 2005 */
2 /* ALL RIGHTS RESERVED. */
3 /* Don't put this into the SVN repo. */
4
5 #ifndef _LUA_H
6 #define _LUA_H
7
8 #include <lua.h>
9 #include <lauxlib.h>
10 #include <lualib.h>
11 #include <string.h>
12
13 #include "../lib/sstring.h"
14
15 #define LUA_BOTVERSION "1.34"
16 #define LUA_CHANFIXBOT "Z"
17 #define LUA_OPERCHAN "#twilightzone"
18 #define LUA_PUKECHAN "#qnet.keepout"
19
20 #define LUA_DEBUGSOCKET
21
22 #ifdef LUA_JITLIBNAME
23
24 #define LUA_USEJIT
25
26 #endif
27
28 #define LUA_DEBUGSOCKET_ADDRESS "127.0.0.1"
29 #define LUA_DEBUGSOCKET_PORT 7733
30
31 typedef struct lua_list {
32 lua_State *l;
33 sstring *name;
34 unsigned long calls;
35 struct lua_list *next;
36 struct lua_list *prev;
37 } lua_list;
38
39 #define LUA_STARTLOOP(l) { lua_list *ll; for(ll=lua_head;ll;ll=ll->next) { l = ll->l
40
41 #define LUA_ENDLOOP() } }
42
43 #define LUA_PATHLEN 1024
44
45 extern lua_list *lua_head;
46 extern sstring *cpath;
47
48 lua_State *lua_loadscript(char *file);
49 void lua_unloadscript(lua_list *l);
50 lua_list *lua_scriptloaded(char *name);
51 lua_list *lua_listfromstate(lua_State *l);
52
53 #define lua_toint(l, n) (int)lua_tonumber(l, n)
54 #define lua_isint(l, n) lua_isnumber(l, n)
55 #define lua_pushint(l, n) lua_pushnumber(l, n)
56
57 #define lua_tolong(l, n) (long)lua_tonumber(l, n)
58 #define lua_islong(l, n) lua_isnumber(l, n)
59 #define lua_pushlong(l, n) lua_pushnumber(l, n)
60
61 #ifdef LUA_DEBUGSOCKET
62
63 void lua_debugoutput(char *p, ...);
64 #define DEBUGOUT(p, ...) lua_debugoutput(p , ##__VA_ARGS__)
65 #define lua_debugpcall(l, message, ...) { lua_list *l2 = lua_listfromstate(l); DEBUGOUT("%s: %s\n", l2->name->content, message); l2->calls++; lua_pcall(l , ##__VA_ARGS__); }
66
67 #else
68
69 #define DEBUGOUT(p, ...)
70 #define lua_debugpcall(l, message, ...) { lua_listfromstate(l)->calls++; lua_pcall(l , ##__VA_ARGS__); }
71
72 #endif
73
74 #endif