blob: be01b70f024abcbef8f76a053b81df24cbb3bea1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
/*
** lua.c
** Linguagem para Usuarios de Aplicacao
** TeCGraf - PUC-Rio
** 28 Apr 93
*/
#include <stdio.h>
#include "lua.h"
#include "lualib.h"
void test (void)
{
lua_pushobject(lua_getparam(1));
lua_call ("c", 1);
}
static void callfunc (void)
{
lua_Object obj = lua_getparam (1);
if (lua_isstring(obj)) lua_call(lua_getstring(obj),0);
}
static void execstr (void)
{
lua_Object obj = lua_getparam (1);
if (lua_isstring(obj)) lua_dostring(lua_getstring(obj));
}
void main (int argc, char *argv[])
{
int i;
if (argc < 2)
{
puts ("usage: lua filename [functionnames]");
return;
}
lua_register ("callfunc", callfunc);
lua_register ("execstr", execstr);
lua_register ("test", test);
iolib_open ();
strlib_open ();
mathlib_open ();
lua_dofile (argv[1]);
for (i=2; i<argc; i++)
{
lua_call (argv[i],0);
}
}
|