Lines Matching defs:L

28 lua__exit(lua_State *L)
32 narg = lua_gettop(L);
33 luaL_argcheck(L, narg == 1, 1, "_exit takes exactly one argument");
35 code = luaL_checkinteger(L, 1);
40 lua_basename(lua_State *L)
45 narg = lua_gettop(L);
46 luaL_argcheck(L, narg > 0, 1, "at least one argument required");
47 inpath = strdup(luaL_checkstring(L, 1));
49 lua_pushnil(L);
50 lua_pushstring(L, strerror(ENOMEM));
51 lua_pushinteger(L, ENOMEM);
56 lua_pushstring(L, outpath);
62 lua_chmod(lua_State *L)
68 n = lua_gettop(L);
69 luaL_argcheck(L, n == 2, n > 2 ? 3 : n,
71 path = luaL_checkstring(L, 1);
72 mode = (mode_t)luaL_checkinteger(L, 2);
74 lua_pushnil(L);
75 lua_pushstring(L, strerror(errno));
76 lua_pushinteger(L, errno);
79 lua_pushinteger(L, 0);
84 lua_chown(lua_State *L)
91 n = lua_gettop(L);
92 luaL_argcheck(L, n > 1, n,
94 path = luaL_checkstring(L, 1);
95 if (lua_isinteger(L, 2))
96 owner = (uid_t) lua_tointeger(L, 2);
97 else if (lua_isstring(L, 2)) {
98 struct passwd *p = getpwnam(lua_tostring(L, 2));
102 return (luaL_argerror(L, 2,
103 lua_pushfstring(L, "unknown user %s",
104 lua_tostring(L, 2))));
105 } else if (!lua_isnoneornil(L, 2)) {
106 const char *type = luaL_typename(L, 2);
107 return (luaL_argerror(L, 2,
108 lua_pushfstring(L, "integer or string expected, got %s",
112 if (lua_isinteger(L, 3))
113 group = (gid_t) lua_tointeger(L, 3);
114 else if (lua_isstring(L, 3)) {
115 struct group *g = getgrnam(lua_tostring(L, 3));
119 return (luaL_argerror(L, 3,
120 lua_pushfstring(L, "unknown group %s",
121 lua_tostring(L, 3))));
122 } else if (!lua_isnoneornil(L, 3)) {
123 const char *type = luaL_typename(L, 3);
124 return (luaL_argerror(L, 3,
125 lua_pushfstring(L, "integer or string expected, got %s",
130 lua_pushnil(L);
131 lua_pushstring(L, strerror(errno));
132 lua_pushinteger(L, errno);
135 lua_pushinteger(L, 0);
140 lua_pclose(lua_State *L)
144 n = lua_gettop(L);
145 luaL_argcheck(L, n == 1, 1,
148 fd = luaL_checkinteger(L, 1);
155 lua_pushinteger(L, 0);
161 lua_pushnil(L);
162 lua_pushstring(L, strerror(error));
163 lua_pushinteger(L, error);
169 lua_fnmatch(lua_State *L)
174 n = lua_gettop(L);
175 luaL_argcheck(L, n == 2 || n == 3, 4, "need 2 or 3 arguments");
177 pattern = luaL_checkstring(L, 1);
178 string = luaL_checkstring(L, 2);
179 flags = luaL_optinteger(L, 3, 0);
180 lua_pushinteger(L, fnmatch(pattern, string, flags));
186 lua_uname(lua_State *L)
191 n = lua_gettop(L);
192 luaL_argcheck(L, n == 0, 1, "too many arguments");
197 lua_pushnil(L);
198 lua_pushstring(L, strerror(error));
199 lua_pushinteger(L, error);
203 lua_newtable(L);
205 lua_pushstring(L, name.f); \
206 lua_setfield(L, -2, #f); \
219 lua_dirname(lua_State *L)
224 narg = lua_gettop(L);
225 luaL_argcheck(L, narg > 0, 1,
227 inpath = strdup(luaL_checkstring(L, 1));
229 lua_pushnil(L);
230 lua_pushstring(L, strerror(ENOMEM));
231 lua_pushinteger(L, ENOMEM);
236 lua_pushstring(L, outpath);
242 lua_fork(lua_State *L)
247 narg = lua_gettop(L);
248 luaL_argcheck(L, narg == 0, 1, "too many arguments");
252 lua_pushnil(L);
253 lua_pushstring(L, strerror(errno));
254 lua_pushinteger(L, errno);
258 lua_pushinteger(L, pid);
263 lua_getpid(lua_State *L)
267 narg = lua_gettop(L);
268 luaL_argcheck(L, narg == 0, 1, "too many arguments");
269 lua_pushinteger(L, getpid());
274 lua_pipe(lua_State *L)
278 narg = lua_gettop(L);
279 luaL_argcheck(L, narg == 0, 1, "too many arguments");
283 lua_pushnil(L);
284 lua_pushstring(L, strerror(errno));
285 lua_pushinteger(L, errno);
289 lua_pushinteger(L, fd[0]);
290 lua_pushinteger(L, fd[1]);
295 lua_read(lua_State *L)
302 narg = lua_gettop(L);
303 luaL_argcheck(L, narg == 2, 1,
306 fd = luaL_checkinteger(L, 1);
307 sz = luaL_checkinteger(L, 2);
324 lua_pushlstring(L, buf, ret);
335 lua_pushnil(L);
336 lua_pushstring(L, strerror(error));
337 lua_pushinteger(L, error);
342 lua_realpath(lua_State *L)
348 narg = lua_gettop(L);
349 luaL_argcheck(L, narg > 0, 1, "at least one argument required");
350 inpath = luaL_checkstring(L, 1);
354 lua_pushnil(L);
355 lua_pushstring(L, strerror(errno));
356 lua_pushinteger(L, errno);
360 lua_pushstring(L, outpath);
366 lua_wait(lua_State *L)
372 narg = lua_gettop(L);
376 if (narg >= 1 && !lua_isnil(L, 1))
377 pid = luaL_checkinteger(L, 1);
378 if (narg >= 2 && !lua_isnil(L, 2))
379 options = luaL_checkinteger(L, 2);
383 lua_pushnil(L);
384 lua_pushstring(L, strerror(errno));
385 lua_pushinteger(L, errno);
389 lua_pushinteger(L, pid);
391 lua_pushliteral(L, "running");
396 lua_pushliteral(L, "continued");
399 lua_pushliteral(L, "stopped");
400 lua_pushinteger(L, WSTOPSIG(status));
403 lua_pushliteral(L, "exited");
404 lua_pushinteger(L, WEXITSTATUS(status));
407 lua_pushliteral(L, "killed");
408 lua_pushinteger(L, WTERMSIG(status));
416 lua_write(lua_State *L)
424 narg = lua_gettop(L);
425 luaL_argcheck(L, narg >= 2, 1,
427 luaL_argcheck(L, narg <= 4, 5,
430 fd = luaL_checkinteger(L, 1);
436 buf = luaL_checkstring(L, 2);
438 bufsz = sz = lua_rawlen(L, 2);
439 if (narg >= 3 && !lua_isnil(L, 3))
440 sz = luaL_checkinteger(L, 3);
443 if (narg >= 4 && !lua_isnil(L, 4))
444 offset = luaL_checkinteger(L, 4);
447 lua_pushnil(L);
448 lua_pushfstring(L,
451 lua_pushinteger(L, EINVAL);
461 lua_pushinteger(L, ret);
464 lua_pushnil(L);
465 lua_pushstring(L, strerror(error));
466 lua_pushinteger(L, error);
519 luaopen_posix_libgen(lua_State *L)
521 luaL_newlib(L, libgenlib);
526 luaopen_posix_stdlib(lua_State *L)
528 luaL_newlib(L, stdliblib);
533 luaopen_posix_fnmatch(lua_State *L)
535 luaL_newlib(L, fnmatchlib);
538 lua_pushinteger(L, f); \
539 lua_setfield(L, -2, #f); \
551 luaopen_posix_sys_stat(lua_State *L)
553 luaL_newlib(L, sys_statlib);
558 luaopen_posix_sys_wait(lua_State *L)
560 luaL_newlib(L, sys_waitlib);
562 #define lua_pushflag(L, flag) do { \
563 lua_pushinteger(L, flag); \
564 lua_setfield(L, -2, #flag); \
568 lua_pushflag(L, WNOHANG);
569 lua_pushflag(L, WUNTRACED);
571 lua_pushflag(L, WCONTINUED);
572 lua_pushflag(L, WSTOPPED);
574 lua_pushflag(L, WTRAPPED);
576 lua_pushflag(L, WEXITED);
577 lua_pushflag(L, WNOWAIT);
584 luaopen_posix_sys_utsname(lua_State *L)
586 luaL_newlib(L, sys_utsnamelib);
591 luaopen_posix_unistd(lua_State *L)
593 luaL_newlib(L, unistdlib);