Lines Matching refs:L
41 lua_command(lua_State *L) in lua_command() argument
45 int argc = lua_gettop(L); in lua_command()
52 argv[i] = (char *)(intptr_t)luaL_checkstring(L, i + 1); in lua_command()
56 lua_pushinteger(L, res); in lua_command()
62 lua_has_command(lua_State *L) in lua_has_command() argument
66 cmd = luaL_checkstring(L, 1); in lua_has_command()
68 lua_pushboolean(L, 1); in lua_has_command()
72 lua_pushnil(L); in lua_has_command()
73 lua_pushstring(L, "Builtin command not found"); in lua_has_command()
78 lua_has_feature(lua_State *L) in lua_has_feature() argument
83 feature = luaL_checkstring(L, 1); in lua_has_feature()
86 lua_pushboolean(L, 1); in lua_has_feature()
90 lua_pushnil(L); in lua_has_feature()
91 lua_pushstring(L, "Feature not enabled"); in lua_has_feature()
97 lua_perform(lua_State *L) in lua_perform() argument
103 if (parse(&argc, &argv, luaL_checkstring(L, 1)) == 0) { in lua_perform()
107 lua_pushinteger(L, res); in lua_perform()
113 lua_exit(lua_State *L) in lua_exit() argument
115 exit(luaL_checkinteger(L, 1)); in lua_exit()
120 lua_command_error(lua_State *L) in lua_command_error() argument
123 lua_pushstring(L, command_errbuf); in lua_command_error()
132 lua_interpret(lua_State *L) in lua_interpret() argument
136 if (lua_gettop(L) != 1) { in lua_interpret()
137 lua_pushnil(L); in lua_interpret()
141 interp_string = luaL_checkstring(L, 1); in lua_interpret()
142 lua_pushinteger(L, interp_run(interp_string)); in lua_interpret()
147 lua_parse(lua_State *L) in lua_parse() argument
152 if (parse(&argc, &argv, luaL_checkstring(L, 1)) == 0) { in lua_parse()
154 lua_pushstring(L, argv[nargc]); in lua_parse()
160 lua_pushnil(L); in lua_parse()
165 lua_getchar(lua_State *L) in lua_getchar() argument
168 lua_pushinteger(L, getchar()); in lua_getchar()
173 lua_ischar(lua_State *L) in lua_ischar() argument
176 lua_pushboolean(L, ischar()); in lua_ischar()
181 lua_gets(lua_State *L) in lua_gets() argument
186 lua_pushstring(L, buf); in lua_gets()
191 lua_time(lua_State *L) in lua_time() argument
194 lua_pushinteger(L, time(NULL)); in lua_time()
199 lua_delay(lua_State *L) in lua_delay() argument
202 delay((int)luaL_checknumber(L, 1)); in lua_delay()
207 lua_getenv(lua_State *L) in lua_getenv() argument
209 lua_pushstring(L, getenv(luaL_checkstring(L, 1))); in lua_getenv()
215 lua_setenv(lua_State *L) in lua_setenv() argument
219 key = luaL_checkstring(L, 1); in lua_setenv()
220 val = luaL_checkstring(L, 2); in lua_setenv()
221 lua_pushinteger(L, setenv(key, val, 1)); in lua_setenv()
227 lua_unsetenv(lua_State *L) in lua_unsetenv() argument
231 ev = luaL_checkstring(L, 1); in lua_unsetenv()
232 lua_pushinteger(L, unsetenv(ev)); in lua_unsetenv()
238 lua_printc(lua_State *L) in lua_printc() argument
241 const char *s = luaL_checklstring(L, 1, &l); in lua_printc()
250 lua_openfile(lua_State *L) in lua_openfile() argument
255 nargs = lua_gettop(L); in lua_openfile()
257 lua_pushnil(L); in lua_openfile()
260 str = lua_tostring(L, 1); in lua_openfile()
263 mode = lua_tostring(L, 2); in lua_openfile()
265 lua_pushnil(L); in lua_openfile()
271 FILE ** ptr = (FILE**)lua_newuserdata(L, sizeof(FILE**)); in lua_openfile()
274 lua_pushnil(L); in lua_openfile()
279 lua_closefile(lua_State *L) in lua_closefile() argument
282 if (lua_gettop(L) != 1) { in lua_closefile()
283 lua_pushboolean(L, 0); in lua_closefile()
287 f = (FILE**)lua_touserdata(L, 1); in lua_closefile()
289 lua_pushboolean(L, fclose(*f) == 0 ? 1 : 0); in lua_closefile()
292 lua_pushboolean(L, 0); in lua_closefile()
298 lua_readfile(lua_State *L) in lua_readfile() argument
304 if (lua_gettop(L) < 1 || lua_gettop(L) > 2) { in lua_readfile()
305 lua_pushnil(L); in lua_readfile()
306 lua_pushinteger(L, 0); in lua_readfile()
310 f = (FILE**)lua_touserdata(L, 1); in lua_readfile()
313 lua_pushnil(L); in lua_readfile()
314 lua_pushinteger(L, 0); in lua_readfile()
318 if (lua_gettop(L) == 2) in lua_readfile()
319 size = (size_t)lua_tonumber(L, 2); in lua_readfile()
326 lua_pushlstring(L, buf, r); in lua_readfile()
328 lua_pushinteger(L, r); in lua_readfile()
340 lua_writefile(lua_State *L) in lua_writefile() argument
351 nargs = lua_gettop(L); in lua_writefile()
354 return luaL_fileresult(L, 0, NULL); in lua_writefile()
357 f = (FILE**)lua_touserdata(L, 1); in lua_writefile()
361 return luaL_fileresult(L, 0, NULL); in lua_writefile()
371 if (!lua_isstring(L, i + 2)) { in lua_writefile()
373 return luaL_fileresult(L, 0, NULL); in lua_writefile()
378 buf = lua_tolstring(L, i + 2, &bufsz); in lua_writefile()
381 return luaL_fileresult(L, 0, NULL); in lua_writefile()
384 lua_pushinteger(L, w); in lua_writefile()
422 lua_State *L = cookie; in lua_add_feature() local
428 lua_pushstring(L, desc); in lua_add_feature()
429 lua_setfield(L, -2, name); in lua_add_feature()
433 lua_add_features(lua_State *L) in lua_add_features() argument
436 lua_newtable(L); in lua_add_features()
437 feature_iter(&lua_add_feature, L); in lua_add_features()
443 lua_setfield(L, -2, "features"); in lua_add_features()
447 luaopen_loader(lua_State *L) in luaopen_loader() argument
449 luaL_newlib(L, loaderlib); in luaopen_loader()
451 lua_pushstring(L, MACHINE); in luaopen_loader()
452 lua_setfield(L, -2, "machine"); in luaopen_loader()
453 lua_pushstring(L, MACHINE_ARCH); in luaopen_loader()
454 lua_setfield(L, -2, "machine_arch"); in luaopen_loader()
455 lua_pushstring(L, LUA_PATH); in luaopen_loader()
456 lua_setfield(L, -2, "lua_path"); in luaopen_loader()
457 lua_pushinteger(L, bootprog_rev); in luaopen_loader()
458 lua_setfield(L, -2, "version"); in luaopen_loader()
459 lua_pushinteger(L, CMD_OK); in luaopen_loader()
460 lua_setfield(L, -2, "CMD_OK"); in luaopen_loader()
461 lua_pushinteger(L, CMD_WARN); in luaopen_loader()
462 lua_setfield(L, -2, "CMD_WARN"); in luaopen_loader()
463 lua_pushinteger(L, CMD_ERROR); in luaopen_loader()
464 lua_setfield(L, -2, "CMD_ERROR"); in luaopen_loader()
465 lua_pushinteger(L, CMD_CRIT); in luaopen_loader()
466 lua_setfield(L, -2, "CMD_CRIT"); in luaopen_loader()
467 lua_pushinteger(L, CMD_FATAL); in luaopen_loader()
468 lua_setfield(L, -2, "CMD_FATAL"); in luaopen_loader()
469 lua_add_features(L); in luaopen_loader()
471 lua_register(L, "printc", lua_printc); in luaopen_loader()
476 luaopen_io(lua_State *L) in luaopen_io() argument
478 luaL_newlib(L, iolib); in luaopen_io()