Lines Matching refs:L
25 enforce_max_args(lua_State *L, int max) in enforce_max_args() argument
29 narg = lua_gettop(L); in enforce_max_args()
30 luaL_argcheck(L, narg <= max, max + 1, "too many arguments"); in enforce_max_args()
37 lua__exit(lua_State *L) in lua__exit() argument
41 enforce_max_args(L, 1); in lua__exit()
42 code = luaL_checkinteger(L, 1); in lua__exit()
48 lua_basename(lua_State *L) in lua_basename() argument
52 enforce_max_args(L, 1); in lua_basename()
53 inpath = strdup(luaL_checkstring(L, 1)); in lua_basename()
55 lua_pushnil(L); in lua_basename()
56 lua_pushstring(L, strerror(ENOMEM)); in lua_basename()
57 lua_pushinteger(L, ENOMEM); in lua_basename()
62 lua_pushstring(L, outpath); in lua_basename()
68 lua_chmod(lua_State *L) in lua_chmod() argument
73 enforce_max_args(L, 2); in lua_chmod()
74 path = luaL_checkstring(L, 1); in lua_chmod()
75 mode = (mode_t)luaL_checkinteger(L, 2); in lua_chmod()
78 lua_pushnil(L); in lua_chmod()
79 lua_pushstring(L, strerror(errno)); in lua_chmod()
80 lua_pushinteger(L, errno); in lua_chmod()
83 lua_pushinteger(L, 0); in lua_chmod()
88 lua_chown(lua_State *L) in lua_chown() argument
95 enforce_max_args(L, 3); in lua_chown()
97 path = luaL_checkstring(L, 1); in lua_chown()
98 if (lua_isinteger(L, 2)) in lua_chown()
99 owner = (uid_t)lua_tointeger(L, 2); in lua_chown()
100 else if (lua_isstring(L, 2)) { in lua_chown()
104 error = getpwnam_r(lua_tostring(L, 2), &passwd, in lua_chown()
109 return (luaL_argerror(L, 2, in lua_chown()
110 lua_pushfstring(L, "unknown user %s", in lua_chown()
111 lua_tostring(L, 2)))); in lua_chown()
112 } else if (!lua_isnoneornil(L, 2)) { in lua_chown()
113 const char *type = luaL_typename(L, 2); in lua_chown()
114 return (luaL_argerror(L, 2, in lua_chown()
115 lua_pushfstring(L, "integer or string expected, got %s", in lua_chown()
119 if (lua_isinteger(L, 3)) in lua_chown()
120 group = (gid_t)lua_tointeger(L, 3); in lua_chown()
121 else if (lua_isstring(L, 3)) { in lua_chown()
125 error = getgrnam_r(lua_tostring(L, 3), &gr, buf, sizeof(buf), in lua_chown()
130 return (luaL_argerror(L, 3, in lua_chown()
131 lua_pushfstring(L, "unknown group %s", in lua_chown()
132 lua_tostring(L, 3)))); in lua_chown()
133 } else if (!lua_isnoneornil(L, 3)) { in lua_chown()
134 const char *type = luaL_typename(L, 3); in lua_chown()
135 return (luaL_argerror(L, 3, in lua_chown()
136 lua_pushfstring(L, "integer or string expected, got %s", in lua_chown()
141 lua_pushnil(L); in lua_chown()
142 lua_pushstring(L, strerror(errno)); in lua_chown()
143 lua_pushinteger(L, errno); in lua_chown()
146 lua_pushinteger(L, 0); in lua_chown()
151 lua_pclose(lua_State *L) in lua_pclose() argument
155 enforce_max_args(L, 1); in lua_pclose()
157 fd = luaL_checkinteger(L, 1); in lua_pclose()
164 lua_pushinteger(L, 0); in lua_pclose()
170 lua_pushnil(L); in lua_pclose()
171 lua_pushstring(L, strerror(error)); in lua_pclose()
172 lua_pushinteger(L, error); in lua_pclose()
178 lua_dup2(lua_State *L) in lua_dup2() argument
182 enforce_max_args(L, 2); in lua_dup2()
184 oldd = luaL_checkinteger(L, 1); in lua_dup2()
190 newd = luaL_checkinteger(L, 2); in lua_dup2()
198 lua_pushinteger(L, error); in lua_dup2()
204 lua_pushnil(L); in lua_dup2()
205 lua_pushstring(L, strerror(error)); in lua_dup2()
206 lua_pushinteger(L, error); in lua_dup2()
211 lua_execp(lua_State *L) in lua_execp() argument
217 enforce_max_args(L, 2); in lua_execp()
219 file = luaL_checkstring(L, 1); in lua_execp()
220 luaL_checktype(L, 2, LUA_TTABLE); in lua_execp()
222 lua_len(L, 2); in lua_execp()
223 argc = lua_tointeger(L, -1); in lua_execp()
232 argv = lua_newuserdatauv(L, (argc + 2) * sizeof(char *), 0); in lua_execp()
239 lua_pushinteger(L, 0); in lua_execp()
240 lua_gettable(L, 2); in lua_execp()
241 argv[0] = lua_tostring(L, -1); in lua_execp()
247 lua_pushinteger(L, i); in lua_execp()
248 lua_gettable(L, 2); in lua_execp()
249 argv[i] = lua_tostring(L, -1); in lua_execp()
251 luaL_argerror(L, 2, in lua_execp()
260 lua_pushnil(L); in lua_execp()
261 lua_pushstring(L, strerror(error)); in lua_execp()
262 lua_pushinteger(L, error); in lua_execp()
267 lua_fnmatch(lua_State *L) in lua_fnmatch() argument
272 enforce_max_args(L, 3); in lua_fnmatch()
273 pattern = luaL_checkstring(L, 1); in lua_fnmatch()
274 string = luaL_checkstring(L, 2); in lua_fnmatch()
275 flags = luaL_optinteger(L, 3, 0); in lua_fnmatch()
277 lua_pushinteger(L, fnmatch(pattern, string, flags)); in lua_fnmatch()
283 lua_uname(lua_State *L) in lua_uname() argument
288 enforce_max_args(L, 0); in lua_uname()
293 lua_pushnil(L); in lua_uname()
294 lua_pushstring(L, strerror(error)); in lua_uname()
295 lua_pushinteger(L, error); in lua_uname()
299 lua_newtable(L); in lua_uname()
301 lua_pushstring(L, name.f); \ in lua_uname()
302 lua_setfield(L, -2, #f); \ in lua_uname()
315 lua_dirname(lua_State *L) in lua_dirname() argument
319 enforce_max_args(L, 1); in lua_dirname()
321 inpath = strdup(luaL_checkstring(L, 1)); in lua_dirname()
323 lua_pushnil(L); in lua_dirname()
324 lua_pushstring(L, strerror(ENOMEM)); in lua_dirname()
325 lua_pushinteger(L, ENOMEM); in lua_dirname()
330 lua_pushstring(L, outpath); in lua_dirname()
336 lua_fork(lua_State *L) in lua_fork() argument
340 enforce_max_args(L, 0); in lua_fork()
344 lua_pushnil(L); in lua_fork()
345 lua_pushstring(L, strerror(errno)); in lua_fork()
346 lua_pushinteger(L, errno); in lua_fork()
350 lua_pushinteger(L, pid); in lua_fork()
355 lua_getpid(lua_State *L) in lua_getpid() argument
357 enforce_max_args(L, 0); in lua_getpid()
359 lua_pushinteger(L, getpid()); in lua_getpid()
364 lua_pipe(lua_State *L) in lua_pipe() argument
368 enforce_max_args(L, 0); in lua_pipe()
372 lua_pushnil(L); in lua_pipe()
373 lua_pushstring(L, strerror(errno)); in lua_pipe()
374 lua_pushinteger(L, errno); in lua_pipe()
378 lua_pushinteger(L, fd[0]); in lua_pipe()
379 lua_pushinteger(L, fd[1]); in lua_pipe()
384 lua_read(lua_State *L) in lua_read() argument
391 enforce_max_args(L, 2); in lua_read()
392 fd = luaL_checkinteger(L, 1); in lua_read()
393 sz = luaL_checkinteger(L, 2); in lua_read()
410 lua_pushlstring(L, buf, ret); in lua_read()
421 lua_pushnil(L); in lua_read()
422 lua_pushstring(L, strerror(error)); in lua_read()
423 lua_pushinteger(L, error); in lua_read()
428 lua_realpath(lua_State *L) in lua_realpath() argument
433 enforce_max_args(L, 1); in lua_realpath()
434 inpath = luaL_checkstring(L, 1); in lua_realpath()
438 lua_pushnil(L); in lua_realpath()
439 lua_pushstring(L, strerror(errno)); in lua_realpath()
440 lua_pushinteger(L, errno); in lua_realpath()
444 lua_pushstring(L, outpath); in lua_realpath()
450 lua_wait(lua_State *L) in lua_wait() argument
455 enforce_max_args(L, 2); in lua_wait()
456 pid = luaL_optinteger(L, 1, -1); in lua_wait()
457 options = luaL_optinteger(L, 2, 0); in lua_wait()
462 lua_pushnil(L); in lua_wait()
463 lua_pushstring(L, strerror(errno)); in lua_wait()
464 lua_pushinteger(L, errno); in lua_wait()
468 lua_pushinteger(L, pid); in lua_wait()
470 lua_pushliteral(L, "running"); in lua_wait()
475 lua_pushliteral(L, "continued"); in lua_wait()
478 lua_pushliteral(L, "stopped"); in lua_wait()
479 lua_pushinteger(L, WSTOPSIG(status)); in lua_wait()
482 lua_pushliteral(L, "exited"); in lua_wait()
483 lua_pushinteger(L, WEXITSTATUS(status)); in lua_wait()
486 lua_pushliteral(L, "killed"); in lua_wait()
487 lua_pushinteger(L, WTERMSIG(status)); in lua_wait()
495 lua_write(lua_State *L) in lua_write() argument
503 enforce_max_args(L, 4); in lua_write()
505 fd = luaL_checkinteger(L, 1); in lua_write()
511 buf = luaL_checkstring(L, 2); in lua_write()
513 bufsz = lua_rawlen(L, 2); in lua_write()
514 sz = luaL_optinteger(L, 3, bufsz); in lua_write()
516 offset = luaL_optinteger(L, 4, 0); in lua_write()
520 lua_pushnil(L); in lua_write()
521 lua_pushfstring(L, in lua_write()
524 lua_pushinteger(L, EINVAL); in lua_write()
534 lua_pushinteger(L, ret); in lua_write()
537 lua_pushnil(L); in lua_write()
538 lua_pushstring(L, strerror(error)); in lua_write()
539 lua_pushinteger(L, error); in lua_write()
594 luaopen_posix_libgen(lua_State *L) in luaopen_posix_libgen() argument
596 luaL_newlib(L, libgenlib); in luaopen_posix_libgen()
601 luaopen_posix_stdlib(lua_State *L) in luaopen_posix_stdlib() argument
603 luaL_newlib(L, stdliblib); in luaopen_posix_stdlib()
608 luaopen_posix_fnmatch(lua_State *L) in luaopen_posix_fnmatch() argument
610 luaL_newlib(L, fnmatchlib); in luaopen_posix_fnmatch()
613 lua_pushinteger(L, f); \ in luaopen_posix_fnmatch()
614 lua_setfield(L, -2, #f); \ in luaopen_posix_fnmatch()
626 luaopen_posix_sys_stat(lua_State *L) in luaopen_posix_sys_stat() argument
628 luaL_newlib(L, sys_statlib); in luaopen_posix_sys_stat()
633 luaopen_posix_sys_utsname(lua_State *L) in luaopen_posix_sys_utsname() argument
635 luaL_newlib(L, sys_utsnamelib); in luaopen_posix_sys_utsname()
640 luaopen_posix_sys_wait(lua_State *L) in luaopen_posix_sys_wait() argument
642 luaL_newlib(L, sys_waitlib); in luaopen_posix_sys_wait()
644 #define lua_pushflag(L, flag) do { \ in luaopen_posix_sys_wait() argument
645 lua_pushinteger(L, flag); \ in luaopen_posix_sys_wait()
646 lua_setfield(L, -2, #flag); \ in luaopen_posix_sys_wait()
650 lua_pushflag(L, WNOHANG); in luaopen_posix_sys_wait()
651 lua_pushflag(L, WUNTRACED); in luaopen_posix_sys_wait()
653 lua_pushflag(L, WCONTINUED); in luaopen_posix_sys_wait()
654 lua_pushflag(L, WSTOPPED); in luaopen_posix_sys_wait()
656 lua_pushflag(L, WTRAPPED); in luaopen_posix_sys_wait()
658 lua_pushflag(L, WEXITED); in luaopen_posix_sys_wait()
659 lua_pushflag(L, WNOWAIT); in luaopen_posix_sys_wait()
666 luaopen_posix_unistd(lua_State *L) in luaopen_posix_unistd() argument
668 luaL_newlib(L, unistdlib); in luaopen_posix_unistd()
673 luaopen_posix(lua_State *L) in luaopen_posix() argument
675 lua_newtable(L); /* posix */ in luaopen_posix()
677 luaL_requiref(L, "posix.fnmatch", luaopen_posix_fnmatch, 0); in luaopen_posix()
678 lua_setfield(L, -2, "fnmatch"); in luaopen_posix()
680 luaL_requiref(L, "posix.libgen", luaopen_posix_libgen, 0); in luaopen_posix()
681 lua_setfield(L, -2, "libgen"); in luaopen_posix()
683 luaL_requiref(L, "posix.stdlib", luaopen_posix_stdlib, 0); in luaopen_posix()
684 lua_setfield(L, -2, "stdlib"); in luaopen_posix()
686 lua_newtable(L); /* posix.sys */ in luaopen_posix()
687 luaL_requiref(L, "posix.sys.stat", luaopen_posix_sys_stat, 0); in luaopen_posix()
688 lua_setfield(L, -2, "stat"); in luaopen_posix()
689 luaL_requiref(L, "posix.sys.utsname", luaopen_posix_sys_utsname, 0); in luaopen_posix()
690 lua_setfield(L, -2, "utsname"); in luaopen_posix()
691 luaL_requiref(L, "posix.sys.wait", luaopen_posix_sys_wait, 0); in luaopen_posix()
692 lua_setfield(L, -2, "wait"); in luaopen_posix()
693 lua_setfield(L, -2, "sys"); in luaopen_posix()
695 luaL_requiref(L, "posix.unistd", luaopen_posix_unistd, 0); in luaopen_posix()
696 lua_setfield(L, -2, "unistd"); in luaopen_posix()