1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
#include "AppHdr.h"
#include "dlua.h"
#include "l_libs.h"
#include "initfile.h"
#include "view.h"
LUAFN(_crawl_args)
{
return dlua_stringtable(ls, SysEnv.cmd_args);
}
LUAFN(_crawl_milestone)
{
#ifdef DGL_MILESTONES
mark_milestone(luaL_checkstring(ls, 1),
luaL_checkstring(ls, 2));
#endif
return (0);
}
LUAFN(_crawl_redraw_view)
{
viewwindow(true, false);
return (0);
}
#ifdef UNIX
LUAFN(_crawl_millis)
{
struct timeval tv;
struct timezone tz;
const int error = gettimeofday(&tv, &tz);
if (error)
luaL_error(ls, make_stringf("Failed to get time: %s",
strerror(error)).c_str());
lua_pushnumber(ls, tv.tv_sec * 1000 + tv.tv_usec / 1000);
return (1);
}
#endif
const struct luaL_reg crawl_lib[] =
{
{ "args", _crawl_args },
{ "mark_milestone", _crawl_milestone },
{ "redraw_view", _crawl_redraw_view },
#ifdef UNIX
{ "millis", _crawl_millis },
#endif
{ NULL, NULL }
};
|