blob: 2adb1e998cc374a97fae67b474750689dd3b00ad (
plain)
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
|
/// @submodule system
#include <lua.h>
#include <lauxlib.h>
#include <lualib.h>
#include "compat.h"
#ifndef _MSC_VER
# include <unistd.h>
#endif
/***
Checks if a file-handle is a TTY.
@function isatty
@tparam file file the file-handle to check
@treturn boolean true if the file is a tty
*/
static int lua_isatty(lua_State* L) {
FILE **fh = (FILE **) luaL_checkudata(L, 1, LUA_FILEHANDLE);
lua_pushboolean(L, isatty(fileno(*fh)));
return 1;
}
static luaL_Reg func[] = {
{ "isatty", lua_isatty },
{ NULL, NULL }
};
/*-------------------------------------------------------------------------
* Initializes module
*-------------------------------------------------------------------------*/
void term_open(lua_State *L) {
luaL_setfuncs(L, func, 0);
}
|