aboutsummaryrefslogtreecommitdiff
path: root/core.c
diff options
context:
space:
mode:
authorRob Hoelz <rob@hoelz.ro>2012-06-25 23:16:39 +0200
committerRob Hoelz <rob@hoelz.ro>2012-06-25 23:16:39 +0200
commita6e9ded55fd2852168976ed4e2010e9a38726a74 (patch)
treea87be246a80ee65481c24c7d275c7569c1409984 /core.c
downloadlua-term-a6e9ded55fd2852168976ed4e2010e9a38726a74.tar.gz
lua-term-a6e9ded55fd2852168976ed4e2010e9a38726a74.tar.bz2
lua-term-a6e9ded55fd2852168976ed4e2010e9a38726a74.zip
Import of first release of lua-term
Diffstat (limited to 'core.c')
-rw-r--r--core.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/core.c b/core.c
new file mode 100644
index 0000000..04ff4ef
--- /dev/null
+++ b/core.c
@@ -0,0 +1,22 @@
1#include <lua.h>
2#include <lauxlib.h>
3#include <lualib.h>
4
5static int
6lua_isatty(lua_State *L)
7{
8 FILE *fp = (FILE *) luaL_checkudata(L, -1, LUA_FILEHANDLE);
9
10 lua_pushboolean(L, isatty(fileno(fp)));
11 return 1;
12}
13
14int
15luaopen_term_core(lua_State *L)
16{
17 lua_newtable(L);
18 lua_pushcfunction(L, lua_isatty);
19 lua_setfield(L, -2, "isatty");
20
21 return 1;
22}