immunio 0.15.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE +234 -0
- data/README.md +147 -0
- data/bin/immunio +5 -0
- data/lib/immunio.rb +29 -0
- data/lib/immunio/agent.rb +260 -0
- data/lib/immunio/authentication.rb +96 -0
- data/lib/immunio/blocked_app.rb +38 -0
- data/lib/immunio/channel.rb +432 -0
- data/lib/immunio/cli.rb +39 -0
- data/lib/immunio/context.rb +114 -0
- data/lib/immunio/errors.rb +43 -0
- data/lib/immunio/immunio_ca.crt +45 -0
- data/lib/immunio/logger.rb +87 -0
- data/lib/immunio/plugins/action_dispatch.rb +45 -0
- data/lib/immunio/plugins/action_view.rb +431 -0
- data/lib/immunio/plugins/active_record.rb +707 -0
- data/lib/immunio/plugins/active_record_relation.rb +370 -0
- data/lib/immunio/plugins/authlogic.rb +80 -0
- data/lib/immunio/plugins/csrf.rb +24 -0
- data/lib/immunio/plugins/devise.rb +40 -0
- data/lib/immunio/plugins/environment_reporter.rb +69 -0
- data/lib/immunio/plugins/eval.rb +51 -0
- data/lib/immunio/plugins/exception_handler.rb +55 -0
- data/lib/immunio/plugins/gems_tracker.rb +5 -0
- data/lib/immunio/plugins/haml.rb +36 -0
- data/lib/immunio/plugins/http_finisher.rb +50 -0
- data/lib/immunio/plugins/http_tracker.rb +203 -0
- data/lib/immunio/plugins/io.rb +96 -0
- data/lib/immunio/plugins/redirect.rb +42 -0
- data/lib/immunio/plugins/warden.rb +66 -0
- data/lib/immunio/processor.rb +234 -0
- data/lib/immunio/rails.rb +26 -0
- data/lib/immunio/request.rb +139 -0
- data/lib/immunio/rufus_lua_ext/ref.rb +27 -0
- data/lib/immunio/rufus_lua_ext/state.rb +157 -0
- data/lib/immunio/rufus_lua_ext/table.rb +137 -0
- data/lib/immunio/rufus_lua_ext/utils.rb +13 -0
- data/lib/immunio/version.rb +5 -0
- data/lib/immunio/vm.rb +291 -0
- data/lua-hooks/ext/all.c +78 -0
- data/lua-hooks/ext/bitop/README +22 -0
- data/lua-hooks/ext/bitop/bit.c +189 -0
- data/lua-hooks/ext/extconf.rb +38 -0
- data/lua-hooks/ext/libinjection/COPYING +37 -0
- data/lua-hooks/ext/libinjection/libinjection.h +65 -0
- data/lua-hooks/ext/libinjection/libinjection_html5.c +847 -0
- data/lua-hooks/ext/libinjection/libinjection_html5.h +54 -0
- data/lua-hooks/ext/libinjection/libinjection_sqli.c +2301 -0
- data/lua-hooks/ext/libinjection/libinjection_sqli.h +295 -0
- data/lua-hooks/ext/libinjection/libinjection_sqli_data.h +9349 -0
- data/lua-hooks/ext/libinjection/libinjection_xss.c +531 -0
- data/lua-hooks/ext/libinjection/libinjection_xss.h +21 -0
- data/lua-hooks/ext/libinjection/lualib.c +109 -0
- data/lua-hooks/ext/lpeg/HISTORY +90 -0
- data/lua-hooks/ext/lpeg/lpcap.c +537 -0
- data/lua-hooks/ext/lpeg/lpcap.h +43 -0
- data/lua-hooks/ext/lpeg/lpcode.c +986 -0
- data/lua-hooks/ext/lpeg/lpcode.h +34 -0
- data/lua-hooks/ext/lpeg/lpeg-128.gif +0 -0
- data/lua-hooks/ext/lpeg/lpeg.html +1429 -0
- data/lua-hooks/ext/lpeg/lpprint.c +244 -0
- data/lua-hooks/ext/lpeg/lpprint.h +35 -0
- data/lua-hooks/ext/lpeg/lptree.c +1238 -0
- data/lua-hooks/ext/lpeg/lptree.h +77 -0
- data/lua-hooks/ext/lpeg/lptypes.h +149 -0
- data/lua-hooks/ext/lpeg/lpvm.c +355 -0
- data/lua-hooks/ext/lpeg/lpvm.h +58 -0
- data/lua-hooks/ext/lpeg/makefile +55 -0
- data/lua-hooks/ext/lpeg/re.html +498 -0
- data/lua-hooks/ext/lpeg/test.lua +1409 -0
- data/lua-hooks/ext/lua-cmsgpack/CMakeLists.txt +45 -0
- data/lua-hooks/ext/lua-cmsgpack/README.md +115 -0
- data/lua-hooks/ext/lua-cmsgpack/lua_cmsgpack.c +957 -0
- data/lua-hooks/ext/lua-cmsgpack/test.lua +570 -0
- data/lua-hooks/ext/lua-snapshot/LICENSE +7 -0
- data/lua-hooks/ext/lua-snapshot/Makefile +12 -0
- data/lua-hooks/ext/lua-snapshot/README.md +18 -0
- data/lua-hooks/ext/lua-snapshot/dump.lua +15 -0
- data/lua-hooks/ext/lua-snapshot/snapshot.c +455 -0
- data/lua-hooks/ext/lua/COPYRIGHT +34 -0
- data/lua-hooks/ext/lua/lapi.c +1087 -0
- data/lua-hooks/ext/lua/lapi.h +16 -0
- data/lua-hooks/ext/lua/lauxlib.c +652 -0
- data/lua-hooks/ext/lua/lauxlib.h +174 -0
- data/lua-hooks/ext/lua/lbaselib.c +659 -0
- data/lua-hooks/ext/lua/lcode.c +831 -0
- data/lua-hooks/ext/lua/lcode.h +76 -0
- data/lua-hooks/ext/lua/ldblib.c +398 -0
- data/lua-hooks/ext/lua/ldebug.c +638 -0
- data/lua-hooks/ext/lua/ldebug.h +33 -0
- data/lua-hooks/ext/lua/ldo.c +519 -0
- data/lua-hooks/ext/lua/ldo.h +57 -0
- data/lua-hooks/ext/lua/ldump.c +164 -0
- data/lua-hooks/ext/lua/lfunc.c +174 -0
- data/lua-hooks/ext/lua/lfunc.h +34 -0
- data/lua-hooks/ext/lua/lgc.c +710 -0
- data/lua-hooks/ext/lua/lgc.h +110 -0
- data/lua-hooks/ext/lua/linit.c +38 -0
- data/lua-hooks/ext/lua/liolib.c +556 -0
- data/lua-hooks/ext/lua/llex.c +463 -0
- data/lua-hooks/ext/lua/llex.h +81 -0
- data/lua-hooks/ext/lua/llimits.h +128 -0
- data/lua-hooks/ext/lua/lmathlib.c +263 -0
- data/lua-hooks/ext/lua/lmem.c +86 -0
- data/lua-hooks/ext/lua/lmem.h +49 -0
- data/lua-hooks/ext/lua/loadlib.c +705 -0
- data/lua-hooks/ext/lua/loadlib_rel.c +760 -0
- data/lua-hooks/ext/lua/lobject.c +214 -0
- data/lua-hooks/ext/lua/lobject.h +381 -0
- data/lua-hooks/ext/lua/lopcodes.c +102 -0
- data/lua-hooks/ext/lua/lopcodes.h +268 -0
- data/lua-hooks/ext/lua/loslib.c +243 -0
- data/lua-hooks/ext/lua/lparser.c +1339 -0
- data/lua-hooks/ext/lua/lparser.h +82 -0
- data/lua-hooks/ext/lua/lstate.c +214 -0
- data/lua-hooks/ext/lua/lstate.h +169 -0
- data/lua-hooks/ext/lua/lstring.c +111 -0
- data/lua-hooks/ext/lua/lstring.h +31 -0
- data/lua-hooks/ext/lua/lstrlib.c +871 -0
- data/lua-hooks/ext/lua/ltable.c +588 -0
- data/lua-hooks/ext/lua/ltable.h +40 -0
- data/lua-hooks/ext/lua/ltablib.c +287 -0
- data/lua-hooks/ext/lua/ltm.c +75 -0
- data/lua-hooks/ext/lua/ltm.h +54 -0
- data/lua-hooks/ext/lua/lua.c +392 -0
- data/lua-hooks/ext/lua/lua.def +131 -0
- data/lua-hooks/ext/lua/lua.h +388 -0
- data/lua-hooks/ext/lua/lua.rc +28 -0
- data/lua-hooks/ext/lua/lua_dll.rc +26 -0
- data/lua-hooks/ext/lua/luac.c +200 -0
- data/lua-hooks/ext/lua/luac.rc +1 -0
- data/lua-hooks/ext/lua/luaconf.h +763 -0
- data/lua-hooks/ext/lua/luaconf.h.in +724 -0
- data/lua-hooks/ext/lua/luaconf.h.orig +763 -0
- data/lua-hooks/ext/lua/lualib.h +53 -0
- data/lua-hooks/ext/lua/lundump.c +227 -0
- data/lua-hooks/ext/lua/lundump.h +36 -0
- data/lua-hooks/ext/lua/lvm.c +767 -0
- data/lua-hooks/ext/lua/lvm.h +36 -0
- data/lua-hooks/ext/lua/lzio.c +82 -0
- data/lua-hooks/ext/lua/lzio.h +67 -0
- data/lua-hooks/ext/lua/print.c +227 -0
- data/lua-hooks/ext/luautf8/README.md +152 -0
- data/lua-hooks/ext/luautf8/lutf8lib.c +1274 -0
- data/lua-hooks/ext/luautf8/unidata.h +3064 -0
- data/lua-hooks/lib/boot.lua +254 -0
- data/lua-hooks/lib/encode.lua +4 -0
- data/lua-hooks/lib/lexers/LICENSE +21 -0
- data/lua-hooks/lib/lexers/bash.lua +134 -0
- data/lua-hooks/lib/lexers/bash_dqstr.lua +62 -0
- data/lua-hooks/lib/lexers/css.lua +216 -0
- data/lua-hooks/lib/lexers/html.lua +106 -0
- data/lua-hooks/lib/lexers/javascript.lua +68 -0
- data/lua-hooks/lib/lexers/lexer.lua +1575 -0
- data/lua-hooks/lib/lexers/markers.lua +33 -0
- metadata +308 -0
@@ -0,0 +1,388 @@
|
|
1
|
+
/*
|
2
|
+
** $Id: lua.h,v 1.218.1.7 2012/01/13 20:36:20 roberto Exp $
|
3
|
+
** Lua - An Extensible Extension Language
|
4
|
+
** Lua.org, PUC-Rio, Brazil (http://www.lua.org)
|
5
|
+
** See Copyright Notice at the end of this file
|
6
|
+
*/
|
7
|
+
|
8
|
+
|
9
|
+
#ifndef lua_h
|
10
|
+
#define lua_h
|
11
|
+
|
12
|
+
#include <stdarg.h>
|
13
|
+
#include <stddef.h>
|
14
|
+
|
15
|
+
|
16
|
+
#include "luaconf.h"
|
17
|
+
|
18
|
+
|
19
|
+
#define LUA_VERSION "Lua 5.1"
|
20
|
+
#define LUA_RELEASE "Lua 5.1.5"
|
21
|
+
#define LUA_VERSION_NUM 501
|
22
|
+
#define LUA_COPYRIGHT "Copyright (C) 1994-2012 Lua.org, PUC-Rio"
|
23
|
+
#define LUA_AUTHORS "R. Ierusalimschy, L. H. de Figueiredo & W. Celes"
|
24
|
+
|
25
|
+
|
26
|
+
/* mark for precompiled code (`<esc>Lua') */
|
27
|
+
#define LUA_SIGNATURE "\033Lua"
|
28
|
+
|
29
|
+
/* option for multiple returns in `lua_pcall' and `lua_call' */
|
30
|
+
#define LUA_MULTRET (-1)
|
31
|
+
|
32
|
+
|
33
|
+
/*
|
34
|
+
** pseudo-indices
|
35
|
+
*/
|
36
|
+
#define LUA_REGISTRYINDEX (-10000)
|
37
|
+
#define LUA_ENVIRONINDEX (-10001)
|
38
|
+
#define LUA_GLOBALSINDEX (-10002)
|
39
|
+
#define lua_upvalueindex(i) (LUA_GLOBALSINDEX-(i))
|
40
|
+
|
41
|
+
|
42
|
+
/* thread status; 0 is OK */
|
43
|
+
#define LUA_YIELD 1
|
44
|
+
#define LUA_ERRRUN 2
|
45
|
+
#define LUA_ERRSYNTAX 3
|
46
|
+
#define LUA_ERRMEM 4
|
47
|
+
#define LUA_ERRERR 5
|
48
|
+
|
49
|
+
|
50
|
+
typedef struct lua_State lua_State;
|
51
|
+
|
52
|
+
typedef int (*lua_CFunction) (lua_State *L);
|
53
|
+
|
54
|
+
|
55
|
+
/*
|
56
|
+
** functions that read/write blocks when loading/dumping Lua chunks
|
57
|
+
*/
|
58
|
+
typedef const char * (*lua_Reader) (lua_State *L, void *ud, size_t *sz);
|
59
|
+
|
60
|
+
typedef int (*lua_Writer) (lua_State *L, const void* p, size_t sz, void* ud);
|
61
|
+
|
62
|
+
|
63
|
+
/*
|
64
|
+
** prototype for memory-allocation functions
|
65
|
+
*/
|
66
|
+
typedef void * (*lua_Alloc) (void *ud, void *ptr, size_t osize, size_t nsize);
|
67
|
+
|
68
|
+
|
69
|
+
/*
|
70
|
+
** basic types
|
71
|
+
*/
|
72
|
+
#define LUA_TNONE (-1)
|
73
|
+
|
74
|
+
#define LUA_TNIL 0
|
75
|
+
#define LUA_TBOOLEAN 1
|
76
|
+
#define LUA_TLIGHTUSERDATA 2
|
77
|
+
#define LUA_TNUMBER 3
|
78
|
+
#define LUA_TSTRING 4
|
79
|
+
#define LUA_TTABLE 5
|
80
|
+
#define LUA_TFUNCTION 6
|
81
|
+
#define LUA_TUSERDATA 7
|
82
|
+
#define LUA_TTHREAD 8
|
83
|
+
|
84
|
+
|
85
|
+
|
86
|
+
/* minimum Lua stack available to a C function */
|
87
|
+
#define LUA_MINSTACK 20
|
88
|
+
|
89
|
+
|
90
|
+
/*
|
91
|
+
** generic extra include file
|
92
|
+
*/
|
93
|
+
#if defined(LUA_USER_H)
|
94
|
+
#include LUA_USER_H
|
95
|
+
#endif
|
96
|
+
|
97
|
+
|
98
|
+
/* type of numbers in Lua */
|
99
|
+
typedef LUA_NUMBER lua_Number;
|
100
|
+
|
101
|
+
|
102
|
+
/* type for integer functions */
|
103
|
+
typedef LUA_INTEGER lua_Integer;
|
104
|
+
|
105
|
+
|
106
|
+
|
107
|
+
/*
|
108
|
+
** state manipulation
|
109
|
+
*/
|
110
|
+
LUA_API lua_State *(lua_newstate) (lua_Alloc f, void *ud);
|
111
|
+
LUA_API void (lua_close) (lua_State *L);
|
112
|
+
LUA_API lua_State *(lua_newthread) (lua_State *L);
|
113
|
+
|
114
|
+
LUA_API lua_CFunction (lua_atpanic) (lua_State *L, lua_CFunction panicf);
|
115
|
+
|
116
|
+
|
117
|
+
/*
|
118
|
+
** basic stack manipulation
|
119
|
+
*/
|
120
|
+
LUA_API int (lua_gettop) (lua_State *L);
|
121
|
+
LUA_API void (lua_settop) (lua_State *L, int idx);
|
122
|
+
LUA_API void (lua_pushvalue) (lua_State *L, int idx);
|
123
|
+
LUA_API void (lua_remove) (lua_State *L, int idx);
|
124
|
+
LUA_API void (lua_insert) (lua_State *L, int idx);
|
125
|
+
LUA_API void (lua_replace) (lua_State *L, int idx);
|
126
|
+
LUA_API int (lua_checkstack) (lua_State *L, int sz);
|
127
|
+
|
128
|
+
LUA_API void (lua_xmove) (lua_State *from, lua_State *to, int n);
|
129
|
+
|
130
|
+
|
131
|
+
/*
|
132
|
+
** access functions (stack -> C)
|
133
|
+
*/
|
134
|
+
|
135
|
+
LUA_API int (lua_isnumber) (lua_State *L, int idx);
|
136
|
+
LUA_API int (lua_isstring) (lua_State *L, int idx);
|
137
|
+
LUA_API int (lua_iscfunction) (lua_State *L, int idx);
|
138
|
+
LUA_API int (lua_isuserdata) (lua_State *L, int idx);
|
139
|
+
LUA_API int (lua_type) (lua_State *L, int idx);
|
140
|
+
LUA_API const char *(lua_typename) (lua_State *L, int tp);
|
141
|
+
|
142
|
+
LUA_API int (lua_equal) (lua_State *L, int idx1, int idx2);
|
143
|
+
LUA_API int (lua_rawequal) (lua_State *L, int idx1, int idx2);
|
144
|
+
LUA_API int (lua_lessthan) (lua_State *L, int idx1, int idx2);
|
145
|
+
|
146
|
+
LUA_API lua_Number (lua_tonumber) (lua_State *L, int idx);
|
147
|
+
LUA_API lua_Integer (lua_tointeger) (lua_State *L, int idx);
|
148
|
+
LUA_API int (lua_toboolean) (lua_State *L, int idx);
|
149
|
+
LUA_API const char *(lua_tolstring) (lua_State *L, int idx, size_t *len);
|
150
|
+
LUA_API size_t (lua_objlen) (lua_State *L, int idx);
|
151
|
+
LUA_API lua_CFunction (lua_tocfunction) (lua_State *L, int idx);
|
152
|
+
LUA_API void *(lua_touserdata) (lua_State *L, int idx);
|
153
|
+
LUA_API lua_State *(lua_tothread) (lua_State *L, int idx);
|
154
|
+
LUA_API const void *(lua_topointer) (lua_State *L, int idx);
|
155
|
+
|
156
|
+
|
157
|
+
/*
|
158
|
+
** push functions (C -> stack)
|
159
|
+
*/
|
160
|
+
LUA_API void (lua_pushnil) (lua_State *L);
|
161
|
+
LUA_API void (lua_pushnumber) (lua_State *L, lua_Number n);
|
162
|
+
LUA_API void (lua_pushinteger) (lua_State *L, lua_Integer n);
|
163
|
+
LUA_API void (lua_pushlstring) (lua_State *L, const char *s, size_t l);
|
164
|
+
LUA_API void (lua_pushstring) (lua_State *L, const char *s);
|
165
|
+
LUA_API const char *(lua_pushvfstring) (lua_State *L, const char *fmt,
|
166
|
+
va_list argp);
|
167
|
+
LUA_API const char *(lua_pushfstring) (lua_State *L, const char *fmt, ...);
|
168
|
+
LUA_API void (lua_pushcclosure) (lua_State *L, lua_CFunction fn, int n);
|
169
|
+
LUA_API void (lua_pushboolean) (lua_State *L, int b);
|
170
|
+
LUA_API void (lua_pushlightuserdata) (lua_State *L, void *p);
|
171
|
+
LUA_API int (lua_pushthread) (lua_State *L);
|
172
|
+
|
173
|
+
|
174
|
+
/*
|
175
|
+
** get functions (Lua -> stack)
|
176
|
+
*/
|
177
|
+
LUA_API void (lua_gettable) (lua_State *L, int idx);
|
178
|
+
LUA_API void (lua_getfield) (lua_State *L, int idx, const char *k);
|
179
|
+
LUA_API void (lua_rawget) (lua_State *L, int idx);
|
180
|
+
LUA_API void (lua_rawgeti) (lua_State *L, int idx, int n);
|
181
|
+
LUA_API void (lua_createtable) (lua_State *L, int narr, int nrec);
|
182
|
+
LUA_API void *(lua_newuserdata) (lua_State *L, size_t sz);
|
183
|
+
LUA_API int (lua_getmetatable) (lua_State *L, int objindex);
|
184
|
+
LUA_API void (lua_getfenv) (lua_State *L, int idx);
|
185
|
+
|
186
|
+
|
187
|
+
/*
|
188
|
+
** set functions (stack -> Lua)
|
189
|
+
*/
|
190
|
+
LUA_API void (lua_settable) (lua_State *L, int idx);
|
191
|
+
LUA_API void (lua_setfield) (lua_State *L, int idx, const char *k);
|
192
|
+
LUA_API void (lua_rawset) (lua_State *L, int idx);
|
193
|
+
LUA_API void (lua_rawseti) (lua_State *L, int idx, int n);
|
194
|
+
LUA_API int (lua_setmetatable) (lua_State *L, int objindex);
|
195
|
+
LUA_API int (lua_setfenv) (lua_State *L, int idx);
|
196
|
+
|
197
|
+
|
198
|
+
/*
|
199
|
+
** `load' and `call' functions (load and run Lua code)
|
200
|
+
*/
|
201
|
+
LUA_API void (lua_call) (lua_State *L, int nargs, int nresults);
|
202
|
+
LUA_API int (lua_pcall) (lua_State *L, int nargs, int nresults, int errfunc);
|
203
|
+
LUA_API int (lua_cpcall) (lua_State *L, lua_CFunction func, void *ud);
|
204
|
+
LUA_API int (lua_load) (lua_State *L, lua_Reader reader, void *dt,
|
205
|
+
const char *chunkname);
|
206
|
+
|
207
|
+
LUA_API int (lua_dump) (lua_State *L, lua_Writer writer, void *data);
|
208
|
+
|
209
|
+
|
210
|
+
/*
|
211
|
+
** coroutine functions
|
212
|
+
*/
|
213
|
+
LUA_API int (lua_yield) (lua_State *L, int nresults);
|
214
|
+
LUA_API int (lua_resume) (lua_State *L, int narg);
|
215
|
+
LUA_API int (lua_status) (lua_State *L);
|
216
|
+
|
217
|
+
/*
|
218
|
+
** garbage-collection function and options
|
219
|
+
*/
|
220
|
+
|
221
|
+
#define LUA_GCSTOP 0
|
222
|
+
#define LUA_GCRESTART 1
|
223
|
+
#define LUA_GCCOLLECT 2
|
224
|
+
#define LUA_GCCOUNT 3
|
225
|
+
#define LUA_GCCOUNTB 4
|
226
|
+
#define LUA_GCSTEP 5
|
227
|
+
#define LUA_GCSETPAUSE 6
|
228
|
+
#define LUA_GCSETSTEPMUL 7
|
229
|
+
|
230
|
+
LUA_API int (lua_gc) (lua_State *L, int what, int data);
|
231
|
+
|
232
|
+
|
233
|
+
/*
|
234
|
+
** miscellaneous functions
|
235
|
+
*/
|
236
|
+
|
237
|
+
LUA_API int (lua_error) (lua_State *L);
|
238
|
+
|
239
|
+
LUA_API int (lua_next) (lua_State *L, int idx);
|
240
|
+
|
241
|
+
LUA_API void (lua_concat) (lua_State *L, int n);
|
242
|
+
|
243
|
+
LUA_API lua_Alloc (lua_getallocf) (lua_State *L, void **ud);
|
244
|
+
LUA_API void lua_setallocf (lua_State *L, lua_Alloc f, void *ud);
|
245
|
+
|
246
|
+
|
247
|
+
|
248
|
+
/*
|
249
|
+
** ===============================================================
|
250
|
+
** some useful macros
|
251
|
+
** ===============================================================
|
252
|
+
*/
|
253
|
+
|
254
|
+
#define lua_pop(L,n) lua_settop(L, -(n)-1)
|
255
|
+
|
256
|
+
#define lua_newtable(L) lua_createtable(L, 0, 0)
|
257
|
+
|
258
|
+
#define lua_register(L,n,f) (lua_pushcfunction(L, (f)), lua_setglobal(L, (n)))
|
259
|
+
|
260
|
+
#define lua_pushcfunction(L,f) lua_pushcclosure(L, (f), 0)
|
261
|
+
|
262
|
+
#define lua_strlen(L,i) lua_objlen(L, (i))
|
263
|
+
|
264
|
+
#define lua_isfunction(L,n) (lua_type(L, (n)) == LUA_TFUNCTION)
|
265
|
+
#define lua_istable(L,n) (lua_type(L, (n)) == LUA_TTABLE)
|
266
|
+
#define lua_islightuserdata(L,n) (lua_type(L, (n)) == LUA_TLIGHTUSERDATA)
|
267
|
+
#define lua_isnil(L,n) (lua_type(L, (n)) == LUA_TNIL)
|
268
|
+
#define lua_isboolean(L,n) (lua_type(L, (n)) == LUA_TBOOLEAN)
|
269
|
+
#define lua_isthread(L,n) (lua_type(L, (n)) == LUA_TTHREAD)
|
270
|
+
#define lua_isnone(L,n) (lua_type(L, (n)) == LUA_TNONE)
|
271
|
+
#define lua_isnoneornil(L, n) (lua_type(L, (n)) <= 0)
|
272
|
+
|
273
|
+
#define lua_pushliteral(L, s) \
|
274
|
+
lua_pushlstring(L, "" s, (sizeof(s)/sizeof(char))-1)
|
275
|
+
|
276
|
+
#define lua_setglobal(L,s) lua_setfield(L, LUA_GLOBALSINDEX, (s))
|
277
|
+
#define lua_getglobal(L,s) lua_getfield(L, LUA_GLOBALSINDEX, (s))
|
278
|
+
|
279
|
+
#define lua_tostring(L,i) lua_tolstring(L, (i), NULL)
|
280
|
+
|
281
|
+
|
282
|
+
|
283
|
+
/*
|
284
|
+
** compatibility macros and functions
|
285
|
+
*/
|
286
|
+
|
287
|
+
#define lua_open() luaL_newstate()
|
288
|
+
|
289
|
+
#define lua_getregistry(L) lua_pushvalue(L, LUA_REGISTRYINDEX)
|
290
|
+
|
291
|
+
#define lua_getgccount(L) lua_gc(L, LUA_GCCOUNT, 0)
|
292
|
+
|
293
|
+
#define lua_Chunkreader lua_Reader
|
294
|
+
#define lua_Chunkwriter lua_Writer
|
295
|
+
|
296
|
+
|
297
|
+
/* hack */
|
298
|
+
LUA_API void lua_setlevel (lua_State *from, lua_State *to);
|
299
|
+
|
300
|
+
|
301
|
+
/*
|
302
|
+
** {======================================================================
|
303
|
+
** Debug API
|
304
|
+
** =======================================================================
|
305
|
+
*/
|
306
|
+
|
307
|
+
|
308
|
+
/*
|
309
|
+
** Event codes
|
310
|
+
*/
|
311
|
+
#define LUA_HOOKCALL 0
|
312
|
+
#define LUA_HOOKRET 1
|
313
|
+
#define LUA_HOOKLINE 2
|
314
|
+
#define LUA_HOOKCOUNT 3
|
315
|
+
#define LUA_HOOKTAILRET 4
|
316
|
+
|
317
|
+
|
318
|
+
/*
|
319
|
+
** Event masks
|
320
|
+
*/
|
321
|
+
#define LUA_MASKCALL (1 << LUA_HOOKCALL)
|
322
|
+
#define LUA_MASKRET (1 << LUA_HOOKRET)
|
323
|
+
#define LUA_MASKLINE (1 << LUA_HOOKLINE)
|
324
|
+
#define LUA_MASKCOUNT (1 << LUA_HOOKCOUNT)
|
325
|
+
|
326
|
+
typedef struct lua_Debug lua_Debug; /* activation record */
|
327
|
+
|
328
|
+
|
329
|
+
/* Functions to be called by the debuger in specific events */
|
330
|
+
typedef void (*lua_Hook) (lua_State *L, lua_Debug *ar);
|
331
|
+
|
332
|
+
|
333
|
+
LUA_API int lua_getstack (lua_State *L, int level, lua_Debug *ar);
|
334
|
+
LUA_API int lua_getinfo (lua_State *L, const char *what, lua_Debug *ar);
|
335
|
+
LUA_API const char *lua_getlocal (lua_State *L, const lua_Debug *ar, int n);
|
336
|
+
LUA_API const char *lua_setlocal (lua_State *L, const lua_Debug *ar, int n);
|
337
|
+
LUA_API const char *lua_getupvalue (lua_State *L, int funcindex, int n);
|
338
|
+
LUA_API const char *lua_setupvalue (lua_State *L, int funcindex, int n);
|
339
|
+
|
340
|
+
LUA_API int lua_sethook (lua_State *L, lua_Hook func, int mask, int count);
|
341
|
+
LUA_API lua_Hook lua_gethook (lua_State *L);
|
342
|
+
LUA_API int lua_gethookmask (lua_State *L);
|
343
|
+
LUA_API int lua_gethookcount (lua_State *L);
|
344
|
+
|
345
|
+
|
346
|
+
struct lua_Debug {
|
347
|
+
int event;
|
348
|
+
const char *name; /* (n) */
|
349
|
+
const char *namewhat; /* (n) `global', `local', `field', `method' */
|
350
|
+
const char *what; /* (S) `Lua', `C', `main', `tail' */
|
351
|
+
const char *source; /* (S) */
|
352
|
+
int currentline; /* (l) */
|
353
|
+
int nups; /* (u) number of upvalues */
|
354
|
+
int linedefined; /* (S) */
|
355
|
+
int lastlinedefined; /* (S) */
|
356
|
+
char short_src[LUA_IDSIZE]; /* (S) */
|
357
|
+
/* private part */
|
358
|
+
int i_ci; /* active function */
|
359
|
+
};
|
360
|
+
|
361
|
+
/* }====================================================================== */
|
362
|
+
|
363
|
+
|
364
|
+
/******************************************************************************
|
365
|
+
* Copyright (C) 1994-2012 Lua.org, PUC-Rio. All rights reserved.
|
366
|
+
*
|
367
|
+
* Permission is hereby granted, free of charge, to any person obtaining
|
368
|
+
* a copy of this software and associated documentation files (the
|
369
|
+
* "Software"), to deal in the Software without restriction, including
|
370
|
+
* without limitation the rights to use, copy, modify, merge, publish,
|
371
|
+
* distribute, sublicense, and/or sell copies of the Software, and to
|
372
|
+
* permit persons to whom the Software is furnished to do so, subject to
|
373
|
+
* the following conditions:
|
374
|
+
*
|
375
|
+
* The above copyright notice and this permission notice shall be
|
376
|
+
* included in all copies or substantial portions of the Software.
|
377
|
+
*
|
378
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
379
|
+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
380
|
+
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
381
|
+
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
382
|
+
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
383
|
+
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
384
|
+
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
385
|
+
******************************************************************************/
|
386
|
+
|
387
|
+
|
388
|
+
#endif
|
@@ -0,0 +1,28 @@
|
|
1
|
+
0 ICON "..\\etc\\lua.ico"
|
2
|
+
|
3
|
+
1 VERSIONINFO
|
4
|
+
FILEVERSION 5,1,4,0
|
5
|
+
PRODUCTVERSION 5,1,4,0
|
6
|
+
BEGIN
|
7
|
+
BLOCK "StringFileInfo"
|
8
|
+
BEGIN
|
9
|
+
BLOCK "040904b0"
|
10
|
+
BEGIN
|
11
|
+
VALUE "Comments", "www.lua.org\0"
|
12
|
+
VALUE "CompanyName", "Lua.org\0"
|
13
|
+
VALUE "FileDescription", "Lua Console Standalone Interpreter\0"
|
14
|
+
VALUE "FileVersion", "5.1.4\0"
|
15
|
+
VALUE "LegalCopyright", "Copyright � 1994-2008 Lua.org, PUC-Rio.\0"
|
16
|
+
VALUE "OriginalFilename", "lua5.1.exe\0"
|
17
|
+
VALUE "ProductName", "Lua - The Programming Language\0"
|
18
|
+
VALUE "ProductVersion", "5.1.4\0"
|
19
|
+
VALUE "PrivateBuild", "Built for LuaDist\0"
|
20
|
+
END
|
21
|
+
END
|
22
|
+
END
|
23
|
+
|
24
|
+
#ifdef MSVC8
|
25
|
+
1 24 "lua_dll8.manifest"
|
26
|
+
#elif MSVC9
|
27
|
+
1 24 "lua_dll9.manifest"
|
28
|
+
#endif
|
@@ -0,0 +1,26 @@
|
|
1
|
+
1 VERSIONINFO
|
2
|
+
FILEVERSION 5,1,4,0
|
3
|
+
PRODUCTVERSION 5,1,4,0
|
4
|
+
BEGIN
|
5
|
+
BLOCK "StringFileInfo"
|
6
|
+
BEGIN
|
7
|
+
BLOCK "040904b0"
|
8
|
+
BEGIN
|
9
|
+
VALUE "Comments", "www.lua.org\0"
|
10
|
+
VALUE "CompanyName", "Lua.org\0"
|
11
|
+
VALUE "FileDescription", "Lua Language Run Time\0"
|
12
|
+
VALUE "FileVersion", "5.1.4\0"
|
13
|
+
VALUE "LegalCopyright", "Copyright � 1994-2009 Lua.org, PUC-Rio.\0"
|
14
|
+
VALUE "OriginalFilename", "lua5.1.dll\0"
|
15
|
+
VALUE "ProductName", "Lua - The Programming Language\0"
|
16
|
+
VALUE "ProductVersion", "5.1.4\0"
|
17
|
+
VALUE "PrivateBuild", "Built for LuaDist\0"
|
18
|
+
END
|
19
|
+
END
|
20
|
+
END
|
21
|
+
|
22
|
+
#ifdef MSVC8
|
23
|
+
2 24 "lua_dll8.manifest"
|
24
|
+
#elif MSVC9
|
25
|
+
2 24 "lua_dll9.manifest"
|
26
|
+
#endif
|
@@ -0,0 +1,200 @@
|
|
1
|
+
/*
|
2
|
+
** $Id: luac.c,v 1.54 2006/06/02 17:37:11 lhf Exp $
|
3
|
+
** Lua compiler (saves bytecodes to files; also list bytecodes)
|
4
|
+
** See Copyright Notice in lua.h
|
5
|
+
*/
|
6
|
+
|
7
|
+
#include <errno.h>
|
8
|
+
#include <stdio.h>
|
9
|
+
#include <stdlib.h>
|
10
|
+
#include <string.h>
|
11
|
+
|
12
|
+
#define luac_c
|
13
|
+
#define LUA_CORE
|
14
|
+
|
15
|
+
#include "lua.h"
|
16
|
+
#include "lauxlib.h"
|
17
|
+
|
18
|
+
#include "ldo.h"
|
19
|
+
#include "lfunc.h"
|
20
|
+
#include "lmem.h"
|
21
|
+
#include "lobject.h"
|
22
|
+
#include "lopcodes.h"
|
23
|
+
#include "lstring.h"
|
24
|
+
#include "lundump.h"
|
25
|
+
|
26
|
+
#define PROGNAME "luac" /* default program name */
|
27
|
+
#define OUTPUT PROGNAME ".out" /* default output file */
|
28
|
+
|
29
|
+
static int listing=0; /* list bytecodes? */
|
30
|
+
static int dumping=1; /* dump bytecodes? */
|
31
|
+
static int stripping=0; /* strip debug information? */
|
32
|
+
static char Output[]={ OUTPUT }; /* default output file name */
|
33
|
+
static const char* output=Output; /* actual output file name */
|
34
|
+
static const char* progname=PROGNAME; /* actual program name */
|
35
|
+
|
36
|
+
static void fatal(const char* message)
|
37
|
+
{
|
38
|
+
fprintf(stderr,"%s: %s\n",progname,message);
|
39
|
+
exit(EXIT_FAILURE);
|
40
|
+
}
|
41
|
+
|
42
|
+
static void cannot(const char* what)
|
43
|
+
{
|
44
|
+
fprintf(stderr,"%s: cannot %s %s: %s\n",progname,what,output,strerror(errno));
|
45
|
+
exit(EXIT_FAILURE);
|
46
|
+
}
|
47
|
+
|
48
|
+
static void usage(const char* message)
|
49
|
+
{
|
50
|
+
if (*message=='-')
|
51
|
+
fprintf(stderr,"%s: unrecognized option " LUA_QS "\n",progname,message);
|
52
|
+
else
|
53
|
+
fprintf(stderr,"%s: %s\n",progname,message);
|
54
|
+
fprintf(stderr,
|
55
|
+
"usage: %s [options] [filenames].\n"
|
56
|
+
"Available options are:\n"
|
57
|
+
" - process stdin\n"
|
58
|
+
" -l list\n"
|
59
|
+
" -o name output to file " LUA_QL("name") " (default is \"%s\")\n"
|
60
|
+
" -p parse only\n"
|
61
|
+
" -s strip debug information\n"
|
62
|
+
" -v show version information\n"
|
63
|
+
" -- stop handling options\n",
|
64
|
+
progname,Output);
|
65
|
+
exit(EXIT_FAILURE);
|
66
|
+
}
|
67
|
+
|
68
|
+
#define IS(s) (strcmp(argv[i],s)==0)
|
69
|
+
|
70
|
+
static int doargs(int argc, char* argv[])
|
71
|
+
{
|
72
|
+
int i;
|
73
|
+
int version=0;
|
74
|
+
if (argv[0]!=NULL && *argv[0]!=0) progname=argv[0];
|
75
|
+
for (i=1; i<argc; i++)
|
76
|
+
{
|
77
|
+
if (*argv[i]!='-') /* end of options; keep it */
|
78
|
+
break;
|
79
|
+
else if (IS("--")) /* end of options; skip it */
|
80
|
+
{
|
81
|
+
++i;
|
82
|
+
if (version) ++version;
|
83
|
+
break;
|
84
|
+
}
|
85
|
+
else if (IS("-")) /* end of options; use stdin */
|
86
|
+
break;
|
87
|
+
else if (IS("-l")) /* list */
|
88
|
+
++listing;
|
89
|
+
else if (IS("-o")) /* output file */
|
90
|
+
{
|
91
|
+
output=argv[++i];
|
92
|
+
if (output==NULL || *output==0) usage(LUA_QL("-o") " needs argument");
|
93
|
+
if (IS("-")) output=NULL;
|
94
|
+
}
|
95
|
+
else if (IS("-p")) /* parse only */
|
96
|
+
dumping=0;
|
97
|
+
else if (IS("-s")) /* strip debug information */
|
98
|
+
stripping=1;
|
99
|
+
else if (IS("-v")) /* show version */
|
100
|
+
++version;
|
101
|
+
else /* unknown option */
|
102
|
+
usage(argv[i]);
|
103
|
+
}
|
104
|
+
if (i==argc && (listing || !dumping))
|
105
|
+
{
|
106
|
+
dumping=0;
|
107
|
+
argv[--i]=Output;
|
108
|
+
}
|
109
|
+
if (version)
|
110
|
+
{
|
111
|
+
printf("%s %s\n",LUA_RELEASE,LUA_COPYRIGHT);
|
112
|
+
if (version==argc-1) exit(EXIT_SUCCESS);
|
113
|
+
}
|
114
|
+
return i;
|
115
|
+
}
|
116
|
+
|
117
|
+
#define toproto(L,i) (clvalue(L->top+(i))->l.p)
|
118
|
+
|
119
|
+
static const Proto* combine(lua_State* L, int n)
|
120
|
+
{
|
121
|
+
if (n==1)
|
122
|
+
return toproto(L,-1);
|
123
|
+
else
|
124
|
+
{
|
125
|
+
int i,pc;
|
126
|
+
Proto* f=luaF_newproto(L);
|
127
|
+
setptvalue2s(L,L->top,f); incr_top(L);
|
128
|
+
f->source=luaS_newliteral(L,"=(" PROGNAME ")");
|
129
|
+
f->maxstacksize=1;
|
130
|
+
pc=2*n+1;
|
131
|
+
f->code=luaM_newvector(L,pc,Instruction);
|
132
|
+
f->sizecode=pc;
|
133
|
+
f->p=luaM_newvector(L,n,Proto*);
|
134
|
+
f->sizep=n;
|
135
|
+
pc=0;
|
136
|
+
for (i=0; i<n; i++)
|
137
|
+
{
|
138
|
+
f->p[i]=toproto(L,i-n-1);
|
139
|
+
f->code[pc++]=CREATE_ABx(OP_CLOSURE,0,i);
|
140
|
+
f->code[pc++]=CREATE_ABC(OP_CALL,0,1,1);
|
141
|
+
}
|
142
|
+
f->code[pc++]=CREATE_ABC(OP_RETURN,0,1,0);
|
143
|
+
return f;
|
144
|
+
}
|
145
|
+
}
|
146
|
+
|
147
|
+
static int writer(lua_State* L, const void* p, size_t size, void* u)
|
148
|
+
{
|
149
|
+
UNUSED(L);
|
150
|
+
return (fwrite(p,size,1,(FILE*)u)!=1) && (size!=0);
|
151
|
+
}
|
152
|
+
|
153
|
+
struct Smain {
|
154
|
+
int argc;
|
155
|
+
char** argv;
|
156
|
+
};
|
157
|
+
|
158
|
+
static int pmain(lua_State* L)
|
159
|
+
{
|
160
|
+
struct Smain* s = (struct Smain*)lua_touserdata(L, 1);
|
161
|
+
int argc=s->argc;
|
162
|
+
char** argv=s->argv;
|
163
|
+
const Proto* f;
|
164
|
+
int i;
|
165
|
+
if (!lua_checkstack(L,argc)) fatal("too many input files");
|
166
|
+
for (i=0; i<argc; i++)
|
167
|
+
{
|
168
|
+
const char* filename=IS("-") ? NULL : argv[i];
|
169
|
+
if (luaL_loadfile(L,filename)!=0) fatal(lua_tostring(L,-1));
|
170
|
+
}
|
171
|
+
f=combine(L,argc);
|
172
|
+
if (listing) luaU_print(f,listing>1);
|
173
|
+
if (dumping)
|
174
|
+
{
|
175
|
+
FILE* D= (output==NULL) ? stdout : fopen(output,"wb");
|
176
|
+
if (D==NULL) cannot("open");
|
177
|
+
lua_lock(L);
|
178
|
+
luaU_dump(L,f,writer,D,stripping);
|
179
|
+
lua_unlock(L);
|
180
|
+
if (ferror(D)) cannot("write");
|
181
|
+
if (fclose(D)) cannot("close");
|
182
|
+
}
|
183
|
+
return 0;
|
184
|
+
}
|
185
|
+
|
186
|
+
int main(int argc, char* argv[])
|
187
|
+
{
|
188
|
+
lua_State* L;
|
189
|
+
struct Smain s;
|
190
|
+
int i=doargs(argc,argv);
|
191
|
+
argc-=i; argv+=i;
|
192
|
+
if (argc<=0) usage("no input files given");
|
193
|
+
L=lua_open();
|
194
|
+
if (L==NULL) fatal("not enough memory for state");
|
195
|
+
s.argc=argc;
|
196
|
+
s.argv=argv;
|
197
|
+
if (lua_cpcall(L,pmain,&s)!=0) fatal(lua_tostring(L,-1));
|
198
|
+
lua_close(L);
|
199
|
+
return EXIT_SUCCESS;
|
200
|
+
}
|