]> jfr.im git - irc/quakenet/newserv.git/blame - lua/lua.h
Fix warnings on Y's box.
[irc/quakenet/newserv.git] / lua / lua.h
CommitLineData
2da56f0d
CP
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
fe0f6b25
CP
8#define __USE_BSD
9
2da56f0d
CP
10#include <lua.h>
11#include <lauxlib.h>
12#include <lualib.h>
13#include <string.h>
fe0f6b25
CP
14#include <sys/times.h>
15#include <sys/time.h>
16#include <sys/resource.h>
17#include <unistd.h>
2da56f0d
CP
18
19#include "../lib/sstring.h"
20
0225bed3 21#include "lualocal.h"
065c0091 22#include "luasocket.h"
0225bed3 23
fe0f6b25
CP
24/*** defines ************************************/
25
3cf6947a 26#define LUA_BOTVERSION "1.84"
ebe20bb8
CP
27#define LUA_CHANFIXBOT "Z"
28#define LUA_OPERCHAN "#twilightzone"
ba436ecf
CP
29
30#ifndef LUA_PUKECHAN
380a5b17 31#define LUA_PUKECHAN "#qnet.keepout"
ba436ecf 32#endif
ebe20bb8 33
fe0f6b25 34#define LUA_PROFILE
9887536a 35
9887536a
CP
36#define LUA_DEBUGSOCKET_ADDRESS "127.0.0.1"
37#define LUA_DEBUGSOCKET_PORT 7733
38
0225bed3
CP
39#ifdef LUA_USEJIT
40#include <luajit.h>
41#define LUA_AUXVERSION " + " LUAJIT_VERSION
42#else
b7252b44 43#define LUA_AUXVERSION ""
0225bed3
CP
44#endif
45
46#define LUA_FULLVERSION "Lua engine v" LUA_BOTVERSION " (" LUA_VERSION LUA_AUXVERSION ")"
47
fe0f6b25
CP
48/*** end defines ************************************/
49
2da56f0d
CP
50typedef struct lua_list {
51 lua_State *l;
52 sstring *name;
d0d1e2a3 53 unsigned long calls;
fe0f6b25 54 struct timeval ru_utime, ru_stime;
2da56f0d
CP
55 struct lua_list *next;
56 struct lua_list *prev;
0225bed3 57 lua_localnick *nicks;
065c0091 58 lua_socket *sockets;
2da56f0d
CP
59} lua_list;
60
61#define LUA_STARTLOOP(l) { lua_list *ll; for(ll=lua_head;ll;ll=ll->next) { l = ll->l
62
63#define LUA_ENDLOOP() } }
64
65#define LUA_PATHLEN 1024
66
67extern lua_list *lua_head;
6269435f 68extern sstring *cpath;
2da56f0d
CP
69
70lua_State *lua_loadscript(char *file);
71void lua_unloadscript(lua_list *l);
72lua_list *lua_scriptloaded(char *name);
d0d1e2a3 73lua_list *lua_listfromstate(lua_State *l);
55cee062 74int lua_listexists(lua_list *l);
0225bed3 75int lua_lineok(const char *data);
2da56f0d
CP
76
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)
80
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)
84
fe0f6b25
CP
85extern struct rusage r_usages;
86extern struct rusage r_usagee;
87
88#define USEC_DIFFERENTIAL 1000000
89
90#ifdef LUA_PROFILE
91
92#define ACCOUNTING_START(l) { l->calls++; getrusage(RUSAGE_SELF, &r_usages);
93
94#define twrap(A2, B2, C2, D2) A2(&(B2), &(C2), &(D2))
95
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);
98
99#define ACCOUNTING_STOP(l) getrusage(RUSAGE_SELF, &r_usagee); SET_TIMEDIFF(l, r_usages, r_usagee); }
100
fe0f6b25
CP
101#endif
102
9887536a
CP
103#ifdef LUA_DEBUGSOCKET
104
105void lua_debugoutput(char *p, ...);
106#define DEBUGOUT(p, ...) lua_debugoutput(p , ##__VA_ARGS__)
9887536a 107
2da56f0d
CP
108#endif
109
24da5817
CP
110#ifndef INLINE
111
112#ifdef __GNUC__
113#define INLINE __attribute((always_inline)) inline
114#endif
115
116#ifdef _MSC_VER
117#define INLINE __forceinline
118#endif
119
120#ifndef INLINE
121#define INLINE inline
122#endif
123
124#endif /* INLINE */
125
ea15be33
CP
126INLINE int lua_debugpcall(lua_State *l, char *message, int a, int b, int c);
127
9887536a 128#endif