tmueller@0
|
1 |
|
tmueller@0
|
2 |
#include <stdlib.h>
|
tmueller@0
|
3 |
#include <string.h>
|
tmueller@0
|
4 |
#include <sys/types.h>
|
tmueller@0
|
5 |
#include <sys/stat.h>
|
tmueller@0
|
6 |
#include <unistd.h>
|
tmueller@0
|
7 |
#include <dirent.h>
|
tmueller@0
|
8 |
#include <errno.h>
|
tmueller@172
|
9 |
#include <math.h>
|
tmueller@172
|
10 |
#include <time.h>
|
tmueller@0
|
11 |
#include <lua.h>
|
tmueller@0
|
12 |
#include <lualib.h>
|
tmueller@0
|
13 |
#include <lauxlib.h>
|
tmueller@0
|
14 |
|
tmueller@0
|
15 |
|
tmueller@0
|
16 |
#define DIRCLASSNAME "dir*"
|
tmueller@0
|
17 |
|
tmueller@0
|
18 |
|
tmueller@0
|
19 |
static void
|
tmueller@0
|
20 |
setfield(lua_State *L, const char *attr, const char *key, lua_Integer n)
|
tmueller@0
|
21 |
{
|
tmueller@0
|
22 |
if (attr == NULL || strcmp(attr, key) == 0)
|
tmueller@0
|
23 |
lua_pushinteger(L, n);
|
tmueller@0
|
24 |
if (attr == NULL)
|
tmueller@0
|
25 |
lua_setfield(L, -2, key);
|
tmueller@0
|
26 |
}
|
tmueller@0
|
27 |
|
tmueller@18
|
28 |
|
tmueller@0
|
29 |
static int
|
tmueller@0
|
30 |
setstat(lua_State *L, int result, struct stat *s, const char *attr)
|
tmueller@0
|
31 |
{
|
tmueller@0
|
32 |
if (result != 0)
|
tmueller@0
|
33 |
{
|
tmueller@0
|
34 |
lua_pushnil(L);
|
tmueller@0
|
35 |
lua_pushstring(L, strerror(errno));
|
tmueller@0
|
36 |
return 2;
|
tmueller@0
|
37 |
}
|
tmueller@0
|
38 |
|
tmueller@0
|
39 |
if (attr == NULL)
|
tmueller@0
|
40 |
lua_newtable(L);
|
tmueller@0
|
41 |
|
tmueller@0
|
42 |
setfield(L, attr, "dev", s->st_dev);
|
tmueller@0
|
43 |
setfield(L, attr, "ino", s->st_ino);
|
tmueller@0
|
44 |
|
tmueller@0
|
45 |
if (attr == NULL || strcmp(attr, "mode") == 0)
|
tmueller@0
|
46 |
{
|
tmueller@0
|
47 |
if (S_ISREG(s->st_mode))
|
tmueller@0
|
48 |
lua_pushstring(L, "file");
|
tmueller@0
|
49 |
else if (S_ISDIR(s->st_mode))
|
tmueller@0
|
50 |
lua_pushstring(L, "directory");
|
tmueller@0
|
51 |
else if (S_ISLNK(s->st_mode))
|
tmueller@0
|
52 |
lua_pushstring(L, "link");
|
tmueller@0
|
53 |
else if (S_ISSOCK(s->st_mode))
|
tmueller@0
|
54 |
lua_pushstring(L, "socket");
|
tmueller@0
|
55 |
else if (S_ISFIFO(s->st_mode))
|
tmueller@0
|
56 |
lua_pushstring(L, "named pipe");
|
tmueller@0
|
57 |
else if (S_ISCHR(s->st_mode))
|
tmueller@0
|
58 |
lua_pushstring(L, "char device");
|
tmueller@0
|
59 |
else if (S_ISBLK(s->st_mode))
|
tmueller@0
|
60 |
lua_pushstring(L, "block device");
|
tmueller@0
|
61 |
else
|
tmueller@0
|
62 |
lua_pushstring(L, "other");
|
tmueller@0
|
63 |
if (attr == NULL)
|
tmueller@0
|
64 |
lua_setfield(L, -2, "mode");
|
tmueller@0
|
65 |
}
|
tmueller@0
|
66 |
|
tmueller@0
|
67 |
setfield(L, attr, "nlink", s->st_nlink);
|
tmueller@0
|
68 |
setfield(L, attr, "uid", s->st_uid);
|
tmueller@0
|
69 |
setfield(L, attr, "gid", s->st_gid);
|
tmueller@0
|
70 |
setfield(L, attr, "rdev", s->st_rdev);
|
tmueller@0
|
71 |
setfield(L, attr, "access", s->st_atime);
|
tmueller@0
|
72 |
setfield(L, attr, "modifications", s->st_mtime);
|
tmueller@0
|
73 |
setfield(L, attr, "change", s->st_ctime);
|
tmueller@165
|
74 |
setfield(L, attr, "size", s->st_size);
|
tmueller@0
|
75 |
setfield(L, attr, "blocks", s->st_blocks);
|
tmueller@0
|
76 |
setfield(L, attr, "blksize", s->st_blksize);
|
tmueller@0
|
77 |
|
tmueller@0
|
78 |
return 1;
|
tmueller@0
|
79 |
}
|
tmueller@0
|
80 |
|
tmueller@0
|
81 |
|
tmueller@0
|
82 |
static int
|
tmueller@0
|
83 |
posix_stat(lua_State *L)
|
tmueller@0
|
84 |
{
|
tmueller@0
|
85 |
const char *path = luaL_checkstring(L, 1);
|
tmueller@0
|
86 |
const char *attr = luaL_optstring(L, 2, NULL);
|
tmueller@0
|
87 |
struct stat s;
|
tmueller@0
|
88 |
return setstat(L, stat(path, &s), &s, attr);
|
tmueller@0
|
89 |
}
|
tmueller@0
|
90 |
|
tmueller@0
|
91 |
|
tmueller@0
|
92 |
static int
|
tmueller@0
|
93 |
posix_lstat(lua_State *L)
|
tmueller@0
|
94 |
{
|
tmueller@0
|
95 |
const char *path = luaL_checkstring(L, 1);
|
tmueller@0
|
96 |
const char *attr = luaL_optstring(L, 2, NULL);
|
tmueller@0
|
97 |
struct stat s;
|
tmueller@0
|
98 |
return setstat(L, lstat(path, &s), &s, attr);
|
tmueller@0
|
99 |
}
|
tmueller@0
|
100 |
|
tmueller@0
|
101 |
|
tmueller@0
|
102 |
static int
|
tmueller@0
|
103 |
posix_opendir(lua_State *L)
|
tmueller@0
|
104 |
{
|
tmueller@0
|
105 |
const char *path = luaL_checkstring(L, 1);
|
tmueller@0
|
106 |
DIR **pdir = lua_newuserdata(L, sizeof(void *));
|
tmueller@0
|
107 |
*pdir = NULL;
|
tmueller@0
|
108 |
lua_pushvalue(L, lua_upvalueindex(2)); /* class metatable */
|
tmueller@0
|
109 |
/* attach metatable to the userdata object */
|
tmueller@0
|
110 |
lua_setmetatable(L, -2); /* s: udata */
|
tmueller@0
|
111 |
/* create class instance */
|
tmueller@0
|
112 |
*pdir = opendir(path);
|
tmueller@0
|
113 |
if (*pdir == NULL)
|
tmueller@0
|
114 |
{
|
tmueller@0
|
115 |
lua_pushnil(L);
|
tmueller@0
|
116 |
lua_pushstring(L, strerror(errno));
|
tmueller@0
|
117 |
return 2;
|
tmueller@0
|
118 |
}
|
tmueller@0
|
119 |
return 1;
|
tmueller@0
|
120 |
}
|
tmueller@0
|
121 |
|
tmueller@0
|
122 |
|
tmueller@0
|
123 |
static DIR **
|
tmueller@0
|
124 |
getinstptr(lua_State *L, int narg, const char *classname)
|
tmueller@0
|
125 |
{
|
tmueller@0
|
126 |
DIR **pinst = luaL_checkudata(L, narg, classname);
|
tmueller@0
|
127 |
if (*pinst) return pinst;
|
tmueller@0
|
128 |
luaL_argerror(L, narg, "Closed handle");
|
tmueller@0
|
129 |
return NULL;
|
tmueller@0
|
130 |
}
|
tmueller@0
|
131 |
|
tmueller@0
|
132 |
|
tmueller@0
|
133 |
static int
|
tmueller@0
|
134 |
posix_closedir(lua_State *L)
|
tmueller@0
|
135 |
{
|
tmueller@0
|
136 |
DIR **pdir = getinstptr(L, 1, DIRCLASSNAME);
|
tmueller@0
|
137 |
closedir(*pdir);
|
tmueller@0
|
138 |
*pdir = NULL;
|
tmueller@0
|
139 |
return 0;
|
tmueller@0
|
140 |
}
|
tmueller@0
|
141 |
|
tmueller@0
|
142 |
|
tmueller@0
|
143 |
static int
|
tmueller@0
|
144 |
posix_readdir(lua_State *L)
|
tmueller@0
|
145 |
{
|
tmueller@0
|
146 |
DIR *dir = *getinstptr(L, 1, DIRCLASSNAME);
|
tmueller@0
|
147 |
struct dirent *de = readdir(dir);
|
tmueller@0
|
148 |
if (de)
|
tmueller@0
|
149 |
lua_pushstring(L, de->d_name);
|
tmueller@0
|
150 |
else
|
tmueller@0
|
151 |
lua_pushnil(L);
|
tmueller@0
|
152 |
return 1;
|
tmueller@0
|
153 |
}
|
tmueller@0
|
154 |
|
tmueller@0
|
155 |
|
tmueller@0
|
156 |
static int
|
tmueller@0
|
157 |
posix_readlink(lua_State *L)
|
tmueller@0
|
158 |
{
|
tmueller@0
|
159 |
const char *path = luaL_checkstring(L, 1);
|
tmueller@0
|
160 |
char buf[PATH_MAX + 1];
|
tmueller@0
|
161 |
ssize_t len = readlink(path, buf, sizeof(buf) - 1);
|
tmueller@0
|
162 |
if (len < 0)
|
tmueller@0
|
163 |
{
|
tmueller@0
|
164 |
lua_pushnil(L);
|
tmueller@0
|
165 |
lua_pushstring(L, strerror(errno));
|
tmueller@0
|
166 |
return 2;
|
tmueller@0
|
167 |
}
|
tmueller@0
|
168 |
buf[len] = 0;
|
tmueller@0
|
169 |
lua_pushstring(L, buf);
|
tmueller@0
|
170 |
return 1;
|
tmueller@0
|
171 |
}
|
tmueller@0
|
172 |
|
tmueller@0
|
173 |
|
tmueller@0
|
174 |
static int
|
tmueller@0
|
175 |
posix_mkdir(lua_State *L)
|
tmueller@0
|
176 |
{
|
tmueller@0
|
177 |
const char *path = luaL_checkstring(L, 1);
|
tmueller@0
|
178 |
if (mkdir(path, 0775) == 0)
|
tmueller@0
|
179 |
{
|
tmueller@0
|
180 |
lua_pushboolean(L, 1);
|
tmueller@0
|
181 |
return 1;
|
tmueller@0
|
182 |
}
|
tmueller@0
|
183 |
lua_pushnil(L);
|
tmueller@0
|
184 |
lua_pushstring(L, strerror(errno));
|
tmueller@0
|
185 |
return 2;
|
tmueller@0
|
186 |
}
|
tmueller@0
|
187 |
|
tmueller@0
|
188 |
|
tmueller@0
|
189 |
static int
|
tmueller@0
|
190 |
posix_symlink(lua_State *L)
|
tmueller@0
|
191 |
{
|
tmueller@0
|
192 |
const char *oldpath = luaL_checkstring(L, 1);
|
tmueller@0
|
193 |
const char *newpath = luaL_checkstring(L, 2);
|
tmueller@0
|
194 |
if (symlink(oldpath, newpath) == 0)
|
tmueller@0
|
195 |
{
|
tmueller@0
|
196 |
lua_pushboolean(L, 1);
|
tmueller@0
|
197 |
return 1;
|
tmueller@0
|
198 |
}
|
tmueller@0
|
199 |
lua_pushnil(L);
|
tmueller@0
|
200 |
lua_pushstring(L, strerror(errno));
|
tmueller@0
|
201 |
return 2;
|
tmueller@0
|
202 |
}
|
tmueller@0
|
203 |
|
tmueller@0
|
204 |
|
tmueller@0
|
205 |
static int
|
tmueller@0
|
206 |
resolvepath(const char *src, char *dest)
|
tmueller@0
|
207 |
{
|
tmueller@0
|
208 |
int len = strlen(src);
|
tmueller@0
|
209 |
const char *sp = src + len;
|
tmueller@0
|
210 |
char *dp = dest;
|
tmueller@0
|
211 |
int dc = 0, slc = 0, eac = 0, wc = 0;
|
tmueller@0
|
212 |
int i, c;
|
tmueller@0
|
213 |
|
tmueller@0
|
214 |
while (len--)
|
tmueller@0
|
215 |
{
|
tmueller@0
|
216 |
c = *(--sp);
|
tmueller@0
|
217 |
switch (c)
|
tmueller@0
|
218 |
{
|
tmueller@0
|
219 |
case '/':
|
tmueller@0
|
220 |
if (dc == 2)
|
tmueller@0
|
221 |
eac++;
|
tmueller@0
|
222 |
dc = 0;
|
tmueller@0
|
223 |
slc = 1;
|
tmueller@0
|
224 |
wc = 0;
|
tmueller@0
|
225 |
break;
|
tmueller@0
|
226 |
|
tmueller@0
|
227 |
case '.':
|
tmueller@0
|
228 |
if (slc)
|
tmueller@0
|
229 |
{
|
tmueller@0
|
230 |
dc++;
|
tmueller@0
|
231 |
break;
|
tmueller@0
|
232 |
}
|
tmueller@0
|
233 |
/* fallthru: */
|
tmueller@0
|
234 |
|
tmueller@0
|
235 |
default:
|
tmueller@0
|
236 |
if (wc)
|
tmueller@0
|
237 |
break;
|
tmueller@0
|
238 |
|
tmueller@0
|
239 |
if (slc)
|
tmueller@0
|
240 |
{
|
tmueller@0
|
241 |
slc = 0;
|
tmueller@0
|
242 |
|
tmueller@0
|
243 |
if (eac > 0)
|
tmueller@0
|
244 |
{
|
tmueller@0
|
245 |
/* resolve one eatcount */
|
tmueller@0
|
246 |
eac--;
|
tmueller@0
|
247 |
/* now wait for next path part */
|
tmueller@0
|
248 |
wc = 1;
|
tmueller@0
|
249 |
break;
|
tmueller@0
|
250 |
}
|
tmueller@0
|
251 |
|
tmueller@0
|
252 |
*dp++ = '/';
|
tmueller@0
|
253 |
}
|
tmueller@0
|
254 |
|
tmueller@0
|
255 |
while (dc == 2 || dc == 1)
|
tmueller@0
|
256 |
{
|
tmueller@0
|
257 |
*dp++ = '.';
|
tmueller@0
|
258 |
dc--;
|
tmueller@0
|
259 |
}
|
tmueller@0
|
260 |
dc = 0;
|
tmueller@0
|
261 |
|
tmueller@0
|
262 |
*dp++ = c;
|
tmueller@0
|
263 |
break;
|
tmueller@0
|
264 |
}
|
tmueller@0
|
265 |
}
|
tmueller@0
|
266 |
|
tmueller@0
|
267 |
/* unresolved eatcount */
|
tmueller@0
|
268 |
if (eac)
|
tmueller@0
|
269 |
return 0;
|
tmueller@0
|
270 |
|
tmueller@0
|
271 |
/* resolve remaining slash */
|
tmueller@0
|
272 |
if (slc)
|
tmueller@0
|
273 |
*dp++ = '/';
|
tmueller@0
|
274 |
|
tmueller@0
|
275 |
*dp = 0;
|
tmueller@0
|
276 |
|
tmueller@0
|
277 |
len = dp - dest;
|
tmueller@0
|
278 |
for (i = 0; i < len / 2; ++i)
|
tmueller@0
|
279 |
{
|
tmueller@0
|
280 |
char t = dest[i];
|
tmueller@0
|
281 |
dest[i] = dest[len - i - 1];
|
tmueller@0
|
282 |
dest[len - i - 1] = t;
|
tmueller@0
|
283 |
}
|
tmueller@0
|
284 |
|
tmueller@0
|
285 |
return 1;
|
tmueller@0
|
286 |
}
|
tmueller@0
|
287 |
|
tmueller@0
|
288 |
|
tmueller@0
|
289 |
static int
|
tmueller@0
|
290 |
posix_abspath(lua_State *L)
|
tmueller@0
|
291 |
{
|
tmueller@0
|
292 |
const char *path = luaL_checkstring(L, 1);
|
tmueller@0
|
293 |
char *pwd = NULL;
|
tmueller@0
|
294 |
size_t pwdsize = 16;
|
tmueller@0
|
295 |
|
tmueller@0
|
296 |
for (;;)
|
tmueller@0
|
297 |
{
|
tmueller@0
|
298 |
char *newpwd = realloc(pwd, pwdsize);
|
tmueller@0
|
299 |
if (newpwd == NULL)
|
tmueller@0
|
300 |
break;
|
tmueller@0
|
301 |
|
tmueller@0
|
302 |
pwd = newpwd;
|
tmueller@0
|
303 |
if (getcwd(pwd, pwdsize))
|
tmueller@0
|
304 |
{
|
tmueller@0
|
305 |
size_t len1 = strlen(pwd);
|
tmueller@0
|
306 |
size_t len2 = strlen(path);
|
tmueller@0
|
307 |
char *srcpath = malloc(len1 + 1 + len2 + 1);
|
tmueller@0
|
308 |
char *dstpath = malloc(len1 + 1 + len2 + 1);
|
tmueller@0
|
309 |
if (srcpath && dstpath)
|
tmueller@0
|
310 |
{
|
tmueller@0
|
311 |
int res;
|
tmueller@0
|
312 |
|
tmueller@0
|
313 |
strcpy(srcpath, pwd);
|
tmueller@0
|
314 |
free(pwd);
|
tmueller@0
|
315 |
srcpath[len1] = '/';
|
tmueller@0
|
316 |
strcpy(srcpath + len1 + 1, path);
|
tmueller@0
|
317 |
res = resolvepath(srcpath, dstpath);
|
tmueller@0
|
318 |
free(srcpath);
|
tmueller@0
|
319 |
|
tmueller@0
|
320 |
if (res)
|
tmueller@0
|
321 |
{
|
tmueller@0
|
322 |
lua_pushstring(L, dstpath);
|
tmueller@0
|
323 |
free(dstpath);
|
tmueller@0
|
324 |
return 1;
|
tmueller@0
|
325 |
}
|
tmueller@0
|
326 |
|
tmueller@0
|
327 |
free(dstpath);
|
tmueller@0
|
328 |
lua_pushnil(L);
|
tmueller@0
|
329 |
lua_pushstring(L, "Not a valid path");
|
tmueller@0
|
330 |
return 2;
|
tmueller@0
|
331 |
}
|
tmueller@0
|
332 |
|
tmueller@0
|
333 |
free(srcpath);
|
tmueller@0
|
334 |
free(dstpath);
|
tmueller@0
|
335 |
break;
|
tmueller@0
|
336 |
}
|
tmueller@0
|
337 |
|
tmueller@0
|
338 |
if (errno == ERANGE)
|
tmueller@0
|
339 |
{
|
tmueller@0
|
340 |
pwdsize <<= 1;
|
tmueller@0
|
341 |
continue;
|
tmueller@0
|
342 |
}
|
tmueller@0
|
343 |
|
tmueller@0
|
344 |
lua_pushnil(L);
|
tmueller@0
|
345 |
lua_pushstring(L, strerror(errno));
|
tmueller@0
|
346 |
return 2;
|
tmueller@0
|
347 |
}
|
tmueller@0
|
348 |
|
tmueller@0
|
349 |
free(pwd);
|
tmueller@0
|
350 |
luaL_error(L, "Out of memory");
|
tmueller@0
|
351 |
return 0;
|
tmueller@0
|
352 |
}
|
tmueller@0
|
353 |
|
tmueller@0
|
354 |
|
tmueller@172
|
355 |
static int
|
tmueller@172
|
356 |
posix_nanosleep(lua_State *L)
|
tmueller@172
|
357 |
{
|
tmueller@172
|
358 |
struct timespec req;
|
tmueller@172
|
359 |
lua_Number d = luaL_checknumber(L, 1);
|
tmueller@172
|
360 |
|
tmueller@172
|
361 |
req.tv_sec = (time_t) d;
|
tmueller@172
|
362 |
req.tv_nsec = (long) ((d - req.tv_sec) * 1000000000);
|
tmueller@172
|
363 |
|
tmueller@172
|
364 |
if (nanosleep(&req, NULL) == 0)
|
tmueller@172
|
365 |
{
|
tmueller@172
|
366 |
lua_pushboolean(L, 1);
|
tmueller@172
|
367 |
return 1;
|
tmueller@172
|
368 |
}
|
tmueller@172
|
369 |
|
tmueller@172
|
370 |
lua_pushnil(L);
|
tmueller@172
|
371 |
lua_pushstring(L, strerror(errno));
|
tmueller@172
|
372 |
return 2;
|
tmueller@172
|
373 |
}
|
tmueller@172
|
374 |
|
tmueller@172
|
375 |
|
tmueller@0
|
376 |
static const luaL_Reg lib[] =
|
tmueller@0
|
377 |
{
|
tmueller@0
|
378 |
{ "stat", posix_stat },
|
tmueller@0
|
379 |
{ "lstat", posix_lstat },
|
tmueller@0
|
380 |
{ "opendir", posix_opendir },
|
tmueller@0
|
381 |
{ "closedir", posix_closedir },
|
tmueller@0
|
382 |
{ "readdir", posix_readdir },
|
tmueller@0
|
383 |
{ "mkdir", posix_mkdir },
|
tmueller@0
|
384 |
{ "readlink", posix_readlink },
|
tmueller@0
|
385 |
{ "symlink", posix_symlink },
|
tmueller@0
|
386 |
{ "abspath", posix_abspath },
|
tmueller@172
|
387 |
{ "nanosleep", posix_nanosleep },
|
tmueller@0
|
388 |
{ NULL, NULL }
|
tmueller@0
|
389 |
};
|
tmueller@0
|
390 |
|
tmueller@0
|
391 |
|
tmueller@0
|
392 |
static const luaL_Reg methods[] =
|
tmueller@0
|
393 |
{
|
tmueller@0
|
394 |
{"read", posix_readdir },
|
tmueller@0
|
395 |
{"close", posix_closedir },
|
tmueller@0
|
396 |
{"__gc", posix_closedir },
|
tmueller@0
|
397 |
{NULL, NULL}
|
tmueller@0
|
398 |
};
|
tmueller@0
|
399 |
|
tmueller@0
|
400 |
|
tmueller@0
|
401 |
static void
|
tmueller@0
|
402 |
addclass(lua_State *L, const char *libname, const char *classname,
|
tmueller@0
|
403 |
luaL_Reg *functions, luaL_Reg *methods, void *userdata)
|
tmueller@0
|
404 |
{
|
tmueller@18
|
405 |
luaL_newmetatable(L, classname); /* classtab */
|
tmueller@18
|
406 |
lua_pushliteral(L, "__index"); /* classtab, "__index" */
|
tmueller@0
|
407 |
|
tmueller@0
|
408 |
/* insert self: classtab.__index = classtab */
|
tmueller@18
|
409 |
lua_pushvalue(L, -2); /* classtab, "__index", classtab */
|
tmueller@18
|
410 |
lua_rawset(L, -3); /* classtab */
|
tmueller@0
|
411 |
|
tmueller@0
|
412 |
/* insert methods. consume 1 userdata. do not create a new tab */
|
tmueller@18
|
413 |
lua_pushlightuserdata(L, userdata); /* classtab, userdata */
|
tmueller@18
|
414 |
luaL_openlib(L, NULL, methods, 1); /* classtab */
|
tmueller@0
|
415 |
|
tmueller@0
|
416 |
/* first upvalue: userdata */
|
tmueller@18
|
417 |
lua_pushlightuserdata(L, userdata); /* classtab, userdata */
|
tmueller@0
|
418 |
|
tmueller@0
|
419 |
/* duplicate table argument to be used as second upvalue for cclosure */
|
tmueller@18
|
420 |
lua_pushvalue(L, -2); /* classtab, userdata, classtab */
|
tmueller@0
|
421 |
|
tmueller@0
|
422 |
/* insert functions */
|
tmueller@0
|
423 |
luaL_openlib(L, libname, functions, 2); /* classtab, libtab */
|
tmueller@0
|
424 |
|
tmueller@18
|
425 |
/* adjust stack */
|
tmueller@0
|
426 |
lua_pop(L, 2);
|
tmueller@0
|
427 |
}
|
tmueller@0
|
428 |
|
tmueller@0
|
429 |
|
tmueller@0
|
430 |
int luaopen_tek_posix(lua_State *L)
|
tmueller@0
|
431 |
{
|
tmueller@0
|
432 |
addclass(L, "tek.posix", DIRCLASSNAME,
|
tmueller@0
|
433 |
(luaL_Reg *) lib, (luaL_Reg *) methods, NULL);
|
tmueller@0
|
434 |
return 0;
|
tmueller@0
|
435 |
}
|