3 ** Linguagem para Usuarios de Aplicacao
6 char *rcs_lua
="$Id: lua.c,v 1.4 1995/02/07 16:04:15 lhf Exp $";
15 static char **lua_argv
;
18 %F Allow Lua code to access argv strings.
19 %i Receive from Lua the argument number (starting with 1).
20 %o Return to Lua the argument, or nil if it does not exist.
22 static void lua_getargv (void)
24 lua_Object lo
= lua_getparam(1);
25 if (!lua_isnumber(lo
))
29 int n
= (int)lua_getnumber(lo
);
30 if (n
< 1 || n
> lua_argc
) lua_pushnil();
31 else lua_pushstring(lua_argv
[n
]);
36 int main (int argc
, char *argv
[])
44 lua_register("argv", lua_getargv
);
49 while (gets(buffer
) != 0)
50 result
= lua_dostring(buffer
);
54 for (i
=1; i
<argc
; i
++)
56 if (strcmp(argv
[i
], "--") == 0)
63 for (i
=1; i
<argc
; i
++)
65 if (strcmp(argv
[i
], "--") == 0)
68 result
= lua_dofile (argv
[i
]);